def createNamespacePackage(package_name, module_relpath): parts = package_name.split('.') source_ref = SourceCodeReference.fromFilenameAndLine( filename = module_relpath, line = 1, future_spec = FutureSpec(), ) source_ref = source_ref.atInternal() package_package_name = '.'.join(parts[:-1]) or None package = PythonPackage( name = parts[-1], package_name = package_package_name, source_ref = source_ref, ) if Utils.python_version >= 300: statement = createPython3NamespacePath( package_name = package_name, module_relpath = module_relpath, source_ref = source_ref ) else: statement = createPathAssignment(source_ref) package.setBody( makeStatementsSequenceFromStatement( statement = statement ) ) completeVariableClosures(package) return source_ref, package
def createNamespacePackage(package_name, module_relpath): parts = package_name.split(".") source_ref = SourceCodeReference.fromFilenameAndLine( module_relpath, 1, FutureSpec(), False ) source_ref = source_ref.atInternal() package_package_name = ".".join(parts[:-1]) or None package = PythonPackage( name = parts[-1], package_name = package_package_name, source_ref = source_ref, ) package.setBody( makeStatementsSequenceFromStatement( statement = ( StatementAssignmentVariable( variable_ref = ExpressionTargetVariableRef( variable_name = "__path__", source_ref = source_ref ), source = ExpressionCallNoKeywords( called = ExpressionImportName( module = ExpressionImportModule( module_name = "_frozen_importlib", import_list = (), level = 0, source_ref = source_ref ), import_name = "_NamespacePath", source_ref = source_ref ), args = ExpressionConstantRef( constant = ( package_name, [ module_relpath ], None ), source_ref = source_ref ), source_ref = source_ref ), source_ref = source_ref ) ) ) ) completeVariableClosures( package ) return source_ref, package
def createNamespacePackage(package_name, module_relpath): parts = package_name.split('.') source_ref = SourceCodeReference.fromFilenameAndLine( filename = module_relpath, line = 1, future_spec = FutureSpec(), ) source_ref = source_ref.atInternal() package_package_name = '.'.join(parts[:-1]) or None package = PythonPackage( name = parts[-1], package_name = package_package_name, source_ref = source_ref, ) package.setBody( makeStatementsSequenceFromStatement( statement = ( StatementAssignmentVariable( variable_ref = ExpressionTargetVariableRef( variable_name = "__path__", source_ref = source_ref ), source = ExpressionCallNoKeywords( called = ExpressionImportName( module = ExpressionImportModule( module_name = "_frozen_importlib", import_list = (), level = 0, source_ref = source_ref ), import_name = "_NamespacePath", source_ref = source_ref ), args = ExpressionConstantRef( constant = ( package_name, [module_relpath], None ), source_ref = source_ref ), source_ref = source_ref ), source_ref = source_ref ) ) ) ) completeVariableClosures(package) return source_ref, package