shinerainsevenlib.core.m3_core_nonpure

Classes

IndependentRNG

Keep a separate random stream that won't get affected by someone else.

Functions

getClipboardText()

Get clipboard text

setClipboardText(s)

Set clipboard text

DBG([obj])

Print values of local variables

registerDebughook([b])

Register callback for printing values of local variables

getRandomString([maxVal, asHex, rng])

Generate a random string of digits

genUuid([asBase64])

Generate a UUID

downloadUrl(url[, toFile, timeout, asText])

Download a URL, if toFile is not specified returns the results as a string.

startThread(fn[, args])

Start a thread

softDeleteFile(path[, allowDirs, doTrace])

Delete a file in a recoverable way, either OS Trash or a designated folder.

getSoftTempDir([path, preferEphemeral])

Get a temporary directory.

Module Contents

shinerainsevenlib.core.m3_core_nonpure.getClipboardText()

Get clipboard text

shinerainsevenlib.core.m3_core_nonpure.setClipboardText(s)

Set clipboard text

shinerainsevenlib.core.m3_core_nonpure.DBG(obj=None)

Print values of local variables

shinerainsevenlib.core.m3_core_nonpure.registerDebughook(b=True)

Register callback for printing values of local variables

shinerainsevenlib.core.m3_core_nonpure.getRandomString(maxVal=1000 * 1000, asHex=False, rng=_random)

Generate a random string of digits

shinerainsevenlib.core.m3_core_nonpure.genUuid(asBase64=False)

Generate a UUID

class shinerainsevenlib.core.m3_core_nonpure.IndependentRNG(seed=None)

Keep a separate random stream that won’t get affected by someone else. sometimes you want to set rng state to get a repeatable sequence of numbers back, which would get thrown off by other parts of the program also getting rng values.

rng
shinerainsevenlib.core.m3_core_nonpure.downloadUrl(url, toFile=None, timeout=30, asText=False)

Download a URL, if toFile is not specified returns the results as a string.

shinerainsevenlib.core.m3_core_nonpure.startThread(fn, args=None)

Start a thread

shinerainsevenlib.core.m3_core_nonpure.softDeleteFile(path, allowDirs=False, doTrace=False)

Delete a file in a recoverable way, either OS Trash or a designated folder. Defaults to ~/trash Configure behavior by editing shinerainsevenlib.cfg, trashDir=’recycleBin’ or ‘currentDriveDataLocalTrash’ or a path

shinerainsevenlib.core.m3_core_nonpure.getSoftTempDir(path='', preferEphemeral=False)

Get a temporary directory. Defaults to default OS temp directory, can be configured in shinerainsevenlib.cfg tempDir = (path to dir) tempEphemeralDir = (path to dir) An ephemeral dir is one where data isn’t kept long term. I often configure this to be a RAM drive, which are useful for heavy read/write scenarios.