comparison lib/python3.8/site-packages/pip/_vendor/pep517/compat.py @ 1:64071f2a4cf0 draft default tip

Deleted selected files
author guerler
date Mon, 27 Jul 2020 03:55:49 -0400
parents 9e54283cc701
children
comparison
equal deleted inserted replaced
0:9e54283cc701 1:64071f2a4cf0
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