for any info/changes follow me: @nickmilon

Hellas.Pella module

mostly dict list and file related functions and classes named after the ancient city of Pella

exception Hellas.Pella.ErrorFileTooBig[source]

Bases: Hellas.Sparta.Error

Hellas.Pella.file_to_base64(path_or_obj, max_mb=None)[source]

converts contents of a file to base64 encoding

Parameters:
  • path_or_obj (str_or_object) – fool pathname string for a file or a file like object that supports read
  • max_mb (int) – maximum number in MegaBytes to accept
  • lon2 (float) – longitude of second place (decimal degrees)
Raises:
  • ErrorFileTooBig – if file contents > max_mb (see ErrorFileTooBig)
  • IOError – if file path can’t be found (Also possible other exceptions depending on file_object)
Hellas.Pella.dict_copy(a_dict, exclude_keys_lst=[], exclude_values_lst=[])[source]

a SALLOW copy of a dict that excludes items in exclude_keys_lst and exclude_values_lst useful for copying locals() etc..

Parameters:
  • a_dict (dict) – dictionary to be copied
  • exclude_keys_lst (list) – a list or tuple of keys to exclude
  • exclude_values_lst (list) – a list or tuple of values to exclude

Warning

remember it is NOT a deep copy

Hellas.Pella.dict_clip(a_dict, inlude_keys_lst=[])[source]

returns a new dict with keys not in included in inlude_keys_lst clipped off

Hellas.Pella.list_randomize(lst)[source]

returns list in random order

Hellas.Pella.list_pp(ll, separator='|', header_line=True, autonumber=True)[source]

pretty print list of lists ll

Hellas.Pella.signal_terminate(on_terminate)[source]

a common case program termination signal

class Hellas.Pella.Base62[source]

Bases: object

unsigned integer coder class codes to and from base 62, useful for compressing integer values

Warning

any encoded values can only be decoded by this class

Example:
>>> b62 = Base62()
>>> vl = 2 ** 24
16777216
>>> b62.encode(vl)
'18OWG'
>>> b62.decode('18OWG')
16777216
symbols = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
numeric_symbols = '0123456789'
classmethod encode(number)[source]
classmethod decode(number)[source]
Hellas.Pella.random() → x in the interval [0, 1).