old_contents: import logging
  
  from weboob.core.modules import ModuleLoadError
  from weboob.exceptions import BrowserIncorrectPassword
  
  from handlers.base import BaseHandler
  from lib.connector import Connector
  
  logger = logging.getLogger('cozy-data-indexer.' + __name__)
  
  
  class BaseBankHandler(BaseHandler):
      '''
      Base class to handle utility methods.
      '''
  
      def load_from_connector(self, name, method_name):
          '''
          Load given connector (name) and apply the given method on it.
          Supported method: get_accounts and get_history.
          '''
          self.load_json()
          params_connector = { 'login': self.get_field("login"), 'password': self.get_field("password") }
          website = self.get_field("website")
          if website:
              params_connector['website'] = website
  
          try:
              connector = Connector(name, params_connector)
              results = {}
              callback = getattr(connector, method_name)
              results[name] = callback()
          except ModuleLoadError:
              self.raise_error("Could not load module: %s" % name)
          except BrowserIncorrectPassword:
              self.raise_error("Wrong credentials")
          except:
              self.raise_error("Something went wrong (weboob modules should "
                               "probably be updated)")
  
          return results
  
  
  class BankHandler(BaseBankHandler):
      """
      This handler is dedicated to retrieve data from bank accounts.
      """
  
      def post(self, name):
          """
          Grab data about all accounts from a given bank identifier.
  
          Bank type is given as URL parameter, credentials are given in body.
          For available bank type check: http://weboob.org/modules
          """
  
          self.return_json(self.load_from_connector(name, 'get_balances'))
  
  class BankHistoryHandler(BaseBankHandler):
      """
      This handler is dedicated to retrieve transaction history of bank accounts.
      """
  
  
      def post(self, name):
          """
          Grab history of all accounts from a given bank identifier.
  
          Bank type is given as URL parameter, credentials are given in body.
          For available bank type check: http://weboob.org/modules
          """
          self.return_json(self.load_from_connector(name, 'get_history'))
  
  
new_contents: import logging
  
  from weboob.core.modules import ModuleLoadError
  from weboob.exceptions import BrowserIncorrectPassword
  
  from handlers.base import BaseHandler
  from lib.connector import Connector
  
  logger = logging.getLogger('cozy-data-indexer.' + __name__)
  
  
  class BaseBankHandler(BaseHandler):
      '''
      Base class to handle utility methods.
      '''
  
      def load_from_connector(self, name, method_name):
          '''
          Load given connector (name) and apply the given method on it.
          Supported method: get_accounts and get_history.
  
          Expected fields:
  
          * login
          * password
          * website (optional)
          '''
          self.load_json()
          params_connector = {
              'login': self.get_field("login"),
              'password': self.get_field("password")
          }
  
          if "website" in self.request.arguments:
              website = self.get_field("website")
              if website:
                  params_connector['website'] = website
  
          try:
              connector = Connector(name, params_connector)
              results = {}
              callback = getattr(connector, method_name)
              results[name] = callback()
          except ModuleLoadError:
              self.raise_error("Could not load module: %s" % name)
          except BrowserIncorrectPassword:
              self.raise_error("Wrong credentials")
          except:
              self.raise_error("Something went wrong (weboob modules should "
                               "probably be updated)")
  
          return results
  
  
  class BankHandler(BaseBankHandler):
      """
      This handler is dedicated to retrieve data from bank accounts.
      """
  
      def post(self, name):
          """
          Grab data about all accounts from a given bank identifier.
  
          Bank type is given as URL parameter, credentials are given in body.
          For available bank type check: http://weboob.org/modules
          """
  
          self.return_json(self.load_from_connector(name, 'get_balances'))
  
  
  class BankHistoryHandler(BaseBankHandler):
      """
      This handler is dedicated to retrieve transaction history of bank accounts.
      """
  
  
      def post(self, name):
          """
          Grab history of all accounts from a given bank identifier.
  
          Bank type is given as URL parameter, credentials are given in body.
          For available bank type check: http://weboob.org/modules
          """
          self.return_json(self.load_from_connector(name, 'get_history'))
  
subject: fix connector handler