Returns file statistics for a given path.
352215
def stat(self, filename):
        """"""
        # NOTE: Size of the file is given by .st_size as returned from
        # os.stat(), but we convert to .length
        try:
            len = os.stat(compat.as_bytes(filename)).st_size
        except OSError:
            raise errors.NotFoundError(None, None, "Could not find file")
        return StatData(len)
135318
def _get_file_content(self, path):
        """"""
        with open(path, 'r') as file_:
            content = file_.read()
        return content
694608
def read_metrics_file(path: str) -> List[Dict[str, Any]]:
    
    with open(path) as fin:
        metrics = [parse_metrics_line(i, line.strip()) for i, line in enumerate(fin, 1)]
    return metrics
1015382
def lines_stats(dir_path, file_filter):
    
    n_files = 0
    n_lines = 0
    for p in Path(dir_path).select_file(file_filter):
        n_files += 1
        n_lines += count_lines(p.abspath)
    return n_files, n_lines
267089
def _count_files_by_type(self, path, pattern, ignore=True):
        
        # Get all files matching the given path and pattern
        files = glob(os.path.join(path, pattern))
        # Count the files
        files = [ff for ff in files
                 if os.path.split(ff)[-1] not in self._IGNORE_FILES
                 or not ignore]
        num_files = len(files)
        return num_files
355490
def getOxum(dataPath):
    

    fileCount = 0L
    fileSizeTotal = 0L
    for root, dirs, files in os.walk(dataPath):
        for fileName in files:
            fullName = os.path.join(root, fileName)
            stats = os.stat(fullName)
            fileSizeTotal += stats.st_size
            fileCount += 1
    return "%s.%s" % (fileSizeTotal, fileCount)
849940
def get_content_summary(self, path, **kwargs):
        """"""
        return ContentSummary(
            **_json(self._get(path, 'GETCONTENTSUMMARY', **kwargs))['ContentSummary'])
616915
def stat(path, hours, offset=None):
    
    return os.stat(path).st_mtime < (time.time() - _to_sec(hours))
1084750
private void getCounts(String path, Counts counts) {
        DataNode node = getNode(path);
        if (node == null) {
            return;
        }
        String[] children = null;
        int len = 0;
        synchronized (node) {
            Set<String> childs = node.getChildren();
            if (childs != null) {
                children = childs.toArray(new String[childs.size()]);
            }
            len = (node.data == null ? 0 : node.data.length);
        }
        // add itself
        counts.count += 1;
        counts.bytes += len;
        if (children == null || children.length == 0) {
            return;
        }
        for (String child : children) {
            getCounts(path + "/" + child, counts);
        }
    }
796198
protected function countSize($path) {
		$stat = $this->stat($path);

		if (empty($stat) || !$stat['read'] || !empty($stat['hidden'])) {
			return 'unknown';
		}
		
		if ($stat['mime'] != 'directory') {
			return $stat['size'];
		}
		
		$subdirs = $this->options['checkSubfolders'];
		$this->options['checkSubfolders'] = true;
		$result = 0;
		foreach ($this->getScandir($path) as $stat) {
			$size = $stat['mime'] == 'directory' && $stat['read'] 
				? $this->countSize($this->joinPathCE($path, $stat['name'])) 
				: (isset($stat['size']) ? intval($stat['size']) : 0);
			if ($size > 0) {
				$result += $size;
			}
		}
		$this->options['checkSubfolders'] = $subdirs;
		return $result;
	}
21613
def calculate_etag(file_path):
        
        stat = file_path.stat()
        etag = "%x-%x" % (stat.st_mtime_ns, stat.st_size)
        return etag
1009305
def _file_size(file_path, uncompressed=False):
    """"""
    _, ext = os.path.splitext(file_path)

    if uncompressed:
        if ext in {".gz", ".gzip"}:
            with gzip.GzipFile(file_path, mode="rb") as fp:
                try:
                    fp.seek(0, os.SEEK_END)
                    return fp.tell()
                except ValueError:
                    # on python2, cannot seek from end and must instead read to end
                    fp.seek(0)
                    while len(fp.read(8192)) != 0:
                        pass
                    return fp.tell()
        elif ext in {".bz", ".bz2", ".bzip", ".bzip2"}:
            with bz2.BZ2File(file_path, mode="rb") as fp:
                fp.seek(0, os.SEEK_END)
                return fp.tell()

    return os.path.getsize(file_path)
731022
public SFTPv3FileAttributes _stat(String path) throws IOException {
        try {
            return stat(path);
        } catch (SFTPException e) {
            int c = e.getServerErrorCode();
            if (c==ErrorCodes.SSH_FX_NO_SUCH_FILE || c==ErrorCodes.SSH_FX_NO_SUCH_PATH)
                return null;
            else
                throw e;
        }
    }
1337520
def _GetStat(self):
    
    stat_object = super(FakeFileEntry, self)._GetStat()

    location = getattr(self.path_spec, 'location', None)
    if location:
      file_data = self._file_system.GetDataByPath(location)

      if file_data is not None:
        stat_object.size = len(file_data)

    return stat_object
147552
def stat(self, filename, timeout=None):
    """"""
    transport = StatFilesyncTransport(self.stream)
    transport.write_data('STAT', filename, timeout)
    stat_msg = transport.read_message(timeout)
    stat_msg.assert_command_is('STAT')
    return DeviceFileStat(filename, stat_msg.mode, stat_msg.size, stat_msg.time)
12166
def GetDataByPath(self, path):
    
    _, path_data = self._paths.get(path, (None, None))
    return path_data
416940
def stat(self, path=None, client_kwargs=None, header=None):
        
        # Should contain at least the strict minimum of os.stat_result
        stat = OrderedDict((
            ("st_mode", 0), ("st_ino", 0), ("st_dev", 0), ("st_nlink", 0),
            ("st_uid", 0), ("st_gid", 0), ("st_size", 0), ("st_atime", 0),
            ("st_mtime", 0), ("st_ctime", 0)))

        # Populate standard os.stat_result values with object header content
        header = self.head(path, client_kwargs, header)
        for key, method in (
                ('st_size', self._getsize_from_header),
                ('st_ctime', self._getctime_from_header),
                ('st_mtime', self._getmtime_from_header),):
            try:
                stat[key] = int(method(header))
            except UnsupportedOperation:
                continue

        # File mode
        if self.islink(path=path, header=header):
            # Symlink
            stat['st_mode'] = S_IFLNK
        elif ((not path or path[-1] == '/' or self.is_locator(path)) and not
                stat['st_size']):
            # Directory
            stat['st_mode'] = S_IFDIR
        else:
            # File
            stat['st_mode'] = S_IFREG

        # Add storage specific keys
        sub = self._CHAR_FILTER.sub
        for key, value in tuple(header.items()):
            stat['st_' + sub('', key.lower())] = value

        # Convert to "os.stat_result" like object
        stat_result = namedtuple('stat_result', tuple(stat))
        stat_result.__name__ = 'os.stat_result'
        stat_result.__module__ = 'pycosio'
        return stat_result(**stat)