sugar4.util
Various utility functions
Attributes
Classes
Implementation of a length-limited O(1) LRU queue. |
|
str(object='') -> str |
Functions
|
Convert binary hash data into printable characters. |
|
sha1 hash some bytes. |
|
Generate a likely-unique ID for whatever purpose |
|
|
|
Validate an activity ID. |
|
Sets the process title so ps and top show more |
|
|
|
|
|
Module Contents
- sugar4.util.unique_id(data='')[source]
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.
- sugar4.util.set_proc_title(title)[source]
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
- class sugar4.util.LRU(count, pairs=[])[source]
Implementation of a length-limited O(1) LRU queue. Built for and used by PyPE: http://pype.sourceforge.net Copyright 2003 Josiah Carlson.
- class sugar4.util.TempFilePath[source]
Bases:
strstr(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
Initialize self. See help(type(self)) for accurate signature.