#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2006 Zuza Software Foundation # # This file is part of translate. # # translate is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # translate is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with translate; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """factory methods to build real storage objects that conform to base.py""" from translate.storage import base from translate.storage import po from translate.storage import csvl10n from translate.storage import xliff from translate.storage import poxliff from translate.storage import tmx from translate.storage import tbx import os from gzip import GzipFile from bz2 import BZ2File #TODO: Monolingual formats (with template?) classes = {"po": po.pofile, "pot": po.pofile, "csv": csvl10n.csvfile, "xliff": xliff.xlifffile, "xlf": xliff.xlifffile, "tmx": tmx.tmxfile, "tbx": tbx.tbxfile} decompressclass = { 'gz': GzipFile, 'bz2': BZ2File, } def guessextention(storefile): """Guesses the type of a file object by looking at the first few characters. The return value is a file extention .""" start = storefile.read(200).strip() if '