cola.utils – Miscellaneous helpers
This module provides miscellaneous utility functions.
-
cola.utils.add_parents(path_entry_set)
- Iterate over each item in the set and add its parent directories.
-
cola.utils.basename(path)
An os.path.basename() implementation that always uses ‘/’
Avoid os.path.basename because git’s output always
uses ‘/’ regardless of platform.
-
cola.utils.checksum(path)
- Return a cheap md5 hexdigest for a path.
-
cola.utils.dirname(path)
An os.path.dirname() implementation that always uses ‘/’
Avoid os.path.dirname because git’s output always
uses ‘/’ regardless of platform.
-
cola.utils.file_icon(filename)
- Returns the full path to an icon file corresponding to
filename”s contents.
-
cola.utils.fork(args)
- Launch a command in the background.
-
cola.utils.grep(pattern, items, squash=True)
- Greps a list for items that match a pattern and return a list of
matching items. If only one item matches, return just that item.
-
cola.utils.ident_file_type(filename)
- Returns an icon based on the contents of filename.
-
cola.utils.is_broken()
- Is it windows or mac? (e.g. is running git-mergetool non-trivial?)
-
cola.utils.is_darwin()
- Return True on OSX.
-
cola.utils.is_debian()
- Is it debian?
-
cola.utils.is_linux()
- Is this a linux machine?
-
cola.utils.qm_for_locale(locale)
- Returns the .qm file for a particular $LANG values.
-
cola.utils.quote_repopath(repopath)
- Quote a path for nt/dos only.
-
cola.utils.run_cmd(command)
Run arguments as a command and return output.
>>> run_cmd(["echo", "hello", "world"])
'hello world'
-
cola.utils.sanitize(s)
- Removes shell metacharacters from a string.
-
cola.utils.slurp(path)
- Slurps a filepath into a string.
-
cola.utils.strip_prefix(prefix, string)
- Return string, without the prefix. Blow up if string doesn’t
start with prefix.
-
cola.utils.sublist(a, b)
- Subtracts list b from list a and returns the resulting list.
-
cola.utils.win32_abspath(exe)
- Return the absolute path to an .exe if it exists
-
cola.utils.win32_expand_paths(args)
- Expand filenames after the double-dash
-
cola.utils.write(path, contents)
- Writes a string to a file.