that takes a name and returns another function (the actual extractor)
which takes a deployment and returns the value of the extracted variable.
+ The regular expression requires a very specific form, essentially ()()()
+ (with the second subgroup being the value we care about), so that we can
+ reuse the regex for other things.
+
Its Haskell-style type signature would be:
(String -> (Filename, Regex)) -> (String -> (Deployment -> String))
contents = deployment.read(file) # cached
match = regex.search(contents)
if not match: return None
- # assumes that the first match is the one we want. Hopefully
- # our regexes can be clever enough to make this work
- return match.group(1)
+ # assumes that the second match is the one we want.
+ return match.group(2)
return h
return g
from wizard import app, deploy, util
from wizard.app import php
-@app.filename_regex_extractor
-def make_extractor(var):
- return 'LocalSettings.php', re.compile('^\$' + re.escape(var) + r'''\s*=\s*((["\']).*\2);$''', re.M)
+def make_filename_regex(var):
+ return 'LocalSettings.php', re.compile('^\$(' + re.escape(var) + r'''\s*=\s*)(.*)(;)$''', re.M)
+
+make_extractor = app.filename_regex_extractor(make_filename_regex)
class Application(deploy.Application):
@property
from wizard import app, util
-@app.filename_regex_extractor
-def make_extractor(var):
- return 'php.ini', re.compile('^' + re.escape(var) + r'\s*=\s*(.*)$', re.M)
+def make_filename_regex(var):
+ return 'php.ini', re.compile('^(' + re.escape(var) + r'\s*=\s*)(.*)()$', re.M)
+
+make_extractor = app.filename_regex_extractor(make_filename_regex)
extractors = util.dictmap(make_extractor,
{'WIZARD_SESSIONNAME': 'session.name'