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, classes=None, classes_str={'_trados_txt_tm': ('trados', 'TradosTxtTmFile'), '_wftm': ('w..., hiddenclasses=hiddenclasses)
Factory that returns the applicable class for the type of file presented.
source code
 
getobject(storefile, ignore=None, classes=None, classes_str={'_trados_txt_tm': ('trados', 'TradosTxtTmFile'), '_wftm': ('w..., hiddenclasses=hiddenclasses)
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]
  decompressclass = {'bz2': ('bz2', 'BZ2File'), 'gz': ('gzip', '...
  classes_str = {'_trados_txt_tm': ('trados', 'TradosTxtTmFile')...
Dictionary of file extensions and the names of their associated class.
  hiddenclasses = hiddenclasses
  supported = [('Gettext PO file', ['po', 'pot'], ['text/x-gette...
  __package__ = 'translate.storage'

Imports: os


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, classes=None, classes_str={'_trados_txt_tm': ('trados', 'TradosTxtTmFile'), '_wftm': ('w..., hiddenclasses=hiddenclasses)

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, classes=None, classes_str={'_trados_txt_tm': ('trados', 'TradosTxtTmFile'), '_wftm': ('w..., hiddenclasses=hiddenclasses)

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]

decompressclass

Value:
{'bz2': ('bz2', 'BZ2File'), 'gz': ('gzip', 'GzipFile')}

classes_str

Dictionary of file extensions and the names of their associated class.

Used for dynamic lazy loading of modules. _ext is a pseudo extension, that is their is no real extension by that name.

Value:
{'_trados_txt_tm': ('trados', 'TradosTxtTmFile'),
 '_wftm': ('wordfast', 'WordfastTMFile'),
 'catkeys': ('catkeys', 'CatkeysFile'),
 'csv': ('csvl10n', 'csvfile'),
 'gmo': ('mo', 'mofile'),
 'mo': ('mo', 'mofile'),
 'po': ('po', 'pofile'),
 'pot': ('po', 'pofile'),
...

supported

Value:
[('Gettext PO file',
  ['po', 'pot'],
  ['text/x-gettext-catalog',
   'text/x-gettext-translation',
   'text/x-po',
   'text/x-pot']),
 ('XLIFF Translation File',
  ['xlf', 'xliff', 'sdlxliff'],
...