2004-09-07 20:05:27

Utility functions used by command-line scripts

Copyright 2004 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Some command-line scripts take an argument that is supposed to be either "-" (denoting standard input) or a URI reference that can be resolved against the URI equivalent of the current working directory. This function processes such an argument, given as a string, and returns an appropriate InputSource object.

Since users tend to expect local OS paths to work as URIs, this function will accept and use an OS path argument if does appear to point to an existing local file, even though this could interfere with catalog-based resolution.

Raises a ValueError if arg is neither a local file nor a valid URI reference nor "-". Raises a UriException if a stream for the InputSource could not be opened (e.g., when the URI refers to a directory or unreadable file).

Extra arguments given to this function are passed to the InputSourceFactory method that creates the InputSource instance. The factory must support the methods fromStream() and fromUri(), as defined in Ft.Xml.InputSource.InputSourceFactory. The factory must also provide a resolver object with a normalize() method that can resolve a URI reference against a base URI, returning a URI.

Some command-line scripts take an argument that is supposed to be either "-" (denoting standard input) or a URI reference that can be resolved against the URI equivalent of the current working directory. This function processes such an argument, given as a string, and returns an appropriate URI.

Since users tend to expect local OS paths to work as URIs, this function will accept and use an OS path argument if does appear to point to an existing local file, even though this could interfere with catalog-based resolution.

Raises a ValueError if arg is neither a local file nor a valid URI reference nor "-".

The resolver object must support a normalize() method that can resolve a URI reference against a base URI, returning a URI.

Split 'text' into multiple lines of no more than 'width' characters each, and return the result as a list of strings.

This function differs from distutils.fancy_getopt.wrap_text() in that the distutils version collapses blank lines; this one doesn't.

See also: Ft.Lib.Wrap()
['ArgumentError', 'GetoptError', 'wrap_text', 'SourceArgToUri', 'SourceArgToInputSource']