本文整理汇总了Python中nuitka.Utils.relpath方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.relpath方法的具体用法?Python Utils.relpath怎么用?Python Utils.relpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuitka.Utils
的用法示例。
在下文中一共展示了Utils.relpath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: considerImplicitImports
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def considerImplicitImports(self, signal_change):
for module_name, module_package in self.getImplicitImports():
_module_package, _module_name, module_filename = \
Importing.findModule(
source_ref = self.source_ref,
module_name = module_name,
parent_package = module_package,
level = -1,
warn = True
)
if module_filename is None:
sys.exit(
"Error, implicit module '%s' expected by '%s' not found" % (
module_name,
self.getFullName()
)
)
elif Utils.isDir(module_filename):
module_kind = "py"
elif module_filename.endswith(".py"):
module_kind = "py"
elif module_filename.endswith(".so"):
module_kind = "shlib"
elif module_filename.endswith(".pyd"):
module_kind = "shlib"
else:
assert False, module_filename
from nuitka.tree import Recursion
decision, reason = Recursion.decideRecursion(
module_filename = module_filename,
module_name = module_name,
module_package = module_package,
module_kind = module_kind
)
assert decision or reason == "Module is frozen."
if decision:
module_relpath = Utils.relpath(module_filename)
imported_module, added_flag = Recursion.recurseTo(
module_package = module_package,
module_filename = module_filename,
module_relpath = module_relpath,
module_kind = module_kind,
reason = reason
)
from nuitka.ModuleRegistry import addUsedModule
addUsedModule(imported_module)
if added_flag:
signal_change(
"new_code",
imported_module.getSourceReference(),
"Recursed to module."
)
示例2: attemptRecursion
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def attemptRecursion( self, module ):
if not Options.shallMakeModule():
# Make sure the package is recursed to.
module_package = module.getPackage()
if module_package is not None:
package_package, _package_module_name, package_filename = Importing.findModule(
source_ref = module.getSourceReference(),
module_name = module_package,
parent_package = None,
level = 1
)
imported_module, added_flag = Recursion.recurseTo(
module_package = package_package,
module_filename = package_filename,
module_relpath = Utils.relpath( package_filename )
)
if added_flag:
self.signalChange(
"new_code",
imported_module.getSourceReference(),
"Recursed to module package."
)
示例3: buildModuleTree
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def buildModuleTree(filename, package, is_top, is_main):
module, source_ref, source_filename = decideModuleTree(
filename = filename,
package = package,
is_top = is_top,
is_main = is_main,
is_shlib = False
)
addImportedModule(
module_relpath = Utils.relpath(filename),
imported_module = module
)
# If there is source code associated (not the case for namespace packages of
# Python3.3 or higher, then read it.
if source_filename is not None:
createModuleTree(
module = module,
source_ref = source_ref,
source_filename = source_filename,
is_main = is_main
)
return module
示例4: considerFilename
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def considerFilename( module_filename, module_package ):
assert module_package is None or ( type( module_package ) is str and module_package != "" )
module_filename = Utils.normpath( module_filename )
if Utils.isDir( module_filename ):
module_filename = Utils.abspath( module_filename )
module_name = Utils.basename( module_filename )
module_relpath = Utils.relpath( module_filename )
return module_filename, module_relpath, module_name
elif module_filename.endswith( ".py" ):
module_name = Utils.basename( module_filename )[:-3]
module_relpath = Utils.relpath( module_filename )
return module_filename, module_relpath, module_name
else:
return None
示例5: attemptRecursion
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def attemptRecursion(self):
# Make sure the package is recursed to.
from nuitka.tree import Recursion
from nuitka import Importing
# Return the list of newly added modules.
result = []
if self.package_name is not None and self.package is None:
package_package, _package_module_name, package_filename = \
Importing.findModule(
source_ref = self.getSourceReference(),
module_name = self.package_name,
parent_package = None,
level = 1,
warn = Utils.python_version < 330
)
# TODO: Temporary, if we can't find the package for Python3.3 that
# is semi-OK, maybe.
if Utils.python_version >= 330 and not package_filename:
return []
imported_module, is_added = Recursion.recurseTo(
module_package = package_package,
module_filename = package_filename,
module_relpath = Utils.relpath(package_filename),
module_kind = "py",
reason = "Containing package of recursed module.",
)
self.package = imported_module
if is_added:
result.append(imported_module)
if self.package:
from nuitka.ModuleRegistry import addUsedModule
addUsedModule(self.package)
# print "Recursed to package", self.package_name
result.extend(self.package.attemptRecursion())
return result
示例6: _consider
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def _consider( self, constraint_collection, module_filename, module_package ):
assert module_package is None or ( type( module_package ) is str and module_package != "" )
module_filename = Utils.normpath( module_filename )
if Utils.isDir( module_filename ):
module_name = Utils.basename( module_filename )
elif module_filename.endswith( ".py" ):
module_name = Utils.basename( module_filename )[:-3]
else:
module_name = None
if module_name is not None:
decision = self._decide( module_filename, module_name, module_package )
if decision:
module_relpath = Utils.relpath( module_filename )
return self._recurseTo(
constraint_collection = constraint_collection,
module_package = module_package,
module_filename = module_filename,
module_relpath = module_relpath
)
elif decision is None:
if module_package is None:
module_fullpath = module_name
else:
module_fullpath = module_package + "." + module_name
if module_filename not in self._warned_about:
self._warned_about.add( module_filename )
warning( # long message, but shall be like it, pylint: disable=C0301
"""\
Not recursing to '%(full_path)s' (%(filename)s), please specify \
--recurse-none (do not warn), \
--recurse-all (recurse to all), \
--recurse-not-to=%(full_path)s (ignore it), \
--recurse-to=%(full_path)s (recurse to it) to change.""" % {
"full_path" : module_fullpath,
"filename" : module_filename
}
)
示例7: _consider
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
def _consider(self, constraint_collection, module_filename, module_package):
assert module_package is None or \
(type(module_package) is str and module_package != "")
module_filename = Utils.normpath(module_filename)
if Utils.isDir(module_filename):
module_name = Utils.basename(module_filename)
module_kind = "py"
elif module_filename.endswith(".py"):
module_name = Utils.basename(module_filename)[:-3]
module_kind = "py"
elif module_filename.endswith(".so"):
module_kind = "shlib"
module_name = Utils.basename(module_filename)[:-3]
elif module_filename.endswith(".pyd"):
module_kind = "shlib"
module_name = Utils.basename(module_filename)[:-4]
else:
module_kind = None
module_name = None
if module_kind is not None:
from nuitka.tree import Recursion
decision, reason = Recursion.decideRecursion(
module_filename = module_filename,
module_name = module_name,
module_package = module_package,
module_kind = module_kind
)
if decision:
module_relpath = Utils.relpath(module_filename)
imported_module, added_flag = Recursion.recurseTo(
module_package = module_package,
module_filename = module_filename,
module_relpath = module_relpath,
module_kind = module_kind,
reason = reason
)
if added_flag:
constraint_collection.signalChange(
"new_code",
imported_module.getSourceReference(),
"Recursed to module."
)
return imported_module
elif decision is None and module_kind == "py":
if module_package is None:
module_fullpath = module_name
else:
module_fullpath = module_package + "." + module_name
if module_filename not in self._warned_about and \
module_fullpath not in getModuleWhiteList():
self._warned_about.add(module_filename)
warning(
"""\
Not recursing to '%(full_path)s' (%(filename)s), please specify \
--recurse-none (do not warn), \
--recurse-all (recurse to all), \
--recurse-not-to=%(full_path)s (ignore it), \
--recurse-to=%(full_path)s (recurse to it) to change.""" % {
"full_path" : module_fullpath,
"filename" : module_filename
}
)
示例8: buildModuleTree
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import relpath [as 别名]
#.........这里部分代码省略.........
"%s: can't find '__main__' module in '%s'\n" % (
Utils.basename( sys.argv[0] ),
filename
)
)
sys.exit( 2 )
filename = source_filename
main_added = True
else:
main_added = False
if Utils.isFile( filename ):
source_filename = filename
source_ref = SourceCodeReferences.fromFilename(
filename = filename,
future_spec = FutureSpec()
)
if is_main:
module_name = "__main__"
else:
module_name = Utils.basename( filename )
if module_name.endswith( ".py" ):
module_name = module_name[:-3]
if "." in module_name:
sys.stderr.write(
"Error, '%s' is not a proper python module name.\n" % (
module_name
)
)
sys.exit( 2 )
if is_main:
result = PythonMainModule(
source_ref = source_ref,
main_added = main_added
)
else:
result = PythonModule(
name = module_name,
package = package,
source_ref = source_ref
)
elif Utils.isDir( filename ) and Utils.isFile( Utils.joinpath( filename, "__init__.py" ) ):
source_filename = Utils.joinpath( filename, "__init__.py" )
if is_top:
source_ref = SourceCodeReferences.fromFilename(
filename = Utils.abspath( source_filename ),
future_spec = FutureSpec()
)
package_name = Utils.splitpath( filename )[-1]
else:
source_ref = SourceCodeReferences.fromFilename(
filename = Utils.abspath( source_filename ),
future_spec = FutureSpec()
)
package_name = Utils.basename( filename )
result = PythonPackage(
name = package_name,
package = package,
source_ref = source_ref
)
else:
sys.stderr.write(
"%s: can't open file '%s'.\n" % (
Utils.basename( sys.argv[0] ),
filename
)
)
sys.exit( 2 )
if not Options.shallHaveStatementLines():
source_ref = source_ref.atInternal()
source_code = readSourceCodeFromFilename( source_filename )
module_body = buildParseTree(
provider = result,
source_code = source_code,
source_ref = source_ref,
is_module = True
)
result.setBody( module_body )
addImportedModule( Utils.relpath( filename ), result )
completeVariableClosures( result )
return result