Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commands/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def remove_unused_external(html):


def preprocess_html_file(root, fn, rename_map):
parser = etree.HTMLParser()
parser = etree.HTMLParser(encoding='utf-8')
html = etree.parse(fn, parser)
output = io.StringIO()

Expand Down
4 changes: 2 additions & 2 deletions commands/preprocess_cssless.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


def preprocess_html_merge_cssless(src_path, dst_path):
with open(src_path, 'r') as a_file:
with open(src_path, 'r', encoding='utf-8') as a_file:
content = a_file.read()
parser = etree.HTMLParser()
parser = etree.HTMLParser(encoding='utf-8')
stripped = content.strip()
root = etree.fromstring(stripped, parser)

Expand Down
4 changes: 2 additions & 2 deletions gadgets/replace_tests_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ def main():

for path in paths:
print('Processing {0}'.format(path))
with open(path, 'r') as file:
with open(path, 'r', encoding='utf-8') as file:
text = file.read()

# TODO user proper XML parser, not this hack
text = re.sub('<link rel="selenium.base" href="(.*)" />',
'<link rel="selenium.base" href="' + args.url + '" />', text)

with open(path, 'w') as file:
with open(path, 'w', encoding='utf-8') as file:
file.write(text)

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions gadgets/sync_tests_mwiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def sync_single_page(page, direction, dest_root):
if direction == SYNC_DIRECTION_UPLOAD:
if not os.path.exists(dest_path):
return
with open(dest_path, 'r') as file:
with open(dest_path, 'r', encoding='utf-8') as file:
new_text = file.read()
if fix_whitespace(text) != fix_whitespace(new_text):
page.put(new_text, 'sync with git')
Expand All @@ -82,7 +82,7 @@ def sync_single_page(page, direction, dest_root):
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)

with open(dest_path, 'w') as file:
with open(dest_path, 'w', encoding='utf-8') as file:
file.write(fix_whitespace(text))
print('Downloaded {0}'.format(dest_path))

Expand Down
2 changes: 1 addition & 1 deletion index2ddg.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def main():
# i+=1

root = e.parse(os.path.join(args.reference, fn),
parser=html.HTMLParser())
parser=html.HTMLParser(encoding='utf-8'))

for ident in idents:

Expand Down
2 changes: 1 addition & 1 deletion tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def setUp(self):
self.testdata = os.path.join(os.path.dirname(__file__),
'preprocess_data')
infile = os.path.join(self.testdata, "fabs.html")
self.parser = etree.HTMLParser()
self.parser = etree.HTMLParser(encoding='utf-8')
self.html = etree.parse(infile, self.parser)

# Check whether the HTML matches the contents of the specified test data
Expand Down
10 changes: 5 additions & 5 deletions tests/test_preprocess_cssless.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def test_preprocess_html_merge_cssless(self):

preprocess_html_merge_cssless(src_path, dst_path)

with open(dst_path, 'r') as a_file:
with open(dst_path, 'r', encoding='utf-8') as a_file:
test = a_file.read()

with open(expected_path, 'r') as a_file:
with open(expected_path, 'r', encoding='utf-8') as a_file:
expected = a_file.read()

self.assertEqual(test, expected)
Expand All @@ -63,10 +63,10 @@ def test_preprocess_html_merge_cssless2(self):

preprocess_html_merge_cssless(src_path, dst_path)

with open(dst_path, 'r') as a_file:
with open(dst_path, 'r', encoding='utf-8') as a_file:
test = a_file.read()

with open(expected_path, 'r') as a_file:
with open(expected_path, 'r', encoding='utf-8') as a_file:
expected = a_file.read()

self.assertEqual(test, expected)
Expand All @@ -83,7 +83,7 @@ def assert_converts_html(self, input, expected_output, function):
expected_output = \
'<html><body>{0}</body></html>'.format(expected_output)

parser = etree.HTMLParser()
parser = etree.HTMLParser(encoding='utf-8')
root = etree.fromstring(input, parser)

root = function(root)
Expand Down