Skip to content

Commit e351cb0

Browse files
committed
Merge branch 'remove-buysellads' into master
Fixes #21. * remove-buysellads: Preprocess: fix pylint errors Preprocess: remove BuySellAds
2 parents dacd6e1 + b85b469 commit e351cb0

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

commands/preprocess.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,22 @@ def remove_google_analytics(html):
321321
el.getparent().remove(el)
322322

323323

324-
# remove Carbon ads
324+
# remove ads
325325
def remove_ads(html):
326+
# Carbon Ads
326327
for el in html.xpath('//script[@src]'):
327328
if 'carbonads.com/carbon.js' in el.get('src'):
328329
el.getparent().remove(el)
329330
for el in html.xpath('/html/body/style'):
330331
if el.text is not None and '#carbonads' in el.text:
331332
el.getparent().remove(el)
333+
# BuySellAds
334+
for el in html.xpath('//script[@type]'):
335+
if 'buysellads.com' in el.text:
336+
el.getparent().remove(el)
337+
for el in html.xpath('//div[@id]'):
338+
if el.get('id').startswith('bsap_'):
339+
el.getparent().remove(el)
332340

333341

334342
# remove links to file info pages (e.g. on images)

preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with this program. If not, see http://www.gnu.org/licenses/.
1919

20-
from commands import preprocess
2120
import argparse
2221
import concurrent.futures
2322
import os
2423
import shutil
24+
from commands import preprocess
2525

2626

2727
def main():

tests/test_preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import contextlib
2525
import unittest
2626
import unittest.mock
27+
from lxml import etree
2728
from commands.preprocess import build_rename_map
2829
from commands.preprocess import convert_loader_name
2930
from commands.preprocess import has_class
@@ -38,7 +39,6 @@
3839
from commands.preprocess import transform_ranges_placeholder
3940
from commands.preprocess import trasform_relative_link
4041
from commands.preprocess import rename_files
41-
from lxml import etree
4242

4343

4444
class DummyFile(object):

tests/test_preprocess_cssless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import os
1919
import unittest
20+
from lxml import etree
2021
from commands.preprocess_cssless import preprocess_html_merge_cssless
2122
from commands.preprocess_cssless import silence_cssutils_warnings
2223
from commands.preprocess_cssless import convert_span_tables_to_tr_td
@@ -26,7 +27,6 @@
2627
from commands.preprocess_cssless import convert_font_size_property_to_pt
2728
from commands.preprocess_cssless \
2829
import convert_table_border_top_to_tr_background
29-
from lxml import etree
3030

3131

3232
class TestPreprocessHtmlMergeCss(unittest.TestCase):

0 commit comments

Comments
 (0)