pycmdtools package

Submodules

pycmdtools.configs module

All configurations for pycmdtools

class pycmdtools.configs.ConfigAlgorithm[source]

Bases: Config

Configuration options to select the digest algorithm

algorithm = 'md5'
class pycmdtools.configs.ConfigChangeLine[source]

Bases: Config

Change a line in file parameters

from_line = None
to_line = <pytconf.param.Unique object>
class pycmdtools.configs.ConfigCopy[source]

Bases: Config

Configure copy stuff

copy = False
class pycmdtools.configs.ConfigDebug[source]

Bases: Config

Enable debug output

debug = False
class pycmdtools.configs.ConfigDownloadGdriveURL[source]

Bases: Config

Parameters to download a share url from google drive

url = <pytconf.param.Unique object>
class pycmdtools.configs.ConfigDownloadGoogleDrive[source]

Bases: Config

Parameters for downloading a file from google drive

destination = <pytconf.param.Unique object>
file_id = <pytconf.param.Unique object>
class pycmdtools.configs.ConfigFolder[source]

Bases: Config

Parameters for the symlink install tool

folder = <pytconf.param.Unique object>
class pycmdtools.configs.ConfigOutput[source]

Bases: Config

Control output

print = None
class pycmdtools.configs.ConfigProgress[source]

Bases: Config

Configuration options for progress reporting

progress = False
class pycmdtools.configs.ConfigSchemaUrl[source]

Bases: Config

A schema URL parameter

schema_url = <pytconf.param.Unique object>
class pycmdtools.configs.ConfigUseCache[source]

Bases: Config

Enable or disable disk-based schema cache

use_cache = True
class pycmdtools.configs.ConfigUseStandardExceptions[source]

Bases: Config

Should we use standard exceptions

use_standard_exceptions = True

pycmdtools.main module

The default group of operations that pycmdtools has

pycmdtools.main.change_first_line() → None[source]
pycmdtools.main.extension_stats()[source]
pycmdtools.main.google_drive_download_by_id() → None[source]

If you have a link to a google drive file like this: https://drive.google.com/open?id=0BwNoUKizWBdnRmRmLVlWSWxzWnM or like this: https://drive.google.com/file/d/0BwNoUKizWBdnSHF4SFlyRkxNSVE/view?usp=sharing Then the file id of the relevant files are: 0BwNoUKizWBdnRmRmLVlWSWxzWnM 0BwNoUKizWBdnSHF4SFlyRkxNSVE And this is what you have to supply to this script to download the files.

References: - http://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive

pycmdtools.main.google_drive_download_by_url() → None[source]
pycmdtools.main.line_value_histogram() → None[source]
pycmdtools.main.linecount_csv() → None[source]
pycmdtools.main.main()[source]
pycmdtools.main.mcmp() → None[source]

TODO: - make the algorithm faster by looking only at the beginning of the files. - make the algorithm faster by looking at the length of the files. - make the algorithm faster by having a gnu dbm ~/.mcmp which already stores hashes of known files.

pycmdtools.main.print_all_args() → None[source]
pycmdtools.main.progress() → None[source]

enable to show progress by pointing to a FILE and not a PROCESS NAME or PID. If you point to a file then something like fuser(1) should be called on the file, and if there is just one process holding the file open then show the progress on that file.

References: - https://unix.stackexchange.com/questions/66795/how-to-check-progress-of-running-cp - https://github.com/Xfennec/progress - https://gist.github.com/azat/2830255 - https://stackoverflow.com/questions/10980689/how-to-follow-the-progress-of-a-linux-command

pycmdtools.main.python_check_syntax() → None[source]
pycmdtools.main.schema_cache_clear() → None[source]
pycmdtools.main.schema_cache_list() → None[source]
pycmdtools.main.schema_cache_remove() → None[source]
pycmdtools.main.stats() → None[source]
pycmdtools.main.unique() → None[source]
pycmdtools.main.validate_csv() → None[source]
pycmdtools.main.validate_html()[source]
pycmdtools.main.validate_json() → None[source]
pycmdtools.main.validate_jsonschema() → None[source]
pycmdtools.main.validate_xml() → None[source]
pycmdtools.main.validate_yaml() → None[source]
pycmdtools.main.validate_yaml_advanced() → None[source]
pycmdtools.main.xprofile_select() → None[source]

pycmdtools.python module

This script checks the syntax of other python scripts. It returns a bad error code to the parent if something goes wrong.

Its basically a more sophisticated version of something like this:

python2 -m py_compile $< || python3 -m py_compile $<

pycmdtools.python.do_python_check_syntax(filename: str) → None[source]

pycmdtools.schema_cache module

Disk-persistent cache for JSON schemas fetched by URL. Stores schemas as individual JSON files under ~/.cache/pycmdtools/schemas/.

pycmdtools.schema_cache.clear_all() → int[source]
pycmdtools.schema_cache.fetch_schema(url: str, use_cache: bool, memory_cache: dict[str, dict]) → dict[source]
pycmdtools.schema_cache.list_entries() → list[tuple[str, str]][source]
pycmdtools.schema_cache.remove_entry(url: str) → bool[source]

pycmdtools.static module

version which can be consumed from within the module

pycmdtools.utils module

utils.py

pycmdtools.utils.checksum(file_name: str, algorithm: str) → str[source]

calculate a checksum of a file. You dictate which algorithm. If you want to see all algorithms try: hashlib.algorithms_available :param file_name: :param algorithm: :return:

pycmdtools.utils.diamond_lines(filenames: list[str])[source]
pycmdtools.utils.download_file_from_google_drive(file_id: str, destination: str)[source]
pycmdtools.utils.error(args)[source]

Here is a sample google drive shared url: https://drive.google.com/file/d/1EbAbRUKowIi7ZL8fcktsEqj-gvcyq0a6/view?usp=sharing This function will: - download the link - extract the name of the file from the link - extract the id of the file from the link - use the method above to download the file :param url: the share link you got from google :return:

pycmdtools.utils.get_confirm_token(response)[source]

remove bad symbolic links from a folder

pycmdtools.utils.save_response_content(response, destination)[source]

remove bad symbolic links from a folder.

Control this functions verbosity using the python logging framework :param folder: :param use_standard_exceptions: :param onerror: passed to os.walk :return:

Module contents

Initialize the module