コード例 #1
0
ファイル: gitdm.py プロジェクト: zyfjeff/gitdm
def ParseOpts():
    global MapUnknown, DevReports
    global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB
    global CFName, CSVFile, CSVPrefix, DirName, Aggregate, Numstat
    global ReportByFileType, ReportUnknowns

    opts, rest = getopt.getopt(sys.argv[1:], 'ab:dc:Dh:l:no:p:r:stUuwx:yz')
    for opt in opts:
        if opt[0] == '-a':
            AkpmOverLt = 1
        elif opt[0] == '-b':
            DirName = opt[1]
        elif opt[0] == '-c':
            CFName = opt[1]
        elif opt[0] == '-d':
            DevReports = 0
        elif opt[0] == '-D':
            DateStats = 1
        elif opt[0] == '-h':
            reports.SetHTMLOutput(open(opt[1], 'w'))
        elif opt[0] == '-l':
            reports.SetMaxList(int(opt[1]))
        elif opt[0] == '-n':
            Numstat = 1
        elif opt[0] == '-o':
            reports.SetOutput(open(opt[1], 'w'))
        elif opt[0] == '-p':
            CSVPrefix = opt[1]
        elif opt[0] == '-r':
            print 'Filter on "%s"' % (opt[1])
            FileFilter = re.compile(opt[1])
        elif opt[0] == '-s':
            AuthorSOBs = 0
        elif opt[0] == '-t':
            ReportByFileType = 1
        elif opt[0] == '-u':
            MapUnknown = 1
        elif opt[0] == '-U':
            ReportUnknowns = True
        elif opt[0] == '-x':
            CSVFile = open(opt[1], 'w')
            print "open output file " + opt[1] + "\n"
        elif opt[0] == '-w':
            Aggregate = 'week'
        elif opt[0] == '-y':
            Aggregate = 'year'
        elif opt[0] == '-z':
            DumpDB = 1
コード例 #2
0
ファイル: lpdm.py プロジェクト: zyfjeff/gitdm
def ParseOpts ():
    global MapUnknown, DevReports
    global DumpDB
    global CFName, DirName, Aggregate

    opts, rest = getopt.getopt (sys.argv[1:], 'b:dc:h:l:o:uz')
    for opt in opts:
        if opt[0] == '-b':
            DirName = opt[1]
        elif opt[0] == '-c':
            CFName = opt[1]
        elif opt[0] == '-d':
            DevReports = 0
        elif opt[0] == '-h':
            reports.SetHTMLOutput (open (opt[1], 'w'))
        elif opt[0] == '-l':
            reports.SetMaxList (int (opt[1]))
        elif opt[0] == '-o':
            reports.SetOutput (open (opt[1], 'w'))
        elif opt[0] == '-u':
            MapUnknown = 1
        elif opt[0] == '-z':
            DumpDB = 1
コード例 #3
0
def ParseOpts():
    global MapUnknown, DevReports, FileStats
    global DateStats, AuthorSOBs, FileFilter, InvertFilter, DumpDB
    global CFName, CSVFile, CSVPrefix, DirName, Aggregate, Numstat
    global ReportByFileType, ReportUnknowns, AffFile, ReportAll
    global InputData, InputDataIsFile, DebugHalt, DateFrom, DateTo

    opts, rest = getopt.getopt(sys.argv[1:],
                               'a:i:I:b:dc:Dh:l:no:p:r:stAUumwx:yzXf:e:R')
    for opt in opts:
        if opt[0] == '-b':
            DirName = opt[1]
        elif opt[0] == '-c':
            CFName = opt[1]
        elif opt[0] == '-d':
            DevReports = 0
        elif opt[0] == '-D':
            DateStats = 1
        elif opt[0] == '-h':
            reports.SetHTMLOutput(open(opt[1], 'w'))
        elif opt[0] == '-l':
            reports.SetMaxList(int(opt[1]))
        elif opt[0] == '-n':
            Numstat = 1
        elif opt[0] == '-o':
            reports.SetOutput(open(opt[1], 'w'))
        elif opt[0] == '-p':
            CSVPrefix = opt[1]
        elif opt[0] == '-R':
            InvertFilter = True
        elif opt[0] == '-r':
            print 'Filter on "%s"' % (opt[1])
            FileFilter = re.compile(opt[1])
        elif opt[0] == '-s':
            AuthorSOBs = 0
        elif opt[0] == '-t':
            ReportByFileType = 1
        elif opt[0] == '-m':
            MapUnknown = 1
        elif opt[0] == '-u':
            MapUnknown = 2
        elif opt[0] == '-U':
            ReportUnknowns = True
        elif opt[0] == '-A':
            ReportAll = True
        elif opt[0] == '-I':
            FileStats = open(opt[1], 'w')
            print "Save all file statistics in " + opt[1] + "\n"
        elif opt[0] == '-x':
            CSVFile = open(opt[1], 'w')
            print "Open output file " + opt[1] + "\n"
        elif opt[0] == '-a':
            AffFile = open(opt[1], 'w')
            print "Save all affiliations in " + opt[1] + "\n"
        elif opt[0] == '-w':
            Aggregate = 'week'
        elif opt[0] == '-y':
            Aggregate = 'year'
        elif opt[0] == '-z':
            DumpDB = 1
        elif opt[0] == '-X':
            DebugHalt = True
        elif opt[0] == '-f':
            DateFrom = datetime.datetime.strptime(opt[1], '%Y-%m-%d')
        elif opt[0] == '-e':
            DateTo = datetime.datetime.strptime(opt[1], '%Y-%m-%d')
        elif opt[0] == '-i':
            try:
                InputData = open(opt[1], 'r')
                InputDataIsFile = True
            except IOError:
                print "Cannot open input file: " + opt[1] + "\n"
                sys.exit(1)