fs.glob¶
-
class
fs.glob.
BoundGlobber
(fs)[source]¶ A
Globber
object bound to a filesystem.An instance of this object is available on every Filesystem object as
.glob
.Parameters: fs (FS) – A filesystem object. -
__call__
(pattern, path=u'/', namespaces=None, case_sensitive=True, exclude_dirs=None)[source]¶ Match resources on the bound filesystem againsts a glob pattern.
Parameters: - pattern (str) – A glob pattern, e.g.
"**/*.py"
- namespaces (list) – A list of additional info namespaces.
- case_sensitive (bool) – If
True
, the path matching will be case sensitive i.e."FOO.py"
and"foo.py"
will be different, otherwise path matching will be case insensitive. - exclude_dirs (list) – A list of patterns to exclude when searching,
e.g.
["*.git"]
.
Returns: An object that may be queried for the glob matches.
Return type: - pattern (str) – A glob pattern, e.g.
-
-
class
fs.glob.
Counts
(files, directories, data)¶ -
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__repr__
()¶ Return a nicely formatted representation string
-
data
¶ Alias for field number 2
-
directories
¶ Alias for field number 1
-
files
¶ Alias for field number 0
-
-
class
fs.glob.
GlobMatch
(path, info)¶ -
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__repr__
()¶ Return a nicely formatted representation string
-
info
¶ Alias for field number 1
-
path
¶ Alias for field number 0
-
-
class
fs.glob.
Globber
(fs, pattern, path=u'/', namespaces=None, case_sensitive=True, exclude_dirs=None)[source]¶ A generator of glob results.
Parameters: - fs (FS) – A filesystem object
- pattern (str) – A glob pattern, e.g.
"**/*.py"
- path (str) – A path to a directory in the filesystem.
- namespaces (list) – A list of additional info namespaces.
- case_sensitive (bool) – If
True
, the path matching will be case sensitive i.e."FOO.py"
and"foo.py"
will be different, otherwise path matching will be case insensitive. - exclude_dirs (list) – A list of patterns to exclude when searching,
e.g.
["*.git"]
.
-
__iter__
()[source]¶ An iterator of
fs.glob.GlobMatch
objects.
-
count
()[source]¶ Count files / directories / data in matched paths.
Example
>>> import fs >>> fs.open_fs('~/projects').glob('**/*.py').count() Counts(files=18519, directories=0, data=206690458)
Returns: A named tuple containing results. Return type: Counts
-
count_lines
()[source]¶ Count the lines in the matched files.
Returns: A named tuple containing line counts. Return type: LineCounts
Example
>>> import fs >>> fs.open_fs('~/projects').glob('**/*.py').count_lines() LineCounts(lines=5767102, non_blank=4915110)
-
class
fs.glob.
LineCounts
(lines, non_blank)¶ -
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
__repr__
()¶ Return a nicely formatted representation string
-
lines
¶ Alias for field number 0
-
non_blank
¶ Alias for field number 1
-