当前位置: 首页>>代码示例>>Python>>正文


Python Utils.dirname方法代码示例

本文整理汇总了Python中nuitka.Utils.dirname方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.dirname方法的具体用法?Python Utils.dirname怎么用?Python Utils.dirname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nuitka.Utils的用法示例。


在下文中一共展示了Utils.dirname方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: isSameModulePath

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [as 别名]
def isSameModulePath(path1, path2):
    if Utils.basename(path1) == "__init__.py":
        path1 = Utils.dirname(path1)
    if Utils.basename(path2) == "__init__.py":
        path2 = Utils.dirname(path2)

    return Utils.abspath(path1) == Utils.abspath(path2)
开发者ID:jenshiller,项目名称:Nuitka,代码行数:9,代码来源:Recursion.py

示例2: __init__

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [as 别名]
    def __init__(self, *args):
        QtGui.QDialog.__init__(self, *args)

        ui_dir = Utils.dirname(__file__)
        ui_filename = Utils.joinpath(ui_dir, "dialogs", "InspectPythonTree.ui")

        uic.loadUi(ui_filename, self)

        self.treeview_nodes.setSelectionMode(self.treeview_nodes.SingleSelection)

        self.displayed = None
        self.source_code = None
        self.model = None
        self.moving = None
开发者ID:Wkryst,项目名称:Nuitka,代码行数:16,代码来源:TreeDisplay.py

示例3: _checkPluginPath

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [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] )
开发者ID:ballacky13,项目名称:Nuitka,代码行数:39,代码来源:Recursion.py

示例4: _checkPluginPath

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [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] )
开发者ID:jenshiller,项目名称:Nuitka,代码行数:89,代码来源:Recursion.py

示例5: getOutputFilename

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [as 别名]
 def getOutputFilename(self):
     return Utils.dirname( self.getFilename() )
开发者ID:jenshiller,项目名称:Nuitka,代码行数:4,代码来源:ModuleNodes.py

示例6: buildParseTree

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [as 别名]
def buildParseTree( provider, source_code, source_ref, is_module ):
    # Workaround: ast.parse cannot cope with some situations where a file is not terminated
    # by a new line.
    if not source_code.endswith( "\n" ):
        source_code = source_code + "\n"

    body = ast.parse( source_code, source_ref.getFilename() )
    assert getKind( body ) == "Module"

    line_offset = source_ref.getLineNumber() - 1

    if line_offset > 0:
        for created_node in ast.walk( body ):
            if hasattr( created_node, "lineno" ):
                created_node.lineno += line_offset

    body, doc = extractDocFromBody( body )

    result = buildStatementsNode(
        provider   = provider,
        nodes      = body,
        source_ref = source_ref,
        frame      = is_module
    )

    # Check if a __future__ imports really were at the beginning of the file.
    for node in body:
        if node in _future_import_nodes:
            _future_import_nodes.remove( node )
        else:
            if _future_import_nodes:
                SyntaxErrors.raiseSyntaxError(
                    reason     = "from __future__ imports must occur at the beginning of the file",
                    col_offset = 1 if Utils.python_version >= 300 or not Options.isFullCompat() else None,
                    source_ref = _future_import_nodes[0].source_ref
                )

    internal_source_ref = source_ref.atInternal()

    statements = []

    if is_module:
        statements.append(
            StatementAssignmentVariable(
                variable_ref = ExpressionTargetVariableRef(
                    variable_name = "__doc__",
                    source_ref    = internal_source_ref
                ),
                source       = ExpressionConstantRef(
                    constant   = doc,
                    source_ref = internal_source_ref
                ),
                source_ref   = internal_source_ref
            )
        )

        statements.append(
            StatementAssignmentVariable(
                variable_ref = ExpressionTargetVariableRef(
                    variable_name = "__file__",
                    source_ref    = internal_source_ref
                ),
                source       = ExpressionConstantRef(
                    constant   = source_ref.getFilename(),
                    source_ref = internal_source_ref
                ),
                source_ref   = internal_source_ref
            )
        )

        if provider.isPythonPackage():
            # TODO: __package__ is not set here, but automatically, which makes it invisible
            # though
            statements.append(
                StatementAssignmentVariable(
                    variable_ref = ExpressionTargetVariableRef(
                        variable_name = "__path__",
                        source_ref    = internal_source_ref
                    ),
                    source       = ExpressionConstantRef(
                        constant   = [ Utils.dirname( source_ref.getFilename() ) ],
                        source_ref = internal_source_ref
                    ),
                    source_ref   = internal_source_ref
                )
            )

    if Utils.python_version >= 300:
        statements.append(
            StatementAssignmentVariable(
                variable_ref = ExpressionTargetVariableRef(
                    variable_name = "__cached__",
                    source_ref    = internal_source_ref
                ),
                source       = ExpressionConstantRef(
                    constant   = None,
                    source_ref = internal_source_ref
                ),
                source_ref   = internal_source_ref
            )
#.........这里部分代码省略.........
开发者ID:ballacky13,项目名称:Nuitka,代码行数:103,代码来源:Building.py

示例7: getSconsDataPath

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [as 别名]
def getSconsDataPath():
    return Utils.dirname( __file__ )
开发者ID:linkerlin,项目名称:Nuitka,代码行数:4,代码来源:SconsInterface.py

示例8: buildParseTree

# 需要导入模块: from nuitka import Utils [as 别名]
# 或者: from nuitka.Utils import dirname [as 别名]

#.........这里部分代码省略.........
                    source_ref    = internal_source_ref,
                    user_provided = True
                ),
                source_ref   = internal_source_ref
            )
        )

        statements.append(
            StatementAssignmentVariable(
                variable_ref = ExpressionTargetVariableRef(
                    variable_name = "__file__",
                    source_ref    = internal_source_ref
                ),
                source       = ExpressionConstantRef(
                    constant      = source_ref.getFilename(),
                    source_ref    = internal_source_ref,
                    user_provided = True
                ),
                source_ref   = internal_source_ref
            )
        )

        if provider.isPythonPackage():
            # TODO: __package__ is not set here, but automatically, which makes
            # it invisible though
            statements.append(
                StatementAssignmentVariable(
                    variable_ref = ExpressionTargetVariableRef(
                        variable_name = "__path__",
                        source_ref    = internal_source_ref
                    ),
                    source       = ExpressionConstantRef(
                        constant      = [
                            Utils.dirname( source_ref.getFilename() )
                        ],
                        source_ref    = internal_source_ref,
                        user_provided = True
                    ),
                    source_ref   = internal_source_ref
                )
            )

    if Utils.python_version >= 300:
        statements.append(
            StatementAssignmentVariable(
                variable_ref = ExpressionTargetVariableRef(
                    variable_name = "__cached__",
                    source_ref    = internal_source_ref
                ),
                source       = ExpressionConstantRef(
                    constant      = None,
                    source_ref    = internal_source_ref,
                    user_provided = True
                ),
                source_ref   = internal_source_ref
            )
        )


    if Utils.python_version >= 330:
        # For Python3.3, it's set for both packages and non-packages.
        statements.append(
            StatementAssignmentVariable(
                variable_ref = ExpressionTargetVariableRef(
                    variable_name = "__package__",
                    source_ref    = internal_source_ref
开发者ID:TheKK,项目名称:Nuitka,代码行数:70,代码来源:Building.py


注:本文中的nuitka.Utils.dirname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。