Ejemplo n.º 1
0
def convert(input_file, output_file, options=[]):

    init_uniconv()

    from app.io import load
    from uniconvertor import filters
    import app

    app.init_lib()

    filters.load_plugin_configuration()

    if len(options) and options[0] == '-parse':
        load.parse_drawing(input_file, output_file)
    else:
        doc = load.load_drawing(input_file)
        extension = os.path.splitext(output_file)[1].lower()
        fileformat = filters.guess_export_plugin(extension)
        if fileformat:
            saver = filters.find_export_plugin(fileformat)
            saver(doc, output_file)
        else:
            sys.stderr.write('ERROR: unrecognized extension %s\n' % extension)
            sys.exit(1)
        doc.Destroy()
Ejemplo n.º 2
0
def convert(input_file, output_file, options=[]):

	init_uniconv()

	from app.io import load
	from uniconvertor import filters
	import app

	app.init_lib()

	filters.load_plugin_configuration()

	if len(options) and options[0] == '-parse':
		load.parse_drawing(input_file, output_file)
	else:
		doc = load.load_drawing(input_file)
		extension = os.path.splitext(output_file)[1].lower()
		fileformat = filters.guess_export_plugin(extension)
		if fileformat:
			saver = filters.find_export_plugin(fileformat)
			saver(doc, output_file)
		else:
			sys.stderr.write('ERROR: unrecognized extension %s\n' % extension)
			sys.exit(1)
		doc.Destroy()
def uniconv_run():	
	_pkgdir = __path__[0]
	app_dir = os.path.join(_pkgdir, 'app')
	app_ver = string.strip(open(os.path.join(app_dir, 'VERSION')).read())

	if len(sys.argv)<3 or sys.argv[1]=='--help':
		print '\nUniConvertor',app_ver
		print __doc__
		sys.exit(0)
		
	options=[]
	input_file=sys.argv[-2]
	output_file=sys.argv[-1]
	
	if len(sys.argv)>3:
		options=sys.argv[1:-2]
		
	if not os.path.isfile(input_file):
		print '\nERROR: %s file is not found!' % input_file
		print '\nUniConvertor',app_ver
		print __doc__
		sys.exit(1)
	
	sys.path.insert(1, _pkgdir)
	
	from app.io import load
	from sk1libs import filters
	import app
	
	app.init_lib()
	
	filters.load_plugin_configuration()
	
	if len(options) and options[0]=='-parse':
		load.parse_drawing(input_file, output_file)
		sys.exit(0)
	else:
		doc = load.load_drawing(input_file)
		extension = os.path.splitext(output_file)[1]
		fileformat = filters.guess_export_plugin(extension)
		if fileformat:
			saver = filters.find_export_plugin(fileformat)
			saver(doc, output_file)
		else:
			sys.stderr.write('ERROR: unrecognized extension %s\n' % extension)
			sys.exit(1)
		doc.Destroy()
	
	sys.exit(0)
def uniconv_run():
    _pkgdir = __path__[0]
    app_dir = os.path.join(_pkgdir, 'app')
    app_ver = string.strip(open(os.path.join(app_dir, 'VERSION')).read())

    if len(sys.argv) < 3 or sys.argv[1] == '--help':
        print '\nUniConvertor', app_ver
        print __doc__
        sys.exit(0)

    options = []
    input_file = sys.argv[-2]
    output_file = sys.argv[-1]

    if len(sys.argv) > 3:
        options = sys.argv[1:-2]

    if not os.path.isfile(input_file):
        print '\nERROR: %s file is not found!' % input_file
        print '\nUniConvertor', app_ver
        print __doc__
        sys.exit(1)

    sys.path.insert(1, _pkgdir)

    from app.io import load
    from sk1libs import filters
    import app

    app.init_lib()

    filters.load_plugin_configuration()

    if len(options) and options[0] == '-parse':
        load.parse_drawing(input_file, output_file)
        sys.exit(0)
    else:
        doc = load.load_drawing(input_file)
        extension = os.path.splitext(output_file)[1]
        fileformat = filters.guess_export_plugin(extension)
        if fileformat:
            saver = filters.find_export_plugin(fileformat)
            saver(doc, output_file)
        else:
            sys.stderr.write('ERROR: unrecognized extension %s\n' % extension)
            sys.exit(1)
        doc.Destroy()

    sys.exit(0)
Ejemplo n.º 5
0
 def _load_uniconvertor(self):
     for p in sys.path:
         d = os.path.join(p, 'uniconvertor')
         if os.path.isdir(d):
             sys.path.append(d)
             from app.io import load
             from app.plugins import plugins
             import app
             from uniconvsaver import save
             app.init_lib()
             plugins.load_plugin_configuration()
             break
     else:
         raise ImportError
     return load, plugins, save
Ejemplo n.º 6
0
 def _load_uniconvertor(self):
     for p in sys.path:
         d = os.path.join(p, 'uniconvertor')
         if os.path.isdir(d):
             sys.path.append(d)
             from app.io import load
             from app.plugins import plugins
             import app
             from uniconvsaver import save
             app.init_lib()
             plugins.load_plugin_configuration()
             break
     else:
         raise ImportError
     return load, plugins, save
Ejemplo n.º 7
0
	def callback(self):
		self.init_convertor()
		self.send_msgs("Start", "UniConvertor is initialized",0.02)
		
		from app.io import load
		from sk1libs import filters
		import app, time
		
		app.receiver=self.progress_dlg.msg_receiver

		app.init_lib()
		
		self.send_msgs("Start", "Loading plugin configuration",0.03)
		time.sleep(0.3)
		filters.load_plugin_configuration()
		
		input_file=self.file
		output_file=self.file+'.'+self.options[self.combo.get_active()][1]
		
		doc=None
		
		try:
			self.send_msgs("Start", "Parsing document file",0.05)
			doc = load.load_drawing(input_file)
			extension = os.path.splitext(output_file)[1]
			
			self.send_msgs("", "Parsing is completed",1.0)
			
			fileformat = filters.guess_export_plugin(extension)
			
			self.send_msgs("", "Saving translated file",0.5)
			if fileformat:
				
				saver = filters.find_export_plugin(fileformat)
				saver(doc, output_file)
				self.send_msgs("", "Translated file is saved",1.0)
			else:
				self.msg_dialog('\nERROR: unrecognized extension %s\n' % extension, gtk.MESSAGE_WARNING)
		except Exception, value:
			self.msg_dialog("\nAn error occurred: " + str(value), gtk.MESSAGE_WARNING)
Ejemplo n.º 8
0
from reportlab.platypus import Flowable, Paragraph
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT

from log import log

try:
    for p in sys.path:
        d = os.path.join(p, 'uniconvertor')
        if os.path.isdir(d):
            sys.path.append(d)
            from app.io import load
            from app.plugins import plugins
            import app
            from uniconvsaver import save
            app.init_lib()
            plugins.load_plugin_configuration()
            break
    else:
        raise ImportError
except ImportError:
    load = None

try:
    from svglib import svglib
except ImportError:
    svglib = None


class SVGImage(Flowable):
    def __init__(self, filename, width=None, height=None, kind='direct'):
Ejemplo n.º 9
0
class DummyOut:
   def write( m):
      pass
 
sortida=sys.stdout
xungo=sys.exit
try:
    sys.stdout=DummyOut()
    sys.exit=lambda x:1 
    import uniconvertor
    sys.path.insert(1, os.path.dirname( uniconvertor.__file__))
    from app.io import load
    from app.plugins import plugins
    import app

    app.init_lib()
    plugins.load_plugin_configuration()
    HAS_UNICONVERTOR=True

## workaround for a bug that stops bgtrml2pdf from working with svg
## files winth font properties in style attributes, even if they apply
## to no text because all text is empty or transformed to paths
## see http://svn.berlios.de/viewcvs/bulmages/branches/docsMonolitic/bulmages/installbulmages/openreports/ca/

    class FakeFont(app.Graphics.font.Font):
      def __init__(self, name):
        self.name = name
        self.family = name
        self.font_attrs = 'Regular Italic'
        self.xlfd_start = '-adobe-Nimbus Roman No9 L-regular-i-normal'
        self.encoding_name = 'iso8859-1'