コード例 #1
0
ファイル: odf2xliff.py プロジェクト: lukakama/translate
def convertodf(inputfile, outputfile, templates):
    """reads in stdin using fromfileclass, converts using convertorclass,
       writes to stdout
    """
    @contextmanager
    def store_context():
        store = factory.getobject(outputfile)
        try:
            store.setfilename(store.getfilenode('NoName'), inputfile.name)
        except:
            print("couldn't set origin filename")
        yield store
        store.save()

    # Since the convertoptionsparser will give us an open file, we risk that
    # it could have been opened in non-binary mode on Windows, and then we'll
    # have problems, so let's make sure we have what we want.
    inputfile.close()
    inputfile = file(inputfile.name, mode='rb')

    with store_context() as store:
        contents = odf_io.open_odf(inputfile)
        for data in contents.values():
            parse_state = extract.ParseState(odf_shared.no_translate_content_elements,
                                             odf_shared.inline_elements)
            extract.build_store(StringIO(data), store, parse_state)

    return True
コード例 #2
0
ファイル: convert.py プロジェクト: xiaozwu2018/weblate
 def convertfile(storefile):
     store = xlifffile()
     store.setfilename(store.getfilenode("NoName"), "odf")
     contents = open_odf(storefile)
     for data in contents.values():
         parse_state = ParseState(no_translate_content_elements, inline_elements)
         build_store(BytesIO(data), store, parse_state)
     return store
コード例 #3
0
ファイル: odf2xliff.py プロジェクト: anderson916/translate
    def translate_toolkit_implementation(store):
        from translate.storage.xml_extract import extract
        from translate.storage import odf_shared

        contents = odf_io.open_odf(inputfile)
        for data in contents.values():
            parse_state = extract.ParseState(odf_shared.no_translate_content_elements,
                                             odf_shared.inline_elements)
            extract.build_store(StringIO(data), store, parse_state)
コード例 #4
0
ファイル: odf2xliff.py プロジェクト: feiyu2016/kuma
    def translate_toolkit_implementation(store):
        from translate.storage.xml_extract import extract
        from translate.storage import odf_shared

        contents = odf_io.open_odf(inputfile)
        for data in contents.values():
            parse_state = extract.ParseState(odf_shared.no_translate_content_elements,
                                             odf_shared.inline_elements)
            extract.build_store(StringIO(data), store, parse_state)
コード例 #5
0
ファイル: odf2xliff.py プロジェクト: dwaynebailey/translate
def convertodf(inputfile, outputfile, templates):
    """Convert an ODF package to XLIFF."""

    store = factory.getobject(outputfile)

    try:
        store.setfilename(store.getfilenode('NoName'), inputfile.name)
    except Exception:
        print("couldn't set origin filename")

    contents = open_odf(inputfile)
    for data in contents.values():
        parse_state = ParseState(no_translate_content_elements, inline_elements)
        build_store(BytesIO(data), store, parse_state)

    store.save()
    return True
コード例 #6
0
ファイル: odf2xliff.py プロジェクト: wojtek555/translate
def convertodf(inputfile, outputfile, templates):
    """Convert an ODF package to XLIFF."""

    store = factory.getobject(outputfile)

    try:
        store.setfilename(store.getfilenode('NoName'), inputfile.name)
    except Exception:
        print("couldn't set origin filename")

    contents = open_odf(inputfile)
    for data in contents.values():
        parse_state = ParseState(no_translate_content_elements, inline_elements)
        build_store(BytesIO(data), store, parse_state)

    store.save()
    return True
コード例 #7
0
ファイル: odf2xliff.py プロジェクト: PhoneixS/translate
def convertodf(inputfile, outputfile, templates):
    """Convert an ODF package to XLIFF."""
    # Since the convertoptionsparser will give us an open file, we risk that
    # it could have been opened in non-binary mode on Windows, and then we'll
    # have problems, so let's make sure we have what we want.
    inputfile.close()
    inputfile = file(inputfile.name, mode='rb')

    store = factory.getobject(outputfile)

    try:
        store.setfilename(store.getfilenode('NoName'), inputfile.name)
    except:
        print("couldn't set origin filename")

    contents = open_odf(inputfile)
    for data in contents.values():
        parse_state = ParseState(no_translate_content_elements, inline_elements)
        build_store(StringIO(data), store, parse_state)

    store.save()
    return True
コード例 #8
0
def convertodf(inputfile, outputfile, templates):
    """Convert an ODF package to XLIFF."""
    # Since the convertoptionsparser will give us an open file, we risk that
    # it could have been opened in non-binary mode on Windows, and then we'll
    # have problems, so let's make sure we have what we want.
    inputfile.close()
    inputfile = file(inputfile.name, mode='rb')

    store = factory.getobject(outputfile)

    try:
        store.setfilename(store.getfilenode('NoName'), inputfile.name)
    except:
        print("couldn't set origin filename")

    contents = open_odf(inputfile)
    for data in contents.values():
        parse_state = ParseState(no_translate_content_elements, inline_elements)
        build_store(BytesIO(data), store, parse_state)

    store.save()
    return True