spambayes/spambayes storage.py,1.46,1.47

"Tony Meyer" <[email protected]>
Newsgroups gmane.mail.spam.spambayes.cvs
Message-ID <[email protected]>
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18819/spambayes

Modified Files:
	storage.py 
Log Message:
Move the ensureDir function to storage, as many scripts use it.

Index: storage.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/storage.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** storage.py	23 Dec 2004 04:32:57 -0000	1.46
--- storage.py	7 Feb 2005 23:13:47 -0000	1.47
***************
*** 1,3 ****
! #! /usr/bin/env python
  
  '''storage.py - Spambayes database management framework.
--- 1,3 ----
! ! /usr/bin/env python
  
  '''storage.py - Spambayes database management framework.
***************
*** 39,44 ****
  
  To Do:
-     o Would Trainer.trainall really want to train with the whole corpus,
-         or just a random subset?
      o Suggestions?
  
--- 39,42 ----
***************
*** 952,955 ****
--- 950,964 ----
      return nm, typ
  
+ def ensureDir(dirname):
+     """Ensure that the given directory exists - in other words, if it
+     does not exist, attempt to create it."""
+     try:
+         os.mkdir(dirname)
+         if options["globals", "verbose"]:
+             print >>sys.stderr, "Creating directory", dirname
+     except OSError, e:
+         if e.errno != errno.EEXIST:
+             raise
+ 
  if __name__ == '__main__':
      print >> sys.stderr, __doc__
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.