Skip to content

Commit 6a6abc6

Browse files
author
Richard Jones
committed
more modernisation
1 parent fd3137c commit 6a6abc6

File tree

12 files changed

+199
-166
lines changed

12 files changed

+199
-166
lines changed

2to3-done.txt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@ CAN'T VERIFY
22

33
./roundup/backends/back_mysql.py
44
./roundup/backends/back_tsearch2.py
5-
./roundup/backends/indexer_xapian.py
65

76
TODO
87

9-
./roundup/backends/sessions_dbm.py
10-
./roundup/backends/sessions_rdbms.py
11-
./roundup/backends/tsearch2_setup.py
12-
./roundup/cgi/__init__.py
13-
./roundup/cgi/accept_language.py
14-
./roundup/cgi/actions.py
15-
./roundup/cgi/apache.py
16-
./roundup/cgi/cgitb.py
17-
./roundup/cgi/client.py
188
./roundup/cgi/exceptions.py
199
./roundup/cgi/form_parser.py
2010
./roundup/cgi/MultiMapping.py
@@ -133,24 +123,37 @@ TODO
133123
./frontends/ZRoundup/ZRoundup.py
134124

135125

136-
137126
DONE
138127

139128
./doc/conf.py
140-
./roundup/__init__.py
141129
./roundup/admin.py
142-
./roundup/actions.py
143-
./roundup/anypy/__init__.py
144-
./roundup/anypy/hashlib_.py
145-
./roundup/anypy/sets_.py
146130
./roundup/backends/__init__.py
147131
./roundup/backends/back_anydbm.py
148132
./roundup/backends/back_postgresql.py
149133
./roundup/backends/back_sqlite.py
150-
./roundup/backends/blobfiles.py
151134
./roundup/backends/indexer_common.py
152135
./roundup/backends/indexer_dbm.py
153136
./roundup/backends/indexer_rdbms.py
154137
./roundup/backends/locking.py
155138
./roundup/backends/portalocker.py
156139
./roundup/backends/rdbms_common.py
140+
./roundup/backends/sessions_dbm.py
141+
./roundup/backends/sessions_rdbms.py
142+
./roundup/cgi/accept_language.py
143+
./roundup/cgi/actions.py
144+
./roundup/cgi/cgitb.py
145+
146+
147+
NOTHING DONE
148+
149+
./roundup/__init__.py
150+
./roundup/actions.py
151+
./roundup/anypy/__init__.py
152+
./roundup/anypy/hashlib_.py
153+
./roundup/anypy/sets_.py
154+
./roundup/backends/blobfiles.py
155+
./roundup/backends/indexer_xapian.py
156+
./roundup/backends/tsearch2_setup.py
157+
./roundup/cgi/__init__.py
158+
./roundup/cgi/apache.py
159+
./roundup/cgi/client.py

roundup/anypy/cookie_.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
try:
3+
from http import cookies as Cookie
4+
from http.cookies import CookieError, BaseCookie, SimpleCookie
5+
from http.cookies import _getdate as get_cookie_date
6+
except:
7+
from Cookie import CookieError, BaseCookie, SimpleCookie
8+
from Cookie import _getdate as get_cookie_date

roundup/anypy/http_.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
try:
2+
from http import client
3+
except:
4+
import httplib as client
5+

roundup/anypy/io_.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
try:
3+
from io import StringIO
4+
except:
5+
from StringIO import StringIO
6+

roundup/anypy/urllib_.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
try:
3+
from urllib.parse import quote, urlparse
4+
except:
5+
from urllib import quote
6+
from urlparse import urlparse

roundup/backends/indexer_dbm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def find(self, wordlist):
168168
hits[k] = self.fileids[k]
169169
else:
170170
# Eliminate hits for every non-match
171-
for fileid in hits:
171+
for fileid in list(hits):
172172
if fileid not in entry:
173173
del hits[fileid]
174174
if hits is None:

roundup/backends/sessions_dbm.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"""
88
__docformat__ = 'restructuredtext'
99

10-
import anydbm, whichdb, os, marshal, time
10+
import os, marshal, time
11+
1112
from roundup import hyperdb
1213
from roundup.i18n import _
14+
from roundup.anypy.dbm_ import anydbm, whichdb
1315

1416
class BasicDatabase:
1517
''' Provide a nice encapsulation of an anydbm store.
@@ -26,7 +28,7 @@ def __init__(self, db):
2628
def exists(self, infoid):
2729
db = self.opendb('c')
2830
try:
29-
return db.has_key(infoid)
31+
return infoid in db
3032
finally:
3133
db.close()
3234

@@ -46,8 +48,8 @@ def cache_db_type(self, path):
4648
if os.path.exists(path):
4749
db_type = whichdb.whichdb(path)
4850
if not db_type:
49-
raise hyperdb.DatabaseError, \
50-
_("Couldn't identify database type")
51+
raise hyperdb.DatabaseError(
52+
_("Couldn't identify database type"))
5153
elif os.path.exists(path+'.db'):
5254
# if the path ends in '.db', it's a dbm database, whether
5355
# anydbm says it's dbhash or not!
@@ -58,12 +60,12 @@ def cache_db_type(self, path):
5860
def get(self, infoid, value, default=_marker):
5961
db = self.opendb('c')
6062
try:
61-
if db.has_key(infoid):
63+
if infoid in db:
6264
values = marshal.loads(db[infoid])
6365
else:
6466
if default != self._marker:
6567
return default
66-
raise KeyError, 'No such %s "%s"'%(self.name, infoid)
68+
raise KeyError('No such %s "%s"'%(self.name, infoid))
6769
return values.get(value, None)
6870
finally:
6971
db.close()
@@ -76,14 +78,14 @@ def getall(self, infoid):
7678
del d['__timestamp']
7779
return d
7880
except KeyError:
79-
raise KeyError, 'No such %s "%s"'%(self.name, infoid)
81+
raise KeyError('No such %s "%s"'%(self.name, infoid))
8082
finally:
8183
db.close()
8284

8385
def set(self, infoid, **newvalues):
8486
db = self.opendb('c')
8587
try:
86-
if db.has_key(infoid):
88+
if infoid in db:
8789
values = marshal.loads(db[infoid])
8890
else:
8991
values = {'__timestamp': time.time()}
@@ -95,14 +97,14 @@ def set(self, infoid, **newvalues):
9597
def list(self):
9698
db = self.opendb('r')
9799
try:
98-
return db.keys()
100+
return list(db)
99101
finally:
100102
db.close()
101103

102104
def destroy(self, infoid):
103105
db = self.opendb('c')
104106
try:
105-
if db.has_key(infoid):
107+
if infoid in db:
106108
del db[infoid]
107109
finally:
108110
db.close()

roundup/backends/sessions_rdbms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get(self, infoid, value, default=_marker):
3636
if not res:
3737
if default != self._marker:
3838
return default
39-
raise KeyError, 'No such %s "%s"'%(self.name, infoid)
39+
raise KeyError('No such %s "%s"'%(self.name, infoid))
4040
values = eval(res[0])
4141
return values.get(value, None)
4242

@@ -46,7 +46,7 @@ def getall(self, infoid):
4646
n, n, self.db.arg), (infoid,))
4747
res = self.cursor.fetchone()
4848
if not res:
49-
raise KeyError, 'No such %s "%s"'%(self.name, infoid)
49+
raise KeyError('No such %s "%s"'%(self.name, infoid))
5050
return eval(res[0])
5151

5252
def set(self, infoid, **newvalues):

roundup/cgi/accept_language.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# both
3636
lre = re.compile(nqlre + "|" + qlre)
3737

38-
ascii = ''.join([chr(x) for x in xrange(256)])
38+
ascii = ''.join([chr(x) for x in range(256)])
3939
whitespace = ' \t\n\r\v\f'
4040

4141
def parse(language_header):

0 commit comments

Comments
 (0)