Commits

Dan Connolly committed 24695af

txget works for one financial institution

  • Participants
  • Parent commits a77a004

Comments (0)

Files changed (1)

 def main(argv):
     import datetime
 
-    logging.basicConfig(level=logging.DEBUG)
+    logging.basicConfig(level=logging.INFO)
 
     config_fn, section = argv[1:3]
     config = ConfigParser.SafeConfigParser()
     def txget(self, conf, section):
         self.login(conf.get(section, 'home'),
                    conf.get(section, 'logged_in'))
-        s2 = conf.get(section, 'next')
-        self.follow_link(conf.get(s2, 'link'))
-        self.form_fill(conf, s2)
+
+        while conf.has_option(section, 'next'):
+            section = conf.get(section, 'next')
+            if conf.has_option(section, 'link'):
+                self.follow_link(conf.get(section, 'link'))
+            if conf.has_option(section, 'submit'):
+                self.form_fill(conf, section, conf.get(section, 'submit'))
+            if conf.has_option(section, 'ofx'):
+                return conf.get(section, 'ofx')
+
+        raise ValueError('no ofx option in any section')
 
     def login(self, home, logged_in):
         log.info('opening home: %s', home)
         e = self.__ua.find_element_by_link_text(text)
         e.click()
 
-    def form_fill(self, conf, section):
+    def form_fill(self, conf, section, submit):
         f = self.__ua.find_element_by_id(conf.get(section, 'form_id'))
 
-        submit = None
-
         for n, v in conf.items(section):
             if n.startswith('select_'):
                 name, idx = v.split(' ', 1)
             elif n == 'submit':
                 submit = v
 
-        if submit:
-            f.find_element_by_name(submit).click()
+        f.find_element_by_name(submit).click()
 
 
 def select_option(f, name, idx):