Add option to get the configuration files from a given base directory

Instead boringly be replicating the directory base name where gitdm is
installed and write it on each option inside the configuration file, just send
it through the command line.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
This commit is contained in:
Tiago Vignatti
2010-06-30 20:13:21 +03:00
parent 03238ecf17
commit a91d5f59e5
3 changed files with 15 additions and 7 deletions

View File

@@ -95,7 +95,8 @@ def ReadGroupMap (fname, employer):
# #
# Read an overall config file. # Read an overall config file.
# #
def ConfigFile (name):
def ConfigFile (name, confdir):
try: try:
file = open (name, 'r') file = open (name, 'r')
except IOError: except IOError:
@@ -106,13 +107,13 @@ def ConfigFile (name):
if len (sline) < 2: if len (sline) < 2:
croak ('Funky config line: "%s"' % (line)) croak ('Funky config line: "%s"' % (line))
if sline[0] == 'EmailAliases': if sline[0] == 'EmailAliases':
ReadEmailAliases (sline[1]) ReadEmailAliases (confdir + sline[1])
elif sline[0] == 'EmailMap': elif sline[0] == 'EmailMap':
ReadEmailEmployers (sline[1]) ReadEmailEmployers (confdir + sline[1])
elif sline[0] == 'GroupMap': elif sline[0] == 'GroupMap':
if len (sline) != 3: if len (sline) != 3:
croak ('Funky group map line "%s"' % (line)) croak ('Funky group map line "%s"' % (line))
ReadGroupMap (sline[1], sline[2]) ReadGroupMap (confdir + sline[1], sline[2])
else: else:
croak ('Unrecognized config line: "%s"' % (line)) croak ('Unrecognized config line: "%s"' % (line))
line = ReadConfigLine (file) line = ReadConfigLine (file)

2
README
View File

@@ -26,6 +26,8 @@ be:
-a If a patch contains signoff lines from both Andrew Morton -a If a patch contains signoff lines from both Andrew Morton
and Linus Torvalds, omit Linus's. and Linus Torvalds, omit Linus's.
-b dir Specify the base directory to fetch the configuration files.
-c file Specify the name of the gitdm configuration file. -c file Specify the name of the gitdm configuration file.
By default, "./gitdm.config" is used. By default, "./gitdm.config" is used.

11
gitdm
View File

@@ -35,10 +35,13 @@ CSVFile = None
AkpmOverLt = 0 AkpmOverLt = 0
DumpDB = 0 DumpDB = 0
CFName = 'gitdm.config' CFName = 'gitdm.config'
DirName = ''
# #
# Options: # Options:
# #
# -a Andrew Morton's signoffs shadow Linus's # -a Andrew Morton's signoffs shadow Linus's
# -b dir Specify the base directory to fetch the configuration files
# -c cfile Specify a configuration file # -c cfile Specify a configuration file
# -d Output individual developer stats # -d Output individual developer stats
# -D Output date statistics # -D Output date statistics
@@ -54,12 +57,14 @@ CFName = 'gitdm.config'
def ParseOpts (): def ParseOpts ():
global MapUnknown, DevReports global MapUnknown, DevReports
global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB global DateStats, AuthorSOBs, FileFilter, AkpmOverLt, DumpDB
global CFName, CSVFile global CFName, CSVFile, DirName
opts, rest = getopt.getopt (sys.argv[1:], 'adc:Dh:l:o:r:sux:z') opts, rest = getopt.getopt (sys.argv[1:], 'ab:dc:Dh:l:o:r:sux:z')
for opt in opts: for opt in opts:
if opt[0] == '-a': if opt[0] == '-a':
AkpmOverLt = 1 AkpmOverLt = 1
elif opt[0] == '-b':
DirName = opt[1]
elif opt[0] == '-c': elif opt[0] == '-c':
CFName = opt[1] CFName = opt[1]
elif opt[0] == '-d': elif opt[0] == '-d':
@@ -302,7 +307,7 @@ ParseOpts ()
# #
# Read the config files. # Read the config files.
# #
ConfigFile.ConfigFile (CFName) ConfigFile.ConfigFile (CFName, DirName)
# #
# Let's pre-seed the database with a couple of hackers # Let's pre-seed the database with a couple of hackers