Alternative constructor. Creates a mutator and returns section object.

        :param dict options:
        :param str|unicode dir_base:

        :rtype: SectionMutator
199287
def spawn(cls, options=None, dir_base=None):
        
        from uwsgiconf.utils import ConfModule

        options = options or {
            'compile': True,
        }

        dir_base = os.path.abspath(dir_base or find_project_dir())

        name_module = ConfModule.default_name
        name_project = get_project_name(dir_base)
        path_conf = os.path.join(dir_base, name_module)

        if os.path.exists(path_conf):
            # Read an existing config for further modification of first section.
            section = cls._get_section_existing(name_module, name_project)

        else:
            # Create section on-fly.
            section = cls._get_section_new(dir_base)

        mutator = cls(
            section=section,
            dir_base=dir_base,
            project_name=name_project,
            options=options)

        mutator.mutate()

        return mutator
257459
def _make_dir(self, client_kwargs):
        
        with _handle_oss_error():
            bucket = self._get_bucket(client_kwargs)

            # Object
            if 'key' in client_kwargs:
                return bucket.put_object(
                    key=client_kwargs['key'], data=b'')

            # Bucket
            return bucket.create_bucket()
374026
def generate_requirements_files(self, base_dir='.'):
        

        print("Creating requirements files\n")

        # TODO How to deal with requirements that are not simple, e.g. a github url

        shared = self._get_shared_section()

        requirements_dir = self._make_requirements_directory(base_dir)

        for section in self.config.sections():
            if section == 'metadata':
                continue

            requirements = {}
            for option in self.config.options(section):
                requirements[option] = self.config.get(section, option)

            if not requirements:
                # No need to write out an empty file
                continue

            filename = os.path.join(requirements_dir, '%s.txt' % section)
            self._write_requirements_file(shared, section, requirements, filename)
834510
def create_repro(self):
    
    path = self.get_options().capture
    if path is None:
      return None
    buildroot = get_buildroot()
    # Ignore a couple of common cases. Note: If we support SCMs other than git in the future,
    # add their (top-level only) metadata dirs here if relevant.
    ignore = ['.git', os.path.relpath(self.get_options().pants_distdir, buildroot)]
    if self.get_options().ignore:
      ignore.extend(self.get_options().ignore)
    return Repro(path, buildroot, ignore)
1303741
def set_option(section='main', cfg_file=cfg_file, **kwargs):
    
    parser = get_parser(cfg_file=cfg_file)
    if section not in parser.sections():
        parser.add_section(section)

    for k, v in kwargs.items():
        parser.set(section=section, option=k, value=v)

    with open(cfg_file, 'w') as f:
        parser.write(f)
    return "Done"
398279
def _dir2(obj, pref='', excl=(), slots=None, itor=''):
    '''
    '''
    if slots:  # __slots__ attrs
        if hasattr(obj, slots):
             # collect all inherited __slots__ attrs
             # from list, tuple, or dict __slots__,
             # while removing any duplicate attrs
            s = {}
            for c in type(obj).mro():
                for a in getattr(c, slots, ()):
                    if hasattr(obj, a):
                        s.setdefault(a, getattr(obj, a))
             # assume __slots__ tuple/list
             # is holding the attr values
            yield slots, _Slots(s)  # _keys(s)
            for t in _items(s):
                yield t  # attr name, value
    elif itor:  # iterator referents
        for o in obj:  # iter(obj)
            yield itor, o
    else:  # regular attrs
        for a in dir(obj):
            if a.startswith(pref) and a not in excl and hasattr(obj, a):
               yield a, getattr(obj, a)
1223741
def _createWorkingDir(rootdir,input):
    
    # extract rootname from input
    rootname = input[:input.find('_')]
    newdir = os.path.join(rootdir,rootname)
    if not os.path.exists(newdir):
        os.mkdir(newdir)
    return newdir
531986
def _make_section_node(self, template, tag_type, tag_key, parsed_section,
                           section_start_index, section_end_index):
        
        if tag_type == '#':
            return _SectionNode(tag_key, parsed_section, self._delimiters,
                               template, section_start_index, section_end_index)

        if tag_type == '^':
            return _InvertedNode(tag_key, parsed_section)

        raise Exception("Invalid symbol for section tag: %s" % repr(tag_type))
1171578
def _make_dir(self, client_kwargs):
        
        with _handle_client_error():
            # Object
            if 'Key' in client_kwargs:
                return self.client.put_object(Body=b'', **client_kwargs)

            # Bucket
            return self.client.create_bucket(
                Bucket=client_kwargs['Bucket'],
                CreateBucketConfiguration=dict(
                    LocationConstraint=self._get_session().region_name))
941685
def create_section(self, name, overwrite=True):
        

        if overwrite:
            sect = ManifestSection(name)
            self.sub_sections[name] = sect

        else:
            sect = self.sub_sections.get(name, None)
            if sect is None:
                sect = ManifestSection(name)
                self.sub_sections[name] = sect

        return sect
280790
def new_section(name, data, options={})
      XCRes::Section.new(name, data, self.options.merge(options))
    end
1333245
def make_directories(self):
        

        # get the directories from the template
        directories = []
        try:
            directories = self.directories()
        except AttributeError:
            self.term.print_info(u"No directory in the template.")

        working_dir = os.getcwd()
        # iteratively create the directories
        for directory in directories:
            dir_name = working_dir + '/' + directory
            if not os.path.isdir(dir_name):
                try:
                    os.makedirs(dir_name)
                except OSError as error:
                    if error.errno != errno.EEXIST:
                        raise
            else:
                self.term.print_error_and_exit(u"The directory {0} already exists."
                         .format(directory))

            self.term.print_info(u"Creating directory '{0}'"
                                 .format(self.term.text_in_color(directory, TERM_GREEN)))
231304
def chdir(new_dir):
    
    cur_dir = os.getcwd()
    safe_mkdir(new_dir)
    os.chdir(new_dir)
    try:
        yield
    finally:
        os.chdir(cur_dir)
461125
def makedir(self):
        
        try:
            os.makedirs(self.model_dir)
        except OSError as exception:
            if exception.errno != errno.EEXIST:
                raise
157266
private void createRepositoryDirectoryStructure(File rootDir) {
		this.objs = new File(rootDir, OBJECT_DIR);
		if (!objs.exists()) {
			if (!objs.mkdirs()) {
				throw new RuntimeException("Could not create dir: " + objs.getAbsolutePath());
			}
		}

		this.refs = new File(rootDir, REFERENCE_DIR);
		if (!refs.exists()) {
			if (!refs.mkdirs()) {
				throw new RuntimeException("Could not create dir: " + refs.getAbsolutePath());
			}
		}
	}
1312833
def _make_dir(self, client_kwargs):
        
        with _handle_client_exception():
            # Object
            if 'obj' in client_kwargs:
                return self.client.put_object(
                    client_kwargs['container'], client_kwargs['obj'], b'')

            # Container
            return self.client.put_container(client_kwargs['container'])
671616
def chdir(new_dir):
    
    cur_dir = os.getcwd()
    _mkdir(new_dir)
    os.chdir(new_dir)
    try:
        yield
    finally:
        os.chdir(cur_dir)