4Suite API Documentation: Ft.Lib

4Suite™ API Documentation

# ► Module Ft.Lib

Module providing common utilities for many 4Suite components, as well as for general use.

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

Classes: UriException |  |  |  | Functions: CloseStream, Truncate, Wrap

## Modules

CommandLine | Things to set up before importing other Ft.Lib.CommandLine modules
DbUtil | Utilities for database connections
DistExt | Extensions to distutils to support building, installing, packaging 4Suite
EscapeQuotesc |
Gettext | Internationalization and localization support.
ImportUtil | Utilites for working with Python PEP 302 import hooks.
Iri | Classes and functions related to IRI processing
MessageSource | Messages for Ft.Lib
ObjectPrint | Pretty-printing of objects
ProgressIndicator | Progress indicator
Random | Thread-safe random number generation
Regex | Tools to manage the many different flavors of regex
Resolvers | Specialized and useful URI resolvers
Set | Operations on ordered sets
Terminal | Provides some of the information from the terminfo database.
Terminfo | Provides some of the information from the terminfo database.
TestSuite | Package for testing utilities
Time | Date and time related functionality for use within 4Suite only.
Uri | Classes and functions related to URI validation and resolution
Uuid | Functions for generating and comparing Universal Unique Identifiers (UUIDs), based on ideas from e2fsprogs.
boolean |
number |

## Classes

class UriException(Ft.FtException)
  Exceptions used by the Uri module, and possibly others.

  ### Methods

  __init__(self, errorCode, *args, **kwargs)
    Overrides: __init__ from class FtException

  ### Methods inherited from class Ft.FtException

  __getattr__, __repr__, __str__

  ### Methods inherited from class Exception

  __getitem__

  ### Members

  IDNA_UNSUPPORTED = 202
  INVALID_BASE_URI = 100
  INVALID_PUBLIC_ID_URN = 300
  NON_FILE_URI = 120
  OPAQUE_BASE_URI = 112
  RELATIVE_BASE_URI = 111
  RESOURCE_ERROR = 130
  SCHEME_REQUIRED = 200
  UNIX_REMOTE_HOST_FILE_URI = 121
  UNSUPPORTED_PLATFORM = 1000
  UNSUPPORTED_SCHEME = 201

## Functions

CloseStream(stream, quiet=False)
  Closes a stream, ignoring errors if quiet=True. If the stream is a terminal (e.g. sys.stdin, stdout, stderr), does not attempt to close the stream.

      Closing terminal streams could interfere with subsequent read or
      write attempts. For example, after calling sys.stdout.close(),
      subsequent writes to stdout will not raise an exception, but may
      also fail to actually write anything to stdout.

      The stream argument can be any Python file-like object with a
      close() method, such as a regular file object or an instance of
      Ft.Xml.InputSource.InputSource (or subclass thereof).

Truncate(text, length)
  Returns text truncated to length, with "..." appended if truncation was necessary.
Wrap(text, width)
  A word-wrap function that preserves existing line breaks and most spaces in the text. Expects that existing line breaks are posix newlines (\n).

      See also: Ft.Lib.CommandLine.CommandLineUtil.wrap_text()