def compile(self): code = self.code_textedit.toPlainText() if code == "": return compilation_failed_last_time = self.executed_footprint == [] self.executed_footprint = [] (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) if interim != None: self.executed_footprint = interim self.result_textedit.setPlainText(str(interim)) if self.auto_zoom.isChecked(): (dx, dy, x1, y1, x2, y2) = inter.size(interim) self.update_zoom(dx, dy, x1, y1, x2, y2) filter_out = [] if not self.display_docu: filter_out.append('docu') if not self.display_restrict: filter_out.append('restrict') if not self.display_stop: filter_out.append('stop') if not self.display_keepout: filter_out.append('keepout') self.glw.set_shapes(inter.prepare_for_display(interim, filter_out)) if not self.explorer.active_footprint.readonly: with open(self.explorer.active_footprint_file(), "w+") as f: f.write(code) if compilation_failed_last_time: self.status("Compilation successful.") [s1, s2] = self.lsplitter.sizes() self.lsplitter.setSizes([s1+s2, 0]) else: self.executed_footprint = [] self.result_textedit.setPlainText(error_txt) self.status(status_txt) [s1, s2] = self.lsplitter.sizes() self.lsplitter.setSizes([s1+s2-150, 150])
def _export_kicad_old_package(code, expected_name, expected, timestamp): (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) assert interim != None exporter = export.kicad_old.Export("dummy.mod") kicad_name = exporter.export_footprint(interim, timestamp) assert kicad_name == expected_name assert_multi_line_equal(expected, exporter.get_string())
def _export_eagle(code, expected): eagle_lib = 'test/eagle_empty.lbr' (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) assert interim != None version = export.eagle.check_xml_file(eagle_lib) assert version == 'Eagle CAD 6.4 library' exporter = export.eagle.Export(eagle_lib) exporter.export_footprint(interim) data = exporter.get_pretty_data() assert_multi_line_equal(expected, data)
def _export_eagle(code, expected): eagle_lib = "test/eagle_empty.lbr" (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) assert interim != None version = export.eagle.check_xml_file(eagle_lib) assert version == "Eagle CAD 6.4 library" exporter = export.eagle.Export(eagle_lib) exporter.export_footprint(interim) data = exporter.get_pretty_data() assert_multi_line_equal(expected, data)
def _export_eagle_package(code, expected_name, expected): eagle_lib = 'test/eagle_empty.lbr' (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) assert interim != None version = export.eagle.check_xml_file(eagle_lib) assert version == 'Eagle CAD 6.4 library' exporter = export.eagle.Export(eagle_lib) eagle_name = exporter.export_footprint(interim) assert eagle_name == expected_name data = exporter.get_pretty_footprint(eagle_name) assert_multi_line_equal(expected, data) #print code, expected return data
def name_of_footprint(remaining): parser = argparse.ArgumentParser(prog=sys.argv[0] + ' name') parser.add_argument('footprint', help='footprint file') args = parser.parse_args(remaining) with open(args.footprint, 'r') as f: code = f.read() (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) if interim == None: print >> sys.stderr, error_txt return 1 meta = filter(lambda x: x['type'] == 'meta', interim)[0] name = meta['name'].replace(' ', '_') dir_name = os.path.dirname(args.footprint) if dir_name != "": new_name = os.path.dirname(args.footprint) + "/" + name + ".coffee" else: new_name = name + ".coffee" print new_name
def export_footprint(remaining): parser = argparse.ArgumentParser(prog=sys.argv[0] + ' export') parser.add_argument('footprint', help='footprint file') parser.add_argument('library', help='library file') args = parser.parse_args(remaining) with open(args.footprint, 'r') as f: code = f.read() (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) if interim == None: print >> sys.stderr, error_txt return 1 meta = filter(lambda x: x['type'] == 'meta', interim)[0] name = meta['name'] print name, 'compiled.' try: exporter = detect.make_exporter(args.library) except Exception as ex: print >> sys.stderr, str(ex) return 1 exporter.export_footprint(interim) exporter.save() print "Exported to "+args.library+"." return 0
def export_footprint(remaining): parser = argparse.ArgumentParser(prog=sys.argv[0] + ' export') parser.add_argument('footprint', help='footprint file') parser.add_argument('library', help='library file') args = parser.parse_args(remaining) with open(args.footprint, 'r') as f: code = f.read() (error_txt, status_txt, interim) = pycoffee.compile_coffee(code) if interim == None: print >> sys.stderr, error_txt return 1 meta = filter(lambda x: x['type'] == 'meta', interim)[0] name = meta['name'] print name, 'compiled.' try: exporter = detect.make_exporter(args.library) except Exception as ex: print >> sys.stderr, str(ex) return 1 exporter.export_footprint(interim) exporter.save() print "Exported to " + args.library + "." return 0