Skip to content

Commit 41367d1

Browse files
committed
Uniformly use """...""" instead of '''...''' for comments.
1 parent 4e72c40 commit 41367d1

File tree

1 file changed

+72
-73
lines changed

1 file changed

+72
-73
lines changed

roundup/hyperdb.py

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.132 2008-08-18 06:21:53 richard Exp $
1918

2019
"""Hyperdatabase implementation, especially field types.
2120
"""
@@ -137,8 +136,8 @@ class _Pointer(_Type):
137136
"""An object designating a Pointer property that links or multilinks
138137
to a node in a specified class."""
139138
def __init__(self, classname, do_journal='yes', required=False):
140-
''' Default is to journal link and unlink events
141-
'''
139+
""" Default is to journal link and unlink events
140+
"""
142141
super(_Pointer, self).__init__(required)
143142
self.classname = classname
144143
self.do_journal = do_journal == 'yes'
@@ -273,15 +272,15 @@ def from_raw(self, value, **kw):
273272
class DesignatorError(ValueError):
274273
pass
275274
def splitDesignator(designator, dre=re.compile(r'([^\d]+)(\d+)')):
276-
''' Take a foo123 and return ('foo', 123)
277-
'''
275+
""" Take a foo123 and return ('foo', 123)
276+
"""
278277
m = dre.match(designator)
279278
if m is None:
280279
raise DesignatorError, _('"%s" not a node designator')%designator
281280
return m.group(1), m.group(2)
282281

283282
class Proptree(object):
284-
''' Simple tree data structure for optimizing searching of
283+
""" Simple tree data structure for optimizing searching of
285284
properties. Each node in the tree represents a roundup Class
286285
Property that has to be navigated for finding the given search
287286
or sort properties. The sort_type attribute is used for
@@ -293,7 +292,7 @@ class Proptree(object):
293292
The Proptree is also used for transitively searching attributes for
294293
backends that do not support transitive search (e.g. anydbm). The
295294
_val attribute with set_val is used for this.
296-
'''
295+
"""
297296

298297
def __init__(self, db, cls, name, props, parent = None):
299298
self.db = db
@@ -565,11 +564,11 @@ def __repr__(self):
565564
# the base Database class
566565
#
567566
class DatabaseError(ValueError):
568-
'''Error to be raised when there is some problem in the database code
569-
'''
567+
"""Error to be raised when there is some problem in the database code
568+
"""
570569
pass
571570
class Database:
572-
'''A database for storing records containing flexible data types.
571+
"""A database for storing records containing flexible data types.
573572
574573
This class defines a hyperdatabase storage layer, which the Classes use to
575574
store their data.
@@ -592,7 +591,7 @@ class Database:
592591
593592
All methods except __repr__ must be implemented by a concrete backend Database.
594593
595-
'''
594+
"""
596595

597596
# flag to set on retired entries
598597
RETIRED_FLAG = '__hyperdb_retired'
@@ -634,8 +633,8 @@ def __getattr__(self, classname):
634633
raise NotImplementedError
635634

636635
def addclass(self, cl):
637-
'''Add a Class to the hyperdatabase.
638-
'''
636+
"""Add a Class to the hyperdatabase.
637+
"""
639638
raise NotImplementedError
640639

641640
def getclasses(self):
@@ -650,14 +649,14 @@ def getclass(self, classname):
650649
raise NotImplementedError
651650

652651
def clear(self):
653-
'''Delete all database contents.
654-
'''
652+
"""Delete all database contents.
653+
"""
655654
raise NotImplementedError
656655

657656
def getclassdb(self, classname, mode='r'):
658-
'''Obtain a connection to the class db that will be used for
657+
"""Obtain a connection to the class db that will be used for
659658
multiple actions.
660-
'''
659+
"""
661660
raise NotImplementedError
662661

663662
def addnode(self, classname, nodeid, node):
@@ -666,73 +665,73 @@ def addnode(self, classname, nodeid, node):
666665
raise NotImplementedError
667666

668667
def serialise(self, classname, node):
669-
'''Copy the node contents, converting non-marshallable data into
668+
"""Copy the node contents, converting non-marshallable data into
670669
marshallable data.
671-
'''
670+
"""
672671
return node
673672

674673
def setnode(self, classname, nodeid, node):
675-
'''Change the specified node.
676-
'''
674+
"""Change the specified node.
675+
"""
677676
raise NotImplementedError
678677

679678
def unserialise(self, classname, node):
680-
'''Decode the marshalled node data
681-
'''
679+
"""Decode the marshalled node data
680+
"""
682681
return node
683682

684683
def getnode(self, classname, nodeid):
685-
'''Get a node from the database.
684+
"""Get a node from the database.
686685
687686
'cache' exists for backwards compatibility, and is not used.
688-
'''
687+
"""
689688
raise NotImplementedError
690689

691690
def hasnode(self, classname, nodeid):
692-
'''Determine if the database has a given node.
693-
'''
691+
"""Determine if the database has a given node.
692+
"""
694693
raise NotImplementedError
695694

696695
def countnodes(self, classname):
697-
'''Count the number of nodes that exist for a particular Class.
698-
'''
696+
"""Count the number of nodes that exist for a particular Class.
697+
"""
699698
raise NotImplementedError
700699

701700
def storefile(self, classname, nodeid, property, content):
702-
'''Store the content of the file in the database.
701+
"""Store the content of the file in the database.
703702
704703
The property may be None, in which case the filename does not
705704
indicate which property is being saved.
706-
'''
705+
"""
707706
raise NotImplementedError
708707

709708
def getfile(self, classname, nodeid, property):
710-
'''Get the content of the file in the database.
711-
'''
709+
"""Get the content of the file in the database.
710+
"""
712711
raise NotImplementedError
713712

714713
def addjournal(self, classname, nodeid, action, params):
715-
''' Journal the Action
714+
""" Journal the Action
716715
'action' may be:
717716
718717
'create' or 'set' -- 'params' is a dictionary of property values
719718
'link' or 'unlink' -- 'params' is (classname, nodeid, propname)
720719
'retire' -- 'params' is None
721-
'''
720+
"""
722721
raise NotImplementedError
723722

724723
def getjournal(self, classname, nodeid):
725-
''' get the journal for id
726-
'''
724+
""" get the journal for id
725+
"""
727726
raise NotImplementedError
728727

729728
def pack(self, pack_before):
730-
''' pack the database
731-
'''
729+
""" pack the database
730+
"""
732731
raise NotImplementedError
733732

734733
def commit(self):
735-
''' Commit the current transactions.
734+
""" Commit the current transactions.
736735
737736
Save all data changed since the database was opened or since the
738737
last commit() or rollback().
@@ -742,15 +741,15 @@ def commit(self):
742741
database. We don't care if there's a concurrency issue there.
743742
744743
The only backend this seems to affect is postgres.
745-
'''
744+
"""
746745
raise NotImplementedError
747746

748747
def rollback(self):
749-
''' Reverse all actions from the current transaction.
748+
""" Reverse all actions from the current transaction.
750749
751750
Undo all the changes made since the database was opened or the last
752751
commit() or rollback() was performed.
753-
'''
752+
"""
754753
raise NotImplementedError
755754

756755
def close(self):
@@ -798,8 +797,8 @@ def __init__(self, db, classname, **properties):
798797
self.reactors = dict([(a, PrioList()) for a in actions])
799798

800799
def __repr__(self):
801-
'''Slightly more useful representation
802-
'''
800+
"""Slightly more useful representation
801+
"""
803802
return '<hyperdb.Class "%s">'%self.classname
804803

805804
# Editing nodes:
@@ -837,18 +836,18 @@ def get(self, nodeid, propname, default=_marker, cache=1):
837836

838837
# not in spec
839838
def getnode(self, nodeid):
840-
''' Return a convenience wrapper for the node.
839+
""" Return a convenience wrapper for the node.
841840
842841
'nodeid' must be the id of an existing node of this class or an
843842
IndexError is raised.
844843
845844
'cache' exists for backwards compatibility, and is not used.
846-
'''
845+
"""
847846
return Node(self, nodeid)
848847

849848
def getnodeids(self, retired=None):
850-
'''Retrieve all the ids of the nodes for a particular Class.
851-
'''
849+
"""Retrieve all the ids of the nodes for a particular Class.
850+
"""
852851
raise NotImplementedError
853852

854853
def set(self, nodeid, **propvalues):
@@ -883,15 +882,15 @@ def retire(self, nodeid):
883882
raise NotImplementedError
884883

885884
def restore(self, nodeid):
886-
'''Restpre a retired node.
885+
"""Restpre a retired node.
887886
888887
Make node available for all operations like it was before retirement.
889-
'''
888+
"""
890889
raise NotImplementedError
891890

892891
def is_retired(self, nodeid):
893-
'''Return true if the node is rerired
894-
'''
892+
"""Return true if the node is rerired
893+
"""
895894
raise NotImplementedError
896895

897896
def destroy(self, nodeid):
@@ -932,8 +931,8 @@ def history(self, nodeid):
932931

933932
# Locating nodes:
934933
def hasnode(self, nodeid):
935-
'''Determine if the given nodeid actually exists
936-
'''
934+
"""Determine if the given nodeid actually exists
935+
"""
937936
raise NotImplementedError
938937

939938
def setkey(self, propname):
@@ -1230,11 +1229,11 @@ def export_propnames(self):
12301229

12311230

12321231
class HyperdbValueError(ValueError):
1233-
''' Error converting a raw value into a Hyperdb value '''
1232+
""" Error converting a raw value into a Hyperdb value """
12341233
pass
12351234

12361235
def convertLinkValue(db, propname, prop, value, idre=re.compile('^\d+$')):
1237-
''' Convert the link value (may be id or key value) to an id value. '''
1236+
""" Convert the link value (may be id or key value) to an id value. """
12381237
linkcl = db.classes[prop.classname]
12391238
if not idre.match(value):
12401239
if linkcl.getkey():
@@ -1259,14 +1258,14 @@ def fixNewlines(text):
12591258
return text.replace('\r', '\n')
12601259

12611260
def rawToHyperdb(db, klass, itemid, propname, value, **kw):
1262-
''' Convert the raw (user-input) value to a hyperdb-storable value. The
1261+
""" Convert the raw (user-input) value to a hyperdb-storable value. The
12631262
value is for the "propname" property on itemid (may be None for a
12641263
new item) of "klass" in "db".
12651264
12661265
The value is usually a string, but in the case of multilink inputs
12671266
it may be either a list of strings or a string with comma-separated
12681267
values.
1269-
'''
1268+
"""
12701269
properties = klass.getprops()
12711270

12721271
# ensure it's a valid property name
@@ -1288,21 +1287,21 @@ def rawToHyperdb(db, klass, itemid, propname, value, **kw):
12881287
return value
12891288

12901289
class FileClass:
1291-
''' A class that requires the "content" property and stores it on
1290+
""" A class that requires the "content" property and stores it on
12921291
disk.
1293-
'''
1292+
"""
12941293
default_mime_type = 'text/plain'
12951294

12961295
def __init__(self, db, classname, **properties):
1297-
'''The newly-created class automatically includes the "content"
1296+
"""The newly-created class automatically includes the "content"
12981297
property.
1299-
'''
1298+
"""
13001299
if not properties.has_key('content'):
13011300
properties['content'] = String(indexme='yes')
13021301

13031302
def export_propnames(self):
1304-
''' Don't export the "content" property
1305-
'''
1303+
""" Don't export the "content" property
1304+
"""
13061305
propnames = self.getprops().keys()
13071306
propnames.remove('content')
13081307
propnames.sort()
@@ -1313,17 +1312,17 @@ def exportFilename(self, dirname, nodeid):
13131312
return os.path.join(dirname, self.classname+'-files', subdir_filename)
13141313

13151314
def export_files(self, dirname, nodeid):
1316-
''' Export the "content" property as a file, not csv column
1317-
'''
1315+
""" Export the "content" property as a file, not csv column
1316+
"""
13181317
source = self.db.filename(self.classname, nodeid)
13191318

13201319
dest = self.exportFilename(dirname, nodeid)
13211320
ensureParentsExist(dest)
13221321
shutil.copyfile(source, dest)
13231322

13241323
def import_files(self, dirname, nodeid):
1325-
''' Import the "content" property as a file
1326-
'''
1324+
""" Import the "content" property as a file
1325+
"""
13271326
source = self.exportFilename(dirname, nodeid)
13281327

13291328
dest = self.db.filename(self.classname, nodeid, create=1)
@@ -1341,8 +1340,8 @@ def import_files(self, dirname, nodeid):
13411340
self.get(nodeid, 'content'), mime_type)
13421341

13431342
class Node:
1344-
''' A convenience wrapper for the given node
1345-
'''
1343+
""" A convenience wrapper for the given node
1344+
"""
13461345
def __init__(self, cl, nodeid, cache=1):
13471346
self.__dict__['cl'] = cl
13481347
self.__dict__['nodeid'] = nodeid
@@ -1392,8 +1391,8 @@ def retire(self):
13921391

13931392

13941393
def Choice(name, db, *options):
1395-
'''Quick helper to create a simple class with choices
1396-
'''
1394+
"""Quick helper to create a simple class with choices
1395+
"""
13971396
cl = Class(db, name, name=String(), order=String())
13981397
for i in range(len(options)):
13991398
cl.create(name=options[i], order=i)

0 commit comments

Comments
 (0)