Helper: Create a mock user-dir-config.
491090
function (path) {
		var mockDirConfig = {
			openRoute: function (req, res, params) {
			},
			
			closeRoute: function (req, res, params) {
			},
		};

		spyOn(mockDirConfig, 'openRoute').and.callThrough();
		spyOn(mockDirConfig, 'closeRoute').and.callThrough();

		registerRequireMock(testObject._formatPathForRequire(path), function () {
			return mockDirConfig;
		});

		filesThatExist.push(path);

		return mockDirConfig;
	}
48767
def create_dir_unless_exists(*args):
    """"""
    path = os.path.join(*args)
    if not os.path.isdir(path):
        os.makedirs(path)
934479
def from_user_config(cls):
        
        # Try in the current directory.
        path = os.path.join(os.getcwd(), cls.YAML_FILE)

        if os.path.exists(path):
            return cls.from_file(path)

        # Try in the configuration directory.
        path = os.path.join(cls.USER_CONFIG_DIR, cls.YAML_FILE)

        if os.path.exists(path):
            return cls.from_file(path)

        raise cls.Error("Cannot locate %s neither in current directory nor in %s" % (cls.YAML_FILE, path))
50650
def load_or_create_config(self, filename, config=None):
        """"""
        os.makedirs(os.path.dirname(os.path.expanduser(filename)), exist_ok=True)
        if os.path.exists(filename):
            return self.load(filename)

        if(config == None):
            config = self.random_config()

        self.save(filename, config)
        return config
357245
def create_config():
    """"""
    file_exists = exists(CONFIG_FILE)
    if not file_exists:
        # Set directories
        config.add_section('Directories')
        defaults = [
            ('AbstractRetrieval', expanduser('~/.scopus/abstract_retrieval')),
            ('AffiliationSearch', expanduser('~/.scopus/affiliation_search')),
            ('AuthorRetrieval', expanduser('~/.scopus/author_retrieval')),
            ('AuthorSearch', expanduser('~/.scopus/author_search')),
            ('CitationOverview', expanduser('~/.scopus/citation_overview')),
            ('ContentAffiliationRetrieval', expanduser('~/.scopus/affiliation_retrieval')),
            ('ScopusSearch', expanduser('~/.scopus/scopus_search'))
        ]
        for key, value in defaults:
            config.set('Directories', key, value)
            if not exists(value):
                makedirs(value)
        # Set authentication
        config.add_section('Authentication')
        prompt_key = "Please enter your API Key, obtained from "\
                     "http://dev.elsevier.com/myapikey.html: \n"
        if py3:
            key = input(prompt_key)
        else:
            key = raw_input(prompt_key)
        config.set('Authentication', 'APIKey', key)
        prompt_token = "API Keys are sufficient for most users.  If you "\
                       "have to use Authtoken authentication, please enter "\
                       "the token, otherwise press Enter: \n"
        if py3:
            token = input(prompt_token)
        else:
            token = raw_input(prompt_token)
        if len(token) > 0:
            config.set('Authentication', 'InstToken', token)
        # Write out
        with open(CONFIG_FILE, 'w') as f:
            config.write(f)
    else:
        text = "Configuration file already exists at {}; process to create "\
               "the file aborted.  Please open the file and edit the "\
               "entries manually.".format(CONFIG_FILE)
        raise FileExistsError(text)
1199676
def setup(interactive, not_relative, dry_run, reset, root_dir, testuser):
    """"""

    click.echo("[cellpy] (setup)")

    # generate variables
    init_filename = create_custom_init_filename()
    userdir, dst_file = get_user_dir_and_dst(init_filename)

    if testuser:
        if not root_dir:
            root_dir = os.getcwd()

        click.echo(f"[cellpy] (setup) DEV-MODE testuser: {testuser}")
        init_filename = create_custom_init_filename(testuser)
        userdir = root_dir
        dst_file = get_dst_file(userdir, init_filename)
        click.echo(f"[cellpy] (setup) DEV-MODE userdir: {userdir}")
        click.echo(f"[cellpy] (setup) DEV-MODE dst_file: {dst_file}")

    if not pathlib.Path(dst_file).is_file():
        reset = True

    if interactive:
        click.echo(" interactive mode ".center(80, "-"))
        _update_paths(root_dir, not not_relative, dry_run=dry_run, reset=reset)
        _write_config_file(
            userdir, dst_file,
            init_filename, dry_run,
        )
        _check()

    else:
        _write_config_file(userdir, dst_file, init_filename, dry_run)
        _check()
133376
def create_required_directories(self):
        """"""
        required = (self.CACHE_DIR,
                    self.LOG_DIR,
                    self.OUTPUT_DIR,
                    self.ENGINEER.JINJA_CACHE_DIR,)

        for folder in required:
            ensure_exists(folder, assume_dirs=True)
446411
def _setup_user_dir(self):
        """"""
        user_dir = self._get_user_dir_path()

        rules_dir = user_dir.joinpath('rules')
        if not rules_dir.is_dir():
            rules_dir.mkdir(parents=True)
        self.user_dir = user_dir
522596
def setup_dirs(self, storage_dir):
        ''''''
        self.storage_dir = expanduser(storage_dir)
        if ' ' in self.storage_dir:
            raise ValueError('storage dir path cannot contain spaces, please '
                             'specify a path with --storage-dir')
        self.build_dir = join(self.storage_dir, 'build')
        self.dist_dir = join(self.storage_dir, 'dists')
26852
def create_conf_file (self, data, directory=None):
        """"""
        data.insert(0, "# this file is automatically created by setup.py")
        data.insert(0, "# -*- coding: iso-8859-1 -*-")
        if directory is None:
            directory = os.getcwd()
        filename = self.get_conf_filename(directory)
        # add metadata
        metanames = ("name", "version", "author", "author_email",
                     "maintainer", "maintainer_email", "url",
                     "license", "description", "long_description",
                     "keywords", "platforms", "fullname", "contact",
                     "contact_email")
        for name in metanames:
            method = "get_" + name
            val = getattr(self.metadata, method)()
            if isinstance(val, str):
                val = unicode(val)
            cmd = "%s = %r" % (name, val)
            data.append(cmd)
        data.append('release_date = "%s"' % get_release_date())
        data.append('portable = %s' % get_portable())
        # write the config file
        util.execute(write_file, (filename, data),
                     "creating %s" % filename, self.verbose >= 1, self.dry_run)
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))
627196
def read_config(conf_dir=DEFAULT_CONFIG_DIR):
    ""

    conf_path = os.path.expanduser(conf_dir)
    if not os.path.exists(conf_path):
        # only throw if not default
        if conf_dir != DEFAULT_CONFIG_DIR:
            raise IOError("Config directory not found at %s" % (conf_path, ))

    return munge.load_datafile('config', conf_path, default=None)
54865
def config_dir(mkcustom=False):
    
    from acorn.utility import reporoot
    from acorn.base import testmode
    from os import path
    alternate = path.join(path.abspath(path.expanduser("~")), ".acorn")
    if testmode or (not path.isdir(alternate) and not mkcustom):
        return path.join(reporoot, "acorn", "config")
    else:
        if mkcustom:# pragma: no cover
            #This never gets reached when we are in testmode because we don't
            #want to clobber the user's local config cache.
            from os import mkdir
            mkdir(alternate)
        return alternate
525202
function createEasyAccess() {
  var userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var conf = Object.assign({}, defaultConfig, userConfig);
  return function (store) {
    generateSetterModules(store, conf);

    store[conf.setter] = function (path, payload) {
      return defaultSetter(path, payload, store, conf);
    };

    store[conf.getter] = function (path) {
      return defaultGetter(path, store);
    };

    store[conf.deletor] = function (path, payload) {
      return defaultDeletor(path, payload, store, conf);
    };
  };
}
387346
def run_putgist(filename, user, **kwargs):
    """"""
    assume_yes = kwargs.get("yes_to_all")
    private = kwargs.get("private")
    getgist = GetGist(
        user=user,
        filename=filename,
        assume_yes=assume_yes,
        create_private=private,
        allow_none=True,
    )
    getgist.put()
994807
def cli(ctx, hostname, username, password, config_dir, https):
    """"""
    ctx.is_root = True
    ctx.user_values_entered = False
    ctx.config_dir = os.path.abspath(os.path.expanduser(config_dir))
    ctx.config = load_config(ctx)
    ctx.hostname = hostname
    ctx.username = username
    ctx.password = password
    ctx.https = https

    # Creating the WVA object is deferred as some commands like clearconfig
    # should not require a username/password to perform them
    ctx.wva = None
570360
function create(options, cb) {

	options.force = (options.force) ? options.force : false;
	options.preserve = (options.preserve) ? options.preserve : true;
	options.password = getPwHash(options.password);  
	console.log('Gernerating directories with folling options:\n', options, '\n');
	if(options.test) {return;}
	//create directory
	if(options.force || !fs.existsSync(options.dest)) {
		wrench.mkdirSyncRecursive(options.dest);
		wrench.copyDirSyncRecursive(options.src, options.dest, { preserve: options.preserve }); 
	}
	if(options.files.length) {
		_.each(options.files, function(file) {
			fs.exists(path.join(options.dest,options.pwfile), function(exists) {
				if(!exists || options.force || file.force) {
					fs.writeFile(path.join(options.dest,strReplace(file.name, options)),  strReplace(file.data, options), function(err){
						if(err) {throw err;}
					});
				}
			});
		});
	}
	//Search and replace 
	replace(options.dest, {
		filters: ['index\.php$', '\.htaccess']
		, type: 'replace' 
		, values: [{
			user: options.user
			, root: options.root
			, project: options.project
			, title: options.title
			, userDir: options.userDir
			, pwfile: options.pwfile
		}]
	}, function(err, data) {
		if(cb) {
			cb(err, data);
			}
	});
}