コード例 #1
0
ファイル: scrapeNewComponent.py プロジェクト: NVSL/BOBBuilder
if "eagle_link" in r:
    out_dir = os.path.dirname(fname)
    print "Downloading Eagle .brd and .sch zip file to ext folder..."
    ext_folder = out_dir + "/ext"
    pyUtil.docmd("mkdir " + ext_folder)
    pyUtil.docmd("curl -s {0} > {1}/eagle.zip".format(r["eagle_link"],ext_folder))
    if args.bob:
        et.insert(3,ET.Element('bobspec'))      #Inserts after <keyname>, wasn't sure how to just say 'insert after keyname'
        bobspec = et.find('bobspec')
        bobspec.attrib['device-name'] = args.keyname[0]
        download = ET.SubElement(bobspec,'downloadURL')
        download.attrib['protocol'] = 'zip'     #Nothing other than zip at the moment
        download.text = r['eagle_link']
        brd = ET.SubElement(bobspec,'brdfile')
        sch = ET.SubElement(bobspec,'schfile')
        try:
            pyUtil.docmd("unzip {0}/eagle.zip -d {1}".format(ext_folder,ext_folder))
            pyUtil.docmd("rm {0}/eagle.zip".format(ext_folder))
            for f in os.walk(ext_folder).next()[2]:
                if f.endswith('.brd'):
                    brd.text = 'ext/' + f
                if f.endswith('.sch'):
                    sch.text = 'ext/' + f
        except OSError as e:
            print str(e)
            print "Couldn't unzip Eagle stuff"


XMLUtil.formatAndWrite(e,fname, xml_declaration=True)
コード例 #2
0
ファイル: editSVGStyle.py プロジェクト: NVSL/SVGUtil
if args.classes is not None:
    paths = [ ".//*[@class='" + c + "']" for c in args.classes ]
else:
    paths = args.path

for p in paths:
    #print p
    #print c
    for t in b.getroot().xpath(p, namespaces=InkscapeNS.namespaces):
        #print t
        if args.styleAttr is not None:
            pat = args.styleAttr[0]+":[^;]*;"
            #print pat
            if t.get("style") is None:
                t.set("style","")

            if re.match(pat, t.get("style")):
                n = re.sub(pat, args.styleAttr[0]+":"+args.value[0] +";", t.get("style"))
            else:
                if t.get("style") == "":
                    n = args.styleAttr[0]+":"+args.value[0]
                else:
                    n = t.get("style") + ";" +args.styleAttr[0]+":"+args.value[0]

#            print n
            t.set("style", n)
        elif args.attr is not None:
            t.set(args.attr[0], args.value[0])
            
XMLUtil.formatAndWrite(b, args.svgOut[0])