]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/app/mediawiki.py
Add mediawiki variable extraction support for deployments.
[wizard.git] / wizard / app / mediawiki.py
index 9931b1b0fe6f47514e5a274f8420b96cac1bccdb..7ae758373be07dbdb314107c320d76b4dd0cef09 100644 (file)
@@ -1,20 +1,26 @@
 import re
 
-from wizard import deploy
+from wizard import app, deploy, util
+from wizard.app import php
 
-def make_regex(var):
-    return re.compile('^\$' + var + r'''\s*=\s*((["\']).*\2;)$''', re.M)
-
-wizard_to_var = \
-        {'WIZARD_IP': 'IP' # obsolete
-        ,'WIZARD_SITENAME': 'wgSitename'
-        ,'WIZARD_SCRIPTPATH': 'wgScriptPath'
-        ,'WIZARD_EMERGENCYCONTACT': 'wgEmergencyContact'
-        ,'WIZARD_DBSERVER': 'wgDBserver'
-        ,'WIZARD_DBNAME': 'wgDBname'
-        ,'WIZARD_DBUSER': 'wgDBuser'
-        ,'WIZARD_DBPASSWORD': 'wgDBpassword'
-        ,'WIZARD_PROXYKEY': 'wgProxyKey'}
+@app.filename_regex_extractor
+def make_extractor(var):
+    return 'LocalSettings.php', re.compile('^\$' + re.escape(var) + r'''\s*=\s*((["\']).*\2);$''', re.M)
 
 class Application(deploy.Application):
-    pass
+    @property
+    def extractors(self):
+        if not self._extractors:
+            self._extractors = util.dictmap(make_extractor,
+                {'WIZARD_IP': 'IP' # obsolete
+                ,'WIZARD_SITENAME': 'wgSitename'
+                ,'WIZARD_SCRIPTPATH': 'wgScriptPath'
+                ,'WIZARD_EMERGENCYCONTACT': 'wgEmergencyContact'
+                ,'WIZARD_DBSERVER': 'wgDBserver'
+                ,'WIZARD_DBNAME': 'wgDBname'
+                ,'WIZARD_DBUSER': 'wgDBuser'
+                ,'WIZARD_DBPASSWORD': 'wgDBpassword'
+                ,'WIZARD_PROXYKEY': 'wgProxyKey'
+                })
+            self._extractors.update(php.extractors)
+        return self._extractors