Mercurial > p > roundup > code
comparison roundup/instance.py @ 5383:6fbb7d52e38f
Python 3 preparation: use open() instead of file().
Tool-assisted patch. Note one case where a simple substitution did not
suffice because the change was in a class that defined its own open()
method earlier, and thus needed to use builtins.open (respectively
__builtin__.open in Python 2).
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 22:10:24 +0000 |
| parents | 0942fe89e82e |
| children | 23b8e6067f7c |
comparison
equal
deleted
inserted
replaced
| 5382:1556b39fde7c | 5383:6fbb7d52e38f |
|---|---|
| 26 The "db" handle you get back is the tracker's hyperdb which has the interface | 26 The "db" handle you get back is the tracker's hyperdb which has the interface |
| 27 described in `roundup.hyperdb.Database`. | 27 described in `roundup.hyperdb.Database`. |
| 28 """ | 28 """ |
| 29 __docformat__ = 'restructuredtext' | 29 __docformat__ = 'restructuredtext' |
| 30 | 30 |
| 31 try: | |
| 32 import builtins | |
| 33 except ImportError: | |
| 34 import __builtin__ as builtins | |
| 35 | |
| 31 import os | 36 import os |
| 32 import sys | 37 import sys |
| 33 import warnings | 38 import warnings |
| 34 | 39 |
| 35 from roundup import configuration, mailgw | 40 from roundup import configuration, mailgw |
| 78 The 'backend_name' file is no longer used to configure the database backend | 83 The 'backend_name' file is no longer used to configure the database backend |
| 79 used for the tracker. Please read 'doc/upgrading.txt' to find out how to | 84 used for the tracker. Please read 'doc/upgrading.txt' to find out how to |
| 80 update your config.ini | 85 update your config.ini |
| 81 """ | 86 """ |
| 82 try: | 87 try: |
| 83 with file(filename) as backend_file: | 88 with open(filename) as backend_file: |
| 84 rdbms_backend = backend_file.readline().strip() | 89 rdbms_backend = backend_file.readline().strip() |
| 85 | 90 |
| 86 with warnings.catch_warnings(): | 91 with warnings.catch_warnings(): |
| 87 warnings.simplefilter("once", DeprecationWarning) | 92 warnings.simplefilter("once", DeprecationWarning) |
| 88 warnings.warn(msg, DeprecationWarning, stacklevel=2) | 93 warnings.warn(msg, DeprecationWarning, stacklevel=2) |
| 222 def nuke(self): | 227 def nuke(self): |
| 223 self.backend.db_nuke(self.config) | 228 self.backend.db_nuke(self.config) |
| 224 | 229 |
| 225 def _compile(self, fname): | 230 def _compile(self, fname): |
| 226 fname = os.path.join(self.tracker_home, fname) | 231 fname = os.path.join(self.tracker_home, fname) |
| 227 return compile(file(fname).read(), fname, 'exec') | 232 return compile(builtins.open(fname).read(), fname, 'exec') |
| 228 | 233 |
| 229 def _exec(self, obj, env): | 234 def _exec(self, obj, env): |
| 230 if self.libdir: | 235 if self.libdir: |
| 231 sys.path.insert(1, self.libdir) | 236 sys.path.insert(1, self.libdir) |
| 232 exec(obj, env) | 237 exec(obj, env) |
