Package itools :: Package handlers

Package handlers

This package provides an abstraction layer for files and directories. There are two key concepts, resources and handlers.

A resource is anything that behaves like a file (it contains an array of bytes), as a directory (it contains other resources) or as a link (it contains a path or an uri to another resource). Doesn't matters wether a resource lives in the local file system, in a database or is a remote object accessed with an URI.

A resource handler adds specific semantics to different resources, for example there is a handler to manage XML files, another to manage PO files, etc...

Classes
  BaseDatabase
  Bzip2File
  ConfigFile
The data structure of this handler is:
  File
This is the base handler class for any file handler.
  Folder
This is the base handler class for any folder handler.
  GitDatabase
  GzipFile
  Handler
This class represents a resource handler; where a resource can be a file or a directory, and is identified by a unique key.
  Image
  RODatabase
The read-only database works as a cache for file handlers.
  ROGitDatabase
  RWDatabase
  TARFile
  TBZ2File
  TGZFile
  TextFile
  ZIPFile
Functions
 
checkid(id)
Turn a bytestring or unicode into an identifier only composed of alphanumerical characters and a limited list of signs.
 
get_handler_class_by_mimetype(mimetype)
 
guess_encoding(data)
Tries to guess the encoding by brute force.
 
make_git_database(path, size_min, size_max)
Create a new empty Git database if the given path does not exists or is a folder.
 
register_handler_class(handler_class)
Variables
  ro_database = <itools.handlers.database.RODatabase object at 0...
Function Details

checkid(id)

 

Turn a bytestring or unicode into an identifier only composed of alphanumerical characters and a limited list of signs.

It only supports Latin-based alphabets.

guess_encoding(data)

 
Tries to guess the encoding by brute force. It is likely to get the wrong encoding, for example many utf8 files will be identified as latin1.

make_git_database(path, size_min, size_max)

 

Create a new empty Git database if the given path does not exists or is a folder.

If the given path is a folder with content, the Git archive will be initialized and the content of the folder will be added to it in a first commit.


Variables Details

ro_database

Value:
<itools.handlers.database.RODatabase object at 0xeace90>