summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 527a7a1)
raw | patch | inline | side by side (parent: 527a7a1)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 17 Apr 2003 07:33:08 +0000 (07:33 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 17 Apr 2003 07:33:08 +0000 (07:33 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1665 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/admin.py | patch | blob | history |
diff --git a/roundup/admin.py b/roundup/admin.py
index fda6e461e9639348cc729543d8cbace41f4c2be9..2641526ff9be7ce1fb17e9a8d292f07281cffbe4 100644 (file)
--- a/roundup/admin.py
+++ b/roundup/admin.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: admin.py,v 1.51 2003-04-17 03:37:57 richard Exp $
+# $Id: admin.py,v 1.52 2003-04-17 07:33:08 richard Exp $
'''Administration commands for maintaining Roundup trackers.
'''
''' List all the available templates.
Look in three places:
- <prefix>/share/roundup/templates
- <__file__>/../templates
- current dir
+ <prefix>/share/roundup/templates/*
+ <__file__>/../templates/*
+ current dir/*
+ current dir as a template
'''
# OK, try <prefix>/share/roundup/templates
# -- this module (roundup.admin) will be installed in something
if os.path.isdir(tdir):
templates.update(listTemplates(tdir))
+ # Try subdirs of the current dir
+ templates.update(listTemplates(os.getcwd()))
+
+ # Finally, try the current directory as a template
+ template = loadTemplate(os.getcwd())
+ if template:
+ templates[template['name']] = template
+
return templates
def help_initopts(self):
ret = {}
for idir in os.listdir(dir):
idir = os.path.join(dir, idir)
- ti = os.path.join(idir, 'TEMPLATE-INFO.txt')
- if os.path.isfile(ti):
- m = rfc822.Message(open(ti))
- ti = {}
- ti['name'] = m['name']
- ti['description'] = m['description']
- ti['intended-for'] = m['intended-for']
- ti['path'] = idir
- ret[m['name']] = ti
+ 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())