當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。