Misc. Tools (rever.tools)

Some special rever tools


Checks that gpg is available and useable. Returns a boolean and message.

rever.tools.download(url, encoding=None, errors=None, **kwargs)

Gets a URL in a given encoding.

rever.tools.download_bytes(url, **kwargs)

Gets the bytes from a URL


Evalauates the argument either as a template string which contains $VERSION (or other environment variables) or a callable which takes a single argument (that is $VERSION) and returns a string.


Returns the set of field names in a format string.

rever.tools.hash_url(url, hash='sha256', quiet=False)

Hashes a URL, with a progress bar, and returns the hex representation


Context manager for temporarily entering into a directory.

rever.tools.progress(count, total=None, prefix='', suffix='', width=60, file=None, fill='`·.,¸,.·*¯`·.,¸,.·*¯', color=None, empty=' ', quiet=False)

CLI progress bar


Parse a list of of tuples of authors into valid bibtex

authors: list of str

The authors eg [‘Your name in nicely formatted bibtex’]. Please see <http://nwalsh.com/tex/texhelp/bibtx-23.html> for information about how to format your name for bibtex


Valid bibtex authors

rever.tools.replace_in_file(pattern, new, fname, leading_whitespace=True)

Replaces a given pattern in a file. If leading whitespace is True, whitespace at the begining of a line will be captured and preserved. Otherwise, the pattern itself must contain all leading whitespace.

rever.tools.stream_url_progress(url, verb='downloading', chunksize=1024, width=60, quiet=False)

Generator yielding successive bytes from a URL.


URL to open and stream


Verb to prefix the url downloading with, default ‘downloading’


Number of bytes to return, defaults to 1 kb.

quietbool, optional

If true don’t print out progress bar, defaults to False

yields the bytes which is at most chunksize in length.
rever.tools.user_group(filename, return_ids=False)

Returns the user and group name for a file, and optionally ids too. returns (user_name, group_name) if return_ids is False. If True, returns (user_name, group_name, user_id, group_id). On windows, the user id and group id will be None and the group name will be the same as the user name.