2 Common data and functions for use in PHP applications.
6 from wizard.app.php import *
12 from wizard import app, util
16 Generates a regexp for assignment to ``var`` in PHP; the quoted
17 value is the second subpattern.
19 >>> re_var('key').search("$key = 'val';").group(2)
22 return re.compile('^(\$' + app.expand_re(var) + r'''\s*=\s*)(.*)(;)''', re.M)
26 Generates a regexp for the definition of a constant in PHP; the
27 quoted value is the second subpattern.
29 >>> re_define('FOO').search("define('FOO', 'bar');").group(2)
32 return re.compile('^(define\([\'"]' + app.expand_re(var) + r'''['"]\s*,\s*)(.*)(\);)''', re.M)
34 def _make_filename_regex(var):
35 return 'php.ini', re.compile('^(' + app.expand_re(var) + r'\s*=\s*)(.*)()$', re.M)
37 def ini_replace_vars():
39 Replace ``WIZARD_TMPDIR`` and ``WIZARD_SESSIONNAME`` with with user-specific values.
41 text = open('php.ini', "r").read()
42 text = text.replace('WIZARD_TMPDIR', '/mit/%s/web_scripts_tmp' % os.environ['USER'])
43 text = text.replace('WIZARD_SESSIONNAME', '%s_SID' % os.environ['USER'])
44 open('php.ini', "w").write(text)
46 seed = util.dictmap(_make_filename_regex, {
47 'WIZARD_SESSIONNAME': 'session.name',
48 'WIZARD_TMPDIR': ('upload_tmp_dir', 'session.save_path'),
51 #: Common extractors for parameters in :file:`php.ini`.
52 extractors = app.make_extractors(seed)
53 #: Common substitutions for parameters in :file:`php.ini`.
54 substitutions = app.make_substitutions(seed)
55 #: A list containing :file:`php.ini`.
56 parametrized_files = ["php.ini"]
57 #: Nop for consistency.
58 deprecated_keys = set([])