1
- From 5939fd0b80d765a6572d9560b36c8223da53ce6b Mon Sep 17 00:00:00 2001
1
+ From 89d9ddfb25ecd6b0f974ac65dc0ef01a6c42e29e Mon Sep 17 00:00:00 2001
2
2
From: myfreeer <
[email protected] >
3
- Date: Sun, 14 Oct 2018 16:43:53 +0800
3
+ Date: Sun, 30 Dec 2018 17:35:34 +0800
4
4
Subject: [PATCH] source: use zh localized version
5
5
6
6
---
7
7
Makefile | 54 ++++++++++++------------
8
- commands/preprocess.py | 23 + +++++----
8
+ commands/preprocess.py | 19 +++++----
9
9
commands/preprocess_cssless.py | 5 ++-
10
10
gadgets/standard_revisions-tests/base.py | 2 +-
11
11
gadgets/sync_tests_mwiki.py | 2 +-
@@ -14,7 +14,7 @@ Subject: [PATCH] source: use zh localized version
14
14
preprocess.py | 8 ++--
15
15
tests/test_preprocess.py | 19 ++++++---
16
16
tests/test_preprocess_cssless.py | 2 +-
17
- 10 files changed, 67 insertions(+), 54 deletions(-)
17
+ 10 files changed, 64 insertions(+), 53 deletions(-)
18
18
19
19
diff --git a/Makefile b/Makefile
20
20
index 2366fbc..423be32 100644
@@ -149,7 +149,7 @@ index 2366fbc..423be32 100644
149
149
- ./export.py --url=http://en.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10
150
150
+ ./export.py --url=https://zh.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10
151
151
diff --git a/commands/preprocess.py b/commands/preprocess.py
152
- index 12cb4e3..9e394d9 100644
152
+ index 7a0cd5c..16dc1b2 100644
153
153
--- a/commands/preprocess.py
154
154
+++ b/commands/preprocess.py
155
155
@@ -41,15 +41,15 @@ def rearrange_archive(root):
@@ -190,18 +190,7 @@ index 12cb4e3..9e394d9 100644
190
190
191
191
# remove the XML source file
192
192
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):
205
194
206
195
# make custom footer
207
196
def add_footer(html, root, fn):
@@ -213,8 +202,8 @@ index 12cb4e3..9e394d9 100644
213
202
for child in footer.getchildren():
214
203
id = child.get('id')
215
204
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) )
218
207
219
208
def preprocess_html_file(root, fn, rename_map):
220
209
- parser = etree.HTMLParser()
@@ -223,7 +212,7 @@ index 12cb4e3..9e394d9 100644
223
212
output = io.StringIO()
224
213
225
214
diff --git a/commands/preprocess_cssless.py b/commands/preprocess_cssless.py
226
- index 2f75d5a..64742c6 100644
215
+ index 2f75d5a..0aa10db 100644
227
216
--- a/commands/preprocess_cssless.py
228
217
+++ b/commands/preprocess_cssless.py
229
218
@@ -27,11 +27,12 @@ import io
@@ -234,7 +223,7 @@ index 2f75d5a..64742c6 100644
234
223
235
224
def preprocess_html_merge_cssless(src_path, dst_path):
236
225
- 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:
238
227
content = a_file.read()
239
228
- parser = etree.HTMLParser()
240
229
+ parser = etree.HTMLParser(encoding="utf-8")
@@ -303,7 +292,7 @@ index d2e625c..11375f2 100644
303
292
return res
304
293
305
294
diff --git a/preprocess.py b/preprocess.py
306
- index ba5d37b..f852885 100755
295
+ index 1a3b5c6..288fe0c 100755
307
296
--- a/preprocess.py
308
297
+++ b/preprocess.py
309
298
@@ -29,12 +29,12 @@ def main():
@@ -324,10 +313,10 @@ index ba5d37b..f852885 100755
324
313
preprocess.rearrange_archive(root)
325
314
326
315
diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py
327
- index 0c6568c..247d062 100644
316
+ index d4616aa..ef4de50 100644
328
317
--- a/tests/test_preprocess.py
329
318
+++ b/tests/test_preprocess.py
330
- @@ -26 ,19 +26 ,26 @@ from lxml import etree
319
+ @@ -40 ,19 +40 ,26 @@ def nostdout():
331
320
332
321
class TestConvertLoaderName(unittest.TestCase):
333
322
def test_convert_loader_name(self):
@@ -359,7 +348,7 @@ index 0c6568c..247d062 100644
359
348
self.assertEqual('ext.css', convert_loader_name(url))
360
349
361
350
with self.assertRaises(Exception):
362
- @@ -196 ,7 +203 ,7 @@ class TestPreprocessHtml(unittest.TestCase):
351
+ @@ -227 ,7 +234 ,7 @@ class TestPreprocessHtml(unittest.TestCase):
363
352
def setUp(self):
364
353
self.testdata = os.path.join(os.path.dirname(__file__), 'preprocess_data')
365
354
infile = os.path.join(self.testdata, "fabs.html")
@@ -382,5 +371,5 @@ index fc93019..ffad345 100644
382
371
383
372
root = function(root)
384
373
- -
385
- 2.19.0
374
+ 2.19.1
386
375
0 commit comments