Package translate :: Package storage :: Module factory

[hide private]
[frames] | no frames]

# Module factory

source code

factory methods to build real storage objects that conform to base.py

Functions | [hide private]

_examine_txt(storefile) Determine the true filetype for a .txt file | source code

_guessextention(storefile) Guesses the type of a file object by looking at the first few characters. | source code

_getdummyname(storefile) Provides a dummy name for a file object without a name attribute, by guessing the file type. | source code

_getname(storefile) returns the filename | source code

getclass(storefile, ignore=None) Factory that returns the applicable class for the type of file presented. | source code

getobject(storefile, ignore=None) Factory that returns a usable object for the type of file presented. | source code

list

supported_files() Returns data about all supported files | source code

Variables | [hide private]

| support_xml = `True`
| classes = ``{``'``_wftm``'``:` <class 'translate.storage.wordfast.Wordfas`...`` Dictionary of file extensions and their associated class.
| decompressclass = ``{``'``bz2``'``:` <type 'bz2.BZ2File'>`,` `'``gz``'``:` <class g`...``
| hiddenclasses = `{"txt": _examine_txt}`

Function Details | [hide private]

### _guessextention(storefile)

source code

Guesses the type of a file object by looking at the first few characters. The return value is a file extention .

### getclass(storefile, ignore=None)

source code

Factory that returns the applicable class for the type of file presented. Specify ignore to ignore some part at the back of the name (like .gz).

### getobject(storefile, ignore=None)

source code

Factory that returns a usable object for the type of file presented.

Parameters:
  - `storefile` (file or str) - File object or file name.

    Specify ignore to ignore some part at the back of the name (like .gz).

### supported_files()

source code

Returns data about all supported files

Returns: list
  list of type that include (name, extensions, mimetypes)

Variables Details | [hide private]

### classes

Dictionary of file extensions and their associated class.

_ext is a pseudo extension, that is their is no real extension by that name.

Value:

      {'_wftm': <class 'translate.storage.wordfast.WordfastTMFile'>,
       'csv': <class 'translate.storage.csvl10n.csvfile'>,
       'gmo': <class 'translate.storage.mo.mofile'>,
       'mo': <class 'translate.storage.mo.mofile'>,
       'po': <class 'translate.storage.pypo.pofile'>,
       'pot': <class 'translate.storage.pypo.pofile'>,
       'qm': <class 'translate.storage.qm.qmfile'>,
       'qph': <class 'translate.storage.qph.QphFile'>,
      ...

### decompressclass

Value:

      {'bz2': <type 'bz2.BZ2File'>,
       'gz': <class gzip.GzipFile at 0x85a698c>}