diff options
author | Philip Chimento <philip@endlessm.com> | 2015-06-04 14:17:16 -0700 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2015-06-04 14:28:20 -0700 |
commit | 6363acd835544f411de297a7f3318b2e5c7fd5aa (patch) | |
tree | 69030582d65b6cf437cbbb349744d3012c1dbe32 /tools | |
parent | 6e767f6c2a4953c3469a4e49ff247d9e472a8c4e (diff) |
Port eos-html-extractor to Python 3
May as well be forward compatible, while we're touching this.
[endlessm/eos-sdk#3245]
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/eos-html-extractor | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/eos-html-extractor b/tools/eos-html-extractor index 913695c..72a3acd 100755 --- a/tools/eos-html-extractor +++ b/tools/eos-html-extractor @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2013-2015 Endless Mobile, Inc. @@ -6,16 +6,16 @@ import argparse import os.path import re from bs4 import BeautifulSoup -from HTMLParser import HTMLParser +from html.parser import HTMLParser # Parser that adds line numbers to the HTML strings that need translating class TranslatableHTMLParser(HTMLParser): def __init__(self, translatable_strings): - HTMLParser.__init__(self) + super().__init__() self.all_translatable_data = [] self._comments_with_line_numbers = [] - self._translatable_strings = translatable_strings + self._translatable_strings = set(translatable_strings) def handle_data(self, data): if data not in self._translatable_strings: @@ -61,8 +61,7 @@ soup = BeautifulSoup(page) # Extract all translatable strings from that HTML translatable_divs = soup.find_all(attrs={'name': 'translatable'}) -translatable_strings = map(lambda div: div.contents[0].encode('utf-8'), - translatable_divs) +translatable_strings = map(lambda div: div.contents[0], translatable_divs) # Find the line numbers for those strings parser = TranslatableHTMLParser(translatable_strings) |