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

Package support

source code

Useful support routines (for internal use).

These functions aren't really Zero Install specific; they're things we might wish were in the standard library.


Since: 0.27

Submodules

Classes
  unicode
str(object) -> string
  basestring
str(object) -> string
Functions
str
find_in_path(prog)
Search $PATH for prog.
source code
bytes
read_bytes(fd, nbytes, null_ok=False)
Read exactly nbytes from fd.
source code
str
pretty_size(size)
Format a size for printing.
source code
 
ro_rmtree(root)
Like shutil.rmtree, except that we also delete read-only items.
source code
 
raise_with_traceback(ex, tb)
Raise an exception in a way that works on Python 2 and Python 3
source code
 
portable_rename(src, dst)
Rename 'src' to 'dst', which must be on the same filesystem.
source code
str
windows_args_escape(args)
Combines multiple strings into one for use as a Windows command-line argument.
source code
value
raw_input(prompt=...)
Equivalent to eval(raw_input(prompt)).
ParseResult
urlparse(url) source code
Variables
  intern = sys.intern
Function Details

find_in_path(prog)

source code 

Search $PATH for prog. If prog is an absolute path, return it unmodified.

Parameters:
  • prog (str) - name of executable to find
Returns: str
the full path of prog, or None if not found

Since: 0.27

read_bytes(fd, nbytes, null_ok=False)

source code 

Read exactly nbytes from fd.

Parameters:
  • fd (int) - file descriptor to read from
  • nbytes (int) - number of bytes to read
  • null_ok (bool) - if True, it's OK to receive EOF immediately (we then return None)
Returns: bytes
the bytes read
Raises:
  • Exception - if we received less than nbytes of data

pretty_size(size)

source code 

Format a size for printing.

Parameters:
  • size (int (or None)) - the size in bytes
Returns: str
the formatted size

Since: 0.27

ro_rmtree(root)

source code 

Like shutil.rmtree, except that we also delete read-only items.

Parameters:
  • root (str) - the root of the subtree to remove

Since: 0.28

raise_with_traceback(ex, tb)

source code 

Raise an exception in a way that works on Python 2 and Python 3

Parameters:
  • ex (BaseException)

portable_rename(src, dst)

source code 

Rename 'src' to 'dst', which must be on the same filesystem. On POSIX systems, this operation is atomic. On Windows, do the best we can by deleting dst and then renaming.

Parameters:
  • src (str)
  • dst (str)

Since: 1.9

windows_args_escape(args)

source code 

Combines multiple strings into one for use as a Windows command-line argument. This coressponds to Windows' handling of command-line arguments as specified in: http://msdn.microsoft.com/library/17w5ykft.

Parameters:
  • args ([str])
Returns: str

Since: 1.11

urlparse(url)

source code 
Parameters:
  • url (str)
Returns: ParseResult