Exemplo n.º 1
0
					#add  AUTO_INCREMENT 
					if (a[3] == 1 and re.match('.*int.*',a[1],re.I)) :
						tables[table] += ' AUTO_INCREMENT'
					#Commens
					if (len(a[2])>1) :
						tables[table] +=  ' COMMENT "%s"' % (a[2])

					tables[table] += '\n'
			elif o.type.name == 'Database - Reference':
				continue
				'''src = o.properties['start_point_desc'].value.split('.')
				desc = o.properties['end_point_desc'].value.split('.')
				if len(src) != 2 and len(desc) != 2:
					continue
				if not tables.has_key(desc[0]):
					tables[desc[0]] = ''
				tables[desc[0]] += '%0.3d\tFOREIGN KEY (%s) REFERENCES %s(%s)\n' % (priority['foreign_keys'],desc[1],src[0],src[1])'''
		for k in tables.keys():
			self.f.write('\n-- %s --\nDROP TABLE IF EXISTS `%s`;\n' % (k,k) )
			self.f.write ('CREATE TABLE IF NOT EXISTS `%s` (\n' % k)
			sentences = sorted( tables[k].split('\n') )
			sentences = [str(s[3:]) for s in sentences if len(s)>4]
			sentences = ",\n".join( sentences)
			self.f.write ('%s\n' % sentences)
			self.f.write (') ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\n')
	def end_render (self) :
		self.f.write ('-- End SQL-Dump\n')
		self.f.close()
# reference
dia.register_export ("SICASQL generado de esquema en SQL", "sql", SQLRenderer())
Exemplo n.º 2
0
		if join == 0 : # MITER
			pass # st = st + ' stroke-linejoin="bevel"'
		elif join == 1 : # ROUND
			st = st + ' stroke-linejoin="round"'
		elif join == 2 : # BEVEL
			st = st + ' stroke-linejoin="bevel"'

		if caps == 0 : # BUTT
			pass # default stroke-linecap="butt"
		elif caps == 1 : # ROUND
			st = st + ' stroke-linecap="round"'
		elif caps == 2 : # PROJECTING
			st = st + ' stroke-linecap="square"' # is this the same ?

		return st

class SvgzRenderer(SvgRenderer) :
	def _open(self, filename) :
		# There is some (here) not wanted behaviour in gzip.open/GzipFile :
		# the filename with path is not only used to adress the file but also
		# completely stored in the file itself. Correct it here.
		import os, os.path, gzip
		path, name = os.path.split(filename)
		os.chdir(path)
		self.f = gzip.open (name, "wb")

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("SVG plain", "svg", SvgRenderer())
dia.register_export ("SVG compressed", "svgz", SvgzRenderer())
Exemplo n.º 3
0
			if o.type.name == 'Database - Table' :
				if o.properties.has_key ("name") :
					table = o.properties["name"].value
					self.f.write('\n\n#Section %s\n#%s' % (table,"="*79) )
				else :
					continue
				if len(table) == 0 or string.find (table, " ") >= 0 :
					continue
				if not tables.has_key(table):
					tables[table] = ''
				atributes = o.properties['attributes'].value
				
				for i in range(0,len(atributes)):
					a = atributes[i]
					if len(a[0])<1:
						continue
					#convirtiendo los campos de referencia 'table_id' a 'table'
					inputName = re.sub('_id$', '', a[0],1)
					
					self.f.write('\n\n#%s.%s' % (table,inputName ))
					comment = a[2].split('\n')
					if len(comment)>0 and len(comment[0])>0:
						self.append_nmsgid(self.camel_field(inputName), comment[0])
					if len(comment)>1 and  len(comment[1])>0:
						self.append_nmsgid(table+'.'+inputName, comment[1])
	
	def end_render (self) :
		self.f.close()
# reference
dia.register_export ("SICACakePHP archivo de traducción", "po", PORenderer())
Exemplo n.º 4
0
    def end_render(self):
        module = self.data_get()['module']
        xip = zipfile.ZipFile(self.filename, 'w')

        zip_files = {
            '__init__.py': env.get_template('__init__.py').render(module=module, packages=['models']),
            '__openerp__.py': env.get_template('__openerp__.py').render(module=module, data=self, packages=self.packages.keys()),
            'models/__init__.py': env.get_template('models/__init__.py').render(module=module, data=self, packages=self.packages.keys()),
            'views/menu.xml': env.get_template('menu.xml').render(module=module, data=self, packages=self.packages.keys()),
            'security/ir.model.access.csv': env.get_template('security/ir.model.access.csv').render(module=module, data=self),
        }

        for name, package in self.packages.items():
            zip_files['models/{package}.py'.format(package=package.name)] = env.get_template('models/package.py').render(module=module, data=self, package=package, models=package.classes)
            zip_files['views/{package}.xml'.format(package=package.name)] = env.get_template('view.xml').render(module=module, data=self, package=package, models=package.classes)

        for name, datastr in zip_files.items():
            info = zipfile.ZipInfo(module + '/' + name)
            info.compress_type = zipfile.ZIP_DEFLATED
            info.external_attr = 2175008768
            xip.writestr(info, datastr)
        xip.close()
        ObjRenderer.end_render(self)


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("PyDia Code Generation (Odoo v8)", "zip", OdooRenderer())

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Exemplo n.º 5
0
                  + str(r.right) + "," + str(r.bottom) + "</bbox>\n")

                self.f.write("\t" * 2 + "<connections>\n")
                for c in o.connections:
                    if (len(c.connected) < 1):
                        continue
                    self.f.write("\t" * 3 + str(c) + "\n")
                    for co in c.connected:
                        self.f.write("\t" * 4 + str(co) + "\n")
                    self.f.write("\t" * 3 + "</DiaConnectionPoint>\n")
                self.f.write("\t" * 2 + "</connections>\n")

                self.f.write("\t" * 2 + str(o.properties) + "\n")
                keys = list(o.properties.keys())
                for s in keys:
                    self.f.write("\t" * 3 + str(o.properties[s]) + "\n")
                    if o.properties[s].type == "string":
                        self.f.write("\t" * 3 + str(o.properties[s].value) +
                                     "\n")
                    self.f.write("\t" * 3 + "</DiaProperty>\n")
                self.f.write("\t" * 2 + "</DiaProperties>\n")
                self.f.write("\t" * 1 + "</DiaObject>\n\n")
            self.f.write("\t" * 0 + "</layer>\n")

    def end_render(self):
        self.f.close()


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export(_("PyDia Object Export"), "diapyo", ObjRenderer())
Exemplo n.º 6
0
                if klass.inheritance_type == "template" or method[3] == 0:
                    f.write(";\n\n")
                else:
                    f.write(
                        "\n\t{\n\t\t// TODO Auto-generated method stub\n\t}\n\n"
                    )
            f.write("}\n\n")
            f.close()
            mainfile.write(" *\t%s\n" % classfile)
        mainfile.write(" */\n")
        mainfile.close()
        ObjRenderer.end_render(self)

    def fill_rect(*args):
        pass

    def draw_line(*args):
        pass

    def draw_string(*args):
        pass


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("PyDia Code Generation (Python)", "py", PyRenderer())
dia.register_export("PyDia Code Generation (C++)", "cxx", CxxRenderer())
dia.register_export("PyDia Code Generation (Pascal)", "pas", PascalRenderer())
dia.register_export("PyDia Code Generation (Java)", "java", JavaRenderer())
dia.register_export("PyDia Code Generation (JavaScript)", "js", JsRenderer())
dia.register_export("PyDia Code Generation (PHP)", "php", PhpRenderer())
Exemplo n.º 7
0
			for methodname, method in klass.operations :
				if method[4]: f.write("\t/** %s */\n" % method[4])
				# if there are no parameter names, something else should appear
				pars = []
				v = ord("a")
				for name, type, value, comment, kind in method[2]:
					#TODO: also use: value, comment, kind
					if not name:
						pars.append((type,chr(v)))
						v += 1
					else: pars.append((type,name))
				pars = ", ".join([type+" "+name for type, name in pars])
				
				vis = method[1] in visibilities and visibilities[method[1]] or ""
				returntype = method[0]=="" and "void" or method[0]
				inheritance_type = method[3]==0 and "abstract " or ""
				static = method[4] and "static " or ""
				f.write("\t%s %s%s%s %s (%s)" % (vis, static, inheritance_type, returntype, methodname, pars))
				if klass.inheritance_type == "template" or method[3]==0:
					f.write(";\n\n")
				else: f.write(" {\n\t\t\n\t}\n\n")
			f.write ("}\n\n")
		f.close()
		ObjRenderer.end_render(self)

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia Code Generation (Python)", "py", PyRenderer())
dia.register_export ("PyDia Code Generation (C++)", "cxx", CxxRenderer())
dia.register_export ("PyDia Code Generation (Pascal)", "pas", PascalRenderer())
dia.register_export ("PyDia Code Generation (Java)", "java", JavaRenderer())
Exemplo n.º 8
0
      comment = ops["__init__"][0].Comment()
    else:
      params = []
    indent = NCGenConfig.indent
    self.out.write("%sdef __init__(%s)\n"
                   % (indent, self._strParameters(params)))
    indent = indent * 2
    self._conditionallyWriteDocComment(comment,indent)
    strAttribs = ''
    for a in attribs.itervalues():
      if not a.HasClassScope():
        strAttribs = ''.join([strAttribs,indent,"self.", a.Name(), " = "
                              , a.Name() if attribHasParam(a,params) else "None", "\n"])
    self.out.write(strAttribs if strAttribs else "%spass\n"%indent)
  def _strParameters(self, params, isClassMethod=False):
    strParams = 'cls' if isClassMethod else 'self'
    for p in params:
      strParams = ''.join([strParams,', ',p.Name(),ConditionallyPrefix("=",p.Value())])
    return strParams
  def _conditionallyWriteDocComment(self, comment, indent):
    if comment and (comment!="(NULL)"):
      self.out.write("%s''' %s '''\n" % (indent, comment))

class PythonCodeGenRenderer(CodeGenRenderer):
  ''' Python specific CodeGenRenderer subclass '''
  def __init__(self):
    CodeGenRenderer.__init__(self, PythonWriter)

# Register the code generation export renderers with Dia
dia.register_export ("Next Gen Dia Code Generation (Python)", "py", PythonCodeGenRenderer())
Exemplo n.º 9
0
        value = 1
        generated = []
        for transition in self.transitions:
            if len(transition.trigger) > 0:
                if transition.trigger not in generated:
                    generated.append(transition.trigger)
                    f.write("#define %s_%s_EVENT    0x%02x \n" %
                            (self.basename.upper(), transition.trigger.upper(),
                             value))
                    value = value * 2
        f.write("\n")

    def generate_states_typedef(self, f):
        f.write("typedef enum _%s_fsm_st_t\n{\n" % (self.basename))
        states_keys_list = self.states.keys()
        for key in states_keys_list:
            state = self.states[key].name
            if key == states_keys_list[-1]:
                f.write("\t%s_%s_fsm_st\n" % (self.basename, state))
            else:
                f.write("\t%s_%s_fsm_st,\n" % (self.basename, state))
        f.write("} %s_fsm_st_t;\n" % (self.basename))
        f.write("\n")


INITIAL_STATE, STANDARD_STATE, FINAL_STATE = range(3)
SM_EXPORT_VERSION = "2.1"

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("State Machine C code export", "fsm", DiagramRenderer())
	"#                 source_state,target_state,trigger,action\n"   + \
        "#    [STATES] is states zone begin tag\n"                       + \
        "#    [TRANSITIONS] is transitions zone begin tag\n"             + \
        "#---------------------------------------------------------\n"

    def __init__(self):
        uml_stm_export.SimpleSTM.__init__(self)
        self.filename = ""

    def begin_render (self, data, filename):
        self.filename = filename
        uml_stm_export.SimpleSTM.parse(self, data)
                   
    def end_render(self) :
        f = open(self.filename, "w")
        f.write(self.CODE_PREAMBLE)
        f.write("[STATES]\n")
        for key in self.states.keys():
            state = self.states[key]
            f.write("%s, %s, %s\n" % (state.name, state.iaction, state.oaction))
        f.write("[TRANSITIONS]\n")
        for transition in self.transitions:
            f.write("%s, %s, %s, %s\n" % (transition.source, transition.target, transition.trigger, transition.action))
        f.close()
        self.states = {}
        self.transitions = []


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("State Machine Textual Dump", "txt", TxtDiagramRenderer())
Exemplo n.º 11
0
                    fun,
                    bp.type,
                ))

    def draw_bezier(self, bezpoints, color):
        if len(bezpoints) < 2:
            self.Error("draw_bezier too few points")
        self._bezier(bezpoints, "draw_bezier")

    def fill_bezier(self, bezpoints, color):
        if len(bezpoints) < 3:
            self.Error("fill_bezier too few points")
        self._bezier(bezpoints, "fill_bezier")

    def draw_string(self, text, pos, alignment, color):
        if len(text) < 1:
            self.Warning("draw_string empty text")
        if alignment < 0 or alignment > 2:
            self.Error("draw_string unknown alignmern '%d'" % (alignment, ))

    def draw_image(self, point, width, height, image):
        if width <= 0:
            self.Warning("draw_image width too small")
        if height <= 0:
            self.Warning("draw_image height too small")
        # XXX: check image, e.g. existing file name


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("Dissect", "dissect", DissectRenderer())
Exemplo n.º 12
0
		hbox.show()
		self.win.set_position(gtk.WIN_POS_CENTER)
		self.win.show()

# set up as a dia plugin
try :
	import dia
	
	def open_dialog_import(data, flags):
		ImportDbDialog(data, "import")

	def open_dialog_export(data, flags):
		ImportDbDialog(data, "export")

	dia.register_action ("DialogsPostgresImp", "Import Postgres database", 
	                      "/DisplayMenu/Dialogs/DialogsExtensionStart", 
	                       open_dialog_import)

	dia.register_action ("DialogsPostgresExp", "Export diagram to Postgres", 
	                      "/DisplayMenu/Dialogs/DialogsExtensionStart", 
	                       open_dialog_export)
	                       
	dia.register_export ("Postgres SQL Export", "sql", SQLRenderer())


except :
	print 'Failed to import Dia ...'
	ImportDbDialog(None, "import")
	gtk.main()
Exemplo n.º 13
0
						tables[table] += '"auto_increment": false'
					tables[table] += '}\n'
			elif o.type.name == 'Database - Reference':
				#for p in o.properties.keys(): 
				#	print p, '\t', o.properties[p]
				continue
		tbs=''
		for k in tables.keys():
			tbs += '{\n"nombre" : "%s",\n' % k
			tbs += values[k]
			tbs += '"campos" : [\n'
			campos = sorted( tables[k].split('\n') )
			campos = [str(s[3:]) for s in campos if len(s)>4] #
			campos = ",\n".join( campos)
			tbs +=  '%s\n' % campos
			tbs += ' ]\n},\n'
		if len(tables)>1 :
			tbs = '%s' % tbs[0:-2]
		self.f.write (tbs)
	def end_render (self) :
		self.f.write ("\n]")
		self.f.close()
# reference
	def rgb (color) :
		#convert the color into a string in RGB
		rgb = "#%02X%02X%02X" #% (int(255 * color.red), int(color.green * 255), int(color.blue * 255))
		return rgb

dia.register_export ("SICAJSON exportar datos en formato JSON(JavaScript Object Notation)", "js", JSONRenderer())

Exemplo n.º 14
0
                f.write("    add_initial_state( stm, %s, %s );\n" %
                        (initial_state.name, initial_state.doaction))

        for key in self.states.keys():
            state = self.states[key]
            # initial_state has already been output
            # TODO: the fact that state can be None looks like a bug to me
            if (state != None and state.name != initial_state.name):
                f.write("    add_state( stm, %s, %s );\n" %
                        (state.name, state.doaction))
                # (state.name, state.iaction, state.oaction, state.doaction)

        f.write(self.TRANSITIONS_PREAMBLE)

        for transition in self.transitions:
            if (transition.source == "INITIAL_STATE"):
                continue  # skip the initial state transition
            f.write("    add_transition( stm, %s, %s, %s );\n" %
                    (transition.source, transition.trigger, transition.target))
            #   (transition.source, transition.trigger, transition.target, transition.action))

        f.write(self.CODE_POSTAMBLE)

        f.close()
        self.states = {}
        self.transitions = []


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("State Machine Cstma Dump", "c", CDiagramRenderer())
Exemplo n.º 15
0
	
	def WriteTables (self, layer):
		for o in layer.objects :
			if o.type.name == 'Database - Table' :
				if not o.properties.has_key ("name") :
					continue
				if not o.properties["name"].value == self.fileName :
					continue
				atributes = o.properties['attributes'].value
				for i in range(0,len(atributes)):
					a = atributes[i]
					if len(a[0])<1:
						continue
					inputName = a[0]
					comment = a[2].split('\n')
					if len(comment)>0 and len(comment[0])>0:
						inputName = comment[0]
					if len(inputName)<1:
						continue
					self.f.write('\n\t<th width="%spx">%s</th>' % (10*len( inputName), inputName))
					self.count = self.count + 1

	def end_render (self) :
		#Me latio esta implementacion se me hiso bastante H4ck!
		self.f.write ('\n</tr>\n<tr>%s\n</tr>\n</table>' % ('\n\t<td></td>'* self.count))
		self.f.write('\n</body>\n</html>')
		self.f.close()
# Bind reference

dia.register_export ("SICAODS Hoja Calculo para el oocalc", "ods", CalcRender())
Exemplo n.º 16
0
        hbox.show()
        self.win.set_position(gtk.WIN_POS_CENTER)
        self.win.show()


# set up as a dia plugin
try:
    import dia

    def open_dialog_import(data, flags):
        ImportDbDialog(data, "import")

    def open_dialog_export(data, flags):
        ImportDbDialog(data, "export")

    dia.register_action("DialogsPostgresImp", "Import Postgres database",
                        "/DisplayMenu/Dialogs/DialogsExtensionStart",
                        open_dialog_import)

    dia.register_action("DialogsPostgresExp", "Export diagram to Postgres",
                        "/DisplayMenu/Dialogs/DialogsExtensionStart",
                        open_dialog_export)

    dia.register_export("Postgres SQL Export", "sql", SQLRenderer())

except:
    print 'Failed to import Dia ...'
    ImportDbDialog(None, "import")
    gtk.main()
Exemplo n.º 17
0
        <dia:real val="%.3f"/>
      </dia:attribute>
      <dia:attribute name="file">
        <dia:string>#%s#</dia:string>
      </dia:attribute>
      <dia:attribute name="draw_border">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="keep_aspect">
        <dia:boolean val="%s"/>
      </dia:attribute>
    </dia:object>''' %
            (self.oid, point.x, point.y, width, height, fname, keep_aspect))

    # defining only this line drawer makes almost everything interpolated
    def draw_line(self, start, end, color):
        self.oid = self.oid + 1
        self.f.write('''
    <dia:object type="Standard - Line" version="0" id="O%d">
      <dia:attribute name="conn_endpoints">
        <dia:point val="%.3f,%.3f"/>
        <dia:point val="%.3f,%.3f"/>
      </dia:attribute>
%s%s
    </dia:object>''' % (self.oid, start.x, start.y, end.x, end.y,
                        self._tinting(color), self._stroke_style()))


# register the renderer
dia.register_export(_("Dia plain"), "dia", StandardDiaRenderer())
Exemplo n.º 18
0
                result+="        # returns %s\n" % (op[0], )
            #result += cname+"()\n\n"
            result += "\n\n"
        return result

    def end_render(self) :
        module = self.data_get()['module']
        zip = zipfile.ZipFile(self.filename, 'w')
        filewrite = {
                '__init__.py':self.init_get(),
                '__manifest__.py':self.terp_get(),
                'models/__init__.py':self.init_model_get(),
                'models/'+module+'.py': self.code_get(),
                'views/'+module+'_view.xml': self.view_get(),
                'security/ir.model.access.csv': self.security_get(),
                'static/description/index.html': self.html_get(),
                'static/src/less/'+module+'.less': self.less_get()
        }
        for name,datastr in filewrite.items():
            info = zipfile.ZipInfo(module+'/'+name)
            info.compress_type = zipfile.ZIP_DEFLATED
            info.external_attr = 2175008768
            zip.writestr(info, datastr)
        zip.close()
        ObjRenderer.end_render(self)

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia Generador de Código (Odoo)", "zip", OpenERPRenderer())

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Exemplo n.º 19
0
            st = 'stroke-dasharray="%.2f,%.2f"' % (dashlen, dashlen)
        elif style == 2: # DASH_DOT,
            gaplen = (dashlen - dotlen) / 2.0
            st = 'stroke-dasharray="%.2f,%.2f,%.2f,%.2f"' % (dashlen, gaplen, dotlen, gaplen)
        elif style == 3: # DASH_DOT_DOT,
            gaplen = (dashlen - dotlen) / 3.0
            st = 'stroke-dasharray="%.2f,%.2f,%.2f,%.2f,%.2f,%.2f"' % (dashlen, gaplen, dotlen, gaplen, dotlen, gaplen)
        elif style == 4: # DOTTED
            st = 'stroke-dasharray="%.2f,%.2f"' % (dotlen, dotlen)

        if join == 0: # MITER
            pass # st = st + ' stroke-linejoin="bevel"'
        elif join == 1: # ROUND
            st += ' stroke-linejoin="round"'
        elif join == 2: # BEVEL
            st += ' stroke-linejoin="bevel"'

        if caps == 0: # BUTT
            pass # default stroke-linecap="butt"
        elif caps == 1: # ROUND
            st += ' stroke-linecap="round"'
        elif caps == 2: # PROJECTING
            st += ' stroke-linecap="square"' # is this the same ?

        return st

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export( "MIF/FrameMaker", "mif", MIFMaker())

# vim:ts=4:sw=4:expandtab
Exemplo n.º 20
0
            #result += cname+"()\n\n"
            result += "\n\n"
        return result

    def end_render(self) :
        module = self.data_get()['module']
        zip = zipfile.ZipFile(self.filename, 'w')
        filewrite = {
                '__init__.py':self.init_get(),
                '__openerp__.py':self.terp_get(),
                'models/__init__.py':self.init_model_get(),
                'models/'+module+'.py': self.code_get(),
                'views/'+module+'_view.xml': self.view_get(),
                'security/ir.model.access.csv': self.security_get()
        }
        for name,datastr in filewrite.items():
            info = zipfile.ZipInfo(module+'/'+name)
            info.compress_type = zipfile.ZIP_DEFLATED
            info.external_attr = 2175008768
            zip.writestr(info, datastr)
        zip.close()
        ObjRenderer.end_render(self)


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia Generador de Código (Odoo)", "zip", OpenERPRenderer())

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:


Exemplo n.º 21
0
			file.write(" %s" % val)
		file.write("\n")
			
	def get_sense_id(self, sense_name) :
		# print "sense_name ", sense_name
		sense_id = 0
		if sense_name in self.senses.keys() :
			if "SenseID" in self.senses[sense_name].attributes.keys() :
				sense_id = self.senses[sense_name].attributes["SenseID"][1]
		return sense_id

	def get_action_id(self, action_name) :
		# print "action_name ", action_name
		action_id = 0
		if action_name in self.actions.keys() :
			if "ActionID" in self.actions[action_name].attributes.keys() :
				action_id = self.actions[action_name].attributes["ActionID"][1]
		return action_id

	def get_comparator_val(self, comparator_name) :
		# print "comparator_name ", comparator_name
		comp_val = 0
		comp_values = {'EQ':0, 'NE':1, 'GT':2, 'LT':3, 'TR':4, 'FL':5,}
		if comparator_name in comp_values.keys() :
			comp_val = comp_values[comparator_name]
		return comp_val		
			

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("Instinct Plan Generation", "inst", InstinctRenderer())
Exemplo n.º 22
0
                if op[4]: result+="        \"\"\" %s \"\"\"\n" % op[4]
                result+="        # returns %s\n" % (op[0], )
            #result += cname+"()\n\n"
            result += "\n\n"
        return result

    def end_render(self) :
        module = self.data_get()['module']
        zip = zipfile.ZipFile(self.filename, 'w')
        filewrite = {
                '__init__.py':self.init_get(),
                '__manifest__.py':self.terp_get(),
                'models/__init__.py':self.init_model_get(),
                'models/'+module+'.py': self.code_get(),
                'views/'+module+'_view.xml': self.view_get(),
                'security/ir.model.access.csv': self.security_get(),
                'static/description/index.html': self.html_get(),
                'static/src/less/'+module+'.less': self.less_get(),
                'static/src/js/'+module+'.js': self.java_get()
        }
        for name,datastr in filewrite.items():
            info = zipfile.ZipInfo(module+'/'+name)
            info.compress_type = zipfile.ZIP_DEFLATED
            info.external_attr = 2175008768
            zip.writestr(info, datastr)
        zip.close()
        ObjRenderer.end_render(self)

# dia-python mantiene una referencia a la clase renderer y la usa a demanda
dia.register_export ("CODEGEN ODOO V10)", "zip", ODOORenderer())
Exemplo n.º 23
0
class UninlineRenderer :
	def __init__ (self) :
		self.count = 0
	def begin_render (self, data, filename) :
		imgmap = {}
		dirname = os.path.dirname (filename)
		basename = os.path.basename(filename)
		ext = filename[string.rfind(filename, ".")+1:]
		for layer in data.layers :
			for o in layer.objects :
				if "inline_data" in o.properties.keys() :
					if o.properties["inline_data"].value :
						# remember by position
						pos = o.properties["obj_pos"].value
						xk = "%03g" % pos.x
						yk = "%03g" % pos.y
						key = basename + "-" + layer.name + "x" + xk + "y" + yk
						imgmap[key] = o
			for k, o in imgmap.iteritems() :
				fname = dirname + "/" + k + "." + ext
				print fname
				o.properties["image_file"] = fname
				o.properties["inline_data"] = 0

	def end_render (self) :
		pass
		
# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("Uninline Images", "png", UninlineRenderer())
Exemplo n.º 24
0
    def footer(self):
        s = "\n\n"
        s += "all_classes = ["
        i = 0
        for k in self.built:
            i += 1
            s += "{:s}".format(k)
            if i < len(self.built):
                s += ", "
        s += "]\n"
        return s

    def end_render(self):
        f = open(self.filename, 'w')
        f.write(self.header())
        for sk in self.klasses.keys():
            self.to_build["_{:s}".format(sk)] = \
                    self.build_classes(self.klasses[sk])
        for k in self.to_build.keys():
            self.tree_build(f, k)
        f.write(self.footer())
        f.close()
        self.to_build = {}
        self.built = []
        ObjRenderer.end_render(self)


dia.register_export("Gas chemistry code generation (Python)", "py",
                    MyPyRenderer())
Exemplo n.º 25
0
				self.WriteAreas (layer, scale)
		self.f.write ('</map>\n')

	def WriteAreas (self, layer, scale) :
		for o in layer.objects :
			r = o.bounding_box
			if o.properties.has_key ("name") :
				url = o.properties["name"].value
			elif o.properties.has_key ("text") :
				url = o.properties["text"].value.text
			else :
				continue
			if len(url) == 0 or string.find (url, " ") >= 0 :
				continue

			alt = url
			if o.properties.has_key ("comment") :
				alt = o.properties["comment"].value
			# need to sale the original coords to the bitmap size
			x1 = int(r.left * scale) + self.xofs
			y1 = int(r.top * scale) + self.yofs
			x2 = int(r.right * scale) + self.xofs
			y2 = int(r.bottom * scale) + self.yofs
			self.f.write ('  <area shape="rect" href="%s" title="%s" alt="%s" coords="%d,%d,%d,%d">\n' % \
				 ("#" + url, url, alt, x1, y1, x2, y2))
	def end_render (self) :
		self.f.close()

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export (_("Imagemap"), "cmap", ObjRenderer())
Exemplo n.º 26
0
				for c in o.connections :
					# these are the connection points of the objects. We will have e.g. "UML - Dependency"
					for n in c.connected :
						# we see the connecting lines multiple times, just process once
						if self.edges.has_key(str(n)) :
							continue
						self.edges[str(n)] = 1
						if not (n.handles[0].connected_to and n.handles[1].connected_to) :
							continue
						# the right handles give us the direction 
						a = n.handles[0].connected_to.object
						b = n.handles[1].connected_to.objectlabel = ""
						label = ''
                                                try:
                                                    label = ' [ label = "%s" ]' % n.properties['text'].value
                                                except:
                                                    pass
                                                try :
                                                        self.f.write('"%s" -> "%s"%s\n' % (self.GetName(a), self.GetName(b), label))
							#self.f.write('"%s" -> "%s"\n' % (str(a.properties["text"].value.text), str(b.properties["text"].value.text)))
						except :
							print a, b, " writing connection failed."
				else :
					pass
		self.f.write('}\n')
	def end_render (self) :
		self.f.close()
	
# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia DOT Export", "dot", DotRenderer())
Exemplo n.º 27
0
				self.WriteAreas (layer, scale)
		self.f.write ('</map>\n')

	def WriteAreas (self, layer, scale) :
		for o in layer.objects :
			r = o.bounding_box
			if o.properties.has_key ("name") :
				url = o.properties["name"].value
			elif o.properties.has_key ("text") :
				url = o.properties["text"].value.text
			else :
				continue
			if len(url) == 0 or string.find (url, " ") >= 0 :
				continue

			alt = url
			if o.properties.has_key ("comment") :
				alt = o.properties["comment"].value
			# need to sale the original coords to the bitmap size
			x1 = int(r.left * scale) + self.xofs
			y1 = int(r.top * scale) + self.yofs
			x2 = int(r.right * scale) + self.xofs
			y2 = int(r.bottom * scale) + self.yofs
			self.f.write ('  <area shape="rect" href="%s" title="%s" alt="%s" coords="%d,%d,%d,%d">\n' % \
				 ("#" + url, url, alt, x1, y1, x2, y2))
	def end_render (self) :
		self.f.close()

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("Imagemap", "cmap", ObjRenderer())
Exemplo n.º 28
0
Arquivo: dot.py Projeto: dwbxm/dia
                    self.f.write('"%s" [fillcolor="%s"];\n' % (self.GetName(o), self.GetColor(o)))
        for layer in data.layers:
            for o in layer.objects:
                for c in o.connections:
                    # these are the connection points of the objects. We will have e.g. "UML - Dependency"
                    for n in c.connected:
                        # we see the connecting lines multiple times, just process once
                        if self.edges.has_key(str(n)):
                            continue
                        self.edges[str(n)] = 1
                        if not (n.handles[0].connected_to and n.handles[1].connected_to):
                            continue
                            # the right handles give us the direction
                        a = n.handles[0].connected_to.object
                        b = n.handles[1].connected_to.object
                        try:
                            self.f.write('"%s" -> "%s"\n' % (self.GetName(a), self.GetName(b)))
                            # self.f.write('"%s" -> "%s"\n' % (str(a.properties["text"].value.text), str(b.properties["text"].value.text)))
                        except:
                            print a, b, " writing connection failed."
                else:
                    pass
        self.f.write("}\n")

    def end_render(self):
        self.f.close()


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("PyDia DOT Export", "dot", DotRenderer())
Exemplo n.º 29
0
          + ";" + str(fill) + ";" + str(stroke) + "\n")

    ## \brief Draw a bezier line
    def draw_bezier(self, bezpoints, color):
        self.f.write("draw_bezier: " + str(color) + "\n")
        for pt in bezpoints:
            self.f.write("\t" + str(pt) + "\n")

    ## \brief Fill a bezier shape
    def draw_beziergon(self, bezpoints, fill, stroke):
        self.f.write("draw_bezier: " + str(fill) + "; " + str(stroke) + "\n")
        for pt in bezpoints:
            self.f.write("\t" + str(pt) + "\n")

    ## \brief Draw a string
    def draw_string(self, text, pos, alignment, color):
        self.f.write("draw_string: [" + text + "]; " + str(pos) \
          + str(alignment) + "; " +str(color))

    ## \brief Draw an image
    def draw_image(self, point, width, height, image):
        self.f.write("draw_image: " + str(point) + str(width) + "x" +str(height) \
          + " " + image.filename + "\n")
        self.f.write("<rgb_data>" + image.rgb_data + "</rgb_data>")
        self.f.write("<mask_data>" + image.mask_data + "</mask_data>")


## \brief Register the renderer with Dia's export system
# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export(_("PyDia Render Export"), "diapyr", DumpRenderer())
Exemplo n.º 30
0
                initial_state = self.states[transition.target]
                f.write("    add_initial_state( stm, %s, %s );\n" %
                    (initial_state.name, initial_state.doaction))

        for key in self.states.keys():
            state = self.states[key]
            # initial_state has already been output
            # TODO: the fact that state can be None looks like a bug to me
            if(state != None and state.name != initial_state.name):
                f.write("    add_state( stm, %s, %s );\n" %
                                                       (state.name, state.doaction))
                # (state.name, state.iaction, state.oaction, state.doaction)

        f.write(self.TRANSITIONS_PREAMBLE)

        for transition in self.transitions:
            if(transition.source == "INITIAL_STATE"):
                continue # skip the initial state transition
            f.write("    add_transition( stm, %s, %s, %s );\n" %
                (transition.source, transition.trigger, transition.target ))
            #   (transition.source, transition.trigger, transition.target, transition.action))

        f.write(self.CODE_POSTAMBLE)

        f.close()
        self.states = {}
        self.transitions = []

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("State Machine Cstma Dump", "c", CDiagramRenderer())
Exemplo n.º 31
0
                result += "    def %s(%s) :\n" % (so, pars)
                if op[4]: result += "        \"\"\" %s \"\"\"\n" % op[4]
                result += "        # returns %s\n" % (op[0], )
            result += cname + "()\n\n"
        return result

    def end_render(self):
        module = self.data_get()['module']
        zip = zipfile.ZipFile(self.filename, 'w')
        filewrite = {
            '__init__.py': self.init_get(),
            '__openerp__.py': self.terp_get(),
            module + '.py': self.code_get(),
            module + '_view.xml': self.view_get(),
            'security/ir.model.access.csv': self.security_get()
        }
        for name, datastr in filewrite.items():
            info = zipfile.ZipInfo(module + '/' + name)
            info.compress_type = zipfile.ZIP_DEFLATED
            info.external_attr = 2175008768
            zip.writestr(info, datastr)
        zip.close()
        ObjRenderer.end_render(self)


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("PyDia Code Generation (OpenERP)", "zip",
                    OpenERPRenderer())

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Exemplo n.º 32
0
				+ str(angle1) + "," + str(angle2) + ";" + str(color) + "\n")
	def fill_arc (self, center, width, height, angle1, angle2, color) :
		self.f.write("fill_arc: " + str(center) + ";" \
				+ str(width) + "x" + str(height) + ";" \
				+ str(angle1) + "," + str(angle2) + ";" + str(color) + "\n")
	def draw_ellipse (self, center, width, height, color) :
		self.f.write("draw_ellipse: " + str(center) \
				+ str(width) + "x" +str(height) + ";" + str(color) + "\n")
	def fill_ellipse (self, center, width, height, color) :
		self.f.write("fill_ellipse: " + str(center) \
				+ str(width) + "x" +str(height) + ";" + str(color) + "\n")
	def draw_bezier (self, bezpoints, color) :
		self.f.write("draw_bezier: " + str(color) + "\n")
		for pt in bezpoints :
			self.f.write ("\t" + str(pt) + "\n")
	def fill_bezier (self, bezpoints, color) :
		self.f.write("fill_bezier: " + str(color) + "\n")
		for pt in bezpoints :
			self.f.write ("\t" + str(pt) + "\n")
	def draw_string (self, text, pos, alignment, color) :
		self.f.write("draw_string: [" + text + "]; " + str(pos) \
				+ str(alignment) + "; " +str(color))
	def draw_image (self, point, width, height, image) :
		self.f.write("draw_image: " + str(point) + str(width) + "x" +str(height) \
				+ " " + image.filename + "\n")
		self.f.write("<rgb_data>" + image.rgb_data + "</rgb_data>")
		self.f.write("<mask_data>" + image.mask_data + "</mask_data>")

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia Render Export", "diapyr", DumpRenderer())
Exemplo n.º 33
0
class UninlineRenderer:
    def __init__(self):
        self.count = 0

    def begin_render(self, data, filename):
        imgmap = {}
        dirname = os.path.dirname(filename)
        ext = filename[string.rfind(filename, ".") + 1:]
        for layer in data.layers:
            for o in layer.objects:
                if "inline_data" in o.properties.keys():
                    if o.properties["inline_data"].value:
                        # remember by position
                        pos = o.properties["obj_pos"].value
                        xk = "%03g" % pos.x
                        yk = "%03g" % pos.y
                        key = "L" + layer.name + "x" + xk + "y" + yk
                        imgmap[key] = o
            for k, o in imgmap.iteritems():
                fname = dirname + "/" + k + "." + ext
                print fname
                o.properties["image_file"] = fname
                o.properties["inline_data"] = 0

    def end_render(self):
        pass


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("Uninline Images", "png", UninlineRenderer())
Exemplo n.º 34
0
				self.f.write ("\t"*1 + str(o) + "\n")
				r = o.bounding_box
				self.f.write ("\t"*2 + "<bbox>" + str(r.left) + "," + str(r.top) + ";" \
						+ str(r.right) + "," + str(r.bottom) + "</bbox>\n")

				self.f.write ("\t"*2 + "<connections>\n")
				for c in o.connections :
					if (len(c.connected) < 1) :
						continue
					self.f.write ("\t"*3 + str(c) + "\n")
					for co in c.connected :
						self.f.write ("\t"*4 + str(co) + "\n")
					self.f.write ("\t"*3 + "</DiaConnectionPoint>\n")
				self.f.write ("\t"*2 + "</connections>\n")

				self.f.write ("\t"*2 + str(o.properties) + "\n")
				keys = o.properties.keys()
				for s in keys :
					self.f.write ("\t"*3 + str(o.properties[s]) + "\n")
					if o.properties[s].type == "string" :
						self.f.write ("\t"*3 + str(o.properties[s].value) + "\n")
					self.f.write ("\t"*3 + "</DiaProperty>\n")
				self.f.write ("\t"*2 + "</DiaProperties>\n")
				self.f.write ("\t"*1 + "</DiaObject>\n\n")
			self.f.write ("\t"*0 + "</layer>\n")
	def end_render (self) :
		self.f.close()

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia Object Export", "diapyo", ObjRenderer())
Exemplo n.º 35
0
Arquivo: diasvg.py Projeto: gcms/dia
            pass  # st = st + ' stroke-linejoin="bevel"'
        elif join == 1:  # ROUND
            st = st + ' stroke-linejoin="round"'
        elif join == 2:  # BEVEL
            st = st + ' stroke-linejoin="bevel"'

        if caps == 0:  # BUTT
            pass  # default stroke-linecap="butt"
        elif caps == 1:  # ROUND
            st = st + ' stroke-linecap="round"'
        elif caps == 2:  # PROJECTING
            st = st + ' stroke-linecap="square"'  # is this the same ?

        return st


class SvgzRenderer(SvgRenderer):
    def _open(self, filename):
        # There is some (here) not wanted behaviour in gzip.open/GzipFile :
        # the filename with path is not only used to adress the file but also
        # completely stored in the file itself. Correct it here.
        import os, os.path, gzip
        path, name = os.path.split(filename)
        os.chdir(path)
        self.f = gzip.open(name, "wb")


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export("SVG plain", "svg", SvgRenderer())
dia.register_export("SVG compressed", "svgz", SvgzRenderer())
Exemplo n.º 36
0
                if op[4]: result+="        \"\"\" %s \"\"\"\n" % op[4]
                result+="        # returns %s\n" % (op[0], )
            result += cname+"()\n\n"
        return result

    def end_render(self) :
        module = self.data_get()['module']
        zip = zipfile.ZipFile(self.filename, 'w')
        filewrite = {
                '__init__.py':self.init_get(),
                '__openerp__.py':self.terp_get(),
                module+'.py': self.code_get(),
                module+'_view.xml': self.view_get(),
                'security/ir.model.access.csv': self.security_get()
        }
        for name,datastr in filewrite.items():
            info = zipfile.ZipInfo(module+'/'+name)
            info.compress_type = zipfile.ZIP_DEFLATED
            info.external_attr = 2175008768
            zip.writestr(info, datastr)
        zip.close()
        ObjRenderer.end_render(self)


# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("PyDia Code Generation (OpenERP 6.1 v2)", "zip", OpenERPRenderer())

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:


Exemplo n.º 37
0
      <dia:attribute name="elem_height">
        <dia:real val="%.3f"/>
      </dia:attribute>
      <dia:attribute name="file">
        <dia:string>#%s#</dia:string>
      </dia:attribute>
      <dia:attribute name="draw_border">
        <dia:boolean val="false"/>
      </dia:attribute>
      <dia:attribute name="keep_aspect">
        <dia:boolean val="%s"/>
      </dia:attribute>
    </dia:object>''' % (self.oid, point.x,point.y, width, height, fname, keep_aspect))

	# defining only this line drawer makes almost everything interpolated
	def draw_line (self, start, end, color) :
		self.oid = self.oid + 1
		self.f.write('''
    <dia:object type="Standard - Line" version="0" id="O%d">
      <dia:attribute name="conn_endpoints">
        <dia:point val="%.3f,%.3f"/>
        <dia:point val="%.3f,%.3f"/>
      </dia:attribute>
%s%s
    </dia:object>''' % (self.oid, start.x,start.y, end.x, end.y, 
			self._tinting(color), self._stroke_style()))
		
# register the renderer
dia.register_export ("Dia plain", "dia", StandardDiaRenderer())

Exemplo n.º 38
0
				nMoves = nMoves + 1
				if nMoves > 1 :
					self.Warning ("%s move-to within", (fun,))
			elif bp.type == 1 : # BEZ_LINE_TO
				pass
			elif bp.type == 2 : # BEZ_CURVE_TO
				pass
			else :
				self.Error ("%s invalid BezPoint type='%d'" % (fun, bp.type,))
	def draw_bezier (self, bezpoints, color) :
		if len(bezpoints) < 2 :
			self.Error ("draw_bezier too few points");
		self._bezier (bezpoints, "draw_bezier")
	def fill_bezier (self, bezpoints, color) :
		if len(bezpoints) < 3 :
			self.Error ("fill_bezier too few points");
		self._bezier (bezpoints, "fill_bezier")
	def draw_string (self, text, pos, alignment, color) :
		if len(text) < 1 :
			self.Warning ("draw_string empty text")
		if alignment < 0 or alignment > 2 :
			self.Error ("draw_string unknown alignmern '%d'" % (alignment,))
	def draw_image (self, point, width, height, image) :
		if width <= 0 :
			self.Warning ("draw_image width too small")
		if height <= 0 :
			self.Warning ("draw_image height too small")
		# XXX: check image, e.g. existing file name
# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_export ("Dissect", "dissect", DissectRenderer())