pyguymer3

A Python module containing a bunch of random functions that I have written over the years. If you want to use some of these functions directly from the command line then you can run python3.12 -m pyguymer3 --help to see what is available.

Notes

Copyright 2017 Thomas Guymer [1]

References

Modules

checkSudokuBoard(board, /)

Check a Sudoku board is valid

convert_bytes_to_pretty_bytes(uglySize, /)

Convert a value of bytes to a pretty value of bytes with some units

convert_pretty_bytes_to_bytes(prettyString, /)

Convert a pretty string of a bytes with some units to a value of bytes

convert_seconds_to_pretty_time(secFlt, /)

Convert a value of seconds to a pretty value of time

convert_spreadsheet_to_datetime(val, /)

Convert an Excel spreadsheet date to a timezone-aware datetime object

convert_spreadsheet_to_unix(val, /)

Convert an Excel spreadsheet date to an UNIX timestamp

download(sess, method, url, /, *[, cookies, ...])

Call a URL and return the response

download_file(sess, url, fname, /, *[, ...])

GET a URL and save the content in a file

download_header(sess, url, /, *[, cookies, ...])

HEAD a URL and return the headers

download_stream(sess, url, /, *[, cookies, ...])

GET a URL and return the binary stream

download_text(sess, url, /, *[, cookies, ...])

GET a URL and return the text

elem2dict(elem, /, *[, debug, simplify])

Convert a XML element into a Python dictionary

f90

A Python sub-module containing a bunch of random functions that I have written over the years in FORTRAN to be called from Python using f2py.

find_instances_of_a_file(path, basename, /, *)

Return a recursive list of file names in a directory that match a basename.

find_integer_divisors(n, /)

find_program_version(prog, /, *[, pkgPath, ...])

generate_password()

generate_random_stub()

geo

A Python sub-module containing a bunch of random geo-related functions that I have written over the years.

getatime(fname, /)

Get the access time of a file as a timezone-aware datetime object.

getctime(fname, /)

Get the creation time of a file as a timezone-aware datetime object.

getmtime(fname, /)

Get the modification time of a file as a timezone-aware datetime object.

git_commits(cwd, /, *[, fname, gitPath, timeout])

git_files(cwd, /, *[, gitPath, timeout])

git_remote(cwd, /, *[, gitPath, name, timeout])

gzip(fname, /, *[, cwd, gzipPath, stderr, ...])

Compress a file using "gzip".

hostname()

image

A Python sub-module containing a bunch of random image-related functions that I have written over the years.

interpolate(x1, x2, y1, y2, x, /)

This function extrapolates/interpolates a line segment (defined by two points).

intersection(p1, p2, p3, p4, /)

This function finds the intersection of two line segments (defined by four points).

make_path_safe(path, /, *[, allowHidden, ...])

Make a path safe for using on a filesystem.

mean(arr, /, *[, dof])

Find the arithmetic mean of an array.

media

A Python sub-module containing a bunch of random media-related functions that I have written over the years.

nlines(fname, /)

now()

Get the current date and time as a timezone-aware datetime object.

openstreetmap

A Python sub-module containing functions relating to`OpenStreetMap [2]_.

osterrain

A Python sub-module containing functions relating to the OS Terrain 50 dataset [2]_.

perms(path, /, *[, allowHidden, debug, ...])

Set permissions within a path.

remove_almost_empty_directories(path, /, *)

Remove directories which are almost empty.

return_file_list(path, /, *[, allowHidden, ...])

Return a recursive list of file names in a directory.

return_folder_list(path, /, *[, ...])

Return a recursive list of folder names in a directory.

return_folder_size(path, /, *[, ...])

Return the total size of all files in a directory.

return_link_list(path, /, *[, allowHidden, ...])

Return a recursive list of link names in a directory.

save_file_if_needed(fname, fcontent, /, *[, ...])

Save a file.

serializer(obj, /, *[, evaluate])

Serialize an object into an intrinsic type

sha256(fname, /, *[, chunksize])

Find the SHA-256 hash of a file

sha256_of_GZ(fname, /, *[, chunksize, ...])

Find the SHA-256 hash of a GZ file

sha256_of_MP4(fname, /, *[, chunksize, ...])

Find the SHA-256 hash of a MP4 file

sha512(fname, /, *[, chunksize])

Find the SHA-512 hash of a file

sha512_of_GZ(fname, /, *[, chunksize, ...])

Find the SHA-512 hash of a GZ file

sha512_of_MP4(fname, /, *[, chunksize, ...])

Find the SHA-512 hash of a MP4 file

start_session()

stat(fname, /, *[, follow_symlinks])

This function aims to mimic os.stat() but instead of returning a stat_result object with attributes it returns a dictionary with keys (for more user- friendly serialization to JSON).

stddev(arr, /, *[, dof])

Find the standard deviation of an array.

stderr(arr, /, *[, dof])

Find the standard error of an array.

tar(tarName, fnames, /, *[, cwd, stderr, ...])

Create a PAX formatted TAR file (without any frills or size limits).

var(arr, /, *[, dof])

Find the variance of an array.

xz(fname, /, *[, cwd, stderr, stdout, ...])

Compress a file using "xz" (with SHA-256 integrity checks).