aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-25 07:32:12 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-25 07:32:12 -0400
commita3d5316acfe99f835404d4f8728e5f8acaad4eff (patch)
tree6f641ce9e05bfb1ef23de060c294869b4fafc2ed /libbe
parent9afbe4e78f7a332401ec03008ff66faa5c11e297 (diff)
downloadbugseverywhere-a3d5316acfe99f835404d4f8728e5f8acaad4eff.tar.gz
Added on_disk option to libbe.bugdir.simple_bug_dir().
Now you can easily generate simple_bug_dirs that live only in memory.
Diffstat (limited to 'libbe')
-rw-r--r--libbe/bugdir.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/libbe/bugdir.py b/libbe/bugdir.py
index 6e020ee..f98186e 100644
--- a/libbe/bugdir.py
+++ b/libbe/bugdir.py
@@ -548,7 +548,7 @@ settings easy. Don't set this attribute. Set .rcs instead, and
return True
-def simple_bug_dir():
+def simple_bug_dir(on_disk=True):
"""
For testing
>>> bugdir = simple_bug_dir()
@@ -557,11 +557,18 @@ def simple_bug_dir():
>>> print ls
['a', 'b']
"""
- dir = utility.Dir()
- assert os.path.exists(dir.path)
- bugdir = BugDir(dir.path, sink_to_existing_root=False, allow_rcs_init=True,
+ if on_disk == True:
+ dir = utility.Dir()
+ assert os.path.exists(dir.path)
+ root = dir.path
+ rcs_init = True
+ else:
+ root = None
+ rcs_init = False
+ bugdir = BugDir(root, sink_to_existing_root=False, allow_rcs_init=rcs_init,
manipulate_encodings=False)
- bugdir._dir_ref = dir # postpone cleanup since dir.__del__() removes dir.
+ if on_disk == True: # postpone cleanup since dir.__del__() removes dir.
+ bugdir._dir_ref = dir
bug_a = bugdir.new_bug("a", summary="Bug A")
bug_a.creator = "John Doe <jdoe@example.com>"
bug_a.time = 0
@@ -569,7 +576,8 @@ def simple_bug_dir():
bug_b.creator = "Jane Doe <jdoe@example.com>"
bug_b.time = 0
bug_b.status = "closed"
- bugdir.save()
+ if on_disk == True:
+ bugdir.save()
return bugdir