Skip to content

Commit 3b19394

Browse files
author
Richard Jones
committed
Ran it through pychecker, made fixes
1 parent 3128bd9 commit 3b19394

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

roundup/backends/back_anydbm.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.29 2002-02-25 14:34:31 grubert Exp $
18+
#$Id: back_anydbm.py,v 1.30 2002-02-27 03:40:59 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -24,7 +24,7 @@
2424
'''
2525

2626
import whichdb, anydbm, os, marshal
27-
from roundup import hyperdb, date, password
27+
from roundup import hyperdb, date
2828
from blobfiles import FileStorage
2929

3030
#
@@ -109,7 +109,7 @@ def clear(self):
109109
if hyperdb.DEBUG:
110110
print 'clear', (self,)
111111
for cn in self.classes.keys():
112-
for type in 'nodes', 'journals':
112+
for dummy in 'nodes', 'journals':
113113
path = os.path.join(self.dir, 'journals.%s'%cn)
114114
if os.path.exists(path):
115115
os.remove(path)
@@ -398,7 +398,7 @@ def _doSaveJournal(self, classname, nodeid, action, params):
398398
# now insert the journal entry
399399
if db.has_key(nodeid):
400400
s = db[nodeid]
401-
l = marshal.loads(db[nodeid])
401+
l = marshal.loads(s)
402402
l.append(entry)
403403
else:
404404
l = [entry]
@@ -425,6 +425,11 @@ def rollback(self):
425425

426426
#
427427
#$Log: not supported by cvs2svn $
428+
#Revision 1.29 2002/02/25 14:34:31 grubert
429+
# . use blobfiles in back_anydbm which is used in back_bsddb.
430+
# change test_db as dirlist does not work for subdirectories.
431+
# ATTENTION: blobfiles now creates subdirectories for files.
432+
#
428433
#Revision 1.28 2002/02/16 09:14:17 richard
429434
# . #514854 ] History: "User" is always ticket creator
430435
#

roundup/backends/back_bsddb.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_bsddb.py,v 1.15 2002-02-16 09:15:33 richard Exp $
18+
#$Id: back_bsddb.py,v 1.16 2002-02-27 03:40:59 richard Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in BSDDB.
2121
'''
2222

2323
import bsddb, os, marshal
24-
from roundup import hyperdb, date, password
24+
from roundup import hyperdb, date
2525

2626
# these classes are so similar, we just use the anydbm methods
2727
import back_anydbm
@@ -100,7 +100,7 @@ def _doSaveJournal(self, classname, nodeid, action, params):
100100
db = bsddb.btopen(os.path.join(self.dir, 'journals.%s'%classname), 'c')
101101
if db.has_key(nodeid):
102102
s = db[nodeid]
103-
l = marshal.loads(db[nodeid])
103+
l = marshal.loads(s)
104104
l.append(entry)
105105
else:
106106
l = [entry]
@@ -109,6 +109,9 @@ def _doSaveJournal(self, classname, nodeid, action, params):
109109

110110
#
111111
#$Log: not supported by cvs2svn $
112+
#Revision 1.15 2002/02/16 09:15:33 richard
113+
#forgot to patch bsddb backend too
114+
#
112115
#Revision 1.14 2002/01/22 07:21:13 richard
113116
#. fixed back_bsddb so it passed the journal tests
114117
#

roundup/backends/blobfiles.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,31 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: blobfiles.py,v 1.1 2002-02-25 14:25:41 grubert Exp $
18+
#$Id: blobfiles.py,v 1.2 2002-02-27 03:40:59 richard Exp $
1919
'''
2020
This module exports file storage for roundup backends.
2121
Files are stored into a directory hierarchy.
2222
'''
2323

2424
import os, os.path
2525

26+
def files_in_dir(dir):
27+
if not os.path.exists(dir):
28+
return 0
29+
num_files = 0
30+
for dir_entry in os.listdir(dir):
31+
full_filename = os.path.join(dir,dir_entry)
32+
if os.path.isfile(full_filename):
33+
num_files = num_files + 1
34+
elif os.path.isdir(full_filename):
35+
num_files = num_files + files_in_dir(full_filename)
36+
return num_files
37+
2638
class FileStorage:
2739
"""Store files in some directory structure"""
28-
def __init__(self):
29-
# maybe set "files"
30-
pass
40+
# TODO: maybe set "files"
41+
# def __init__(self):
42+
# pass
3143

3244
def filename(self, classname, nodeid, property=None):
3345
'''Determine what the filename for the given node and optionally
@@ -87,20 +99,10 @@ def numfiles(self):
8799
'''Get number of files in storage, even across subdirectories.
88100
'''
89101
files_dir = os.path.join(self.dir, 'files')
90-
91-
def files_in_dir(dir):
92-
if not os.path.exists(dir):
93-
return 0
94-
num_files = 0
95-
for dir_entry in os.listdir(dir):
96-
full_filename = os.path.join(dir,dir_entry)
97-
if os.path.isfile(full_filename):
98-
num_files = num_files + 1
99-
elif os.path.isdir(full_filename):
100-
num_files = num_files + files_in_dir(full_filename)
101-
return num_files
102-
103102
return files_in_dir(files_dir)
104103

105-
104+
def _doStoreFile(self, name, **databases):
105+
'''Must be implemented by subclass
106+
'''
107+
raise NotImplementedError
106108

0 commit comments

Comments
 (0)