Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: tools/tickprocessor.py

Issue 20452: Refactored command-line options handling in tick processor scripts (Closed)
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/linux-tick-processor.py ('k') | tools/windows-tick-processor.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/tickprocessor.py
diff --git a/tools/tickprocessor.py b/tools/tickprocessor.py
index bd432d21d5492ee0988046b59ec7e9c73f646e72..9459ae8c71db485bc1906dd846d2be2d49ecda90 100644
--- a/tools/tickprocessor.py
+++ b/tools/tickprocessor.py
@@ -27,7 +27,7 @@
import csv, splaytree, sys
from operator import itemgetter
-
+import getopt, os
class CodeEntry(object):
@@ -368,5 +368,49 @@ class TickProcessor(object):
'call_path' : stack[0] + ' <- ' + stack[1]
})
+
+class CmdLineProcessor(object):
+
+ def __init__(self):
+ # default values
+ self.state = None
+ self.ignore_unknown = False
+ self.log_file = None
+
+ def ProcessArguments(self):
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "jgco", ["js", "gc", "compiler", "other", "ignore-unknown"])
+ except getopt.GetoptError:
+ self.PrintUsageAndExit()
+ for key, value in opts:
+ if key in ("-j", "--js"):
+ self.state = 0
+ if key in ("-g", "--gc"):
+ self.state = 1
+ if key in ("-c", "--compiler"):
+ self.state = 2
+ if key in ("-o", "--other"):
+ self.state = 3
+ if key in ("--ignore-unknown"):
+ self.ignore_unknown = True
+ self.ProcessRequiredArgs(args)
+
+ def ProcessRequiredArgs(self, args):
+ return
+
+ def GetRequiredArgsNames(self):
+ return
+
+ def PrintUsageAndExit(self):
+ print('Usage: %(script_name)s --{js,gc,compiler,other} %(req_opts)s' % {
+ 'script_name': os.path.basename(sys.argv[0]),
+ 'req_opts': self.GetRequiredArgsNames()
+ })
+ sys.exit(2)
+
+ def RunLogfileProcessing(self, tick_processor):
+ tick_processor.ProcessLogfile(self.log_file, self.state, self.ignore_unknown)
+
+
if __name__ == '__main__':
sys.exit('You probably want to run windows-tick-processor.py or linux-tick-processor.py.')
« no previous file with comments | « tools/linux-tick-processor.py ('k') | tools/windows-tick-processor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698