def doit(args): cgobj = CompGlyph() glyphcount = 0 for g in ET.parse(args.input).getroot().findall('glyph'): glyphcount += 1 cgobj.CDelement = g cgobj.CDline = None cgobj.parsefromCDelement() if cgobj.CDline != None: args.output.write(cgobj.CDline + '\n') else: pass # error in glyph number glyphcount message return
def doit(args) : cgobj = CompGlyph() glyphcount = 0 for g in ET.parse(args.input).getroot().findall('glyph'): glyphcount += 1 cgobj.CDelement = g cgobj.CDline = None cgobj.parsefromCDelement() if cgobj.CDline != None: args.output.write(cgobj.CDline+'\n') else: pass # error in glyph number glyphcount message return
def doit(args): ofile = args.output lfile = args.log filelinecount = 0 linecount = 0 elementcount = 0 cgobj = CompGlyph() f = ET.Element('font') for line in args.input.readlines(): filelinecount += 1 testline = line.strip() if len(testline ) > 0 and testline[0:1] != '#': # not whitespace or comment linecount += 1 cgobj.CDline = line cgobj.CDelement = None try: cgobj.parsefromCDline() if cgobj.CDelement != None: f.append(cgobj.CDelement) elementcount += 1 except ValueError as e: lfile.write("Line " + str(filelinecount) + ": " + str(e) + '\n') if linecount != elementcount: lfile.write("Lines read from input file: " + str(filelinecount) + '\n') lfile.write("Lines parsed (excluding blank and comment lines): " + str(linecount) + '\n') lfile.write("Valid glyphs found: " + str(elementcount) + '\n') # instead of simple serialization with: ofile.write(ET.tostring(f)) # create ETWriter object and specify indentation and attribute order to get normalized output indentFirst = " " indentIncr = " " attOrder = "PSName,UID,with,at,x,y" for k in args.params: if k == 'indentIncr': indentIncr = args.params['indentIncr'] elif k == 'indentFirst': indentFirst = args.params['indentFirst'] elif k == 'attOrder': attOrder = args.params['attOrder'] x = attOrder.split(',') attributeOrder = dict(zip(x, range(len(x)))) etwobj = ETWriter(f, indentFirst=indentFirst, indentIncr=indentIncr, attributeOrder=attributeOrder) ofile.write(etwobj.serialize_xml()) return
def doit(args) : ofile = args.output lfile = args.log filelinecount = 0 linecount = 0 elementcount = 0 cgobj = CompGlyph() f = ET.Element('font') for line in args.input.readlines(): filelinecount += 1 testline = line.strip() if len(testline) > 0 and testline[0] != '#': # not whitespace or comment linecount += 1 cgobj.CDline=line cgobj.CDelement=None try: cgobj.parsefromCDline() if cgobj.CDelement != None: f.append(cgobj.CDelement) elementcount += 1 except ValueError, e: lfile.write("Line "+str(filelinecount)+": "+str(e)+'\n')