1- From 5939fd0b80d765a6572d9560b36c8223da53ce6b Mon Sep 17 00:00:00 2001
1+ From 89d9ddfb25ecd6b0f974ac65dc0ef01a6c42e29e Mon Sep 17 00:00:00 2001
22From: myfreeer <myfreeer@users.noreply.github.com>
3- Date: Sun, 14 Oct 2018 16:43:53 +0800
3+ Date: Sun, 30 Dec 2018 17:35:34 +0800
44Subject: [PATCH] source: use zh localized version
55
66---
77 Makefile | 54 ++++++++++++------------
8- commands/preprocess.py | 23 + +++++----
8+ commands/preprocess.py | 19 +++++----
99 commands/preprocess_cssless.py | 5 ++-
1010 gadgets/standard_revisions-tests/base.py | 2 +-
1111 gadgets/sync_tests_mwiki.py | 2 +-
@@ -14,7 +14,7 @@ Subject: [PATCH] source: use zh localized version
1414 preprocess.py | 8 ++--
1515 tests/test_preprocess.py | 19 ++++++---
1616 tests/test_preprocess_cssless.py | 2 +-
17- 10 files changed, 67 insertions(+), 54 deletions(-)
17+ 10 files changed, 64 insertions(+), 53 deletions(-)
1818
1919diff --git a/Makefile b/Makefile
2020index 2366fbc..423be32 100644
@@ -149,7 +149,7 @@ index 2366fbc..423be32 100644
149149- ./export.py --url=http://en.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10
150150+ ./export.py --url=https://zh.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10
151151diff --git a/commands/preprocess.py b/commands/preprocess.py
152- index 12cb4e3..9e394d9 100644
152+ index 7a0cd5c..16dc1b2 100644
153153--- a/commands/preprocess.py
154154+++ b/commands/preprocess.py
155155@@ -41,15 +41,15 @@ def rearrange_archive(root):
@@ -190,18 +190,7 @@ index 12cb4e3..9e394d9 100644
190190
191191 # remove the XML source file
192192 for fn in fnmatch.filter(os.listdir(root), 'cppreference-export*.xml'):
193- @@ -295,7 +295,9 @@ def remove_google_analytics(html):
194- for el in html.xpath('/html/body/script'):
195- if el.get('src') is not None and 'google-analytics.com/ga.js' in el.get('src'):
196- el.getparent().remove(el)
197- - elif el.text is not None and ('google-analytics.com/ga.js' in el.text or 'pageTracker' in el.text):
198- + elif el.text is not None and ('google-analytics.com/ga.js' in el.text or 'pageTracker' in el.text or '_trackPageview' in el.text):
199- + el.getparent().remove(el)
200- + elif el.get('src') is not None and 'carbonads.com/carbon.js' in el.get('src'):
201- el.getparent().remove(el)
202-
203- # remove Carbon ads
204- @@ -316,7 +318,10 @@ def remove_fileinfo(html):
193+ @@ -309,7 +309,10 @@ def remove_fileinfo(html):
205194
206195 # make custom footer
207196 def add_footer(html, root, fn):
@@ -213,8 +202,8 @@ index 12cb4e3..9e394d9 100644
213202 for child in footer.getchildren():
214203 id = child.get('id')
215204 if id == 'cpp-navigation':
216- @@ -338 ,7 +343,7 @@ def add_footer (html, root, fn ):
217- footer.remove(child )
205+ @@ -340 ,7 +343,7 @@ def remove_unused_external (html):
206+ el.set('href', os.path.join(head, 'common', tail) )
218207
219208 def preprocess_html_file(root, fn, rename_map):
220209- parser = etree.HTMLParser()
@@ -223,7 +212,7 @@ index 12cb4e3..9e394d9 100644
223212 output = io.StringIO()
224213
225214diff --git a/commands/preprocess_cssless.py b/commands/preprocess_cssless.py
226- index 2f75d5a..64742c6 100644
215+ index 2f75d5a..0aa10db 100644
227216--- a/commands/preprocess_cssless.py
228217+++ b/commands/preprocess_cssless.py
229218@@ -27,11 +27,12 @@ import io
@@ -234,7 +223,7 @@ index 2f75d5a..64742c6 100644
234223
235224 def preprocess_html_merge_cssless(src_path, dst_path):
236225- with open(src_path, 'r') as a_file:
237- + with codecs. open(src_path, 'r', 'utf-8') as a_file:
226+ + with open(src_path, 'r', encoding= 'utf-8') as a_file:
238227 content = a_file.read()
239228- parser = etree.HTMLParser()
240229+ parser = etree.HTMLParser(encoding="utf-8")
@@ -303,7 +292,7 @@ index d2e625c..11375f2 100644
303292 return res
304293
305294diff --git a/preprocess.py b/preprocess.py
306- index ba5d37b..f852885 100755
295+ index 1a3b5c6..288fe0c 100755
307296--- a/preprocess.py
308297+++ b/preprocess.py
309298@@ -29,12 +29,12 @@ def main():
@@ -324,10 +313,10 @@ index ba5d37b..f852885 100755
324313 preprocess.rearrange_archive(root)
325314
326315diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py
327- index 0c6568c..247d062 100644
316+ index d4616aa..ef4de50 100644
328317--- a/tests/test_preprocess.py
329318+++ b/tests/test_preprocess.py
330- @@ -26 ,19 +26 ,26 @@ from lxml import etree
319+ @@ -40 ,19 +40 ,26 @@ def nostdout():
331320
332321 class TestConvertLoaderName(unittest.TestCase):
333322 def test_convert_loader_name(self):
@@ -359,7 +348,7 @@ index 0c6568c..247d062 100644
359348 self.assertEqual('ext.css', convert_loader_name(url))
360349
361350 with self.assertRaises(Exception):
362- @@ -196 ,7 +203 ,7 @@ class TestPreprocessHtml(unittest.TestCase):
351+ @@ -227 ,7 +234 ,7 @@ class TestPreprocessHtml(unittest.TestCase):
363352 def setUp(self):
364353 self.testdata = os.path.join(os.path.dirname(__file__), 'preprocess_data')
365354 infile = os.path.join(self.testdata, "fabs.html")
@@ -382,5 +371,5 @@ index fc93019..ffad345 100644
382371
383372 root = function(root)
384373- -
385- 2.19.0
374+ 2.19.1
386375
0 commit comments