|
def | drop_zeros (v, replace="") |
|
def | ellipsize (text, limit, ellipsis="..") |
|
def | ensure_namespace (val, defaults=None, dashify=("WRITE_OPTIONS",), **kwargs) |
|
def | filter_dict (dct, keys=(), values=(), reverse=False) |
|
def | find_files (names=(), paths=(), extensions=(), skip_extensions=(), recurse=False) |
|
def | format_bytes (size, precision=2, inter=" ", strip=True) |
|
def | format_stamp (stamp) |
|
def | format_timedelta (delta) |
|
def | get_name (obj) |
|
def | has_arg (func, name) |
|
def | import_item (name) |
|
def | is_iterable (value) |
|
def | is_stream (value) |
|
def | makedirs (path) |
|
def | memoize (func) |
|
def | merge_dicts (d1, d2) |
|
def | merge_spans (spans, join_blanks=False) |
|
def | parse_datetime (text) |
|
def | parse_number (value, suffixes=None) |
|
def | plural (word, items=None, numbers=True, single="1", sep=",", pref="", suf="") |
|
def | structcopy (value) |
|
def | unique_path (pathname, empty_ok=False) |
|
def | verify_io (f, mode) |
|
def | wildcard_to_regex (text, end=False) |
|
def grepros.common.find_files |
( |
|
names = () , |
|
|
|
paths = () , |
|
|
|
extensions = () , |
|
|
|
skip_extensions = () , |
|
|
|
recurse = False |
|
) |
| |
Yields filenames from current directory or given paths.
Seeks only files with given extensions if names not given.
Logs errors for names and paths not found.
@param names list of specific files to return (supports * wildcards)
@param paths list of paths to look under, if not using current directory
@param extensions list of extensions to select if not using names, as (".ext1", ..)
@param skip_extensions list of extensions to skip if not using names, as (".ext1", ..)
@param recurse whether to recurse into subdirectories
Definition at line 715 of file common.py.
def grepros.common.merge_spans |
( |
|
spans, |
|
|
|
join_blanks = False |
|
) |
| |
Returns a sorted list of (start, end) spans with overlapping spans merged.
@param join_blanks whether to merge consecutive zero-length spans,
e.g. [(0, 0), (1, 1)] -> [(0, 1)]
Definition at line 903 of file common.py.
def grepros.common.plural |
( |
|
word, |
|
|
|
items = None , |
|
|
|
numbers = True , |
|
|
|
single = "1" , |
|
|
|
sep = "," , |
|
|
|
pref = "" , |
|
|
|
suf = "" |
|
) |
| |
Returns the word as 'count words', or '1 word' if count is 1,
or 'words' if count omitted.
@param items item collection or count,
or None to get just the plural of the word
@param numbers if False, count is omitted from final result
@param single prefix to use for word if count is 1, e.g. "a"
@param sep thousand-separator to use for count
@param pref prefix to prepend to count, e.g. "~150"
@param suf suffix to append to count, e.g. "150+"
Definition at line 953 of file common.py.
def grepros.common.verify_io |
( |
|
f, |
|
|
|
mode |
|
) |
| |
Returns whether stream or file path can be read from and/or written to as binary.
Prints or raises error if not.
Tries to open file in append mode if verifying path writability,
auto-creating missing directories if any, will delete any file or directory created.
@param f file path, or stream
@param mode "r" for readable, "w" for writable, "a" for readable and writable
Definition at line 1019 of file common.py.