Return a file protocol URI e.g. file:///D:/mappyfile/mappyfile/schemas/ on Windows
        and file:////home/user/mappyfile/mappyfile/schemas/ on Linux
349496
def get_schema_path(self, schemas_folder):
        

        # replace any Windows path back slashes with forward slashes
        schemas_folder = schemas_folder.replace("\\", "/")

        # HACK Python 2.7 on Linux seems to remove the root slash
        # so add this back in
        if schemas_folder.startswith("/"):
            schemas_folder = "/" + schemas_folder

        host = ""
        root_schema_path = "file://{}/{}".format(host, schemas_folder) + "/"

        return root_schema_path
1146040
def link(self):
    """"""
    if not self.IsLink():
      return ''

    location = getattr(self.path_spec, 'location', None)
    if location is None:
      return ''

    return self._file_system.GetDataByPath(location)
27853
def FileFinderOSFromClient(args):
  
  stat_cache = filesystem.StatCache()

  opts = args.action.stat

  for path in GetExpandedPaths(args):
    try:
      content_conditions = conditions.ContentCondition.Parse(args.conditions)
      for content_condition in content_conditions:
        with io.open(path, "rb") as fd:
          result = list(content_condition.Search(fd))
        if not result:
          raise _SkipFileException()
      # TODO: `opts.resolve_links` has type `RDFBool`, not `bool`.
      stat = stat_cache.Get(path, follow_symlink=bool(opts.resolve_links))
      stat_entry = client_utils.StatEntryFromStatPathSpec(
          stat, ext_attrs=opts.collect_ext_attrs)
      yield stat_entry
    except _SkipFileException:
      pass
1112227
def to_file_url(filename):
    
    url = 'file://' + os.path.abspath(filename).replace(os.path.sep, '/')
    return url
484822
def url(self, filetype, base_dir=None, sasdir='sas', **kwargs):
        

        location = self.location(filetype, **kwargs)
        return join(self.remote_base, sasdir, location) if self.remote_base and location else None
416140
def get_local_uri(m, file_names, _):
    
    path = m.group(2)
    result = 0
    for root, _, files in os.walk(path):
        for file_name in files:
            absolute_path = os.path.join(root, file_name)
            file_names.append("file:/{}".format(absolute_path))
            result += os.path.getsize(absolute_path)
    return result
522428
def get_file_type_map():
    """"""
    file_type_map = {}
    for strategy_type in get_strategy_types():
        for ext in strategy_type.file_types:
            if ext in file_type_map:
                raise KeyError(
                    'File type {ext} already registered to {file_type_map[ext]}'
                    .format(**locals()))
            file_type_map[ext] = strategy_type
    return file_type_map
361000
def get_pickled_ontology(filename):
	
	pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
	if GLOBAL_DISABLE_CACHE:
		printDebug("WARNING: DEMO MODE cache has been disabled in __init__.py ==============", "red")
	if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_CACHE:
		try:
			return cPickle.load(open(pickledfile, "rb"))
		except:
			print("** WARNING: Cache is out of date ** ...recreating it... ")
			return None
	else:
		return None
386049
def getRemoteFile(urlOrPath, destPath):
    '''
    
    '''
    urlp = urlparse(urlOrPath)
    if urlp.scheme == '':
        return (os.path.abspath(urlOrPath), 'local')
    elif urlp.scheme not in ('http', 'https'):
        return (urlOrPath, 'local')
    else:
        filename = toFilename(urlOrPath)
        destPath = destPath + '/' + filename
        log.info('Retrieving %s to %s.' % (urlOrPath, destPath))
        try:
            urlretrieve(urlOrPath, destPath)
        except IOError:
            # monkey patch fix for SSL/Windows per Tika-Python #54 
            # https://github.com/chrismattmann/tika-python/issues/54
            import ssl
            if hasattr(ssl, '_create_unverified_context'):
                ssl._create_default_https_context = ssl._create_unverified_context
            # delete whatever we had there
            if os.path.exists(destPath) and os.path.isfile(destPath):
                os.remove(destPath)
            urlretrieve(urlOrPath, destPath)
        return (destPath, 'remote')
111220
def get_uris(config):
    
    file_names = []
    if config.INPUT_DATA is None:
        sys.stderr.write("you need to provide INPUT_DATA in config\n")
        sys.exit(1)
    if isinstance(config.INPUT_DATA, basestring):
        config.INPUT_DATA = [config.INPUT_DATA]
    file_size = 0
    for uri in config.INPUT_DATA:
        for regex, uri_method, _, _ in URI_REGEXES:
            m = regex.match(uri)
            if m is not None:
                file_size += uri_method(m, file_names, config)
                break
    print("going to process {} files...".format(len(file_names)))
    return file_size, file_names
1152251
def query(args):
    
    p = OptionParser(query.__doc__)

    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(p.print_help())

    frgscffile, region = args
    gzfile = frgscffile + ".gz"
    tbifile = gzfile + ".tbi"
    outfile = region + ".posmap"

    if not (op.exists(gzfile) and op.exists(tbifile)):
        index(frgscffile)

    assert op.exists(gzfile) and op.exists(tbifile)

    cmd = "tabix {0} {1}".format(gzfile, region)
    sh(cmd, outfile=outfile)
255398
def get_file_checksum(self, path, **kwargs):
        
        metadata_response = self._get(
            path, 'GETFILECHECKSUM', expected_status=httplib.TEMPORARY_REDIRECT, **kwargs)
        assert not metadata_response.content
        data_response = self._requests_session.get(
            metadata_response.headers['location'], **self._requests_kwargs)
        _check_response(data_response)
        return FileChecksum(**_json(data_response)['FileChecksum'])
472742
def file_uri(fname):
    """"""
    if os.name == 'nt':
        # Local file
        if re.search(r'^[a-zA-Z]:', fname):
            return 'file:///' + fname
        # UNC based path
        else:
            return 'file://' + fname
    else:
        return 'file://' + fname
1069646
def OpenFile(self, windows_path):
    
    path_spec = self._path_resolver.ResolvePath(windows_path)
    if path_spec is None:
      return None

    return self._file_system.GetFileObjectByPathSpec(path_spec)
1091258
def choose_uri(metadata, config):
    
    database_name = choose_database_name(metadata, config)
    driver = config.driver
    host, port = config.host, config.port
    username, password = choose_username(metadata, config), config.password

    return f"{driver}://{username}:{password}@{host}:{port}/{database_name}"
733213
def rels_uri(self):
        
        rels_filename = '%s.rels' % self.filename
        rels_uri_str = posixpath.join(self.baseURI, '_rels', rels_filename)
        return PackURI(rels_uri_str)
946189
def _buildFileUrl(self, xml_req):
		""""""
		return '%(protocol)s://%(host)s:%(port)s%(xml_req)s'%{
			'protocol': self._protocol,
			'host': self._host,
			'port': self._port,
			'xml_req': xml_req,
		}