-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
74 lines (58 loc) · 2.06 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# encoding: utf-8
"""
Copyright Russell Ferriday 2010
First release May 2010
This file is part of ATTUsageAnalysis.
ATTUsageAnalysis 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 3 of the License, or
(at your option) any later version.
ATTUsageAnalysis 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 ATTUsageAnalysis. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
import getopt
help_message = '''
The help message goes here.
'''
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
directory = ''
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "hd:v", ["help", "directory="])
except getopt.error, msg:
raise Usage(msg)
# option processing
for option, value in opts:
if option == "-v":
verbose = True
if option in ("-h", "--help"):
raise Usage(help_message)
if option in ("-d", "--directory"):
directory = value
from attusage import AttUsage
from report import Report, Directory
usage = AttUsage()
for filename in args:
usage.process(filename)
directory = Directory(directory)
report = Report(usage, directory=directory)
for line in report.text():
print line
except Usage, err:
print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
print >> sys.stderr, "\t for help use --help"
return 2
if __name__ == "__main__":
sys.exit(main())