本文整理汇总了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)
示例2: shortimport
# 需要导入模块: import asn1crypto [as 别名]
# 或者: from asn1crypto import __file__ [as 别名]
def shortimport():
print 'shortimport'
import asn1crypto
print 'asn1crypto:', asn1crypto.__file__
return 'shortimport'
示例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__)
)
)