Module escaping
source code
Functions for escaping and unescaping strings (for URLs, filenames,
etc).
The underscore escaping functions are useful when generating directory
names which should be reasonably human-readable, and not contain
characters which are likely to confuse programs (e.g. ":"
doesn't work on Windows, "#" confuses cmake, "="
confuses Java, [:;,] confuse anything that uses these as list item
separators, etc.
See also zeroinstall.injector.model.escape for an older escaping
scheme.
Escape troublesome characters in 'src'. The result is a valid file
leaf name (i.e. does not contain / etc). Letters, digits and characters
> 127 are copied unmodified. '/' becomes '__'. Other characters become
'_code_', where code is the lowercase hex value of the character in
Unicode.
- Parameters:
src (str) - the string to escape
- Returns: str
- the escaped string
|