Mercurial > repos > guerler > hhblits
comparison lib/python3.8/site-packages/pip/_vendor/pep517/compat.py @ 0:9e54283cc701 draft
"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
| author | guerler |
|---|---|
| date | Mon, 27 Jul 2020 03:47:31 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:9e54283cc701 |
|---|---|
| 1 """Python 2/3 compatibility""" | |
| 2 import json | |
| 3 import sys | |
| 4 | |
| 5 | |
| 6 # Handle reading and writing JSON in UTF-8, on Python 3 and 2. | |
| 7 | |
| 8 if sys.version_info[0] >= 3: | |
| 9 # Python 3 | |
| 10 def write_json(obj, path, **kwargs): | |
| 11 with open(path, 'w', encoding='utf-8') as f: | |
| 12 json.dump(obj, f, **kwargs) | |
| 13 | |
| 14 def read_json(path): | |
| 15 with open(path, 'r', encoding='utf-8') as f: | |
| 16 return json.load(f) | |
| 17 | |
| 18 else: | |
| 19 # Python 2 | |
| 20 def write_json(obj, path, **kwargs): | |
| 21 with open(path, 'wb') as f: | |
| 22 json.dump(obj, f, encoding='utf-8', **kwargs) | |
| 23 | |
| 24 def read_json(path): | |
| 25 with open(path, 'rb') as f: | |
| 26 return json.load(f) | |
| 27 | |
| 28 | |
| 29 # FileNotFoundError | |
| 30 | |
| 31 try: | |
| 32 FileNotFoundError = FileNotFoundError | |
| 33 except NameError: | |
| 34 FileNotFoundError = IOError |
