Mercurial > p > roundup > code
comparison roundup/hyperdb.py @ 3924:21d3d7eeea8c
assorted pyflakes fixes
I (re-)discovered pyflakes today and ran it over to roundup
code to see what it had to say. It reported a ton of "imported
module foo but you're not actually using it" warnings and a couple
of actual errors that this patch fixes.
The code was wrong but it was mostly stuff that never gets
executed...like hyperdb.Choice.
| author | Justus Pendleton <jpend@users.sourceforge.net> |
|---|---|
| date | Thu, 27 Sep 2007 06:12:57 +0000 |
| parents | c3af8c6a6b5b |
| children | 603ec9630b08 |
comparison
equal
deleted
inserted
replaced
| 3923:d02aad94af5a | 3924:21d3d7eeea8c |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: hyperdb.py,v 1.129 2007-01-10 18:17:00 schlatterbeck Exp $ | 18 # $Id: hyperdb.py,v 1.130 2007-09-27 06:12:56 jpend Exp $ |
| 19 | 19 |
| 20 """Hyperdatabase implementation, especially field types. | 20 """Hyperdatabase implementation, especially field types. |
| 21 """ | 21 """ |
| 22 __docformat__ = 'restructuredtext' | 22 __docformat__ = 'restructuredtext' |
| 23 | 23 |
| 79 value = p | 79 value = p |
| 80 else: | 80 else: |
| 81 try: | 81 try: |
| 82 value = password.Password(value) | 82 value = password.Password(value) |
| 83 except password.PasswordValueError, message: | 83 except password.PasswordValueError, message: |
| 84 raise HyperdbValueError, 'property %s: %s'%(propname, message) | 84 raise HyperdbValueError, 'property %s: %s'%(kw['propname'], message) |
| 85 return value | 85 return value |
| 86 def sort_repr (self, cls, val, name): | 86 def sort_repr (self, cls, val, name): |
| 87 if not val: | 87 if not val: |
| 88 return val | 88 return val |
| 89 return str(val) | 89 return str(val) |
| 485 vals.intersection_update(val) | 485 vals.intersection_update(val) |
| 486 self._val = [v for v in vals] | 486 self._val = [v for v in vals] |
| 487 else: | 487 else: |
| 488 self._val = val | 488 self._val = val |
| 489 self.has_values = True | 489 self.has_values = True |
| 490 | 490 |
| 491 val = property(lambda self: self._val, _set_val) | 491 val = property(lambda self: self._val, _set_val) |
| 492 | 492 |
| 493 def _sort(self, val): | 493 def _sort(self, val): |
| 494 """Finally sort by the given sortattr.sort_result. Note that we | 494 """Finally sort by the given sortattr.sort_result. Note that we |
| 495 do not sort by attrs having attr_sort_done set. The caller is | 495 do not sort by attrs having attr_sort_done set. The caller is |
| 1134 sort/group spec may be transitive, i.e., it may contain | 1134 sort/group spec may be transitive, i.e., it may contain |
| 1135 properties of the form link.link.link.name, e.g. you can search | 1135 properties of the form link.link.link.name, e.g. you can search |
| 1136 for all issues where a message was added by a certain user in | 1136 for all issues where a message was added by a certain user in |
| 1137 the last week with a filterspec of | 1137 the last week with a filterspec of |
| 1138 {'messages.author' : '42', 'messages.creation' : '.-1w;'} | 1138 {'messages.author' : '42', 'messages.creation' : '.-1w;'} |
| 1139 | 1139 |
| 1140 Implementation note: | 1140 Implementation note: |
| 1141 This implements a non-optimized version of Transitive search | 1141 This implements a non-optimized version of Transitive search |
| 1142 using _filter implemented in a backend class. A more efficient | 1142 using _filter implemented in a backend class. A more efficient |
| 1143 version can be implemented in the individual backends -- e.g., | 1143 version can be implemented in the individual backends -- e.g., |
| 1144 an SQL backen will want to create a single SQL statement and | 1144 an SQL backen will want to create a single SQL statement and |
| 1289 def __init__(self, db, classname, **properties): | 1289 def __init__(self, db, classname, **properties): |
| 1290 '''The newly-created class automatically includes the "content" | 1290 '''The newly-created class automatically includes the "content" |
| 1291 property. | 1291 property. |
| 1292 ''' | 1292 ''' |
| 1293 if not properties.has_key('content'): | 1293 if not properties.has_key('content'): |
| 1294 properties['content'] = hyperdb.String(indexme='yes') | 1294 properties['content'] = String(indexme='yes') |
| 1295 | 1295 |
| 1296 def export_propnames(self): | 1296 def export_propnames(self): |
| 1297 ''' Don't export the "content" property | 1297 ''' Don't export the "content" property |
| 1298 ''' | 1298 ''' |
| 1299 propnames = self.getprops().keys() | 1299 propnames = self.getprops().keys() |
| 1388 '''Quick helper to create a simple class with choices | 1388 '''Quick helper to create a simple class with choices |
| 1389 ''' | 1389 ''' |
| 1390 cl = Class(db, name, name=String(), order=String()) | 1390 cl = Class(db, name, name=String(), order=String()) |
| 1391 for i in range(len(options)): | 1391 for i in range(len(options)): |
| 1392 cl.create(name=options[i], order=i) | 1392 cl.create(name=options[i], order=i) |
| 1393 return hyperdb.Link(name) | 1393 return Link(name) |
| 1394 | 1394 |
| 1395 # vim: set filetype=python sts=4 sw=4 et si : | 1395 # vim: set filetype=python sts=4 sw=4 et si : |
