diff --git a/pystdf/IO.py b/pystdf/IO.py index cd072a0..41bc044 100644 --- a/pystdf/IO.py +++ b/pystdf/IO.py @@ -6,12 +6,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -52,7 +52,7 @@ def readAndUnpack(self, header, fmt): header.len -= len(buf) val,=struct.unpack(self.endian + fmt, buf) return val - + def readAndUnpackDirect(self, fmt): size = struct.calcsize(fmt) buf = self.inp.read(size) @@ -61,13 +61,13 @@ def readAndUnpackDirect(self, fmt): raise EofException() val,=struct.unpack(self.endian + fmt, buf) return val - + def readField(self, header, stdfFmt): return self.readAndUnpack(header, packFormatMap[stdfFmt]) - + def readFieldDirect(self, stdfFmt): return self.readAndUnpackDirect(packFormatMap[stdfFmt]) - + def readCn(self, header): if header.len == 0: raise EndOfRecordException() @@ -85,49 +85,49 @@ def readCn(self, header): header.len -= len(buf) val,=struct.unpack(str(slen) + "s", buf) return val - + def readBn(self, header): blen = self.readField(header, "U1") bn = [] for i in range(0, blen): bn.append(readField(header, "B1")) return bn - + def readDn(self, header): dbitlen = self.readField(header, "U2") dlen = dbitlen / 8 if dbitlen % 8 > 0: dlen+=1 dn = [] - for i in range(0, dlen): + for i in range(0, int(dlen)): dn.append(self.readField(header, "B1")) return dn - + def readVn(self, header): vlen = self.readField(header, "U2") vn = [] for i in range(0, vlen): fldtype = self.readField(header, "B1") - if self.vnMap.has_key(fldtype): + if fldtype in self.vnMap: vn.append(self.vnMap[fldtype](header)) return vn - + def readArray(self, header, indexValue, stdfFmt): if (stdfFmt == 'N1'): self.readArray(header, indexValue/2+indexValue%2, 'U1') return arr = [] - for i in range(indexValue): + for i in range(int(indexValue)): arr.append(self.unpackMap[stdfFmt](header, stdfFmt)) return arr - + def readHeader(self): hdr = RecordHeader() hdr.len = self.readFieldDirect("U2") hdr.typ = self.readFieldDirect("U1") hdr.sub = self.readFieldDirect("U1") return hdr - + def __detectEndian(self): self.eof = 0 header = self.readHeader() @@ -142,9 +142,9 @@ def __detectEndian(self): return '<' else: return '>' - + def header(self, header): pass - + def parse_records(self, count=0): i = 0 self.eof = 0 @@ -153,7 +153,7 @@ def parse_records(self, count=0): while self.eof==0: header = self.readHeader() self.header(header) - if (self.recordMap.has_key((header.typ, header.sub))): + if (header.typ, header.sub) in self.recordMap: recType = self.recordMap[(header.typ, header.sub)] recParser = self.recordParsers[(header.typ, header.sub)] fields = recParser(self, header, []) @@ -166,23 +166,23 @@ def parse_records(self, count=0): i += 1 if i >= count: break except EofException: pass - + def auto_detect_endian(self): if self.inp.tell() == 0: self.endian = '@' self.endian = self.__detectEndian() - + def parse(self, count=0): self.begin() - + try: self.auto_detect_endian() self.parse_records(count) self.complete() - except Exception, exception: + except Exception as exception: self.cancel(exception) raise - + def getFieldParser(self, fieldType): if (fieldType.startswith("k")): fieldIndex, arrayFmt = re.match('k(\d+)([A-Z][a-z0-9]+)', fieldType).groups() @@ -190,13 +190,13 @@ def getFieldParser(self, fieldType): else: parseFn = self.unpackMap[fieldType] return lambda self, header, fields: parseFn(header, fieldType) - + def createRecordParser(self, recType): fn = lambda self, header, fields: fields for stdfType in recType.fieldStdfTypes: fn = appendFieldParser(fn, self.getFieldParser(stdfType)) return fn - + def __init__(self, recTypes=V4.records, inp=sys.stdin, reopen_fn=None, endian=None): DataSource.__init__(self, ['header']); self.eof = 1 @@ -204,11 +204,11 @@ def __init__(self, recTypes=V4.records, inp=sys.stdin, reopen_fn=None, endian=No self.inp = inp self.reopen_fn = reopen_fn self.endian = endian - + self.recordMap = dict( [ ( (recType.typ, recType.sub), recType ) for recType in recTypes ]) - + self.unpackMap = { "C1": self.readField, "B1": self.readField, @@ -227,11 +227,11 @@ def __init__(self, recTypes=V4.records, inp=sys.stdin, reopen_fn=None, endian=No "Dn": lambda header, fmt: self.readDn(header), "Vn": lambda header, fmt: self.readVn(header) } - + self.recordParsers = dict( [ ( (recType.typ, recType.sub), self.createRecordParser(recType) ) for recType in recTypes ]) - + self.vnMap = { 0: lambda header: self.inp.read(header, 1), 1: lambda header: self.readField(header, "U1"), @@ -247,4 +247,3 @@ def __init__(self, recTypes=V4.records, inp=sys.stdin, reopen_fn=None, endian=No 12: lambda header: self.readDn(header), 13: lambda header: self.readField(header, "U1") } - diff --git a/pystdf/Mapping.py b/pystdf/Mapping.py index 8350812..d7ec37d 100644 --- a/pystdf/Mapping.py +++ b/pystdf/Mapping.py @@ -6,12 +6,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -22,30 +22,30 @@ from pystdf import V4 class StreamMapper(StreamIndexer): - + def __init__(self, types=V4.records): self.indexes = [] self.types = [] self.__rec_map = dict([((recType.typ, recType.sub), recType) for recType in types]) - + def before_header(self, dataSource, header): StreamIndexer.before_header(self, dataSource, header) self.indexes.append(self.position) key = (self.header.typ, self.header.sub) rectype = self.__rec_map.get(key, UnknownRecord(*key)) self.types.append(rectype) - + class MaterialMapper(MaterialIndexer): indexable_types = set([V4.wir, V4.wrr, V4.pir, V4.prr, V4.ptr, V4.mpr, V4.ftr]) per_part_types = set([V4.pir, V4.prr, V4.ptr, V4.mpr, V4.ftr]) - + def before_begin(self, dataSource): MaterialIndexer.before_begin(self, dataSource) self.waferid = [] self.insertionid = [] self.partid = [] - + def before_send(self, dataSource, data): MaterialIndexer.before_send(self, dataSource, data) rectype, rec = data @@ -62,12 +62,12 @@ def before_send(self, dataSource, data): self.waferid.append(None) self.insertionid.append(None) self.partid.append(None) - + if __name__ == '__main__': from pystdf.IO import Parser from pystdf.Writers import AtdfWriter import pystdf.V4 - + filename, = sys.argv[1:] f = open(filename, 'rb') p=Parser(inp=f) @@ -75,7 +75,6 @@ def before_send(self, dataSource, data): p.addSink(record_mapper) p.parse() f.close() - + for index, rectype in zip(record_mapper.indexes, record_mapper.types): - print index, rectype - + print(index, rectype) diff --git a/pystdf/V4.py b/pystdf/V4.py index 5733bff..e202529 100644 --- a/pystdf/V4.py +++ b/pystdf/V4.py @@ -6,12 +6,12 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -111,7 +111,7 @@ import pdb -class Far(RecordType): +class Far(RecordType, metaclass=StdfRecordMeta): """ **File Attributes Record (FAR)** @@ -158,15 +158,14 @@ class Far(RecordType): Location: Required as the first record of the file. """ - __metaclass__ = StdfRecordMeta typ = 0 sub = 10 fieldMap = ( ('CPU_TYPE', 'U1'), ('STDF_VER', 'U1') ) - -class Atr(RecordType): + +class Atr(RecordType, metaclass=StdfRecordMeta): """ **Audit Trail Record (ATR)** @@ -202,7 +201,6 @@ class Atr(RecordType): Possible Use: Determining whether a particular filter has been applied to the data. """ - __metaclass__ = StdfRecordMeta typ = 0 sub = 20 fieldMap = ( @@ -210,7 +208,7 @@ class Atr(RecordType): ('CMD_LINE', 'Cn') ) -class Mir(RecordType): +class Mir(RecordType, metaclass=StdfRecordMeta): """ **Master Information Record (MIR)** @@ -278,7 +276,6 @@ class Mir(RecordType): Possible Use: Header information for all reports """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 10 fieldMap = ( @@ -322,7 +319,7 @@ class Mir(RecordType): ('SUPR_NAM', 'Cn') ) -class Mrr(RecordType): +class Mrr(RecordType, metaclass=StdfRecordMeta): """ **Master Results Record (MRR)** @@ -371,7 +368,6 @@ class Mrr(RecordType): Repair Report ========================= ============================ """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 20 fieldMap = ( @@ -381,7 +377,7 @@ class Mrr(RecordType): ('EXC_DESC', 'Cn') ) -class Pcr(RecordType): +class Pcr(RecordType, metaclass=StdfRecordMeta): """ **Part Count Record (PCR)** @@ -433,7 +429,6 @@ class Pcr(RecordType): Site Summary Sheet Report for Lot Tracking System ========================= ============================== """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 30 fieldMap = ( @@ -446,7 +441,7 @@ class Pcr(RecordType): ('FUNC_CNT','U4') ) -class Hbr(RecordType): +class Hbr(RecordType, metaclass=StdfRecordMeta): """ **Hardware Bin Record (HBR)** @@ -505,7 +500,6 @@ class Hbr(RecordType): Site Summary Sheet Report for Lot Tracking System ===================== ============================== """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 40 fieldMap = ( @@ -517,7 +511,7 @@ class Hbr(RecordType): ('HBIN_NAM','Cn') ) -class Sbr(RecordType): +class Sbr(RecordType, metaclass=StdfRecordMeta): """ **Software Bin Record (SBR)** @@ -573,7 +567,6 @@ class Sbr(RecordType): Site Summary Sheet Report for Lot Tracking System ===================== ================================ """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 50 fieldMap = ( @@ -585,7 +578,7 @@ class Sbr(RecordType): ('SBIN_NAM','Cn') ) -class Pmr(RecordType): +class Pmr(RecordType, metaclass=StdfRecordMeta): """ **Pin Map Record (PMR)** @@ -642,7 +635,6 @@ class Pmr(RecordType): * Functional Datalog * Functional Histogram """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 60 fieldMap = ( @@ -655,7 +647,7 @@ class Pmr(RecordType): ('SITE_NUM','U1') ) -class Pgr(RecordType): +class Pgr(RecordType, metaclass=StdfRecordMeta): """ **Pin Group Record (PGR)** @@ -695,7 +687,6 @@ class Pgr(RecordType): Possible Use: Functional Datalog """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 62 fieldMap = ( @@ -705,7 +696,7 @@ class Pgr(RecordType): ('PMR_INDX','k2U2') ) -class Plr(RecordType): +class Plr(RecordType, metaclass=StdfRecordMeta): """ **Pin List Record (PLR)** @@ -801,7 +792,6 @@ class Plr(RecordType): Possible Use: Functional Datalog """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 63 fieldMap = ( @@ -815,7 +805,7 @@ class Plr(RecordType): ('RTN_CHAL','k0Cn') ) -class Rdr(RecordType): +class Rdr(RecordType, metaclass=StdfRecordMeta): """ **Retest Data Record (RDR)** @@ -854,7 +844,6 @@ class Rdr(RecordType): Possible Use: Tells data filtering programs how to handle retest data. """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 70 fieldMap = ( @@ -862,7 +851,7 @@ class Rdr(RecordType): ('RTST_BIN','k0U2') ) -class Sdr(RecordType): +class Sdr(RecordType, metaclass=StdfRecordMeta): """ **Site Description Record (SDR)** @@ -927,7 +916,6 @@ class Sdr(RecordType): Possible Use: Correlation of yield to interface or peripheral equipment """ - __metaclass__ = StdfRecordMeta typ = 1 sub = 80 fieldMap = ( @@ -953,7 +941,7 @@ class Sdr(RecordType): ('EXTR_ID','Cn') ) -class Wir(RecordType): +class Wir(RecordType, metaclass=StdfRecordMeta): """ **Wafer Information Record (WIR)** @@ -1000,7 +988,6 @@ class Wir(RecordType): * Datalog * Wafer Map """ - __metaclass__ = StdfRecordMeta typ = 2 sub = 10 fieldMap = ( @@ -1010,7 +997,7 @@ class Wir(RecordType): ('WAFER_ID','Cn') ) -class Wrr(RecordType): +class Wrr(RecordType, metaclass=StdfRecordMeta): """ **Wafer Results Record (WRR)** @@ -1076,7 +1063,6 @@ class Wrr(RecordType): * Datalog * Wafer Map """ - __metaclass__ = StdfRecordMeta typ = 2 sub = 20 fieldMap = ( @@ -1096,7 +1082,7 @@ class Wrr(RecordType): ('EXC_DESC','Cn') ) -class Wcr(RecordType): +class Wcr(RecordType, metaclass=StdfRecordMeta): """ **Wafer Configuration Record (WCR)** @@ -1142,7 +1128,6 @@ class Wcr(RecordType): CENTER_X, CENTER_Y: Use the value -32768 to indicate that the field is invalid. """ - __metaclass__ = StdfRecordMeta typ = 2 sub = 30 fieldMap = ( @@ -1157,7 +1142,7 @@ class Wcr(RecordType): ('POS_Y','C1') ) -class Pir(RecordType): +class Pir(RecordType, metaclass=StdfRecordMeta): """ **Part Information Record (PIR)** @@ -1197,7 +1182,6 @@ class Pir(RecordType): Possible Use: Datalog """ - __metaclass__ = StdfRecordMeta typ = 5 sub = 10 fieldMap = ( @@ -1205,7 +1189,7 @@ class Pir(RecordType): ('SITE_NUM','U1') ) -class Prr(RecordType): +class Prr(RecordType, metaclass=StdfRecordMeta): """ **Part Results Record (PRR)** @@ -1320,7 +1304,6 @@ class Prr(RecordType): * Shmoo Plot * Repair Data """ - __metaclass__ = StdfRecordMeta typ = 5 sub = 20 fieldMap = ( @@ -1338,7 +1321,7 @@ class Prr(RecordType): ('PART_FIX','Bn') ) -class Tsr(RecordType): +class Tsr(RecordType, metaclass=StdfRecordMeta): """ **Test Synopsis Record (TSR)** @@ -1420,7 +1403,6 @@ class Tsr(RecordType): Wafer Map Functional Histogram ====================== ====================== """ - __metaclass__ = StdfRecordMeta typ = 10 sub = 30 fieldMap = ( @@ -1442,7 +1424,7 @@ class Tsr(RecordType): ('TST_SQRS','R4') ) -class Ptr(RecordType): +class Ptr(RecordType, metaclass=StdfRecordMeta): """ **Parametric Test Record (PTR)** @@ -1670,7 +1652,6 @@ class Ptr(RecordType): * Histogram * Wafer Map """ - __metaclass__ = StdfRecordMeta typ = 15 sub = 10 fieldMap = ( @@ -1696,7 +1677,7 @@ class Ptr(RecordType): ('HI_SPEC','R4') ) -class Mpr(RecordType): +class Mpr(RecordType, metaclass=StdfRecordMeta): """ **Multiple-Result Parametric Record (MPR)** @@ -1934,7 +1915,6 @@ class Mpr(RecordType): * Datalog * Shmoo Plot """ - __metaclass__ = StdfRecordMeta typ = 15 sub = 15 fieldMap = ( @@ -1967,7 +1947,7 @@ class Mpr(RecordType): ('HI_SPEC','R4') ) -class Ftr(RecordType): +class Ftr(RecordType, metaclass=StdfRecordMeta): """ **Functional Test Record (FTR)** @@ -2215,7 +2195,6 @@ class Ftr(RecordType): * Functional Histogram * Functional Failure Analyzer """ - __metaclass__ = StdfRecordMeta typ = 15 sub = 20 fieldMap = ( @@ -2249,7 +2228,7 @@ class Ftr(RecordType): ('SPIN_MAP','Dn') ) -class Bps(RecordType): +class Bps(RecordType, metaclass=StdfRecordMeta): """ **Begin Program Section Record (BPS)** @@ -2276,14 +2255,13 @@ class Bps(RecordType): Possible Use: When performing analyses on a particular program segment's test. """ - __metaclass__ = StdfRecordMeta typ = 20 sub = 10 fieldMap = ( ('SEQ_NAME','Cn'), ) -class Eps(RecordType): +class Eps(RecordType, metaclass=StdfRecordMeta): """ **End Program Section Record (EPS)** @@ -2321,12 +2299,11 @@ class Eps(RecordType): Because an EPS record does not contain the name of the sequencer, it should be assumed that each EPS record matches the last unmatched BPS record. """ - __metaclass__ = StdfRecordMeta typ = 20 sub = 20 fieldMap = () -class Gdr(RecordType): +class Gdr(RecordType, metaclass=StdfRecordMeta): """ **Generic Data Record (GDR)** @@ -2434,14 +2411,13 @@ class Gdr(RecordType): Possible Use: User-written reports """ - __metaclass__ = StdfRecordMeta typ = 50 sub = 10 fieldMap = ( ('GEN_DATA', 'Vn'), ) -class Dtr(RecordType): +class Dtr(RecordType, metaclass=StdfRecordMeta): """ **Datalog Text Record (DTR)** @@ -2472,7 +2448,6 @@ class Dtr(RecordType): Possible Use: * Datalog """ - __metaclass__ = StdfRecordMeta typ = 50 sub = 30 fieldMap = ( diff --git a/pystdf/__init__.py b/pystdf/__init__.py index 26a689e..9e3424e 100644 --- a/pystdf/__init__.py +++ b/pystdf/__init__.py @@ -6,20 +6,20 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -from TableTemplate import TableTemplate +from pystdf.TableTemplate import TableTemplate -from BinSummarizer import BinSummarizer -from ParametricSummarizer import ParametricSummarizer -from PartSummarizer import PartSummarizer -from Indexing import * +from pystdf.BinSummarizer import BinSummarizer +from pystdf.ParametricSummarizer import ParametricSummarizer +from pystdf.PartSummarizer import PartSummarizer +from pystdf.Indexing import * diff --git a/scripts/rec_index b/scripts/rec_index index 4ba3caf..e6b4e64 100644 --- a/scripts/rec_index +++ b/scripts/rec_index @@ -1,23 +1,24 @@ #!/usr/bin/env python -# -# PySTDF - The Pythonic STDF Parser -# Copyright (C) 2006 Casey Marshall -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# +# +# PySTDF - The Pythonic STDF Parser +# Copyright (C) 2006 Casey Marshall +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +from __future__ import print_function import sys, os, re try: @@ -49,31 +50,31 @@ bz2Pattern = re.compile('\.bz2', re.I) def process_file(fn): filename, = sys.argv[1:] - + reopen_fn = None if filename is None: f = sys.stdin elif gzPattern.search(filename): if not have_gzip: - print >>sys.stderr, "gzip is not supported on this system" + print("gzip is not supported on this system", file=sys.stderr) sys.exit(1) reopen_fn = lambda: gzip.open(filename, 'rb') f = reopen_fn() elif bz2Pattern.search(filename): if not have_bz2: - print >>sys.stderr, "bz2 is not supported on this system" + print("bz2 is not supported on this system", file=sys.stderr) sys.exit(1) reopen_fn = lambda: bz2.BZ2File(filename, 'rb') f = reopen_fn() else: f = open(filename, 'rb') p=Parser(inp=f, reopen_fn=reopen_fn) - p.addSink(IndexRecords()) + p.addSink(RecordIndexer()) p.parse() f.close() if __name__ == "__main__": if len(sys.argv) < 2: - print "Usage: %s " % (sys.argv[0]) + print("Usage: %s " % (sys.argv[0])) else: process_file(sys.argv[1]) diff --git a/scripts/stdf2atdf b/scripts/stdf2atdf index 84bb364..25a0095 100644 --- a/scripts/stdf2atdf +++ b/scripts/stdf2atdf @@ -1,23 +1,24 @@ #!/usr/bin/env python -# -# PySTDF - The Pythonic STDF Parser -# Copyright (C) 2006 Casey Marshall -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# +# +# PySTDF - The Pythonic STDF Parser +# Copyright (C) 2006 Casey Marshall +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +from __future__ import print_function import sys, re try: @@ -40,19 +41,19 @@ bz2Pattern = re.compile('\.bz2', re.I) def process_file(fn): filename, = sys.argv[1:] - + reopen_fn = None if filename is None: f = sys.stdin elif gzPattern.search(filename): if not have_gzip: - print >>sys.stderr, "gzip is not supported on this system" + print("gzip is not supported on this system", file=sys.stderr) sys.exit(1) reopen_fn = lambda: gzip.open(filename, 'rb') f = reopen_fn() elif bz2Pattern.search(filename): if not have_bz2: - print >>sys.stderr, "bz2 is not supported on this system" + print("bz2 is not supported on this system", file=sys.stderr) sys.exit(1) reopen_fn = lambda: bz2.BZ2File(filename, 'rb') f = reopen_fn() @@ -65,6 +66,6 @@ def process_file(fn): if __name__ == "__main__": if len(sys.argv) < 2: - print "Usage: %s " % (sys.argv[0]) + print("Usage: %s " % (sys.argv[0])) else: process_file(sys.argv[1]) diff --git a/scripts/stdf2xml b/scripts/stdf2xml index febc63b..cc350b3 100644 --- a/scripts/stdf2xml +++ b/scripts/stdf2xml @@ -7,17 +7,18 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # +from __future__ import print_function import sys, re try: @@ -40,19 +41,19 @@ bz2Pattern = re.compile('\.bz2', re.I) def process_file(fn): filename, = sys.argv[1:] - + reopen_fn = None if filename is None: f = sys.stdin elif gzPattern.search(filename): if not have_gzip: - print >>sys.stderr, "gzip is not supported on this system" + print("gzip is not supported on this system", file=sys.stderr) sys.exit(1) reopen_fn = lambda: gzip.open(filename, 'rb') f = reopen_fn() elif bz2Pattern.search(filename): if not have_bz2: - print >>sys.stderr, "bz2 is not supported on this system" + print("bz2 is not supported on this system", file=sys.stderr) sys.exit(1) reopen_fn = lambda: bz2.BZ2File(filename, 'rb') f = reopen_fn() @@ -65,6 +66,6 @@ def process_file(fn): if __name__ == "__main__": if len(sys.argv) < 2: - print "Usage: %s " % (sys.argv[0]) + print("Usage: %s " % (sys.argv[0])) else: process_file(sys.argv[1]) diff --git a/scripts/stdf_slice b/scripts/stdf_slice index 13af8d7..5d4a0d2 100644 --- a/scripts/stdf_slice +++ b/scripts/stdf_slice @@ -1,22 +1,22 @@ #!/usr/bin/env python -# -# PySTDF - The Pythonic STDF Parser -# Copyright (C) 2006 Casey Marshall -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# +# +# PySTDF - The Pythonic STDF Parser +# Copyright (C) 2006 Casey Marshall +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# from pystdf.IO import Parser from pystdf.Mapping import * @@ -26,7 +26,7 @@ if __name__ == '__main__': filename, start, count = sys.argv[1:4] start = int(start) count = int(count) - + f = open(filename, 'rb') p=Parser(inp=f) record_mapper = StreamMapper()