]> scripts.mit.edu Git - wizard.git/blob - wizard/app/mediawiki.py
Implement parametrization.
[wizard.git] / wizard / app / mediawiki.py
1 import re
2
3 from wizard import app, deploy, util
4 from wizard.app import php
5
6 def make_filename_regex(var):
7     return 'LocalSettings.php', re.compile('^(\$' + re.escape(var) + r'''\s*=\s*)(.*)(;)$''', re.M)
8
9 make_extractor = app.filename_regex_extractor(make_filename_regex)
10
11 class Application(deploy.Application):
12     parametrized_files = ['LocalSettings.php', 'php.ini']
13     @property
14     def extractors(self):
15         if not self._extractors:
16             self._extractors = util.dictmap(make_extractor,
17                 {'WIZARD_IP': 'IP' # obsolete, remove after we're done
18                 ,'WIZARD_SITENAME': 'wgSitename'
19                 ,'WIZARD_SCRIPTPATH': 'wgScriptPath'
20                 ,'WIZARD_EMERGENCYCONTACT': 'wgEmergencyContact'
21                 ,'WIZARD_DBSERVER': 'wgDBserver'
22                 ,'WIZARD_DBNAME': 'wgDBname'
23                 ,'WIZARD_DBUSER': 'wgDBuser'
24                 ,'WIZARD_DBPASSWORD': 'wgDBpassword'
25                 ,'WIZARD_PROXYKEY': 'wgProxyKey'
26                 })
27             self._extractors.update(php.extractors)
28         return self._extractors