def __init__(self, qif, fid="UNKNOWN", org="UNKNOWN", bankid="UNKNOWN",
                 accttype="UNKNOWN", acctid="UNKNOWN", balance="UNKNOWN",
                 curdef=None, lang="ENG", dayfirst=False, debug=False):
        self.qif      = qif
        self.fid      = fid
        self.org      = org
        self.bankid   = bankid
        self.accttype = accttype
        self.acctid   = acctid
        self.balance  = balance
        self.curdef   = curdef
        self.lang     = lang
        self.debug    = debug
        self.dayfirst = dayfirst

        self.parsed_qif = None

        # FIXME: Move this to one of the OFX generation classes (Document or Response).
        self.txns_by_date = {}

        # This is a list of possible transaction types embedded in the
        # QIF Payee or Memo field (depending on bank and, it seems,
        # other factors).  The keys are used to match possible fields
        # that we can identify.  The values are used as substitutions,
        # since banks will use their own vernacular (like "DBT"
        # instead of "DEBIT") for some transaction types.  All of the
        # types in the values column (except "ACH", which is given
        # special treatment) are OFX-2.0 standard transaction types;
        # the keys are not all standard.  To add a new translation,
        # find the QIF name for the transaction type, and add it to
        # the keys column, then add the appropriate value from the
        # OFX-2.0 spec (see page 180 of doc/ofx/ofx-2.0/ofx20.pdf).
        # The substitution will be made if either the payee or memo
        # field begins with one of the keys followed by a "/", OR if
        # the payee or memo field exactly matches a key.
        self.txn_types = { "ACH"         : "ACH",
                           "CHECK CARD"  : "POS",
                           "CREDIT"      : "CREDIT",
                           "DBT"         : "DEBIT",
                           "DEBIT"       : "DEBIT",
                           "INT"         : "INT",
                           "DIV"         : "DIV",
                           "FEE"         : "FEE",
                           "SRVCHG"      : "SRVCHG",
                           "DEP"         : "DEP",
                           "DEPOSIT"     : "DEP",
                           "ATM"         : "ATM",
                           "POS"         : "POS",
                           "XFER"        : "XFER",
                           "CHECK"       : "CHECK",
                           "Checks"      : "CHECK",
                           "PAYMENT"     : "PAYMENT",
                           "CASH"        : "CASH",
                           "DIRECTDEP"   : "DIRECTDEP",
                           "DIRECTDEBIT" : "DIRECTDEBIT",
                           "REPEATPMT"   : "REPEATPMT",
                           "OTHER"       : "OTHER"        }

        # Some joker British bank starts QIF with a single bang and nothing
        # else.
        if re.match("!\n", self.qif) is not None:
            if self.debug: sys.stderr.write("Fixing typeless bang header.\n")
            self.qif = self.qif.replace("!", "!Type:Bank", 1)

        # Chase does not provide a Type header, so force one in the
        # case where it is omitted.
        if re.search("!Type:", self.qif, re.IGNORECASE) == None:
            if self.debug: sys.stderr.write("Forcing bank type header.\n")
            self.qif = "!Type:Bank\n" + self.qif

        acctblock = re.search("(!Account.*?\^\s*)", self.qif, re.DOTALL | re.IGNORECASE | re.MULTILINE)
        if acctblock is not None:
            block = acctblock.group(1)
            if self.debug:
                sys.stderr.write("Discarding account block from QIF file:\n%s" % block)
            self.qif = self.qif.replace(block, '', 1)

        # Some other personal finance program puts out a spurious transaction
        # showing current balance, but not as a balance -- instead as a
        # transaction before the type header.  And, there are a bunch of other
        # cases where crap before the type header is messing us up right now.
        # So, this is an awfully big hammer but one that at least lets people
        # import from other finance programs and broken banks.
        straycrap = re.search("^(.*?)!Type", self.qif, re.DOTALL | re.IGNORECASE | re.MULTILINE)
        if straycrap is not None:
            crap = straycrap.group(1)
            if 0 > len(crap):
              if self.debug:
                  sys.stderr.write("Discarding stray crap from beginning of QIF file:\n%s" % crap)
              self.qif = self.qif.replace(crap, '', 1)

        if self.debug: sys.stderr.write("Parsing document.\n")

        parser = ofxtools.QifParser(debug=debug)
        self.parsed_qif = parser.parse(self.qif)

        if self.debug: sys.stderr.write("Cleaning transactions.\n")

        # We do a two-pass conversion in order to check the dates of all
        # transactions in the statement, and convert all the dates using
        # the same date format.  The first pass does nothing but look
        # at dates; the second actually applies the date conversion and
        # all other conversions, and extracts information needed for
        # the final output (like date range).
        txn_list = self._extract_txn_list(self.parsed_qif)
        self._guess_formats(txn_list)
        self._clean_txn_list(txn_list)
dataset/ETHPy150Open wesabe/fixofx/lib/ofxtools/qif_converter.py/QifConverter.__init__/swapped operands of `>`