aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/mapfile.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2008-11-14 19:25:44 -0500
committerW. Trevor King <wking@drexel.edu>2008-11-14 19:25:44 -0500
commit87e356c9208e955fcf6c20c0b271db87bdd48014 (patch)
tree8a9ef32cd7bd9798077824fb26e73c1358599d6a /libbe/mapfile.py
parent91b284cde8c4443cf0997798f4f847ce95409cd3 (diff)
downloadbugseverywhere-87e356c9208e955fcf6c20c0b271db87bdd48014.tar.gz
Split Bug and Comment class out to bug.py from bugdir.py
Comment should probably have it's own file too... I also tried to clean up the interface for setting status and severity. Both attributes involve selecting strings from predefined lists. The lists of valid strings (and descriptions of each string) are now defined in bug.py. The bug.py lists are then used to generate appropriate help strings in becommands/status.py and severity.py. This should make it easier to keep the help strings in synch with the validation information. The original status strings weren't documented, and I didn't know what they all ment, so I elimanted some of them. 'in-progress' and 'disabled' are no longer with us. Of course, it would be simple to add them back in if people don't agree with me on that. Due to the loss of 'disabled' I had to change the status of two bugs (11e and 597) to 'closed'. I removed becommands/inprogress.py as well. It's functionality was replaced by the more general status.py command, which mimics the severity.py command.
Diffstat (limited to 'libbe/mapfile.py')
-rw-r--r--libbe/mapfile.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/libbe/mapfile.py b/libbe/mapfile.py
index 6a304fd..95c3169 100644
--- a/libbe/mapfile.py
+++ b/libbe/mapfile.py
@@ -14,7 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import os.path
+import errno
import utility
+
class IllegalKey(Exception):
def __init__(self, key):
Exception.__init__(self, 'Illegal key "%s"' % key)
@@ -99,6 +102,27 @@ def parse(f):
result[name] = value
return result
+def map_save(rcs, path, map):
+ """Save the map as a mapfile to the specified path"""
+ add = not os.path.exists(path)
+ output = file(path, "wb")
+ generate(output, map)
+ if add:
+ rcs.add_id(path)
+
+class NoSuchFile(Exception):
+ def __init__(self, pathname):
+ Exception.__init__(self, "No such file: %s" % pathname)
+
+
+def map_load(path):
+ try:
+ return parse(file(path, "rb"))
+ except IOError, e:
+ if e.errno != errno.ENOENT:
+ raise e
+ raise NoSuchFile(path)
+
def split_diff3(this, other, f):
"""Split a file or string with diff3 conflicts into two files.