assnake package

Submodules

assnake.utils module

assnake.utils.bytes2human(n, format='%(value).1f %(symbol)s', symbols='customary')

Convert n bytes into a human readable string based on format. symbols can be either “customary”, “customary_ext”, “iec” or “iec_ext”, see: http://goo.gl/kTQMs

>>> bytes2human(0)
'0.0 B'
>>> bytes2human(0.9)
'0.0 B'
>>> bytes2human(1)
'1.0 B'
>>> bytes2human(1.9)
'1.0 B'
>>> bytes2human(1024)
'1.0 K'
>>> bytes2human(1048576)
'1.0 M'
>>> bytes2human(1099511627776127398123789121)
'909.5 Y'
>>> bytes2human(9856, symbols="customary")
'9.6 K'
>>> bytes2human(9856, symbols="customary_ext")
'9.6 kilo'
>>> bytes2human(9856, symbols="iec")
'9.6 Ki'
>>> bytes2human(9856, symbols="iec_ext")
'9.6 kibi'
>>> bytes2human(10000, "%(value).1f %(symbol)s/sec")
'9.8 K/sec'
>>> # precision can be adjusted by playing with %f operator
>>> bytes2human(10000, format="%(value).5f %(symbol)s")
'9.76562 K'
assnake.utils.check_if_assnake_is_initialized()
assnake.utils.dict_norm_print(d, indent=1)
assnake.utils.download_from_url(url, dst)

@param: url to download file @param: dst place to put the file

assnake.utils.get_config_loc()
assnake.utils.get_internal_config()
assnake.utils.get_url_remote_file_size(url)
assnake.utils.graph_of_calls(image2safe)
assnake.utils.human2bytes(s)

Attempts to guess the string format based on default symbols set and return the corresponding bytes as an integer. When unable to recognize the format ValueError is raised.

>>> human2bytes('0 B')
0
>>> human2bytes('1 K')
1024
>>> human2bytes('1 M')
1048576
>>> human2bytes('1 Gi')
1073741824
>>> human2bytes('1 tera')
1099511627776
>>> human2bytes('0.5kilo')
512
>>> human2bytes('0.1  byte')
0
>>> human2bytes('1 k')  # k is an alias for K
1024
>>> human2bytes('12 foo')
Traceback (most recent call last):
    ...
ValueError: can't interpret '12 foo'
assnake.utils.load_config_file()
assnake.utils.load_wc_config()
assnake.utils.pathizer(path)

Make from path absolute path :param path: absolute or relative path :return: absolute path

assnake.utils.read_yaml(file_location)
assnake.utils.update_config(dict_to_add)

Module contents