本文整理汇总了Python中nuitka.Utils.splitpath方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.splitpath方法的具体用法?Python Utils.splitpath怎么用?Python Utils.splitpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nuitka.Utils
的用法示例。
在下文中一共展示了Utils.splitpath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildModuleTree
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import splitpath [as 别名]
def buildModuleTree( filename, package, is_top, is_main ):
# Many variables, branches, due to the many cases, pylint: disable=R0912
assert package is None or type( package ) is str
if is_main and Utils.isDir( filename ):
source_filename = Utils.joinpath( filename, "__main__.py" )
if not Utils.isFile( source_filename ):
sys.stderr.write(
"%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,
#.........这里部分代码省略.........
示例2: decideModuleTree
# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import splitpath [as 别名]
def decideModuleTree(filename, package, is_shlib, is_top, is_main):
# Many variables, branches, due to the many cases, pylint: disable=R0912
assert package is None or type( package ) is str
if is_main and Utils.isDir( filename ):
source_filename = Utils.joinpath( filename, "__main__.py" )
if not Utils.isFile( source_filename ):
sys.stderr.write(
"%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 is_shlib:
module_name = module_name.split(".")[0]
if "." in module_name:
sys.stderr.write(
"Error, '%s' is not a proper python module name.\n" % (
module_name
)
)
sys.exit( 2 )
if is_shlib:
result = PythonShlibModule(
name = module_name,
source_ref = source_ref,
package_name = package,
)
elif is_main:
result = PythonMainModule(
source_ref = source_ref,
main_added = main_added
)
else:
result = PythonModule(
name = module_name,
package_name = package,
source_ref = source_ref
)
elif Importing.isPackageDir(filename):
if is_top:
package_name = Utils.splitpath(filename)[-1]
else:
package_name = Utils.basename(filename)
source_filename = Utils.joinpath(filename, "__init__.py")
if not Utils.isFile( source_filename ):
assert Utils.python_version >= 330, source_filename
source_ref, result = createNamespacePackage(
package_name = package_name,
module_relpath = filename
)
source_filename = None
else:
source_ref = SourceCodeReferences.fromFilename(
filename = Utils.abspath( source_filename ),
future_spec = FutureSpec()
)
result = PythonPackage(
name = package_name,
package_name = package,
source_ref = source_ref
)
else:
sys.stderr.write(
"%s: can't open file '%s'.\n" % (
Utils.basename( sys.argv[0] ),
filename
#.........这里部分代码省略.........