Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
<comment-ja>
python??????PHP?????(????var_export??)?????????
</comment-ja>
<comment-en>
TODO: English Comment
</comment-en>

        def python_dict_to_php_array(dictionary={},var_name=""):
    """
    python??????PHP?????(????var_export??)?????????
    
    
    TODO: English Comment
    
    """
    import signal

    dict_str = preprint_r(dictionary,return_var=True)
    dict_str = dict_str.replace('{','array(')
    dict_str = dict_str.replace('\':','\' =>')
    dict_str = dict_str.replace('}',')')
    dict_str = dict_str.replace('=> [','=> array(')
    dict_str = dict_str.replace('])','))')
    dict_str = re.sub("\)$",')',dict_str)

    php_start = "\n"

    # Convert var_export format
    _php = "/usr/bin/php"
    if is_executable(_php):
        _script = "\"\"" % (re.sub("[\r\n]"," ",dict_str),)
        signal.alarm(10)
        proc = subprocess.Popen(_php,
                   bufsize=1,
                   shell=True,
                   stdin=subprocess.PIPE,
                   stdout=subprocess.PIPE,
                   stderr=subprocess.PIPE)

        proc.stdin.write(_script)
        output = proc.communicate()
        ret = proc.wait()
        signal.alarm(0)
        if ret == 0:
            dict_str = "".join(output)
            dict_str = re.sub("^\"","",dict_str)
            dict_str = re.sub("\"$","",dict_str)

    header = php_start;
    if var_name != "":
        header = "%s$%s = " % (header,var_name,)
    footer = php_end

    return "%s%s;\n%s" % (header,dict_str,footer,)
        


src/k/a/karesansui-HEAD/bin/read_conf.py   karesansui(Download)
    from karesansui.lib.dict_op import DictOp
    from karesansui.lib.file.configfile import ConfigFile
    from karesansui.lib.utils import python_dict_to_php_array
 
except ImportError, e:
                    _var = "Config_Dict_%s" % (_mod,)
                    if opts.php is True:
                        _str = python_dict_to_php_array(dop.getconf(_mod),_var)
                        ConfigFile(_file).write(_str)
                    else: