From 0bf3521deec7a0467f67293527f3cdaf38e7f5f7 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 27 Feb 2002 03:40:59 +0000 Subject: [PATCH] Ran it through pychecker, made fixes git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@662 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/back_anydbm.py | 13 +++++++---- roundup/backends/back_bsddb.py | 9 +++++--- roundup/backends/blobfiles.py | 38 +++++++++++++++++---------------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 7c95841..df287d8 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.29 2002-02-25 14:34:31 grubert Exp $ +#$Id: back_anydbm.py,v 1.30 2002-02-27 03:40:59 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -24,7 +24,7 @@ serious bugs, and is not available) ''' import whichdb, anydbm, os, marshal -from roundup import hyperdb, date, password +from roundup import hyperdb, date from blobfiles import FileStorage # @@ -109,7 +109,7 @@ class Database(FileStorage, hyperdb.Database): if hyperdb.DEBUG: print 'clear', (self,) for cn in self.classes.keys(): - for type in 'nodes', 'journals': + for dummy in 'nodes', 'journals': path = os.path.join(self.dir, 'journals.%s'%cn) if os.path.exists(path): os.remove(path) @@ -398,7 +398,7 @@ class Database(FileStorage, hyperdb.Database): # now insert the journal entry if db.has_key(nodeid): s = db[nodeid] - l = marshal.loads(db[nodeid]) + l = marshal.loads(s) l.append(entry) else: l = [entry] @@ -425,6 +425,11 @@ class Database(FileStorage, hyperdb.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.29 2002/02/25 14:34:31 grubert +# . use blobfiles in back_anydbm which is used in back_bsddb. +# change test_db as dirlist does not work for subdirectories. +# ATTENTION: blobfiles now creates subdirectories for files. +# #Revision 1.28 2002/02/16 09:14:17 richard # . #514854 ] History: "User" is always ticket creator # diff --git a/roundup/backends/back_bsddb.py b/roundup/backends/back_bsddb.py index b30dacb..973e7bc 100644 --- a/roundup/backends/back_bsddb.py +++ b/roundup/backends/back_bsddb.py @@ -15,13 +15,13 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_bsddb.py,v 1.15 2002-02-16 09:15:33 richard Exp $ +#$Id: back_bsddb.py,v 1.16 2002-02-27 03:40:59 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in BSDDB. ''' import bsddb, os, marshal -from roundup import hyperdb, date, password +from roundup import hyperdb, date # these classes are so similar, we just use the anydbm methods import back_anydbm @@ -100,7 +100,7 @@ class Database(back_anydbm.Database): db = bsddb.btopen(os.path.join(self.dir, 'journals.%s'%classname), 'c') if db.has_key(nodeid): s = db[nodeid] - l = marshal.loads(db[nodeid]) + l = marshal.loads(s) l.append(entry) else: l = [entry] @@ -109,6 +109,9 @@ class Database(back_anydbm.Database): # #$Log: not supported by cvs2svn $ +#Revision 1.15 2002/02/16 09:15:33 richard +#forgot to patch bsddb backend too +# #Revision 1.14 2002/01/22 07:21:13 richard #. fixed back_bsddb so it passed the journal tests # diff --git a/roundup/backends/blobfiles.py b/roundup/backends/blobfiles.py index 2080ab4..5270425 100644 --- a/roundup/backends/blobfiles.py +++ b/roundup/backends/blobfiles.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: blobfiles.py,v 1.1 2002-02-25 14:25:41 grubert Exp $ +#$Id: blobfiles.py,v 1.2 2002-02-27 03:40:59 richard Exp $ ''' This module exports file storage for roundup backends. Files are stored into a directory hierarchy. @@ -23,11 +23,23 @@ Files are stored into a directory hierarchy. import os, os.path +def files_in_dir(dir): + if not os.path.exists(dir): + return 0 + num_files = 0 + for dir_entry in os.listdir(dir): + full_filename = os.path.join(dir,dir_entry) + if os.path.isfile(full_filename): + num_files = num_files + 1 + elif os.path.isdir(full_filename): + num_files = num_files + files_in_dir(full_filename) + return num_files + class FileStorage: """Store files in some directory structure""" - def __init__(self): - # maybe set "files" - pass +# TODO: maybe set "files" +# def __init__(self): +# pass def filename(self, classname, nodeid, property=None): '''Determine what the filename for the given node and optionally @@ -87,20 +99,10 @@ class FileStorage: '''Get number of files in storage, even across subdirectories. ''' files_dir = os.path.join(self.dir, 'files') - - def files_in_dir(dir): - if not os.path.exists(dir): - return 0 - num_files = 0 - for dir_entry in os.listdir(dir): - full_filename = os.path.join(dir,dir_entry) - if os.path.isfile(full_filename): - num_files = num_files + 1 - elif os.path.isdir(full_filename): - num_files = num_files + files_in_dir(full_filename) - return num_files - return files_in_dir(files_dir) - + def _doStoreFile(self, name, **databases): + '''Must be implemented by subclass + ''' + raise NotImplementedError -- 2.30.2