Mercurial > p > roundup > code
diff roundup/admin.py @ 2072:cc692b8b8fa9 maint-0.6
back-port template renaming fix
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 05 Mar 2004 00:06:20 +0000 |
| parents | 3d7bb1659d73 |
| children | 332c040b82da |
line wrap: on
line diff
--- a/roundup/admin.py Fri Mar 05 00:04:03 2004 +0000 +++ b/roundup/admin.py Fri Mar 05 00:06:20 2004 +0000 @@ -16,7 +16,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: admin.py,v 1.55.2.2 2003-08-29 12:45:54 richard Exp $ +# $Id: admin.py,v 1.55.2.3 2004-03-05 00:06:20 richard Exp $ '''Administration commands for maintaining Roundup trackers. ''' @@ -298,7 +298,7 @@ path = os.path.dirname(path) tdir = os.path.join(path, 'share', 'roundup', 'templates') if os.path.isdir(tdir): - templates = listTemplates(tdir) + templates = init.listTemplates(tdir) break # OK, now try as if we're in the roundup source distribution @@ -309,13 +309,13 @@ path = os.path.dirname(path) tdir = os.path.join(path, 'templates') if os.path.isdir(tdir): - templates.update(listTemplates(tdir)) + templates.update(init.listTemplates(tdir)) # Try subdirs of the current dir - templates.update(listTemplates(os.getcwd())) + templates.update(init.listTemplates(os.getcwd())) # Finally, try the current directory as a template - template = loadTemplate(os.getcwd()) + template = init.loadTemplateInfo(os.getcwd()) if template: templates[template['name']] = template @@ -1407,40 +1407,6 @@ self.db.close() -def listTemplates(dir): - ''' List all the Roundup template directories in a given directory. - - Find all the dirs that contain a TEMPLATE-INFO.txt and parse it. - - Return a list of dicts of info about the templates. - ''' - ret = {} - for idir in os.listdir(dir): - idir = os.path.join(dir, idir) - ti = loadTemplate(idir) - if ti: - ret[ti['name']] = ti - return ret - -def loadTemplate(dir): - ''' Attempt to load a Roundup template from the indicated directory. - - Return None if there's no template, otherwise a template info - dictionary. - ''' - ti = os.path.join(dir, 'TEMPLATE-INFO.txt') - if not os.path.exists(ti): - return None - - # load up the template's information - m = rfc822.Message(open(ti)) - ti = {} - ti['name'] = m['name'] - ti['description'] = m['description'] - ti['intended-for'] = m['intended-for'] - ti['path'] = dir - return ti - if __name__ == '__main__': tool = AdminTool() sys.exit(tool.main())
