sugar3.util module¶
Various utility functions
- class sugar3.util.LRU(count, pairs=[])¶
Bases:
object
Implementation of a length-limited O(1) LRU queue. Built for and used by PyPE: http://pype.sourceforge.net Copyright 2003 Josiah Carlson.
- iteritems()¶
- iterkeys()¶
- itervalues()¶
- keys()¶
- class sugar3.util.TempFilePath(path=None)¶
Bases:
str
- sugar3.util.format_size(size)¶
- sugar3.util.is_hex(s)¶
- sugar3.util.printable_hash(in_hash)¶
Convert binary hash data into printable characters.
- sugar3.util.set_proc_title(title)¶
Sets the process title so ps and top show more descriptive names. This does not modify argv[0] and only the first 15 characters will be shown.
- title – the title you wish to change the process
title to
Returns True on success. We don’t raise exceptions because if something goes wrong here it is not a big deal as this is intended as a nice thing to have for debugging
- sugar3.util.sha_data(data)¶
sha1 hash some bytes.
- sugar3.util.timestamp_to_elapsed_string(timestamp, max_levels=2)¶
- sugar3.util.unique_id(data='')¶
Generate a likely-unique ID for whatever purpose
data – suffix appended to working data before hashing
Returns a 40-character string with hexidecimal digits representing an SHA hash of the time, a random digit within a constrained range and the data passed.
- Note: these are not crypotographically secure or
globally unique identifiers. While they are likely to be unique-enough, no attempt is made to make perfectly unique values.
- sugar3.util.validate_activity_id(actid)¶
Validate an activity ID.