Trees | Indices | Help |
|
---|
|
Utility functions for manipulating or working with text.
|
|||
ShellWriter Helper class to write scripts with indentation. |
|||
LineSplitter Splits data chunks into lines separated by newline. |
|
|||
None or str |
|
||
|
|||
string |
|
||
str |
|
||
|
|||
str |
|
||
str |
|
||
str |
|
||
str |
|
||
str |
|
||
string |
|
||
|
|||
|
|||
string |
|
||
boolean |
|
||
str |
|
||
string |
|
|
|||
_PARSEUNIT_REGEX = re.compile(r"^([.\d]+)\s*([a-zA-Z]+)?$") Unit checker regexp |
|||
_SHELL_UNQUOTED_RE = re.compile("^[-.,=:/_+@A-Za-z0-9]+$") Characters which don't need to be quoted for shell commands |
|||
_MAC_CHECK_RE = re.compile("^([0-9a-f]{2}:){5}[0-9a-f]{2}$", r MAC checker regexp |
|||
_SHELLPARAM_REGEX = re.compile(r"^[-a-zA-Z0-9._+/:%@]+$") Shell param checker regexp |
Imports: re, os, time, collections, errors
|
Try to match a name against a list. This function will try to match a name like test1 against a list like
|
Helper function for DnsNameGlobPattern. Returns regular expression pattern for parts of the pattern. |
Generates regular expression from DNS name globbing pattern. A DNS name globbing pattern (e.g. Matching always starts at the leftmost part. An asterisk (*) matches all characters except the dot (.) separating DNS name parts. A question mark (?) matches a single character except the dot (.).
|
Formats an incoming number of MiB with the appropriate unit.
|
Tries to extract number and scale from the given string. Input must be in the format |
Quotes shell argument according to POSIX.
|
Quotes a list of shell arguments.
|
Generates a random secret. This will generate a pseudo-random secret returning an hex string (so that it can be used where an ASCII string is needed).
|
Normalizes and check if a MAC address is valid. Checks whether the supplied MAC address is formally correct, only accepts colon separated format. Normalize it to all lower.
|
Return a 'safe' version of a source string. This function mangles the input string and returns a version that should be safe to display/encode as ASCII. To this end, we first convert it to ASCII using the 'backslashreplace' encoding which should get rid of any non-ASCII chars, and then we process it through a loop copied from the string repr sources in the python; we don't use string_escape anymore since that escape single quotes and backslashes too, and that is too much; and that escaping is not stable, i.e. string_escape(string_escape(x)) != string_escape(x).
|
Split and unescape a string based on a given separator. This function splits a string based on a separator where the separator itself can be escape in order to be an element of the elements. The escaping rules are (assuming coma being the separator):
|
Nicely join a set of identifiers.
|
Formats a time value.
|
Formats seconds for easier reading.
|
Verifies is the given word is safe from the shell's p.o.v. This means that we can pass this to a command via the shell and be sure that it doesn't alter the command line and is passed as such to the actual command. Note that we are overly restrictive here, in order to be on the safe side.
|
Build a safe shell command line from the given arguments. This function will check all arguments in the args list so that they are valid shell parameters (i.e. they don't contain shell metacharacters). If everything is ok, it will return the result of template % args.
|
Formats a number as an ordinal in the English language. E.g. the number 1 becomes "1st", 22 becomes "22nd".
|
|
_MAC_CHECK_REMAC checker regexp
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Jul 24 16:51:20 2012 | http://epydoc.sourceforge.net |