Commits

Dan Connolly committed 9308591

Reduce to well-typed dialect of python:
- pass mk_chrome function rather than webdriver.Chrome class as value
- use classOf(C) for class values
- use "" rather than None for the absence of a submit
- TODO: consider using Option[String]

  • Participants
  • Parent commits 1cb865f
  • Branches well-typed

Comments (0)

Files changed (1)

File txget/txget.py

 
 from datetime import date, datetime, timedelta
 from functools import partial as pf_
+from functools import partial as classOf  # TODO: use fp.classOf?
 import ConfigParser
 import logging
 
 
 def _imports_are_not_unused(x):
     ''':type x: Object'''
-    isinstance(x, date)
-    isinstance(x, datetime)
+    date(2000, 1, 1)
+    datetime(2000, 1, 1, 12, 30, 30)
 
-    class X(WebDriver):
-        pass
-
-    class Y(WebElement):
-        pass
+    isinstance(x, classOf(WebDriver))
+    isinstance(x, classOf(WebElement))
 
 
 class AcctSite(object):
         f = self.__ua.find_element_by_xpath(
             conf.get(section, 'form')[1:-1])
 
-        submit = None
+        submit = ""
 
         for n, v in conf.items(section):
             if n.startswith('select_'):
     def use_chromium():
         use_chromium = Options()
         use_chromium.binary_location = path
-        return mk_chrome(chrome_options=use_chromium)
+        return mk_chrome(use_chromium)
     return pf_(use_chromium)
 
 
+def typed(x, t):
+    # TODO: use fp.typed?
+    return x
+
+
 if __name__ == '__main__':
     def _main_with_caps():
         from sys import argv
         import datetime
 
-        from selenium import webdriver
+        from selenium.webdriver import Chrome
 
         def open_arg(path):
             ''':type path: String'''
                 raise IOError('not authorized CLI arg: %s' % path)
             return open(path)
 
+        def mk_chrome(options):
+            ''':type options: Options'''
+            return Chrome(chrome_options=options)
+
         return main(argv=argv[:], open_arg=open_arg,
                     calendar=datetime.date, clock=datetime.datetime,
-                    make_driver=make_use_chromium(webdriver.Chrome))
+                    make_driver=make_use_chromium(pf_(mk_chrome)))
 
     _main_with_caps()