Python Module Index
- -- h | ||
- |
- helpers | - |
diff --git a/_docs_/.buildinfo b/_docs_/.buildinfo deleted file mode 100644 index d0987a4..0000000 --- a/_docs_/.buildinfo +++ /dev/null @@ -1,4 +0,0 @@ -# Sphinx build info version 1 -# This file records the configuration used when building these files. When it is not found, a full rebuild will be done. -config: da6d529f641e04786f2df1c033391b0b -tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/_docs_/_downloads/6f90f976fdbe3f1817d2ddd7ac6481ea/unittest.pdf b/_docs_/_downloads/6f90f976fdbe3f1817d2ddd7ac6481ea/unittest.pdf deleted file mode 100644 index e69de29..0000000 diff --git a/_docs_/_sources/index.rst.txt b/_docs_/_sources/helpers.rst.txt similarity index 100% rename from _docs_/_sources/index.rst.txt rename to _docs_/_sources/helpers.rst.txt diff --git a/_docs_/genindex.html b/_docs_/genindex.html index 6259dd6..8b84f46 100644 --- a/_docs_/genindex.html +++ b/_docs_/genindex.html @@ -77,9 +77,6 @@
- |
- | - |
- | - |
- |
|
-
- | - |
- |
|
-
- |
- |
- | - |
- |
- h | ||
- |
- helpers | - |
Author:
-Dirk Alders <sudo-dirk@mount-mockery.de>
Description:
---This module supports functions and classes which don’t have an own Module (yet).
-
Submodules:
-Unittest:
---See also the
-unittest
documentation.
Module Documentation:
-Bases: dict
This class stores a statistic for a stream of values. The statistic includes: mean, min, max, quantifier.
-Note
-You can use the mathematic operators “+, +=” to add a value to the statistic.
-mean (numeric) – The mean start value, the start value or None.
min_val (numeric) – The min start value or None
max_val (numeric) – The max start value or None
quantifier (int) – The quantifier start value or 0
Note
-You are able to initialise this class in the following ways:
-Without arguments to get an empty instance
With one single value to get an starting instance
With mean, min_val, max_val, quantifier to initialise an existing statistic
Example:
-import sys
-sys.path.append('../..')
-
-import helpers
-
-
-cs = helpers.continues_statistic()
-for val in (1, 3, 5, 4):
- cs += helpers.continues_statistic(val)
- print(cs)
-
Will result to the following output:
-mean=1, min=1, max=1, quantifier=1
-mean=2.0, min=1, max=3, quantifier=2
-mean=3.0, min=1, max=5, quantifier=3
-mean=3.25, min=1, max=5, quantifier=4
-
The current max value.
-The current mean value.
-The current min value.
-This pops out the current statistic data and returns these as an instance of helpers.continues_statistic
.
The current statistic or None, if no value is available.
-helpers.continues_statistic
or None
The current quantifier (number of values for continues statistic).
-Bases: dict
This class stores multiple statistics of stream values. The statistic of each value is stored as helpers.continues_statistic
.
Note
-You can use the mathematic operators “+, +=” to add instances.
-Note
-You are able to initialise this class in the following ways:
-Without arguments to get an empty instance
With a keword argument(s) which will be passed to continues_statistic
With a dict equivalent of continues_statistic_multivalue
to initialise an existing statistic
Example:
-import sys
-sys.path.append('../..')
-
-import helpers
-
-
-csm = helpers.continues_statistic_multivalue()
-print(csm, '\n--------------------------------------------------------------')
-csm += helpers.continues_statistic_multivalue(a={'mean': 3.1, 'min_val': 1, 'max_val': 3.5, 'quantifier': 305})
-print(csm, '\n--------------------------------------------------------------')
-csm += helpers.continues_statistic_multivalue(a=4.31, b={'mean': 17.1, 'min_val': 13.1, 'max_val': 19.3, 'quantifier': 27})
-print(csm, '\n--------------------------------------------------------------')
-print(helpers.continues_statistic_multivalue(dict(csm)), '\n--------------------------------------------------------------')
-print('pop out b:', csm.pop('b'), '\n--------------------------------------------------------------')
-print('pop out b:', csm.pop('b'), '\n--------------------------------------------------------------')
-print(csm, '\n--------------------------------------------------------------')
-print('pop out all:\n%s' % csm.pop(), '\n--------------------------------------------------------------')
-print('pop out all:\n%s' % csm.pop(), '\n--------------------------------------------------------------')
-print(csm, '\n--------------------------------------------------------------')
-
Will result to the following output:
--
---------------------------------------------------------------
-a: mean=3.1, min=1, max=3.5, quantifier=305
---------------------------------------------------------------
-b: mean=17.1, min=13.1, max=19.3, quantifier=27
-a: mean=3.103954248366013, min=1, max=4.31, quantifier=306
---------------------------------------------------------------
-b: mean=17.1, min=13.1, max=19.3, quantifier=27
-a: mean=3.103954248366013, min=1, max=4.31, quantifier=306
---------------------------------------------------------------
-pop out b: mean=17.1, min=13.1, max=19.3, quantifier=27
---------------------------------------------------------------
-pop out b: mean=None, min=None, max=None, quantifier=0
---------------------------------------------------------------
-b: mean=None, min=None, max=None, quantifier=0
-a: mean=3.103954248366013, min=1, max=4.31, quantifier=306
---------------------------------------------------------------
-pop out all:
-b: mean=None, min=None, max=None, quantifier=0
-a: mean=3.103954248366013, min=1, max=4.31, quantifier=306
---------------------------------------------------------------
-pop out all:
--
---------------------------------------------------------------
--
---------------------------------------------------------------
-
This pops out the current statistic data for a given key and returns these as an instance of helpers.continues_statistic
.
If no key is given it pops out the current statistic data and returns these as an instance of helpers.continues_statistic_multiple
.
key (str or NoneType) – The key to get data for
-The current statistic or None, if no value is available.
-helpers.continues_statistic
or None
Bases: object
This is the base class for other classes in this module.
-Method to disconnect client and server.
-With this Method, the channel name for logging can be changed.
-channel_name (str) – The name for the logging channel
-With this Method the connection status can be identified.
-True, if a connection is established, otherwise False.
-bool
-This method returns received data.
-timeout (float) – The timeout for receiving data (at least after the timeout the method returns data or None).
num (int or None) – the number of bytes to receive (use None to get all available data).
The received data.
-bytes
-This method stores the callback which is executed, if data is available. You need to execute receive()
of this instance
-given as first argument.
callback – The callback which will be executed, when data is available.
-This method stores the callback which is executed, if a connection is established.
-callback – The callback which will be executed, when a connection is established.
-This method stores the callback which is executed, after the connection is lost.
-callback – The callback which will be executed, after the connection is lost.
-This method sends data via the initiated communication channel.
-data (bytes) – The data to be send over the communication channel.
timeout (float) – The timeout for sending data (e.g. time to establish new connection).
True if data had been sent, otherwise False.
-bool
-Bases: direct_socket_base
Class to create a direct client socket. See also parent helpers.direct_socket_base
.
Example:
-import sys # nopep8
-sys.path.append('../..') # nopep8
-
-import report
-import helpers
-
-
-def mirror_callback(sock):
- sock.send(sock.receive())
-
-
-report.default_logging_config()
-s = helpers.direct_socket_server(virtual_rate_bps=5)
-s.init_channel_name('example_server')
-s.register_callback(mirror_callback)
-c = helpers.direct_socket_client(max_len=2, virtual_rate_bps=5)
-c.init_channel_name('example_client')
-c.connect(s)
-c.send(b'abc')
-print('The Client received: %s' % repr(c.receive()))
-
Will result to the following output:
- DEBUG - helpers.all_others - comm-server: Cleaning up receive-buffer
- INFO - helpers.all_others - comm-server: Waiting for incomming connection
- DEBUG - helpers.all_others - comm-client: Cleaning up receive-buffer
- INFO - helpers.example_client - comm-client: Connection established...
- DEBUG - helpers.example_client - comm-client: Cleaning up receive-buffer
- INFO - helpers.example_server - comm-server: Connection established...
- DEBUG - helpers.example_server - comm-server: Cleaning up receive-buffer
- INFO - helpers.example_client - comm-client: TX -> (2): 61 62
- INFO - helpers.example_server - comm-server: RX <- (2): 61 62
- INFO - helpers.example_client - comm-client: TX -> (1): 63
- INFO - helpers.example_server - comm-server: TX -> (2): 61 62
- INFO - helpers.example_server - comm-server: RX <- (1): 63
- INFO - helpers.example_client - comm-client: RX <- (2): 61 62
- INFO - helpers.example_server - comm-server: TX -> (1): 63
-The Client received: b'ab'
-
Method to create a connection between this client and a helpers.direct_socket_server
instance.
remote_socket (helpers.direct_socket_server
) – The remote socket to connect to.
Bases: direct_socket_base
Class to create a direct server socket. See also parent helpers.direct_socket_base
.
Example:
-import sys # nopep8
-sys.path.append('../..') # nopep8
-
-import report
-import helpers
-
-
-def mirror_callback(sock):
- sock.send(sock.receive())
-
-
-report.default_logging_config()
-s = helpers.direct_socket_server(virtual_rate_bps=5)
-s.init_channel_name('example_server')
-s.register_callback(mirror_callback)
-c = helpers.direct_socket_client(max_len=2, virtual_rate_bps=5)
-c.init_channel_name('example_client')
-c.connect(s)
-c.send(b'abc')
-print('The Client received: %s' % repr(c.receive()))
-
Will result to the following output:
- DEBUG - helpers.all_others - comm-server: Cleaning up receive-buffer
- INFO - helpers.all_others - comm-server: Waiting for incomming connection
- DEBUG - helpers.all_others - comm-client: Cleaning up receive-buffer
- INFO - helpers.example_client - comm-client: Connection established...
- DEBUG - helpers.example_client - comm-client: Cleaning up receive-buffer
- INFO - helpers.example_server - comm-server: Connection established...
- DEBUG - helpers.example_server - comm-server: Cleaning up receive-buffer
- INFO - helpers.example_client - comm-client: TX -> (2): 61 62
- INFO - helpers.example_server - comm-server: RX <- (2): 61 62
- INFO - helpers.example_client - comm-client: TX -> (1): 63
- INFO - helpers.example_server - comm-server: TX -> (2): 61 62
- INFO - helpers.example_server - comm-server: RX <- (1): 63
- INFO - helpers.example_client - comm-client: RX <- (2): 61 62
- INFO - helpers.example_server - comm-server: TX -> (1): 63
-The Client received: b'ab'
-
Bases: direct_socket_base
This method returns one received messages via the initiated communication channel.
-timeout (float) – The timeout for receiving data (at least after the timeout the method returns data or None).
-The received data.
-bytes
-Bases: direct_socket_stp_base
Method to create a connection between this client and a helpers.direct_socket_server
instance.
remote_socket (helpers.direct_socket_server
) – The remote socket to connect to.
Bases: direct_socket_stp_base
Bases: list
Class for a list with a limited number of elements.
-Note
-On adding Objects, the list will be reduced to the maximum length by deleting entries starting from index 0.
-Example:
-import sys
-sys.path.append('../..')
-
-import helpers
-
-
-rb = helpers.ringbuffer(length=5)
-print(rb, '\n--------------------------------------------------------------')
-rb.append(0)
-print(rb, '\n--------------------------------------------------------------')
-rb.extend((1,2,3,4,5,6))
-print(rb, '\n--------------------------------------------------------------')
-rb.append(17)
-print(rb, '\n--------------------------------------------------------------')
-
Will result to the following output:
-[]
---------------------------------------------------------------
-[0]
---------------------------------------------------------------
-[2, 3, 4, 5, 6]
---------------------------------------------------------------
-[3, 4, 5, 6, 17]
---------------------------------------------------------------
-
Append object to the end of the list.
-Extend list by appending elements from the iterable.
-continues_statistic
-continues_statistic_multivalue
-direct_socket_base
direct_socket_base.DEFAULT_CHANNEL_NAME
direct_socket_base.IS_CLIENT
direct_socket_base.disconnect()
direct_socket_base.init_channel_name()
direct_socket_base.is_connected()
direct_socket_base.receive()
direct_socket_base.register_callback()
direct_socket_base.register_connect_callback()
direct_socket_base.register_disconnect_callback()
direct_socket_base.send()
direct_socket_client
-direct_socket_server
-direct_socket_stp_base
-direct_socket_stp_client
-direct_socket_stp_server
-ringbuffer
-