Revision: 48200
Author:   kim
Date:     2009-03-09 00:58:58 +0000 (Mon, 09 Mar 2009)

Log Message:
-----------
Add installation of revisions

Modified Paths:
--------------
    trunk/wikiation/installer/installation_system.py
    trunk/wikiation/installer/installers.py

Modified: trunk/wikiation/installer/installation_system.py
===================================================================
--- trunk/wikiation/installer/installation_system.py    2009-03-09 00:27:54 UTC 
(rev 48199)
+++ trunk/wikiation/installer/installation_system.py    2009-03-09 00:58:58 UTC 
(rev 48200)
@@ -14,13 +14,14 @@
 class Installation_System:
        system_name=None
        destination_dir=None
-       as_alias=None
 
        def __init__(self,instance=None):
                self.subsystemdir=os.path.join(settings.installfiles, 
self.system_name)
                self.destination_dir=None
                self.instance=None
                self.as_alias=None
+               self.revision=None
+               self.tag=None
                if instance:
                        self.set_instance(instance)
 
@@ -69,7 +70,8 @@
                env["INSTALL_DIR"]=installdir
                env["DESTINATION_DIR"]=self.destination_dir
                env["NAME"]=installer_name
-               env["REVISION"]=""      #reserved for future expansion
+               env["REVISION"]=self.revision or ''
+               env["TAG"]=self.tag or ''
 
                if isinstance(task,str):
                        task2=[task]

Modified: trunk/wikiation/installer/installers.py
===================================================================
--- trunk/wikiation/installer/installers.py     2009-03-09 00:27:54 UTC (rev 
48199)
+++ trunk/wikiation/installer/installers.py     2009-03-09 00:58:58 UTC (rev 
48200)
@@ -100,6 +100,7 @@
        system=get_system(ppath["system"])
        system.get_info(ppath["installer"])
        
+
 def install(args):
        if len(args)<1:
                print "install: Internal error: expected more arguments"
@@ -120,6 +121,10 @@
                system.set_instance(ppath["in_installer"])
        if ppath["as_alias"]:
                system.as_alias=ppath["as_alias"]
+       if ppath["revision"]:
+               system.revision=ppath["revision"]
+       if ppath["tag"]:
+               system.tag=ppath["tag"]
 
        try:
                success=system.install(ppath["installer"])
@@ -163,18 +168,41 @@
                print e.message
                return 
 
+
 def _ppath_defaults(ppath,defaults):
+       """take a parse path, and fill in empty spots with
+       default values.
+       see: parse_path"""
        for key in ppath.keys():
                if key in defaults:
                        ppath[key]=ppath[key] or defaults[key]
                
 
+def _ppath_find(l,keyword):
+       """
+        refactor of parse_path. Take l=inpath.split(),
+        and see if the keyword exists in that list
+        if exists, return the value following the keyword
+        if not exists, nothing happens
+        if keyword exists but no value is provided, throw exception
+        see: parse_path"""
+       if keyword in l:
+               i=l.index(keyword)
+               try:
+                       value=l[i+1]
+               except IndexError:
+                       raise Parse_Exception("Syntax error. Nothing after 
'"+keyword+"'.")
+               
+               return value
+
 def parse_path(path,defaults=None):
        ai=None 
        system=None
        installer=None
        in_installer=None
        as_alias=None
+       revision=None
+       tag=None
 
        #partial components
        whence=None     # eg. 'available.mediawiki:'
@@ -182,18 +210,27 @@
        inpath=None     # eg. 'ImageMap in REL1_13_2"
 
        if ":" in path:
+               # installed.extension: in foo
+               #|-----whence--------|-inpath-|
                whence, inpath=path.split(':')
        elif "." in path:
+               #installed.extension
                whence=path
        else:
+               # ? 
                single_case=path
 
+       # left side (whence)  __________:
        if whence:
                if "." in whence:
+                       # installed.extension    : ...
+                       #|---ai----|-system--|
                        ai,system=whence.split('.')
                else:
+                       # ?    : ...
                        single_case=whence
-
+       
+       # Hmmm, not a well formed path. Perhaps we can still make heads or 
tails of it?
        if single_case:
                if single_case in systems.keys():
                        system=single_case
@@ -204,32 +241,26 @@
                else:
                        raise Parse_Exception("I'm not sure what to do with 
'"+single_case+"' in this context.")
 
+       # right side (inpath)  :_______________
        if inpath:
                l=inpath.split()
-               if l[0] not in ["in","as"]:
+               if l[0] not in ['in', 'as', 'revision', 'tag']:
                        installer=l[0]
 
-               if "in" in l:
-                       i=l.index("in")
-                       try:
-                               in_installer=l[i+1]
-                       except IndexError:
-                               raise Parse_Exception("Syntax error. Nothing 
after 'in'.")
+               in_installer=_ppath_find(l,"in")
+               as_alias=_ppath_find(l,"as")
+               revision=_ppath_find(l,"revision")
+               tag=_ppath_find(l,'tag')        
 
-               if "as" in l:
-                       i=l.index("as")
-                       try:
-                               as_alias=l[i+1]
-                       except IndexError:
-                               raise Parse_Exception("Syntax error. Nothing 
after 'as'.")
-       
        # Ok, we have our basic return value now
        ppath={
                "ai":ai,        #available or installed
                "system":system,
                "installer":installer,
                "in_installer":in_installer,
-               "as_alias":as_alias}
+               "as_alias":as_alias,
+               "revision":revision,
+               "tag":tag}
        
 
        # maybe we can assume some useful defaults (saves typing)
@@ -241,39 +272,26 @@
        if ppath['ai'] not in ["available","installed",None]:
                raise Parse_Exception("By '"+ppath['ai']+"', did you mean 
available or did you mean installed?")
        
-       if ppath['system']=="hailmary": #easter egg
-               ppath['system']='naive'
+       if ppath['system']=="hailmary": # easter egg
+               ppath['system']='naive' # the naive installer was originally 
pitched as a 
+                                       # "hail mary" installer, but that 
sounds a bit
+                                       # unprofessional, so the name was 
changed.
 
        if ppath['system'] not in systems.keys() and not 
ppath['system']=="None":
                system_names=", ".join(ls_systems())
                raise Parse_Exception("Did you mean to specify any of 
"+system_names)
        
        # we assume that the "in" directive always applies to a mediawiki 
instance
+       # NOTE:possibly this snippet of code should be in mediawiki_installer 
instead
        if ppath['in_installer']:
                mediawiki=get_system('mediawiki')
                if not mediawiki.is_installed(ppath['in_installer']):
                        raise Parse_Exception(ppath['in_installer']+' is not 
currently installed')
-       
-       # :-(
-       #if installer:
-       #       if not system:
-       #               system='mediawiki'      # XXX hardcoded default
-       #       mysystem=get_system(system)
-       #       
-       #       if in_installer:
-       #               system.set_instance(ppath["in_installer"])
-       #       
-       #       if system.is_installed(installer)
-       
-       # we can only check if the installer name itself is valid
-       # somewhat later, once we know what context we are in.
-       
+
        return ppath
-       
 
 
 
-
 def get_system(system_name):
        if system_name not in systems:
                print "Cannot find '"+system_name+"' in the list of supported 
installation systems."



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to