Package translate :: Package convert :: Module factory
[hide private]
[frames] | no frames]

Module factory

source code

Factory methods to convert supported input files to supported translatable files.

Classes [hide private]
  UnknownExtensionError
  UnsupportedConversionError
Functions [hide private]
 
get_extension(filename) source code
 
get_converter(in_ext, out_ext=None, templ_ext=None) source code
 
get_output_extensions(ext)
Compiles a list of possible output extensions for the given input extension.
source code
 
convert(inputfile, template=None, options=None, convert_options=None)
Convert the given input file to an appropriate output format, optionally using the given template file and further options.
source code
Variables [hide private]
  converters = {}

Imports: os, tempfile, prop2po, po2prop, odf2xliff, xliff2odf


Function Details [hide private]

convert(inputfile, template=None, options=None, convert_options=None)

source code 

Convert the given input file to an appropriate output format, optionally using the given template file and further options.

If the output extension (format) cannot be inferred the first converter that can handle the input file (and the format/extension it gives as output) is used.

Parameters:
  • inputfile (file) - The input file to be converted
  • template (file) - Template file to use during conversion
  • options (dict (default: None)) - Valid options are:
    • in_ext: The extension (format) of the input file.
    • out_ext: The extension (format) to use for the output file.
    • templ_ext: The extension (format) of the template file.
    • in_fname: File name of the input file; used only to determine the input file extension (format).
    • templ_fname: File name of the template file; used only to determine the template file extension (format).
Returns:
a 2-tuple: The new output file (in a temporary directory) and the extension (format) of the output file. The caller is responsible for deleting the (temporary) output file.