grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
common.py File Reference

Go to the source code of this file.

Classes

class  ArgumentUtil
 Namespace for program argument handling. More...
 
class  ConsolePrinter
 Prints to console, supports color output. More...
 
class  Decompressor
 Decompresses zstandard archives. More...
 
class  ArgumentUtil.HelpFormatter
 RawTextHelpFormatter returning custom metavar for non-flattenable list arguments. More...
 
class  LenIterable
 Wrapper for iterable value with specified fixed length. More...
 
class  MatchMarkers
 Highlight markers for matches in message values. More...
 
class  ProgressBar
 A simple ASCII progress bar with a ticker thread. More...
 
class  TextWrapper
 TextWrapper that supports custom substring widths in line width calculation. More...
 

Namespaces

namespace  grepros
 
namespace  grepros.common
 Common utilities.
 

Functions

 drop_zeros (v, replace="")
 Drops trailing zeros and empty decimal separator, if any.
 
 ellipsize (text, limit, ellipsis="..")
 Returns text ellipsized if beyond limit.
 
 ensure_namespace (val, defaults=None, dashify=("WRITE_OPTIONS",), **kwargs)
 Returns a copy of value as argparse.Namespace, with all keys uppercase.
 
 filter_dict (dct, keys=(), values=(), reverse=False)
 Filters string dictionary by keys and values, supporting * wildcards.
 
 find_files (names=(), paths=(), suffixes=(), skip_suffixes=(), recurse=False)
 Yields filenames from current directory or given paths.
 
 format_bytes (size, precision=2, inter=" ", strip=True)
 Returns a formatted byte size (like 421.40 MB), trailing zeros optionally removed.
 
 format_stamp (stamp)
 Returns ISO datetime from UNIX timestamp.
 
 format_timedelta (delta)
 Formats the datetime.timedelta as "3d 40h 23min 23.1sec".
 
 get_name (obj)
 Returns the fully namespaced name for a Python module, class, function or object.
 
 has_arg (func, name)
 Returns whether function supports taking specified argument by name.
 
 import_item (name)
 Returns imported module, or identifier from imported namespace; raises on error.
 
 is_iterable (value)
 Returns whether value is iterable.
 
 is_stream (value)
 Returns whether value is a file-like object.
 
 makedirs (path)
 Creates directory structure for path if not already existing.
 
 memoize (func)
 Returns a results-caching wrapper for the function, cache used if arguments hashable.
 
 merge_dicts (d1, d2)
 Merges d2 into d1, recursively for nested dicts, returns d1.
 
 merge_spans (spans, join_blanks=False)
 Returns a sorted list of (start, end) spans with overlapping spans merged.
 
 parse_datetime (text)
 Returns datetime object from ISO datetime string (may be partial).
 
 parse_number (value, suffixes=None)
 Returns an integer parsed from text, raises on error.
 
 path_to_regex (text, sep=".", wildcard="*", end=False, intify=False)
 Returns re.Pattern for matching path strings with optional integer indexes.
 
 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.
 
 structcopy (value)
 Returns a deep copy of a standard data structure (dict, list, set, tuple), other object types reused instead of copied.
 
 unique_path (pathname, empty_ok=False)
 Returns a unique version of the path.
 
 verify_io (f, mode)
 Returns whether stream or file path can be read from and/or written to as binary.
 
 wildcard_to_regex (text, end=False)
 Returns plain wildcard like "foo*bar" as re.Pattern("foo.*bar", re.I).
 

Variables

tuple PATH_TYPES = (six.binary_type, six.text_type)
 Python types for filesystem paths.
 
tuple STRING_TYPES = (six.binary_type, six.text_type)
 Python types for both byte strings and text strings.
 
tuple TEXT_TYPES = (six.binary_type, six.text_type) if six.PY2 else (six.text_type, )
 Python types for text strings.