Build a file path to the Whisper database
558502
def whisper_filename(self):
        """"""
        source_name = self.source_id and self.source.name or ''
        return get_valid_filename("{0}__{1}.wsp".format(source_name,
                                                        self.name))
1153220
def __get_pretty_filepath(path, article):
    
    short_filename = hashlib.sha256(article.filename.encode()).hexdigest()
    sub_dir = article.source_domain
    final_path = path + sub_dir + '/'
    if not os.path.exists(final_path):
        os.makedirs(final_path)
    return final_path + short_filename + '.json'
620510
def psql_file(filename, path)
      Preconditions.assert_class(path, String)
      Preconditions.check_state(File.exists?(path), "File[%s] not found" % path)

      options = Db.attribute_values(path).join(" ")

      Library.with_temp_file(:prefix => File.basename(path)) do |tmp|
        File.open(tmp, "w") do |out|
          out << "\\set ON_ERROR_STOP true\n\n"
          out << IO.read(path)
        end

        command = "psql --file \"%s\" #{options} %s" % [tmp, @url]

        Library.with_temp_file do |output|
          result = `#{command} > #{output} 2>&1`.strip
          status = $?
          if status.to_i > 0
            errors = File.exists?(output) ? IO.read(output) : result
            raise ScriptError.new(self, filename, path, errors)
          end
        end
      end
    end
1307054
def pkgPath(root, path, rpath="/"):
    
    global data_files
    if not os.path.exists(path):
        return
    files = []
    for spath in os.listdir(path):
        # Ignore test directories
        if spath == 'test':
            continue
        subpath = os.path.join(path, spath)
        spath = os.path.join(rpath, spath)
        if os.path.isfile(subpath):
            files.append(subpath)
        if os.path.isdir(subpath):
            pkgPath(root, subpath, spath)
    data_files.append((root + rpath, files))
573676
def getDataPath(_system=thisSystem, _FilePath=FilePath):
    
    if _system == "Windows":
        pathName = "~/Crypto101/"
    else:
        pathName = "~/.crypto101/"

    path = _FilePath(expanduser(pathName))
    if not path.exists():
        path.makedirs()

    return path
518273
def _create_path(self):
        """"""

        if self.driver == 'sqlite' and 'memory' not in self.dsn and self.dsn != 'sqlite://':

            dir_ = os.path.dirname(self.path)

            if dir_ and not os.path.exists(dir_):
                try:
                    # Multiple process may try to make, so it could already
                    # exist
                    os.makedirs(dir_)
                except Exception:
                    pass

                if not os.path.exists(dir_):
                    raise Exception("Couldn't create directory " + dir_)
538634
function getSqliteFilePaths(wofRoot, databases) {
  return databases.map((database) => {
    return path.join(wofRoot, 'sqlite', database);
  });
}
1280868
async function buildPathsObject(files) {
  return Promise.all(
    files.map(async filepath => {
      const name = path.basename(filepath, '.svg');
      const svg = fs.readFileSync(filepath, 'utf-8');
      const pathStrings = await svgo.optimize(svg, { path: filepath })
        .then(({ data }) => data.match(/ d="[^"]+"/g) || [])
        .then(paths => paths.map(s => s.slice(3)));
      return `"${name}": [${pathStrings.join(',\n')}]`;
    }),
  );
}
557733
def get_task_db(self, source_path):
        '''
        '''
        sql = 'SELECT * FROM upload WHERE source_path=?'
        req = self.cursor.execute(sql, [source_path, ])
        if req:
            return req.fetchone()
        else:
            None
298719
function createSQLiteRecordStream(dbPaths, importPlace) {
  const sqliteStream = combinedStream.create();
  const sqliteStatement = importPlace ?
    SQLiteStream.findGeoJSONByPlacetypeAndWOFId(getPlacetypes(), importPlace) :
    SQLiteStream.findGeoJSONByPlacetype(getPlacetypes());

  dbPaths.forEach((dbPath) => {
    sqliteStream.append( (next) => {
      logger.info( `Loading ${path.basename(dbPath)} database from ${path.dirname(dbPath)}` );
      next(new SQLiteStream(dbPath, sqliteStatement));
    });
  });

  return sqliteStream;
}
920506
def _get_result_paths(self, data):
        
        # access data through self.Parameters so we know it's been cast
        # to a FilePath
        wd = self.WorkingDir
        db_name = self.Parameters['-n'].Value
        log_name = self.Parameters['-l'].Value
        result = {}
        result['log'] = ResultPath(Path=wd + log_name, IsWritten=True)
        if self.Parameters['-p'].Value == 'F':
            extensions = ['nhr', 'nin', 'nsq', 'nsd', 'nsi']
        else:
            extensions = ['phr', 'pin', 'psq', 'psd', 'psi']
        for extension in extensions:
            for file_path in glob(wd + (db_name + '*' + extension)):
                # this will match e.g. nr.01.psd and nr.psd
                key = file_path.split(db_name + '.')[1]
                result_path = ResultPath(Path=file_path, IsWritten=True)
                result[key] = result_path
        return result
973420
def _get_result_paths(self, data):
        
        # get the filepath of the indexed database (after comma)
        # /path/to/refseqs.fasta,/path/to/refseqs.idx
        #                        ^------------------^
        db_name = (self.Parameters['--ref'].Value).split(',')[1]

        result = {}
        extensions = ['bursttrie', 'kmer', 'pos', 'stats']
        for extension in extensions:
            for file_path in glob("%s.%s*" % (db_name, extension)):
                # this will match e.g. nr.bursttrie_0.dat, nr.bursttrie_1.dat
                # and nr.stats
                key = file_path.split(db_name + '.')[1]
                result[key] = ResultPath(Path=file_path, IsWritten=True)
        return result
5586
def create_database_folder(databasepath, database):
        
        logging.info('Setting up {} database'.format(database))
        # Define the path to store the database files
        databasepath = os.path.join(databasepath, database)
        # Create the path as required
        make_path(databasepath)
        return databasepath
1373961
def file_cmd(context, tags, archive, bundle_name, path):
    """"""
    bundle_obj = context.obj['db'].bundle(bundle_name)
    if bundle_obj is None:
        click.echo(click.style(f"unknown bundle: {bundle_name}", fg='red'))
        context.abort()
    version_obj = bundle_obj.versions[0]
    new_file = context.obj['db'].new_file(
        path=str(Path(path).absolute()),
        to_archive=archive,
        tags=[context.obj['db'].tag(tag_name) if context.obj['db'].tag(tag_name) else
              context.obj['db'].new_tag(tag_name) for tag_name in tags]
    )
    new_file.version = version_obj
    context.obj['db'].add_commit(new_file)
    click.echo(click.style(f"new file added: {new_file.path} ({new_file.id})", fg='green'))
618442
function buildFromDirectory(dirPath){
	var dbsetPath = path.join(dirPath,"dbsets");
	if(fileutil.isExist(dbsetPath)){
		defaultConfig['dbsets'] = dbsetPath;
	}

	var stubsPath = path.join(dirPath,"stubs");
	if(fileutil.isExist(stubsPath)){
		defaultConfig['stubs'] = stubsPath;
	}

	var dumpsPath = path.join(dirPath,"dumps");
	if(fileutil.isExist(dumpsPath)){
		defaultConfig['dumps'] = dumpsPath;
	}

	var mappingsPath = path.join(dirPath,"mappings");
	var files = fileutil.ls(mappingsPath);
	if(files.length > 0){
		defaultConfig['mappings']['requests'] = [];
		files.forEach(function(filename){
			defaultConfig['mappings']['requests'].push(path.join(mappingsPath , filename));
		});
	}

	var trustStorePath = path.join(dirPath,"truststore");
	if(fileutil.isExist(trustStorePath)){
		defaultConfig.server.key = path.join(trustStorePath , "server.key");
		defaultConfig.server.cert = path.join(trustStorePath , "server.crt");

		var cacertPath = path.join(trustStorePath,"ca");
		var cacerts = fileutil.ls(cacertPath);

		if(cacerts.length > 0){
			defaultConfig.server.ca = [];
			cacerts.forEach(function(filename){
				defaultConfig.server.ca.push(path.join(cacertPath , filename));
			});
		}
	}
}
806177
def database_root_path(cls, project, database):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/databases/{database}",
            project=project,
            database=database,
        )
1057391
def build_db():
    
    if not os.path.exists(MISC_PATH):
        os.makedirs(MISC_PATH)
    cities_path = os.path.join(MISC_PATH, "cities1000.txt")
    cities_msgpack = os.path.join(MISC_PATH, "cities1000.bin")
    if not os.path.isfile(cities_path):
        download()
    if not os.path.isfile(cities_msgpack):
        with open(cities_path) as f:
            lines = f.readlines()

        db = []
        for i, line in enumerate(lines):
            l = line.strip().split('\t')
            db.append({'latitude': float(l[4]),
                       'longitude': float(l[5]),
                       'linenr': i})
        packed = msgpack.packb(db, use_bin_type=True)
        with open(cities_msgpack, 'wb') as f:
            f.write(packed)
    else:
        with open(cities_msgpack, 'rb') as f:
            content = f.read()
        db = msgpack.unpackb(content)
    return db