FoxDot.lib.Utils

Useful functions and classes, mostly relating to the Pattern class but used in multiple sub-packages of FoxDot.

FoxDot.lib.Utils.EuclidsAlgorithm(n, k, lo=0, hi=1)[source]
FoxDot.lib.Utils.LCM(*args)[source]

Lowest Common Multiple

FoxDot.lib.Utils.PulsesToDurations(data)[source]

Returns a list of durations based on pulses (1s) and blanks (0s). Data should be a list of [1,0] where 1 is a pulse.

class FoxDot.lib.Utils.Version(version: str)[source]

Bases: object

Minimal representation of a SemVer version.

major: int
minor: int
patch: int
version: str
class FoxDot.lib.Utils.dots[source]

Bases: object

Class for representing long Patterns in strings

FoxDot.lib.Utils.get_expanded_len(data)[source]

(0,(0,2)) returns 4. int returns 1

FoxDot.lib.Utils.get_first_item(array)[source]

Returns first item from a possibly nested list

FoxDot.lib.Utils.get_inverse_op(method)[source]

Returns the opposite __dunder__ method e.g. get_inverse_op(“__add__”) -> “__radd__” get_inverse_op(“__ror__”) -> “__or__”

FoxDot.lib.Utils.get_pypi_version()[source]

Returns the most up-to-date version number on PyPI. Return None on error

FoxDot.lib.Utils.is_version_greather(new, current)[source]

Check if the version is greater than the other.

FoxDot.lib.Utils.isiterable(obj)[source]

Returns true if an object is iterable by using iter(obj)

FoxDot.lib.Utils.max_length(*patterns)[source]

Returns the largest length pattern

FoxDot.lib.Utils.modi(array, i, debug=0)[source]

Returns the modulo index i.e. modi([0,1,2],4) will return 1

FoxDot.lib.Utils.recursive_any(seq)[source]

Like any but checks lists recursively

FoxDot.lib.Utils.sliceToRange(s)[source]
FoxDot.lib.Utils.stdout(*args)[source]

Forces prints to stdout and not console