summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-10-05 13:01:56 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2021-10-05 13:01:56 -0400
commit12b4e12865088354c94cdf6d6b6c0534185253bd (patch)
treed34e55f6bca95fee0a9cd396bf6b2a4431e228e6
parent8e36266d5fc7f9b83f5f5ac30317f75037ae722c (diff)
downloadwfs-12b4e12865088354c94cdf6d6b6c0534185253bd.tar.xz
wfs-12b4e12865088354c94cdf6d6b6c0534185253bd.zip
optimize, delete dead code
-rwxr-xr-xwfs.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/wfs.py b/wfs.py
index c107c67..08ce689 100755
--- a/wfs.py
+++ b/wfs.py
@@ -109,7 +109,7 @@ def extract(path, fonts, screenshots):
height = DRIVER.execute_script(''.join([
"let style = document.createElement('style'); style.innerHTML = '",
''.join(gen_font_face(font) for font in fonts),
- "'; document.body.appendChild(style); return document.body.parentNode.scrollHeight"]))
+ "'; document.body.appendChild(style); return document.documentElement.scrollHeight"]))
logger.info('taking pre-screenshot for %s', path)
DRIVER.set_window_size(1920, height)
screenshot = DRIVER.get_screenshot_as_png()
@@ -155,21 +155,11 @@ def verify(path, screenshot_begin_png):
DRIVER.set_window_size(*screenshot_begin.size)
screenshot_end_png = DRIVER.get_screenshot_as_png()
- logger.info('checking screenshot for %s', path)
screenshot_end = Image.open(BytesIO(screenshot_end_png), formats=('PNG',)).convert('RGB')
+ logger.info('checking %s screenshots for %s', 'x'.join(map(str, screenshot_end.size)), path)
if ImageChops.difference(screenshot_begin, screenshot_end).getbbox():
raise Exception(f'screenshots do not match for {path}')
-class LocalPool:
- def __init__(self, driver_name):
- start_wworker(driver_name)
-
- def starmap(self, func, args, *_):
- return [func(*arg) for arg in args]
-
- def close(self):
- stop_driver()
-
def main(argv):
parser = argparse.ArgumentParser(description='Web Font Subsetter', epilog='see pyftsubset --help for additional options')
parser.add_argument('--driver', help='selenium driver name (chrome or firefox)', default='chrome')