Library reference¶
Core components¶
-
class
py314.globals.SENTINEL¶ A Singleton Sentinel object.
-
py314.console.register_enumeration(cls)¶ A decorator for an enumeration cls that registers its members as global logging levels. The field name represents the logging level name and the field value is the logging level, hence is expected to be an integer.
Parameters: cls ( enum.IntEnum) – Enumeration containing logging levels.Returns: The decorated cls. Return type: enum.IntEnum
-
class
py314.console.SYS¶ System and internal logging enumeration.
-
ACTIVE¶
-
DEBUG¶
-
SQL¶
-
SUCCESS¶
-
PENDING¶
-
FAILURE¶
-
INFO¶
-
WARNING¶
-
ERROR¶
-
FATAL¶
-
AUTH¶ Auth daemon logging level.
-
TRACEBACK¶
-
SYSTEM¶ A generic logging level for system messages.
-
-
class
py314.console.console¶ A generic console logger.
-
verbosity¶ int – Class attribute containing the logger verbosity.
-
debug_state¶ bool – Class attribute denoting whether the console is in debug mode or not.
-
frame_state¶ bool – Class attribute denoting whether the frame info is logged or not.
-
classmethod
log(header, message, verbosity=0, fore=None, style=None)¶ For high enough verbosity, print in the terminal a message prefixed by a suitable header and decorated with ANSI color and style.
If header is a string, use a
SYS.ACTIVElogging level.Parameters: - header (Union[int, str]) – A logging level or an header string.
- message (str) – The message to log.
- verbosity (int [optional]) – Runtime verbosity.
- fore (
py314.vendor.pydec.AnsiFore[optional]) – An optional ANSI text color. - style (
py314.vendor.pydec.AnsiStyle[optional]) – An optional text style.
-
classmethod
traceback(message=None, *, raise_exc=False, depth=None)¶ Log the current frame F where this method is called. If an exception was raised and if message is
None, then this exception is logged. Otherwise, log the message. The optional parameter depth denotes an ancestor frame, that is the first outer frame associated with F.Parameters:
-
classmethod
append(message, fore=None, style=None)¶ Format message with the given arguments and align the log with the previous one if possible. This method must always follow another logging method, or else nothing will be logged. This method provides a multilines records support.
Parameters: - message (str) – The message to log.
- fore (
py314.vendor.pydec.AnsiFore[optional]) – An optional ANSI text color. - style (
py314.vendor.pydec.AnsiStyle[optional]) – An optional text style.
-
classmethod
debug(message)¶ If the debug mode is enabled, log message with a debug style.
Parameters: message (str) – Message to log.
-
classmethod
info(message, verbosity=1, style=None)¶ Log a message with a
SYS.INFOlogging level.Parameters: - message (str) – The message to log.
- verbosity (int [optional]) – Runtime verbosity.
- style (
py314.vendor.pydec.AnsiStyle[optional]) – Optional text style.
-
classmethod
pending(message, verbosity=1)¶ Log a message with a
SYS.PENDINGlogging level.Parameters:
-
classmethod
success(message, verbosity=1)¶ Log a message with a
SYS.PENDINGlogging level.Parameters:
-
classmethod
warning(message)¶ Log a message with a
SYS.WARNINGlogging level.Parameters: message (str) – The message to log.
-
classmethod
failure(message)¶ Log a message with a
SYS.FAILURElogging level.Parameters: message (str) – The message to log.
-
classmethod
alert(level, message, fore='\x1b[31m')¶ Log a message with a level logging level.
Parameters:
-
classmethod
sql(message, verbosity=0)¶ Log a message with a
SYS.SQLlogging level. The console must be enable its debug mode to log this message.Parameters:
-
classmethod
set_verbosity(verbosity)¶ Define the minimum verbosity for enabling logging support.
-
classmethod
set_debug(state)¶ Enable or disable the console debug mode.
-
classmethod
observe(owner)¶ Add an object to benchmark.
Parameters: owner ( WithTimeitPolicy) – Object to benchmark.
-
-
class
py314.console.WithTimeitPolicy¶ Abstact interface for objects that are benchmarked.
-
classmethod
enable_timeit_strategy()¶ Decorate some methods with
WithTimeitPolicy.wraps().
-
classmethod
disable_timeit_strategy()¶ Remove the timing decorators.
-
classmethod
set_timeit_policy(flag)¶ Enable or disable the timeit strategy according to state.
-
classmethod
wraps(callback, timeout=0, message=None)¶ Decorator for timing methods.
-
classmethod
sqltimeit(callback, timeout)¶ SQL methods timing decorator.
-
classmethod
Providers and disk¶
Configuration files¶
-
class
py314.config.FileConfig(path)¶ A config object whose data is extracted from an YAML configuration file. It is possible to add a callback that takes no argument and which will be executed when the configuration has been updated at runtime.
Parameters: path (str) – The absolute path to the YAML file. -
reload()¶ Reload the data from the configuration file and return if changes.
-
dumps()¶ Dump the configuration into the configuration file.
-
at(path, **kwargs)¶ Return the value of the leaf of the path in the configuration file.
See also
-
Disk utilitaries¶
This module provides extended functions to the os builtin module.
-
py314.disk.is_file_null(path)¶ Check either that path does not exist or is empty.
-
py314.disk.traverse(path, *, ordered=False)¶ Return a list of all paths in the directory tree of path.
-
py314.disk.base_filename(path)¶ Return the filname of path without its extension.
-
py314.disk.base_suffix(path)¶ Return the extension of path.
-
py314.disk.prefixed(path, *, prefix)¶ Check that path is not
Noneand starts with prefix.
-
py314.disk.suffixed(path, *, suffix)¶ Check suffix is the suffix of path.
-
py314.disk.rmexpired(path, *, days=10)¶ Delete all files in the path folder older than days.
-
py314.disk.rmfiles(dirpath, *, skip_suffix=None, skip_prefix=None)¶ Delete all files in the dirpath folder not prefixed by skip_prefix and not suffixed by skip_suffix.
-
py314.disk.targzify(path)¶ Compress a path into a .tar.gz file with same file name.
Parameters: path (str) – Absolte file path denoting the file to compress.
-
py314.disk.create_files(dirpath, *filenames, suffix=None)¶ For each name in filenames, create a file named name inside a folder located at dirpath and of desired extension given by suffix.
Parameters:
-
class
py314.disk.FileContext(filename, mode='r', encoding=None, root='')¶ A file context manager for internal processing.
-
class
py314.disk.DirectoryView(*paths)¶ A Directory view for a given root.
-
root¶ str – The joined path.
-
classmethod
isfile(path)¶ Return
Trueif path describes a file path.
-
classmethod
isdir(path)¶ Return
Trueif path describes a directory path.
-
-
class
py314.disk.CompressManager(*paths, skip=None)¶ Compress all files located at path, except those in skip folder.
Parameters: paths (list) – A list of paths to join. -
path¶ str – The compressed folder.
-
targzify(suffix, *, skip_prefix=None)¶ Compress all files in
CompressManager.pathending with suffix but not starting with skip_prefix
-
Base Serializers¶
This module provides basic YAML and JSON serializers.
-
class
py314.serializer.ABCSerializer¶ Abstract serializer.
-
classmethod
load(stream)¶ Load the stream.
-
classmethod
-
class
py314.serializer.JSONSerializer¶ JSON Serializer based on the json.loads and the json.dumps functions.
-
load(*, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)¶ Deserialize
s(astr,bytesorbytearrayinstance containing a JSON document) to a Python object.object_hookis an optional function that will be called with the result of any object literal decode (adict). The return value ofobject_hookwill be used instead of thedict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).object_pairs_hookis an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value ofobject_pairs_hookwill be used instead of thedict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). Ifobject_hookis also defined, theobject_pairs_hooktakes priority.parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.To use a custom
JSONDecodersubclass, specify it with theclskwarg; otherwiseJSONDecoderis used.The
encodingargument is ignored and deprecated.
-
dump(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)¶ Serialize
objto a JSON formattedstr.If
skipkeysis true thendictkeys that are not basic types (str,int,float,bool,None) will be skipped instead of raising aTypeError.If
ensure_asciiis false, then the return value can contain non-ASCII characters if they appear in strings contained inobj. Otherwise, all such characters are escaped in JSON strings.If
check_circularis false, then the circular reference check for container types will be skipped and a circular reference will result in anOverflowError(or worse).If
allow_nanis false, then it will be aValueErrorto serialize out of rangefloatvalues (nan,inf,-inf) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN,Infinity,-Infinity).If
indentis a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.Noneis the most compact representation.If specified,
separatorsshould be an(item_separator, key_separator)tuple. The default is(', ', ': ')if indent isNoneand(',', ': ')otherwise. To get the most compact JSON representation, you should specify(',', ':')to eliminate whitespace.default(obj)is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.If sort_keys is true (default:
False), then the output of dictionaries will be sorted by key.To use a custom
JSONEncodersubclass (e.g. one that overrides the.default()method to serialize additional types), specify it with theclskwarg; otherwiseJSONEncoderis used.
-
-
class
py314.serializer.YAMLSerializer¶ YAML Serializer based on the yaml.load and the yaml.dump functions.
-
load(Loader=<class 'yaml.loader.Loader'>)¶ Parse the first YAML document in a stream and produce the corresponding Python object.
-
dump(stream=None, Dumper=<class 'yaml.dumper.Dumper'>, **kwds)¶ Serialize a Python object into a YAML stream. If stream is None, return the produced string instead.
-
Theoretic sets¶
This module implements a theoretic set object and provides the four basic set
operations, namely union, intersection, difference and symmetric diff.
The builtin set class should be used whenever possible.
-
class
py314.theory.TheoreticSet(iterable, tc=None)¶ A generic iterable class providing intersection, unions, difference and symmetric difference operations. If tc is given, then items are gathered into an iterable of type tc.
Parameters:
Volatile data¶
This module provides data containers with predefined lifespan.
-
class
py314.volatile.Volatile(data, max_age)¶ Represent a data with a certain max_age.
Parameters: - data (object) – The underlying data.
- max_age (int) – The object’s time duration.
- parent (
VolatileCache) – Container storing the volatile data (reference).
-
consume()¶ Consume prematuraly.
-
consumed¶ bool – Determine whether the data is marked as consumed or not.
-
data¶ object – Proxy to the current value.
-
class
py314.volatile.VolatileCache¶ An associative array of volatile data.
-
entry(key)¶ Return the volatile data of key.
-
has(key)¶ Check that key is a valid volatile data key.
-
remove(key)¶ Delete the entry associated with key in the cache.
-
register(key, volatile)¶ Register a volatile with a specific key in the cache.
Parameters: - key (
collections.Hashable) – A key for tracing back the volatile object. - volatile (
Volatile) – A volatile object to insert in the cache.
- key (
-
consume(key)¶ Consume the entry in the cache associated with key. Silent exceptions arising from invalid keys.
-
clear()¶ Consume every items in the cache if possible and clear the cache.
-
-
class
py314.volatile.VolatileCacheMapping(*cache_names)¶ An assocative array name → cache, where name is a
strfor an associative cache name and cache is anVolatileCacheinstance.-
get_cache(cache_name, default=None)¶ Return the
VolatileCacheassociated with cache_name.
-
register(cache_name, key, volatile)¶ Insert volatile into the
VolatileCachenamed cache_name. If the latter does not exist, create it before the insertion.Parameters:
-
has_key(key)¶ Check that key belongs to a cache.
-
cache_of(key)¶ Return the first
VolatileCacheof key orNone.
-
Fonctions and callbacks¶
-
class
py314.adapter.Adapter(*, transformation=None)¶ A decorator that convert the output of a function to another type before returning it, without modifying the function itself.
Parameters: func (callable [optional]) – The transformation callable.
-
class
py314.callback.Callback(callback=None)¶ Implement a strategy which executes a callback and does not care about the messenger.
Parameters: callback (callable [optional]) – The callback to execute. -
__call__(messenger)¶ Call self as a function.
-
-
class
py314.callback.Function(_=None, *args, **kwargs)¶ Represent a routine or a coroutine with bound values or not. Positional and keyword arguments pass to the _ whe invoked and extra arguments can be given at this time. Extra positional arguments are inserted after existing.
Parameters: _ (callable [optional]) – A callback to execute. -
classmethod
wraps(func, *args, **kwargs)¶ Wrap func inside a
Functionif it is not already the case and attach the positional and keyword arguments if needed.
-
execute(*args, **kwargs)¶ Pass positional and keyword arguments to the callback and ensure a synchronous execution of the latter.
-
coroutine
async_execute(*args, **kwargs)¶ Pass positional and keyword arguments to the callback and ensure an asychronous execution of the latter.
-
coroutine
fast_async_execute(*args, **kwargs)¶ Equivalent to
async_execute()with no safe-execution check.
-
classmethod
-
class
py314.callback.ChainMap(missing=None, sloppy=True)¶ A mapping whose keys are strings and values are chained callback. Define a callback to execute when a key is missing via the missing parameter.
Parameters: -
register(key, callback, *args, **kwargs)¶ Put a new
Callbackinto the current chain of callbacks.Parameters:
-
remove(key)¶ Remove the tasks triggered by key.
Parameters: key (str) – The triggering key to remove.
-
on_missing(*args, **kwargs)¶ Called when a key is invalid.
-
-
class
py314.callback.Switch(missing=None, **arrows)¶ Store callbacks and associate them with some keys.
The missing parameter describes a callback executed when a key string is not handled by the switch. If the callback requires parameters, it suffices to wrap it inside a
Functioninstance.Parameters: missing (callable or Function[optional]) – A callback to execute on invalid keys.-
handles(key)¶ Check that key is handled by the switch.
-
register(key, callback, *args, **kwargs)¶ Add a callback for a specific key.
-
execute(key, *args, **kwargs)¶ Pass positional and keyword arguments to the callback attached to key or execute the on_missing callback if there is none.
-
coroutine
async_execute(key, *args, **kwargs)¶ Pass positional and keyword arguments to the callback attached to key or asynchronously execute the on_missing callback if there is none.
-
-
class
py314.callback.Promise(timeout, callback, *args, **kwargs)¶ Represent a scheduled task with callback (coroutine or not). The positional and keyword arguments are passed to callback.
Parameters: -
__call__(*args, **kwargs)¶ Call self as a function.
-
execute()¶ Schedule the task and define its callback.
-
cancel()¶ Cancel the running task.
-
-
class
py314.callback.EPromise(timeout, callback, *args, **kwargs)¶ A
Promiserunning infinitely, restarting when finished.
-
py314.functions.this(x)¶ The identity map x → x.
-
py314.functions.const(obj)¶ A constant map x → obj.
-
py314.functions.aggregated(*, sentinel, n=None)¶ A predicate P(x) checking that x is not sentinel. If n is given, it is expected that x is an indexable iterable and P(x) checks that x[n] is not sentinel.
This module contains helper functions to check the arguments of a function.
All functions raise an AssertionError if the assertion fails.
-
class
py314.asserts.Assertions¶ Basic assertions.
-
classmethod
assert_type(instance, *classinfo)¶ Assert that instance is of suitable type given by classinfo.
-
classmethod
assert_unique(*args)¶ Assert that there is no duplicated arguments.
-
classmethod
assert_values(**kwargs)¶ Assert that all values are true truth.
-
classmethod
assert_has_attribute(func, name)¶ Assert that there is no func has an attribute field.
-
classmethod
-
class
py314.asserts.SilentAssertions¶ Empty assertions.
-
py314.inspect.get_f_kwargs(*, depth=1)¶ Return a tuple for frame formatting.
Decorators and descriptors¶
-
py314.enums.extend_flags(cls)¶ Decorator adding bitwise operations with types convertible to cls.
Parameters: cls (type) – A subclass of enum.Flag.The following operators are implemented.
- __and__(self, other) – Implement
self % other - __or__(self, other) – Implement
self | other. - __xor__(self, other) – Implement
self ^ other.
The following operators use the above operators.
- __ror__(self, other) – Implement
other | self. - __rand__(self, other) – Implement
other & self. - __rxor__(self, other) – Implement
other ^ self.
- __and__(self, other) – Implement
-
py314.enums.as_field_name(cls)¶ Define a default __str__() method for enumerations.
Algorithms¶
Dictionary factory¶
This module contains a dict factory and algorithms dealing in general
with dictionaries or two-dimensional iterables.
-
py314.collections.make_dict(iterable, *, key_adapter=None, val_adapter=None)¶ Make a
dictdefined by key_adapter(x) → val_adapter(x) as x ranges over iterable.Parameter flat passes to
functorize().Parameters:
-
py314.collections.make_dict(mapping, *, key_adapter = None, val_adapter = None) Overloads
make_dict().Make a
dictdefined by key_adapter(key) ↦ val_adapter(value) as (key, value) ranges over mapping.items().Parameters:
-
py314.collections.dict_from_keys(value, *keys)¶ Make a
dictdefined by key → deepcopy(value) as key ranges over keys.
-
py314.collections.alternate(mapping, *keys)¶ Make a
tuplealternating key and mapping[key] from mapping as key ranges over keys.
-
py314.collections.attributes(obj, *attrs)¶ Make a
dictdefined by key → getattr(obj, key) as key ranges over attrs. Exceptions are propagated.
Iteration¶
This module contains algorithms to flatten and iterate over iterables.
-
py314.iteration.next_iter(iterable, default=None)¶ Return the next iterator value or default if nothing can be fetched.
-
py314.iteration.starif(iterable, classinfo)¶ Return tuple(iterable) if iterable is an instance of a class or of a subclass thereof; otherwise, return a 1-uplet consisting of iterable.
Parameters:
-
py314.iteration.flatten(*args)¶ Recursively flatten each tuple in args and make an one-dimensional tuple with no tuples in it.
Nested tuples are not flattened., that is (x, (y)) and (x, [y]) will yield (x, y) and (x, [y]) respectively.
-
py314.iteration.unpack(iterable, classinfo)¶ Deeply flatten items in iterable whose type is given in classinfo.
Parameters:
-
py314.iteration.is_next(iterable, classinfo=(<class 'list'>, <class 'tuple'>))¶ Check that iterable is an instance of a class or of a subclass thereof as well as it is of length 1. In other words, check that iterable is a set in the mathematical sense that is in bijection with its elements.
Parameters:
-
py314.iteration.self_next(iterable, classinfo=(<class 'list'>, <class 'tuple'>))¶ Check that iterable satisfies
is_next()and remove the set delimiters of iterable by returning its value. Otherwise, do nothing.Parameters:
-
py314.iteration.take_next(iterable, classinfo=(<class 'list'>, ))¶ Return the first element iterable[0] of an iterable that is an instance of a class or of a subclass thereof; otherwise, return iterable.
Parameters: Raise: IndexError– Empty iterable.
-
py314.iteration.take_first_leaf(iterable, classinfo=(<class 'list'>, ))¶ Equivalent to take_first_leaf(take_next(iterable, classinfo), classinfo). If iterable is empty or is
None, stop the recursion.Parameters:
Iterators¶
This module contains algorithms dealing with iterators and generators.
-
py314.iterators.zipsafe(*iterables)¶ Make an
zipiterator aggregating items from each of the iterables. The iterator is an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.With a single iterable argument, return the iterable itself and with no arguments, return an empty tuple.
Raise: ValueError– No iterables are given.Raise: IndexError– Iterables have not same size.
-
py314.iterators.side_effect(func, iterable, *, nargs=1)¶ Make a
tupleaggregating func(x(i,1), …, x(i,n)), for all 1 ≤ i ≤ len(iterable) and 1 ≤ n ≤ len(args) as args ranges over iterable or iterable.items().To avoid calculations, it is possible to provide the number of arguments expected by func via nargs. By default, nargs is set to 1 and if it is
Noneor0, then func(*args) is called instead.Parameters:
Search¶
This module contains search algorithms.
-
py314.search.partition(predicate, iterable, adapter=None)¶ Return a pair (yes, no),where yes and no are subsets of iterable over which predicate evaluates to
TrueandFalserespectively. If adapter is given, return (adapter(yes), adapter(no)) instead.Parameters:
-
py314.search.locate(predicate, iterable)¶ A helper to return a list of the indices / keys of the items of iterable that meet the predicate.
Parameters:
-
py314.search.position(predicate, iterable)¶ A helper to return the first index or the key of an element of iterable that meets the predicate. If no index can be retrieved, return
None.Parameters:
-
py314.search.find(predicate, iterable, default=None)¶ A helper to return the first element found in the sequence iterable that meets the predicate.
Parameters: Returns: The first item that meets the predicate or default.
Examples
user = find(lambda u: u.id == 1, user_list)would find the user in the user’s list whose id (assuming that this attribute exists) and returns it.
Note
This is different from filter due to the fact it stops the moment it finds a valid entry.
Decomposition¶
-
py314.splits.take_n(iterable, n, *, adapter=None)¶ Return the first n items of the iterable as a tuple.
Parameters: adapter (callable [optional]) – An adapter to call on each item in iterable.
-
py314.splits.chunkize(iterable, size, *, adapter=None)¶ Make a generator whose elements are
tupleof cardinality size of an iterable iterable supporting elements access via index.Parameters:
-
py314.splits.chunkize(mapping, size) Overloads
chunkize().Slice a mapping into chunks of length size. No order is guaranteed if there is no possible one.
Parameters:
-
py314.splits.evenize(data)¶ Split data into its maximal subset of even size and the rest.
Tree¶
This module implements a graph theoretic approach for dict.
-
py314.tree.reach(tree, path, *, check=False, adapter=None, default=<class 'py314.globals.SENTINEL'>)¶ Navigate in tree via path and return the end node, adapted if needed.
Parameters: - tree (Mapping) – The tree to consider.
- path (str) – A sequence of nested keys of the form k1/k2/k3 ….
- check (bool [optional]) – Check that path is a valid path in tree.
- adapter (callable [optional]) – End-node adapter on non-default value and no error.
- default (object [optional]) – Value to return if the end node cannot be reached.
Raises: KeyError– Invalid path and no default given.
Miscellaneous¶
-
py314.process.reboot()¶ Restart the program, with file objects and descriptors cleanup.
-
py314.process.die()¶ Kill the program.
-
class
py314.requests.HTTPMethod¶ HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. Although they can also be nouns, these request methods are sometimes referred to as HTTP verbs.
Each of them implements a different semantic, but some common features are shared by a group of them: e.g. a request method can be safe, idempotent, or cacheable.
-
GET¶ Retrieve a representation of the specified resource.
-
HEAD¶ Ask for a response identical to that of a GET request, but without the response body.
-
POST¶ Submit an entity to the specified resource, often causing a change in state or side effects on the server.
-
PUT¶ Replace all current representations of the target resource with the request payload.
-
DELETE¶ Delete the specified resource.
-
CONNECT¶ Establish a tunnel to the server identified by the target resource.
-
OPTIONS¶ Describe the communication options for the target resource.
-
TRACE¶ Perform a message loop-back test along the path to the target resource.
-
PATCH¶ Apply partial modifications to a resource.
-
-
coroutine
py314.requests.request(meth, url, *, timeout=300, headers=None, params=None)¶ Execute an HTTP meth request given by url.
Parameters: - meth (
HTTPMethod) – HTTP Method. - url (str) – Request URL.
- timeout (float [optional]) – Timeout in milliseconds.
- headers (dict [optional]) – Request headers.
- params (dict [optional]) – Request parameters.
- meth (
-
class
py314.requests.ABCAPIClient¶ API Client meta class.
-
coroutine
get(url, **kwargs)¶ Execute a
HTTPMethod.GETrequest viarequest().Parameters: url (str) – Request URL.
-
coroutine
post(url, **kwargs)¶ Execute a
HTTPMethod.POSTrequest viarequest().Parameters: url (str) – Request URL.
-
classmethod
gather_error(error)¶ Analyze a possible error and raise an exception on error.
-
coroutine
-
py314.time.deltatime(*, start=datetime.datetime(1970, 1, 1, 0, 0), stop=None, ms=False)¶ Compute the seconds (with microseconds part) between start and stop.
Parameters: - start (datetime.datetime [optional]) – A starting time point.
- stop (datetime.datetime [optional]) – An ending time point (if
None, set to now). - ms (bool [optional]) – Conversion into milliseconds.
-
class
py314.unicode.Unicode¶ Traits class for unicode characters.
-
classmethod
backward()¶ Unicode character for :arrow_backward:.
-
classmethod
fast_backward()¶ Unicode character for :track_previous:.
-
classmethod
forward()¶ Unicode character for :arrow_forward:.
-
classmethod
fast_forward()¶ Unicode character for :track_forward:.
-
classmethod
eject()¶ Unicode character for :thumbsdown:.
-
classmethod
cross()¶ Unicode character for :cross:.
-
classmethod
check()¶ Unicode character for :cross:.
-
classmethod
bullet()¶ Unicode character for a black bullet.
-
classmethod
invsep()¶ Unicode character for soft invsep. Useful for specifying a space that is not consumed by inline markdown.
-
classmethod
electric_arrow()¶ Unicode character for a electric arrow.
-
classmethod
high_voltage()¶ Unicode character for a high voltage sign.
-
classmethod
square_lozenge()¶ Unicode character for a squared lozange.
-
classmethod
hourglass()¶ Unicode character for a hourglass with flowing sand.
-
classmethod
warning_sign()¶ Unicode character for a warning sign.
-
classmethod
thumbsup()¶ Unicode character for :thumbsup:.
-
classmethod
thumbsdown()¶ Unicode character for :thumbsdown:.
-
classmethod
info()¶ Unicode character for info.
-
classmethod
bell()¶ Unicode character for :bell:.
-
classmethod
International System and Unit conversion¶
This module contains basic functions and pre-implemented classes for units conversion.
-
class
py314.unit.Unit¶ Base class for a unit object.
-
standard¶ StandardUnit– A reference to the standard unit attached to this unit.
-
name¶ str – The unit’s abbreviation name.
-
standardize¶ callable – A function which takes a unique parameter, the value, and transforms it into its representation in the International System. SharedSpecs to a multiplication by
Unit.factor.
-
reverse¶ callable – A function which takes a unique parameter, the representation in the international system (IS) of a value, and transforms it into its representation in the current
Unit. SharedSpecs to a division byUnit.factor.
-
classmethod
to_std(value, *, prec=None)¶ Assuming the value’s unit is the same as a children subclass of
Unit, convert this value into its standard form (IS), viaUnit.factororUnit.standardize().Parameters: - value – The value to convert.
- prec (int [optional]) – Maximum amount of digits.
Returns: The desired conversion or
Nonefor a non-conversion.
-
classmethod
from_std(value, *, prec=None)¶ Assuming the value’s unit is the same as
Unit.standard, convert value into its representation as aUnitviaUnit.factororUnit.reverse().Parameters: - value – The value to convert.
- prec (int [optional]) – Maximum amount of digits.
Returns: The desired conversion or
Nonefor a non-conversion.
-
-
class
py314.unit.StandardUnit¶ Standard unit from International Unit System.
-
standard¶ alias of
StandardUnit
-
-
class
py314.unit.Quantity(unit, value, adapter=None)¶ Base class for a value of any form.
Parameters: -
print(*, prec=None)¶ Print the current value with a certain precision.
Parameters: prec (int [optional]) – Maximum amount of digits.
-
-
class
py314.unit.Time¶ Namespace for time quantities.
-
class
SECOND¶ -
standard¶ alias of
Time.SECOND
-
-
class
NANOSECOND¶ -
standard¶ alias of
Time.SECOND
-
-
class
MICROSECOND¶ -
standard¶ alias of
Time.SECOND
-
-
class
MILLISECOND¶ -
standard¶ alias of
Time.SECOND
-
-
class
MINUTE¶ -
standard¶ alias of
Time.SECOND
-
-
class
HOUR¶ -
standard¶ alias of
Time.SECOND
-
-
class
DAY¶ -
standard¶ alias of
Time.SECOND
-
-
class
-
class
py314.unit.Temperature¶ Namespace for temperature quantities.
-
class
KELVIN¶ -
standard¶ alias of
Temperature.KELVIN
-
-
class
CELSIUS¶ -
standard¶ alias of
Temperature.KELVIN
-
-
class
-
class
py314.unit.Speed¶ Namespace for speed quantities.
-
class
py314.unit.Distance¶ Namespace for distance quantities.
-
class
METER¶ -
standard¶ alias of
Distance.METER
-
-
class
NANOMETER¶ -
standard¶ alias of
Distance.METER
-
-
class
MICROMETER¶ -
standard¶ alias of
Distance.METER
-
-
class
KILOMETER¶ -
standard¶ alias of
Distance.METER
-
-
class
LIGHTYEAR¶ -
standard¶ alias of
Distance.METER
-
-
class
Vendor¶
This module generates ANSI character codes to printing colors to terminals.
-
class
py314.vendor.pydec.AnsiCodes¶ The subclasses declare class attributes which are numbers.
Upon instantiation we define instance attributes, which are the same as the class attributes but wrapped with the ANSI escape sequence.
-
class
py314.vendor.pydec.AnsiFore¶ ANSI Codes for BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN and WHITE colors, and a RESET code. Extended support contains the light versions of the above colors but this is non-standard.
-
class
py314.vendor.pydec.AnsiStyle¶ ANSI Codes for BRIGHT, DIM, ITSHAPE, UNDERLINED, STRIKED text decorations. A NORMAL and a RESET_ALL decoration is also available.
Google Text-To-Speech API¶
Provide an interface to deal with Google Text-To-Speech API.