Skip to content

Commit

Permalink
argparse migration for PhysicsTools/PythonAnalysis (& cleanup)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpedro88 committed Oct 24, 2023
1 parent b4dc251 commit 808f8d9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 121 deletions.
6 changes: 3 additions & 3 deletions PhysicsTools/PythonAnalysis/python/diffProv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class difference :

def __init__(self,v):
self.verbose = v
self.verbose = int(v)
self._diffprocess=[]
self._sameprocess=()
def list_diff(self,aList1, aList2, string1, string2):
Expand All @@ -14,7 +14,7 @@ def list_diff(self,aList1, aList2, string1, string2):
for j in range(2,len(aList2)):
if (i==j) and (aList1[i]!=aList2[j]):
if aList1[i][:(aList1[i].index('=')+1)] == aList2[j][:(aList2[j].index('=')+1)]:
if self.verbose==str(2) or self.verbose==str(1):
if self.verbose==2 or self.verbose==1:
str1 = aList1[i][2:aList1[i].index('=')+1] + aList1[i][aList1[i].index('=')+1:]+' ['+ string1+']'
str2 = len(aList1[i][2:aList1[i].index('=')+1])*' '+aList2[j][aList2[j].index('=')+1:]+' ['+string2+']'
print(str1,'\n',str2,'\n')
Expand Down Expand Up @@ -80,7 +80,7 @@ def onefilemodules(self,module1,module2,string):
for name, value in module1[i] :
if (name not in labelList2):
print('Process: '+'"'+i+'"'+'\n'+'Module: '+'"'+name+'"')
if self.verbose==str(2):
if self.verbose==2:
for k in value[1:]:
print(k)

Expand Down
53 changes: 0 additions & 53 deletions PhysicsTools/PythonAnalysis/python/diff_provenance.py

This file was deleted.

47 changes: 0 additions & 47 deletions PhysicsTools/PythonAnalysis/python/read_provenance.py

This file was deleted.

28 changes: 11 additions & 17 deletions PhysicsTools/PythonAnalysis/scripts/edmProvDiff
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
#
# author: Annapaola de Cosa

from optparse import OptionParser
from argparse import ArgumentParser
import sys
from subprocess import Popen, PIPE, STDOUT
from PhysicsTools.PythonAnalysis.readProv import *
from PhysicsTools.PythonAnalysis.diffProv import *


usage = "usage: %prog filename1 filename2"
parser = OptionParser(usage=usage, version="%prog 0.1")
parser.add_option("-v", "--verbosity_level", dest="verbose", help="[0] to print short message [1], to print details about the differences of modules common to both files, [2] to print all the details about the differences between the two files")
(options, args) = parser.parse_args()

if len(args) != 2:
parser.error('Please specify two EDM files to compare')
parser = ArgumentParser()
parser.add_argument('--version', action='version', version='%(prog)s 0.1')
parser.add_argument("-v", "--verbosity_level", dest="verbose", choices=(0,1,2), help="[0] to print short message [1], to print details about the differences of modules common to both files, [2] to print all the details about the differences between the two files")
parser.add_argument("filename1",type=str)
parser.add_argument("filename2",type=str)
options = parser.parse_args()

def provenance(args):
cmd="edmProvDump "+args
Expand All @@ -37,15 +35,11 @@ def provenance(args):
file.write(provenance)

return s
try:
prov1=provenance(args[0])
prov2=provenance(args[1])
except IndexError:
print "Specify input file names\nType 'edmProvDiff -h' to visualize the arguments needed"

prov1=provenance(options.filename1)
prov2=provenance(options.filename2)
f=filereader()
module1=f.readfile(prov1)
module2=f.readfile(prov2)
d=difference(options.verbose)
d.module_diff(module1,module2,args[0],args[1])


d.module_diff(module1,module2,options.filename1,options.filename2)
2 changes: 1 addition & 1 deletion PhysicsTools/PythonAnalysis/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class testEdmProvDiff(unittest.TestCase):

def setUp(self):
self._r=filereader()
self._d=difference(str(2))
self._d=difference(2)

def testStartswith(self):
""" Check the method startswith() of class filereader
Expand Down

0 comments on commit 808f8d9

Please sign in to comment.