if path.isfile(xml_file_name) and not options.skip_eagle: os.remove(xml_file_name) if not path.isfile(xml_file_name): print "Convert file using eagle: {0} -> {1}".format( eagle_file, xml_file_name) os.environ['LD_LIBRARY_PATH'] = path.join(options.eagle_path, 'libeagle') subprocess.call([ path.join(options.eagle_path, 'bin', 'eagle'), "-C", "WRITE {0}; QUIT".format(xml_file_name), eagle_file, ]) output_file_name = re.sub('\s+', '_', path.join(test_dir, file_name + '.xml')) if not options.skip_xml or not path.isfile(output_file_name): print "Parsing file: {0}".format(eagle_file) obj = EAGLE_FILE.parse_stream(open(eagle_file, "rb")) print "Dumping xml file: {0}".format(output_file_name) out = codecs.open(output_file_name, "w", "UTF-8") print_xml(out, obj) out.close() print "Run diff: {0} <-> {1}".format(eagle_file, output_file_name) subprocess.call([ path.join('tkdiff'), xml_file_name, output_file_name, ])
file_name, ext = path.splitext(path.basename(eagle_file)) xml_file_name = re.sub('\s+', '_', path.join(test_dir, file_name + '_new_format.sch')) if path.isfile(xml_file_name) and not options.skip_eagle: os.remove(xml_file_name) if not path.isfile(xml_file_name): print "Convert file using eagle: {0} -> {1}".format(eagle_file, xml_file_name) os.environ['LD_LIBRARY_PATH'] = path.join(options.eagle_path,'libeagle') subprocess.call([ path.join(options.eagle_path, 'bin', 'eagle'), "-C", "WRITE {0}; QUIT".format(xml_file_name), eagle_file, ]) output_file_name = re.sub('\s+', '_', path.join(test_dir, file_name + '.xml')) if not options.skip_xml or not path.isfile(output_file_name): print "Parsing file: {0}".format(eagle_file) obj = EAGLE_FILE.parse_stream(open(eagle_file, "rb")) print "Dumping xml file: {0}".format(output_file_name) out = codecs.open(output_file_name, "w", "UTF-8") print_xml(out, obj) out.close() print "Run diff: {0} <-> {1}".format(eagle_file, output_file_name) subprocess.call([ path.join('tkdiff'), xml_file_name, output_file_name, ])
op.add_option("-o", "--output-file", metavar="FILE", default='-', help="Output file name, use - for standard output (default)") (options, args) = op.parse_args() if len(args) != 1: op.error("Missing eagle file name !") if options.output_file == '-': # TODO try to wrap the stdout in a UTF8 encoder out = sys.stdout else: out = codecs.open(options.output_file, "w", "UTF-8") if options.raw_dump: obj = SCHEMATICS_FILE.parse_stream(open(args[0], "rb")) pretty_println(out, obj, line_length=options.line_length) if options.decoded_dump: obj = EAGLE_FILE.parse_stream(open(args[0], "rb")) pretty_println(out, obj, line_length=options.line_length) if options.flat_dump: obj = EAGLE_SCHEMATICS.parse_stream(open(args[0], "rb")) pretty_println(out, obj, line_length=options.line_length) if options.eagle_xml: obj = EAGLE_FILE.parse_stream(open(args[0], "rb")) print_xml(out, obj)
"--output-file", metavar="FILE", default='-', help="Output file name, use - for standard output (default)") (options, args) = op.parse_args() if len(args) != 1: op.error("Missing eagle file name !") if options.output_file == '-': # TODO try to wrap the stdout in a UTF8 encoder out = sys.stdout else: out = codecs.open(options.output_file, "w", "UTF-8") if options.raw_dump: obj = SCHEMATICS_FILE.parse_stream(open(args[0], "rb")) pretty_println(out, obj, line_length=options.line_length) if options.decoded_dump: obj = EAGLE_FILE.parse_stream(open(args[0], "rb")) pretty_println(out, obj, line_length=options.line_length) if options.flat_dump: obj = EAGLE_SCHEMATICS.parse_stream(open(args[0], "rb")) pretty_println(out, obj, line_length=options.line_length) if options.eagle_xml: obj = EAGLE_FILE.parse_stream(open(args[0], "rb")) print_xml(out, obj)