def get_tests(): """Returns list of tuples: [(odf_path, po_handler), ...] """ # We traverse all ODF documents for odf_uri in vfs.traverse('./documents/'): odf_handler = get_handler(odf_uri) if not isinstance(odf_handler, ODFFile): continue # We found a ODF Document, We search the corresponding PO file po_uri = resolve_uri(odf_uri, 'testDoc.po') yield get_uri_path(odf_uri), get_handler(po_uri)
def itools_implementation(store): from itools.handlers import get_handler from itools.gettext.po import encode_source import itools.odf filename = getattr(inputfile, 'name', 'unkown') handler = get_handler(filename) try: get_units = handler.get_units except AttributeError: raise AttributeError('error: the file "%s" could not be processed' % filename) # Make the XLIFF file for source, context, line in get_units(): source = encode_source(source) unit = store.UnitClass(source) store.addunit(unit)
f = open(filename, 'w') aux = [] for message in messages: if message not in aux: f.write('msgid "%s"\n' % message) f.write('msgstr ""\n') f.write('\n') aux.append(message) f.close() # Parse the rest of the files if filenames2: po = PO() for filename in filenames2: handler = get_handler(filename) for msgid, line_number in handler.get_messages(): po.set_message(msgid, references={filename: [line_number]}) filename = tempfile.mktemp('.po') filenames.append(filename) open(filename, 'w').write(po.to_str()) # Create the POT file if filenames: filename = tempfile.mktemp('.po') cmd = 'msgcat -s --output-file=%s %s' % (filename, ' '.join(filenames)) os.system(cmd) os.system('msgmerge -U locale/locale.pot %s' % filename) # Remove temporal files os.remove(filename)
print print 'Generating test_output/use_case1.odt ...' # Go document = odf_new_document_from_type('text') body = document.get_body() samples = vfs.open('samples') for numero, filename in enumerate(samples.get_names()): # Heading heading = odf_create_heading(2, text=unicode(filename, 'utf-8')) body.append_element(heading) uri = samples.get_uri(filename) handler = get_handler(uri) if isinstance(handler, Image): # Add the image internal_name = 'Pictures/' + filename width, height = handler.get_size() paragraph = odf_create_paragraph('Standard') # 72 ppp frame = odf_create_frame('frame_%d' % numero, 'Graphics', str(width / 72.0) + 'in', str(height / 72.0) + 'in') image = odf_create_image(internal_name) frame.append_element(image) paragraph.append_element(frame) body.append_element(paragraph) # And store the data
def itools_handler(filename): handler = get_handler(filename) units = handler.get_units(srx) return [ encode_source(unit) for unit, context, reference in units ]
# Hello messages print 'lpod installation test' print ' Version : %s' % __version__ print ' Installation path : %s' % __installation_path__ print print 'Generating test_output/use_case2.odt ...' # Go document = odf_new_document_from_type('text') body = document.get_body() # 1- The image # ------------ image_file = get_handler('samples/image.png') width, height = image_file.get_size() paragraph = odf_create_paragraph(style=u"Standard") # 72 ppp frame = odf_create_frame('frame1', 'Graphics', str(width / 72.0) + 'in', str(height / 72.0) + 'in') internal_name = 'Pictures/image.png' image = odf_create_image(internal_name) frame.append_element(image) paragraph.append_element(frame) body.append_element(paragraph) # And store the data container = document.container container.set_part(internal_name, image_file.to_str())
f = open(filename, 'w') aux = [] for message in messages: if message not in aux: f.write('msgid "%s"\n' % message) f.write('msgstr ""\n') f.write('\n') aux.append(message) f.close() # Parse the rest of the files if filenames2: po = POFile() for filename in filenames2: handler = get_handler(filename) for source, context, line in handler.get_units(): po.add_unit(filename, source, context, line) filename = mktemp('.po') filenames.append(filename) open(filename, 'w').write(po.to_str()) # Create the POT file if filenames: filename = mktemp('.po') cmd = 'msgcat -s --output-file=%s %s' % (filename, ' '.join(filenames)) system(cmd) system('msgmerge -U locale/locale.pot %s' % filename) # Remove temporal files remove(filename)