| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe22153 commit d3248ca
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -134,7 +134,7 @@ def exec_code(interpreter, args): | |||
| 134 | 134 | Helper to execute code in a given interpreter. args should be a [faked] | |
| 135 | 135 | sys.argv | |
| 136 | 136 | """ | |
| 137 | - with open(args[0], "r") as sourcefile: | ||
| 137 | + with open(args[0]) as sourcefile: | ||
| 138 | 138 | source = sourcefile.read() | |
| 139 | 139 | old_argv, sys.argv = sys.argv, args | |
| 140 | 140 | sys.path.insert(0, os.path.abspath(os.path.dirname(args[0]))) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -304,7 +304,7 @@ def get_key_no_doublebind(command): | |||
| 304 | 304 | ||
| 305 | 305 | def load_theme(struct, path, colors, default_colors): | |
| 306 | 306 | theme = ConfigParser() | |
| 307 | - with open(path, "r") as f: | ||
| 307 | + with open(path) as f: | ||
| 308 | 308 | theme.readfp(f) | |
| 309 | 309 | for k, v in chain(theme.items("syntax"), theme.items("interface")): | |
| 310 | 310 | if theme.has_option("syntax", k): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,4 @@ | |||
| 1 | 1 | import collections | |
| 2 | - import io | ||
| 3 | 2 | import logging | |
| 4 | 3 | import sys | |
| 5 | 4 | from optparse import Option | |
@@ -178,7 +177,7 @@ def main(args=None, locals_=None, banner=None, welcome_message=None): | |||
| 178 | 177 | if options.paste: | |
| 179 | 178 | paste = curtsies.events.PasteEvent() | |
| 180 | 179 | encoding = inspection.get_encoding_file(exec_args[0]) | |
| 181 | - with io.open(exec_args[0], encoding=encoding) as f: | ||
| 180 | + with open(exec_args[0], encoding=encoding) as f: | ||
| 182 | 181 | sourcecode = f.read() | |
| 183 | 182 | paste.events.extend(sourcecode) | |
| 184 | 183 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,7 +21,6 @@ | |||
| 21 | 21 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 22 | 22 | # THE SOFTWARE. | |
| 23 | 23 | ||
| 24 | - import io | ||
| 25 | 24 | import os | |
| 26 | 25 | import stat | |
| 27 | 26 | from itertools import islice | |
@@ -170,7 +169,7 @@ def reset(self): | |||
| 170 | 169 | self.saved_line = "" | |
| 171 | 170 | ||
| 172 | 171 | def load(self, filename, encoding): | |
| 173 | - with io.open( | ||
| 172 | + with open( | ||
| 174 | 173 | filename, "r", encoding=encoding, errors="ignore" | |
| 175 | 174 | ) as hfile: | |
| 176 | 175 | with FileLock(hfile, filename=filename): | |
@@ -188,7 +187,7 @@ def save(self, filename, encoding, lines=0): | |||
| 188 | 187 | os.O_WRONLY | os.O_CREAT | os.O_TRUNC, | |
| 189 | 188 | stat.S_IRUSR | stat.S_IWUSR, | |
| 190 | 189 | ) | |
| 191 | - with io.open(fd, "w", encoding=encoding, errors="ignore") as hfile: | ||
| 190 | + with open(fd, "w", encoding=encoding, errors="ignore") as hfile: | ||
| 192 | 191 | with FileLock(hfile, filename=filename): | |
| 193 | 192 | self.save_to(hfile, self.entries, lines) | |
| 194 | 193 | ||
@@ -209,7 +208,7 @@ def append_reload_and_write(self, s, filename, encoding): | |||
| 209 | 208 | os.O_APPEND | os.O_RDWR | os.O_CREAT, | |
| 210 | 209 | stat.S_IRUSR | stat.S_IWUSR, | |
| 211 | 210 | ) | |
| 212 | - with io.open(fd, "a+", encoding=encoding, errors="ignore") as hfile: | ||
| 211 | + with open(fd, "a+", encoding=encoding, errors="ignore") as hfile: | ||
| 213 | 212 | with FileLock(hfile, filename=filename): | |
| 214 | 213 | # read entries | |
| 215 | 214 | hfile.seek(0, os.SEEK_SET) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | import inspect | |
| 26 | - import io | ||
| 27 | 26 | import keyword | |
| 28 | 27 | import pydoc | |
| 29 | 28 | from collections import namedtuple | |
@@ -350,7 +349,7 @@ def get_encoding_comment(source): | |||
| 350 | 349 | ||
| 351 | 350 | def get_encoding_file(fname): | |
| 352 | 351 | """Try to obtain encoding information from a Python source file.""" | |
| 353 | - with io.open(fname, "rt", encoding="ascii", errors="ignore") as f: | ||
| 352 | + with open(fname, "rt", encoding="ascii", errors="ignore") as f: | ||
| 354 | 353 | for unused in range(2): | |
| 355 | 354 | line = f.readline() | |
| 356 | 355 | match = get_encoding_line_re.search(line) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | 25 | import code | |
| 26 | 26 | import inspect | |
| 27 | - import io | ||
| 28 | 27 | import os | |
| 29 | 28 | import pkgutil | |
| 30 | 29 | import pydoc | |
@@ -481,7 +480,7 @@ def startup(self): | |||
| 481 | 480 | filename = os.environ.get("PYTHONSTARTUP") | |
| 482 | 481 | if filename: | |
| 483 | 482 | encoding = inspection.get_encoding_file(filename) | |
| 484 | - with io.open(filename, "rt", encoding=encoding) as f: | ||
| 483 | + with open(filename, "rt", encoding=encoding) as f: | ||
| 485 | 484 | source = f.read() | |
| 486 | 485 | self.interp.runsource(source, filename, "exec", encode=False) | |
| 487 | 486 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -434,7 +434,7 @@ def setUp(self): | |||
| 434 | 434 | self.repl = create_repl() | |
| 435 | 435 | ||
| 436 | 436 | def write_startup_file(self, fname, encoding): | |
| 437 | - with io.open(fname, mode="wt", encoding=encoding) as f: | ||
| 437 | + with open(fname, mode="wt", encoding=encoding) as f: | ||
| 438 | 438 | f.write("# coding: ") | |
| 439 | 439 | f.write(encoding) | |
| 440 | 440 | f.write("\n") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,3 @@ | |||
| 1 | - import io | ||
| 2 | 1 | import os | |
| 3 | 2 | ||
| 4 | 3 | ||
@@ -89,7 +88,7 @@ def setUp(self): | |||
| 89 | 88 | self.filename = "history_temp_file" | |
| 90 | 89 | self.encoding = getpreferredencoding() | |
| 91 | 90 | ||
| 92 | - with io.open( | ||
| 91 | + with open( | ||
| 93 | 92 | self.filename, "w", encoding=self.encoding, errors="ignore" | |
| 94 | 93 | ) as f: | |
| 95 | 94 | f.write(b"#1\n#2\n".decode()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1338,7 +1338,7 @@ def start(main_loop, user_data): | |||
| 1338 | 1338 | # this is CLIRepl.startup inlined. | |
| 1339 | 1339 | filename = os.environ.get("PYTHONSTARTUP") | |
| 1340 | 1340 | if filename and os.path.isfile(filename): | |
| 1341 | - with open(filename, "r") as f: | ||
| 1341 | + with open(filename) as f: | ||
| 1342 | 1342 | interpreter.runsource(f.read(), filename, "exec") | |
| 1343 | 1343 | ||
| 1344 | 1344 | if banner is not None: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments