Skip to content

Commit

Permalink
argparse migration for DataFormats/FWLite
Browse files Browse the repository at this point in the history
  • Loading branch information
kpedro88 committed Oct 24, 2023
1 parent aa04564 commit b4dc251
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
2 changes: 0 additions & 2 deletions DataFormats/FWLite/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#! /usr/bin/env python

from __future__ import print_function
import ROOT
import inspect
import sys
import optparse
from FWCore.ParameterSet.VarParsing import VarParsing
from builtins import int

Expand Down
25 changes: 10 additions & 15 deletions DataFormats/FWLite/scripts/edmLumisInFiles.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
#! /usr/bin/env python3

from __future__ import print_function
from FWCore.PythonUtilities.LumiList import LumiList
import optparse

from FWCore.PythonUtilities.LumiList import LumiList
from argparse import ArgumentParser

if __name__ == '__main__':

parser = optparse.OptionParser ("Usage: %prog [--options] edm1.root [edm2.root...]",
description='Runs over input EDM files and prints out a list of contained lumi sections')
parser.add_option ('--intLumi', dest='intLumi', action='store_true',
help='print out total recorded and delivered integrated luminosity')
parser.add_option ('--output', dest='output', type='string',
help='save lumi sections output to file OUTPUT')
(options, args) = parser.parse_args()
parser = ArgumentParser(description='Runs over input EDM files and prints out a list of contained lumi sections')
parser.add_argument('--intLumi', dest='intLumi', action='store_true',
help='print out total recorded and delivered integrated luminosity')
parser.add_argument('--output', dest='output', type=str,
help='save lumi sections output to file OUTPUT')
parser.add_argument("edm", metavar="edm.root", type=str, nargs='+')
options = parser.parse_args()
# put this here after parsing the arguments since ROOT likes to
# grab command line arguments even when it shouldn't.
from DataFormats.FWLite import Lumis, Handle
if not args:
raise RuntimeError("Must provide at least one input file")

# do we want to get the luminosity summary?
if options.intLumi:
Expand All @@ -28,7 +23,7 @@
handle, lable = None, None

runsLumisDict = {}
lumis = Lumis (args)
lumis = Lumis (options.edm)
delivered = recorded = 0
for lum in lumis:
runList = runsLumisDict.setdefault (lum.aux().run(), [])
Expand Down
1 change: 0 additions & 1 deletion DataFormats/FWLite/test/chainEvent_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import print_function
from builtins import range
from DataFormats.FWLite import Events, Handle
import optparse

print("starting python test")

Expand Down

0 comments on commit b4dc251

Please sign in to comment.