コード例 #1
0
ファイル: collector.py プロジェクト: igorgue/konira
def globals_from_file(filename):
    _file = open(filename)
    data  = tokenize.untokenize(translate(_file.readline))
    compiled = compile(data, filename, "exec")
    globals_ = {}
    exec(compiled, globals_)
    return globals_
コード例 #2
0
ファイル: collector.py プロジェクト: akukday/konira
def globals_from_file(filename):
    # be aware of same file path for relative imports
    old_path0   = sys.path[0]
    sys.path[0] = os.path.dirname(filename)

    _file = open(filename)
    data  = tokenize.untokenize(translate(_file.readline))
    compiled = compile(data, filename, "exec")
    globals_ = {}
    exec(compiled, globals_)

    # restore the original sys.path
    sys.path[0] = old_path0
    return globals_, data
コード例 #3
0
ファイル: collector.py プロジェクト: akukday/konira
def globals_from_file(filename):
    # be aware of same file path for relative imports
    old_path0 = sys.path[0]
    sys.path[0] = os.path.dirname(filename)

    _file = open(filename)
    data = tokenize.untokenize(translate(_file.readline))
    compiled = compile(data, filename, "exec")
    globals_ = {}
    exec(compiled, globals_)

    # restore the original sys.path
    sys.path[0] = old_path0
    return globals_, data