Ticket #217: parentdir.diff
File parentdir.diff, 2.0 KB (added by sto@…, 14 years ago) |
---|
-
email2trac.py.in
old new 41 41 [DEFAULT] # REQUIRED 42 42 project : /data/trac/test # REQUIRED 43 43 debug : 1 # OPTIONAL, if set print some DEBUG info 44 parentdir : /data/trac # OPTIONAL, if set used for projects without section 45 # (their project would be: /data/trac/$PROJECT) 44 46 45 47 [jouvin] # OPTIONAL project declaration, if set both fields necessary 46 48 project : /data/trac/jouvin # use -p|--project jouvin. … … 2061 2063 2062 2064 config = trac_config.Configuration(file) 2063 2065 2066 # Read the PARENT_DIR 2067 parentdir = config.get('DEFAULT', 'parentdir') 2068 2064 2069 ## Use given project name else use defaults 2065 2070 # 2066 2071 if name: 2067 2072 sections = config.sections() 2068 2073 if not name in sections: 2069 print "Not a valid project name: %s" %name 2070 print "Valid names: %s" %sections 2071 sys.exit(1) 2072 2073 project = SaraDict() 2074 for option, value in config.options(name): 2075 try: 2076 project[option] = int(value) 2077 except ValueError: 2078 project[option] = value 2074 if not parentdir or parentdir=="": 2075 print "Not a valid project name: %s" %name 2076 print "Valid names: %s" %sections 2077 sys.exit(1) 2078 else: 2079 # Assume that there is a real project under the parentdir 2080 tmp = config.parser.defaults() 2081 project = SaraDict() 2082 for option, value in tmp.items(): 2083 try: 2084 project[option] = int(value) 2085 except ValueError: 2086 project[option] = value 2087 project['project'] = parentdir + '/' + name 2088 else: 2089 project = SaraDict() 2090 for option, value in config.options(name): 2091 try: 2092 project[option] = int(value) 2093 except ValueError: 2094 project[option] = value 2079 2095 2080 2096 else: 2081 2097 ## use some trac internals to get the defaults