Get a retriever and configuration for the given file path.
503362
def integration_and_config(self, path):
        
        if path.startswith(tuple(INTEGRATION_MAP.keys())):
            key = INTEGRATION_MAP[path.split(":")[0] + ":"]
            integration = self._integrations.get(key)
            config = {}
            for sample in self._samples:
                config = tz.get_in(["config", key], sample)
                if config:
                    break
            return integration, config

        return None, None
350626
def _getattr_ (self, name):
        """"""
        value = self._config.get(name)

        if type(value) is dict:
            value = AitConfig(self._filename, config=value)

        return value
120440
def from_file(path):
        """"""
        with open(path) as stream:
            obj = yaml.safe_load(stream)
        Config.lint(obj)
        return Config(config_dict=obj)
395594
def _find_file(f):
        """"""
        if os.path.isabs(f):
            return f
        else:
            for d in Config._dirs:
                _f = os.path.join(d, f)
                if os.path.isfile(_f):
                    return _f
            raise FiggypyError(
                "could not find configuration file {} in dirs {}"
                .format(f, Config._dirs)
            )
34217
def from_file(cls, path):
        
        if path == '-':
            return Configuration(yaml.safe_load(sys.stdin))
        if not osp.exists(path) and not osp.isabs(path):
            path = osp.join(osp.dirname(osp.abspath(__file__)), path)
        with open(path, 'r') as istr:
            return Configuration(yaml.safe_load(istr))
739636
def getkey(self, path, filename=None):
        
        scheme, keys = self.getkeys(path, filename=filename)
        try:
            key = next(keys)
        except StopIteration:
            raise FileNotFoundError("Could not find object for: '%s'" % path)

        # we expect to only have a single key returned
        nextKey = None
        try:
            nextKey = next(keys)
        except StopIteration:
            pass
        if nextKey:
            raise ValueError("Found multiple keys for: '%s'" % path)
        return scheme, key
1197441
def _get_file_size(path, get_retriever):
    
    integration, config = get_retriever.integration_and_config(path)
    if integration:
        return integration.file_size(path, config)
    elif os.path.exists(path):
        return os.path.getsize(path) / (1024.0 * 1024.0)
204436
def query_file(self, path, fetchall=False, **params):
        """"""

        with self.get_connection() as conn:
            return conn.query_file(path, fetchall, **params)
1311824
@NotNull
    public static FileInfo forPath(Path path) {
        try {
            final BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
            return FileInfo.builder()
                    .path(path)
                    .key(attributes.fileKey())
                    .size(attributes.size())
                    .modificationTime(attributes.lastModifiedTime())
                    .build();
        } catch (Exception e) {
            LOG.error("Couldn't get file info for path: {}", path, e);
            return EMPTY_FILE_INFO.toBuilder().path(path).build();
        }
    }
808308
def _getpath(self, path):
        ""
        if is_blacklisted(path):
            raise JottaFuseError('Blacklisted file, refusing to retrieve it')

        return self.client.getObject(path)
1164933
def get(self, path):
        
        assert isinstance(path, mitogen.core.UnicodeType)
        self._lock.acquire()
        try:
            if path in self._cache:
                return self._cache[path]
            latch = mitogen.core.Latch()
            waiters = self._waiters.setdefault(path, [])
            waiters.append(lambda: latch.put(None))
        finally:
            self._lock.release()

        LOG.debug('%r.get(%r) waiting for uncached file to arrive', self, path)
        latch.get()
        LOG.debug('%r.get(%r) -> %r', self, path, self._cache[path])
        return self._cache[path]
699914
def parse_config(file_path):
    
    if not os.path.isfile(file_path):
        return {}
    parser = ConfigParser()
    parser.read(file_path)
    # Strip out inline comments
    for s in parser._sections:
        for v in six.iterkeys(parser._sections[s]):
            parser._sections[s][v] = parser._sections[s][v].split("#")[0].strip()
    return parser._sections
427113
public Configuration fromFile(File path) throws ConfigurationLoadException {
    PropertiesConfiguration configuration = setupConfiguration(new PropertiesConfiguration());
    configuration.setFile(path);
    try {
      configuration.load();
      return configuration;
    } catch (ConfigurationException e) {
      throw new ConfigurationLoadException(
          "Encountered a problem reading the provided configuration file \"" + path + "\"!", e);
    }
  }
1349779
def get_file(self, file_path):
    

    try:
      resp = self._conn.get_object(
        Bucket=self._path.bucket,
        Key=self.get_path_to_file(file_path),
      )

      encoding = ''
      if 'ContentEncoding' in resp:
        encoding = resp['ContentEncoding']

      return resp['Body'].read(), encoding
    except botocore.exceptions.ClientError as err: 
      if err.response['Error']['Code'] == 'NoSuchKey':
        return None, None
      else:
        raise
759499
def read_config(path=None, final=False):
    """"""
    try:
        with open(config_path(path, final=final), 'r') as configfile:
            return yaml.safe_load(configfile) or {}
    except FileNotFoundError:
        return {}
834210
public Entry getMetadata(String path, int fileLimit) {
        return getMetadata(path, fileLimit, null, true);
    }
1189164
public static Map<String, String> getMetadataFromSequenceFile(FileSystem fs, Path path) {
        try {
            Configuration conf = new Configuration();
            conf.setInt("io.file.buffer.size", 4096);
            SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, new Configuration());
            SequenceFile.Metadata meta = reader.getMetadata();
            reader.close();
            TreeMap<Text, Text> map = meta.getMetadata();
            Map<String, String> values = new HashMap<String, String>();
            for(Map.Entry<Text, Text> entry: map.entrySet())
                values.put(entry.getKey().toString(), entry.getValue().toString());

            return values;
        } catch(IOException e) {
            throw new RuntimeException(e);
        }
    }