Package zeroinstall :: Package support :: Module escaping
[frames] | no frames]

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.


Since: 1.13

Functions
str
underscore_escape(src)
Escape troublesome characters in 'src'.
source code
str
ununderscore_escape(escaped) source code
Function Details

underscore_escape(src)

source code 

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

ununderscore_escape(escaped)

source code 
Parameters:
  • escaped (str)
Returns: str