annotate commons/core/parsing/MrepsToSet.py @ 58:5f5c9b74c2dd

Uploaded
author m-zytnicki
date Fri, 07 Feb 2014 11:53:36 -0500
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 from commons.core.parsing.FindRep import FindRep
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 from xml.sax import make_parser
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 from xml.sax.handler import feature_namespaces
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 import os
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7 class MrepsToSet(object):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 def __init__(self, mrepsInputFileName="", mrepsOuputFileName="", outputFileName=None, errorFilter=0):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 self._mrepsInputFileName = mrepsInputFileName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 self._mrepsOuputFileName = mrepsOuputFileName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 self._outputFileName = outputFileName or "%s.Mreps.set" % mrepsOuputFileName
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 self._errorFilter = errorFilter
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 def run(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 xmlParser = make_parser()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 xmlParser.setFeature( feature_namespaces, 0 )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 xmlParser.setContentHandler( FindRep( self._outputFileName, self._errorFilter, 0 ) )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 xmlParser.parse( self._mrepsOuputFileName )
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 def clean( self ):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 Remove the output file (xml) from Mreps to keep only the 'set' file.
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24 """
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 if os.path.exists(self._mrepsOuputFileName):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 os.remove(self._mrepsOuputFileName)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31