本文整理匯總了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__)
)
)