コード例 #1
0
ファイル: please_parser.py プロジェクト: alamaison/please
def glob(package, includes, excludes=None, exclude=None, hidden=False):
    if isinstance(includes, str):
        raise TypeError('The first argument to glob() should be a list')
    excludes = excludes or exclude
    includes_keepalive = [ffi_from_string(include) for include in includes]
    excludes_keepalive = [ffi_from_string(exclude) for exclude in excludes or []]
    filenames = _glob(ffi_from_string(package),
                      ffi.new('char*[]', includes_keepalive),
                      len(includes_keepalive),
                      ffi.new('char*[]', excludes_keepalive),
                      len(excludes_keepalive),
                      hidden)
    return [ffi_to_string(filename) for filename in _null_terminated_array(filenames)]
コード例 #2
0
def glob(package, includes, excludes=None, exclude=None, hidden=False):
    if isinstance(includes, str):
        raise TypeError('The first argument to glob() should be a list')
    excludes = excludes or exclude
    includes_keepalive = [ffi_from_string(include) for include in includes]
    excludes_keepalive = [ffi_from_string(exclude) for exclude in excludes or []]
    filenames = _glob(ffi_from_string(package),
                      ffi.new('char*[]', includes_keepalive),
                      len(includes_keepalive),
                      ffi.new('char*[]', excludes_keepalive),
                      len(excludes_keepalive),
                      hidden)
    return [ffi_to_string(filename) for filename in _null_terminated_array(filenames)]
コード例 #3
0
ファイル: please_parser.py プロジェクト: alamaison/please
    'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'complex', 'delattr', 'dict', 'dir',
    'divmod', 'enumerate', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals',
    'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter',
    'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'ord',
    'bytearray', 'pow', 'print', 'property', 'range', 'reduce', 'repr', 'reversed', 'round',
    'sequenceiterator', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum',
    'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip', '__name__',
    'NotImplemented',
    'compile', '__import__',  # We disallow importing separately, it's too hard to do here
    '__cffi_backend_extern_py',  # This gets added with cpython / cffi 1.6+ and is pretty crucial.
}
if is_py3:
    _WHITELISTED_BUILTINS |= {'bytes', 'exec'}  # These are needed too
    # Have to be more careful with encodings in python 3.
    ffi_to_string = lambda c: ffi.string(c).decode('utf-8')
    ffi_from_string = lambda s: ffi.new('char[]', s.encode('utf-8'))
else:
    ffi_to_string = ffi.string
    ffi_from_string = lambda s: ffi.new('char[]', s)
    builtins.range = builtins.xrange

# Used to indicate that parsing of a target is deferred because it requires another target.
_DEFER_PARSE = '_DEFER_'
_FFI_DEFER_PARSE = ffi_from_string(_DEFER_PARSE)


@ffi.def_extern('ParseFile')
def parse_file(c_filename, c_package_name, c_package):
    try:
        filename = ffi_to_string(c_filename)
        package_name = ffi_to_string(c_package_name)
コード例 #4
0
    'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'complex', 'delattr', 'dict', 'dir',
    'divmod', 'enumerate', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals',
    'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter',
    'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'ord',
    'bytearray', 'pow', 'print', 'property', 'range', 'reduce', 'repr', 'reversed', 'round',
    'sequenceiterator', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum',
    'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip', '__name__',
    'NotImplemented',
    'compile', '__import__',  # We disallow importing separately, it's too hard to do here
    '__cffi_backend_extern_py',  # This gets added with cpython / cffi 1.6+ and is pretty crucial.
}
if is_py3:
    _WHITELISTED_BUILTINS |= {'bytes', 'exec'}  # These are needed too
    # Have to be more careful with encodings in python 3.
    ffi_to_string = lambda c: ffi.string(c).decode('utf-8')
    ffi_from_string = lambda s: ffi.new('char[]', s.encode('utf-8'))
else:
    ffi_to_string = ffi.string
    ffi_from_string = lambda s: ffi.new('char[]', s)
    builtins.range = builtins.xrange

# Used to indicate that parsing of a target is deferred because it requires another target.
_DEFER_PARSE = '_DEFER_'
_FFI_DEFER_PARSE = ffi_from_string(_DEFER_PARSE)


@ffi.def_extern('ParseFile')
def parse_file(c_filename, c_package_name, c_package):
    try:
        filename = ffi_to_string(c_filename)
        package_name = ffi_to_string(c_package_name)