Python 2/3-ify scripts. (7) (6) (8) (1) (2)
Chris Pressey
2 years ago
1 | 1 |
|
2 | 2 |
import json
|
3 | 3 |
import sys
|
4 | |
from urllib.parse import quote
|
|
4 |
try:
|
|
5 |
from urllib import quote
|
|
6 |
except ImportError:
|
|
7 |
from urllib.parse import quote
|
|
8 |
assert quote
|
5 | 9 |
|
6 | 10 |
with open(sys.argv[1], 'r') as f:
|
7 | 11 |
data = json.loads(f.read())
|
5 | 5 |
import re
|
6 | 6 |
import subprocess
|
7 | 7 |
import sys
|
8 | |
import urllib
|
|
8 |
try:
|
|
9 |
from urllib import quote
|
|
10 |
except ImportError:
|
|
11 |
from urllib.parse import quote
|
|
12 |
assert quote
|
9 | 13 |
|
10 | 14 |
|
11 | 15 |
def generate_toc_line(document):
|
12 | 16 |
title = document['title']
|
13 | |
filename = urllib.quote(document['filename'])
|
|
17 |
filename = quote(document['filename'])
|
14 | 18 |
sections = document.get('sections', [])
|
15 | 19 |
properties = document.get('properties', {})
|
16 | 20 |
|