当前位置: 首页>>代码示例>>Python>>正文


Python asn1crypto.__file__方法代码示例

本文整理汇总了Python中asn1crypto.__file__方法的典型用法代码示例。如果您正苦于以下问题:Python asn1crypto.__file__方法的具体用法?Python asn1crypto.__file__怎么用?Python asn1crypto.__file__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在asn1crypto的用法示例。


在下文中一共展示了asn1crypto.__file__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load_order

# 需要导入模块: import asn1crypto [as 别名]
# 或者: from asn1crypto import __file__ [as 别名]
def test_load_order(self):
        deps = {}

        mod_root = os.path.abspath(os.path.dirname(module.__file__))
        files = []
        for root, dnames, fnames in os.walk(mod_root):
            for f in fnames:
                if f.endswith('.py'):
                    full_path = os.path.join(root, f)
                    rel_path = full_path.replace(mod_root + os.sep, '')
                    files.append((full_path, rel_path))

        for full_path, rel_path in sorted(files):
            with open(full_path, 'rb') as f:
                full_code = f.read()
                if sys.version_info >= (3,):
                    full_code = full_code.decode('utf-8')

            modname = rel_path.replace('.py', '').replace(os.sep, '.')
            if modname == '__init__':
                modname = module.__name__
            else:
                modname = '%s.%s' % (module.__name__, modname)

            imports = set([])
            module_node = ast.parse(full_code, filename=full_path)
            walk_ast(module_node, modname, imports)

            deps[modname] = imports

        load_order = module.load_order()
        prev = set([])
        for mod in load_order:
            self.assertEqual(True, mod in deps)
            self.assertEqual((mod, set([])), (mod, deps[mod] - prev))
            prev.add(mod) 
开发者ID:wbond,项目名称:asn1crypto,代码行数:38,代码来源:test_init.py

示例2: shortimport

# 需要导入模块: import asn1crypto [as 别名]
# 或者: from asn1crypto import __file__ [as 别名]
def shortimport():
    print 'shortimport'
    import asn1crypto
    print 'asn1crypto:', asn1crypto.__file__
    return 'shortimport' 
开发者ID:TriggerMail,项目名称:rules_pyz,代码行数:7,代码来源:shortimport.py

示例3: _preload

# 需要导入模块: import asn1crypto [as 别名]
# 或者: from asn1crypto import __file__ [as 别名]
def _preload(require_oscrypto, print_info):
    """
    Preloads asn1crypto and optionally oscrypto from a local source checkout,
    or from a normal install

    :param require_oscrypto:
        A bool if oscrypto needs to be preloaded

    :param print_info:
        A bool if info about asn1crypto and oscrypto should be printed
    """

    if print_info:
        print('Working dir: ' + getcwd())
        print('Python ' + sys.version.replace('\n', ''))

    asn1crypto = None
    oscrypto = None

    if require_oscrypto:
        # Some CI services don't use the package name for the dir
        if package_name == 'oscrypto':
            oscrypto_dir = package_root
        else:
            oscrypto_dir = os.path.join(build_root, 'oscrypto')
        oscrypto_tests = None
        if os.path.exists(oscrypto_dir):
            oscrypto_tests = _import_from('oscrypto_tests', oscrypto_dir, 'tests')
        if oscrypto_tests is None:
            import oscrypto_tests
        asn1crypto, oscrypto = oscrypto_tests.local_oscrypto()

    else:
        if package_name == 'asn1crypto':
            asn1crypto_dir = package_root
        else:
            asn1crypto_dir = os.path.join(build_root, 'asn1crypto')
        if os.path.exists(asn1crypto_dir):
            asn1crypto = _import_from('asn1crypto', asn1crypto_dir)
        if asn1crypto is None:
            import asn1crypto

    if print_info:
        print(
            '\nasn1crypto: %s, %s' % (
                asn1crypto.__version__,
                os.path.dirname(asn1crypto.__file__)
            )
        )
        if require_oscrypto:
            print(
                'oscrypto: %s backend, %s, %s' % (
                    oscrypto.backend(),
                    oscrypto.__version__,
                    os.path.dirname(oscrypto.__file__)
                )
            ) 
开发者ID:wbond,项目名称:oscrypto,代码行数:59,代码来源:_import.py


注:本文中的asn1crypto.__file__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。