From a3d5316acfe99f835404d4f8728e5f8acaad4eff Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 25 Jul 2009 07:32:12 -0400 Subject: Added on_disk option to libbe.bugdir.simple_bug_dir(). Now you can easily generate simple_bug_dirs that live only in memory. --- libbe/bugdir.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'libbe') 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 " bug_a.time = 0 @@ -569,7 +576,8 @@ def simple_bug_dir(): bug_b.creator = "Jane Doe " bug_b.time = 0 bug_b.status = "closed" - bugdir.save() + if on_disk == True: + bugdir.save() return bugdir -- cgit