本文整理汇总了Python中nuitka.Utils.listDir方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.listDir方法的具体用法?Python Utils.listDir怎么用?Python Utils.listDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuitka.Utils
的用法示例。
在下文中一共展示了Utils.listDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkPluginPath
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import listDir [as 别名]
def checkPluginPath(plugin_filename, module_package):
debug(
"Checking top level plugin path %s %s",
plugin_filename,
module_package
)
plugin_info = considerFilename(
module_package = module_package,
module_filename = plugin_filename
)
if plugin_info is not None:
# File or package makes a difference, handle that
if Utils.isFile(plugin_info[0]) or \
Importing.isPackageDir(plugin_info[0]):
_checkPluginPath(plugin_filename, module_package)
elif Utils.isDir(plugin_info[0]):
for sub_path, sub_filename in Utils.listDir(plugin_info[0]):
assert sub_filename != "__init__.py"
if Importing.isPackageDir(sub_path) or \
sub_path.endswith(".py"):
_checkPluginPath(sub_path, None)
else:
warning("Failed to include module from '%s'.", plugin_info[0])
else:
warning("Failed to recurse to directory '%s'.", plugin_filename)
示例2: checkPluginPath
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import listDir [as 别名]
def checkPluginPath( plugin_filename, module_package ):
plugin_info = considerFilename(
module_package = module_package,
module_filename = plugin_filename
)
if plugin_info is not None:
# File or package, handle that.
if Utils.isFile( plugin_info[0] ) or Importing.isPackageDir( plugin_info[0] ):
_checkPluginPath( plugin_filename, module_package )
elif Utils.isDir( plugin_info[0] ):
for sub_path, sub_filename in Utils.listDir( plugin_info[0] ):
assert sub_filename != "__init__.py"
if Importing.isPackageDir( sub_path ) or sub_path.endswith( ".py" ):
_checkPluginPath( sub_path, None )
else:
warning( "Failed to include module from '%s'.", plugin_info[0] )
示例3: _checkPluginPath
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import listDir [as 别名]
def _checkPluginPath( plugin_filename, module_package ):
plugin_info = considerFilename(
module_package = module_package,
module_filename = plugin_filename
)
if plugin_info is not None:
module, added = recurseTo(
module_filename = plugin_info[0],
module_relpath = plugin_info[1],
module_package = module_package
)
if module:
if not added:
warning(
"Recursed to %s '%s' at '%s' twice.",
"package" if module.isPythonPackage() else "module",
module.getName(),
plugin_info[0]
)
if module.isPythonPackage():
package_dir = Utils.dirname( module.getFilename() )
for sub_path, sub_filename in Utils.listDir( package_dir ):
if sub_filename == "__init__.py":
continue
assert sub_path != plugin_filename, package_dir
if Importing.isPackageDir( sub_path ) or sub_path.endswith( ".py" ):
_checkPluginPath( sub_path, module.getFullName() )
else:
warning( "Failed to include module from '%s'.", plugin_info[0] )
示例4: _checkPluginPath
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import listDir [as 别名]
def _checkPluginPath(plugin_filename, module_package):
debug(
"Checking detail plugin path %s %s",
plugin_filename,
module_package
)
plugin_info = considerFilename(
module_package = module_package,
module_filename = plugin_filename
)
if plugin_info is not None:
module, is_added = recurseTo(
module_filename = plugin_info[0],
module_relpath = plugin_info[1],
module_package = module_package,
module_kind = "py",
reason = "Lives in plugin directory."
)
if module:
if not is_added:
warning(
"Recursed to %s '%s' at '%s' twice.",
"package" if module.isPythonPackage() else "module",
module.getName(),
plugin_info[0]
)
if not isSameModulePath(module.getFilename(), plugin_info[0]):
warning(
"Duplicate ignored '%s'.",
plugin_info[1]
)
return
debug(
"Recursed to %s %s %s",
module.getName(),
module.getPackage(),
module
)
if module.isPythonPackage():
package_filename = module.getFilename()
if Utils.isDir(package_filename):
# Must be a namespace package.
assert Utils.python_version >= 330
package_dir = package_filename
# Only include it, if it contains actual modules, which will
# recurse to this one and find it again.
useful = False
else:
package_dir = Utils.dirname(package_filename)
# Real packages will always be included.
useful = True
debug(
"Package directory %s",
package_dir
)
for sub_path, sub_filename in Utils.listDir(package_dir):
if sub_filename in ("__init__.py", "__pycache__"):
continue
assert sub_path != plugin_filename
if Importing.isPackageDir(sub_path) or \
sub_path.endswith(".py"):
_checkPluginPath(sub_path, module.getFullName())
else:
# Modules should always be included.
useful = True
if useful:
ModuleRegistry.addRootModule(module)
else:
warning( "Failed to include module from '%s'.", plugin_info[0] )