[27566] in Source-Commits

home help back first fref pref prev next nref lref last post

python-discuss commit: Add a delete() method to RCFile

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Tue Jan 7 09:04:33 2014

Date: Tue, 7 Jan 2014 09:04:25 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201401071404.s07E4PWk030891@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/python-discuss/commit/2baf624b791e9dc94fb8a298e58411ad30d5d615
commit 2baf624b791e9dc94fb8a298e58411ad30d5d615
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Tue Dec 31 12:45:43 2013 -0500

    Add a delete() method to RCFile
    
    Support deletion of meetings, and raise a ValueError if there is
    an attempt to delete a non-existent meeting.  Like add(), the
    delete() method does not call save() -- that is up to the caller

 discuss/rcfile.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/discuss/rcfile.py b/discuss/rcfile.py
index 1f507af..6c38a29 100644
--- a/discuss/rcfile.py
+++ b/discuss/rcfile.py
@@ -155,3 +155,10 @@ class RCFile:
         self.entries[mtg_id] = entry
         self.recache()
 
+    def delete(self, meeting):
+        """Remove a meeting from the .meetings file"""
+        mtg = self.lookup(meeting)
+        if mtg not in self.entries:
+            raise ValueError("'%s' is not in meetings file." % meeting)
+        del self.entries[mtg]
+        self.recache()

home help back first fref pref prev next nref lref last post