Convert the current module into a package.
770875
def refactor_module_to_package(self):
        """"""
        refactor = ModuleToPackage(self.project, self.resource)
        return self._get_changes(refactor)
1284910
def _module_to_base_modules(s):
    
    parts = s.split('.')
    for i in range(1, len(parts)):
        yield '.'.join(parts[:i])
1230904
def walk(self):
        
        yield (
            self,
            self.parent,
            list(self.sub_packages.values()),
            list(self.sub_modules.values()),
        )

        for pkg in self.sub_packages.values():
            for things in pkg.walk():
                yield things
1141421
def _setup(module, extras):
    """"""

    Qt.__binding__ = module.__name__

    for name in list(_common_members) + extras:
        try:
            submodule = _import_sub_module(
                module, name)
        except ImportError:
            try:
                # For extra modules like sip and shiboken that may not be
                # children of the binding.
                submodule = __import__(name)
            except ImportError:
                continue

        setattr(Qt, "_" + name, submodule)

        if name not in extras:
            # Store reference to original binding,
            # but don't store speciality modules
            # such as uic or QtUiTools
            setattr(Qt, name, _new_module(name))
497010
def pack(self):
        "  "
        pack_name = self.args.prefix + op.basename(self.path)
        pack_path = op.join(self.args.output or self.basedir, pack_name)

        self.out("Packing: %s" % self.path)
        self.out("Output: %s" % pack_path)

        if self.args.format:
            ext = self.get_ext(self.path)
            self.parsers[ext] = self.args.format

        out = "".join(self.merge(self.parse(self.path)))
        try:
            open(pack_path, 'w').write(out)
            self.out("Linked file saved as: '%s'." % pack_path)
        except IOError, ex:
            raise ZetaError(ex)
712383
def processModule(module_name):
  
  """
  Module = sys.modules[module_name]
  MembersTarget = []
  ClassQ = []
  Cls = None
  ClsGroup = None
  ClsGrpMembers = []

  for Member in ModuleMembers[module_name]:
    Underlying = Member.Underlying
    member_name = Member.Config['name']
    member_alias = Member.Config.get('alias', None)

    if ClassQ:
      ClsGroup = ClassQ[-1]
      Cls = ClsGroup.Underlying

      if getattr(Cls, Underlying.__name__, None) is Underlying: # we got a member tht is a child of the previous class
        if isclass(Underlying):
          ClassQ.append(Underlying.__ec_member__)

        elif not isunderlying(Underlying):
          continue

        if member_alias:
          ClsGrpMembers.insert(0, (member_alias, Member))

        ClsGrpMembers.insert(0, (member_name, Member))
        continue

      elif Cls: # we've finished adding children to the previous class
        ClsGroup.Members = OrderedDict(ClsGrpMembers)
        ClsGrpMembers = []
        ClassQ.pop()
        Cls = None
        ClsGroup = None

    if isunderlying(Underlying):
      if member_alias:
        MembersTarget.insert(0, (member_alias, Member))

      MembersTarget.insert(0, (member_name, Member))

      if isclass(Underlying):
        ClassQ.append(Underlying.__ec_member__)

  if ClsGroup:
    ClsGroup.Members = OrderedDict(ClsGrpMembers)

  ModuleMembers[module_name] = []  # remove the existing members from the cache so that they won't be processed again

  if not hasattr(Module.__ec_member__, 'Members'):
    Module.__ec_member__.Members = OrderedDict(MembersTarget)
41372
def post_install_package():
    

    module_name = '.'.join([env.project_package_name,'deploy'])
    funcs_run = []
    try:
        imported = import_module(module_name)
        funcs = vars(imported)
        for f in env.installed_packages[env.host]:
            func = funcs.get(''.join(['post_install_',f.replace('.','_').replace('-','_')]))
            if func:
                func()
                funcs_run.append(func)
    except ImportError:
        pass
    
    #run per app
    for app in env.INSTALLED_APPS:
        if app == 'woven': continue
        module_name = '.'.join([app,'deploy'])
        try:
            imported = import_module(module_name)
            funcs = vars(imported)
            for f in env.installed_packages[env.host]:
                func = funcs.get(''.join(['post_install_',f.replace('.','_').replace('-','_')]))
                if func and func not in funcs_run:
                    func()
                    funcs_run.append(func)
        except ImportError:
            pass
    #run woven last
    import woven.deploy
    funcs = vars(woven.deploy)
    for f in env.installed_packages[env.host]:
        func = funcs.get(''.join(['post_install_',f.replace('.','_').replace('-','_')]))
        if func and func not in funcs_run: func()
869128
def create_module(project, name, sourcefolder=None):
    """"""
    if sourcefolder is None:
        sourcefolder = project.root
    packages = name.split('.')
    parent = sourcefolder
    for package in packages[:-1]:
        parent = parent.get_child(package)
    return parent.create_file(packages[-1] + '.py')
878806
def _prepack(self):
        '''
        
        '''
        current = self
        while current is not None:
            current._parser.prepack(current, skip_self = True)
            current = getattr(current, '_sub', None)
        current = self
        while current is not None:
            current._parser.prepack(current, skip_sub = True)
            current = getattr(current, '_sub', None)
271715
def create_module_file(package, module, opts):
    """"""
    if not opts.noheadings:
        text = format_heading(1, '%s module' % module)
    else:
        text = ''
    # text += format_heading(2, ':mod:`%s` Module' % module)
    text += format_directive(module, package)
    write_file(makename(package, module), text, opts)
563558
def to_build_module(build_file_path: str, conf: Config) -> str:
    """"""
    build_file = Path(build_file_path)
    root = Path(conf.project_root)
    return build_file.resolve().relative_to(root).parent.as_posix().strip('.')
826676
def _ImportModuleHookBySuffix(name, package=None):
  """"""
  _IncrementNestLevel()

  try:
    # Really import modules.
    module = _real_import_module(name, package)
  finally:
    if name.startswith('.'):
      if package:
        name = _ResolveRelativeImport(name, package)
      else:
        # Should not happen. Relative imports require the package argument.
        name = None
    if name:
      _ProcessImportBySuffix(name, None, None)

  return module
1301211
def _copy_module(old):
    """"""
    saved = sys.modules.pop(old.__name__, None)
    new = __import__(old.__name__)
    sys.modules[old.__name__] = saved
    return new
1227859
def from_module(self, path):
        """"""
        bundles = PythonLoader(path).load_bundles()
        for name in bundles:
            self.register(name, bundles[name])
1070144
def modules(self):
        """"""
        defmodule = lib.EnvGetNextDefmodule(self._env, ffi.NULL)

        while defmodule != ffi.NULL:
            yield Module(self._env, defmodule)

            defmodule = lib.EnvGetNextDefmodule(self._env, defmodule)
312433
def create_module(module, target):
    
    module_x = module.split('.')
    cur_path = ''
    for path in module_x:
        cur_path = os.path.join(cur_path, path)
        if not os.path.isdir(os.path.join(target, cur_path)):
            os.mkdir(os.path.join(target, cur_path))
        if not os.path.exists(os.path.join(target, cur_path, '__init__.py')):
            touch(os.path.join(target, cur_path, '__init__.py'))
    return cur_path
1284462
def _import_module(name, package=None):
    
    if name.startswith('.'):
        name = '{package}.{module}'.format(package=package, module=str(name).strip('.'))
    __import__(name)
    return sys.modules[name]