Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
abNet2222Gross3333
"""))
expect = """OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
abNet2222Gross3333
"""
ofx_file = OfxPreprocessedFile(fh)
data = ofx_file.fh.read()
self.assertEqual(data, expect)
def __init__(self, fh):
super(OfxPreprocessedFile, self).__init__(fh)
if self.fh is None:
return
ofx_string = self.fh.read()
# find all closing tags as hints
closing_tags = [t.upper() for t in re.findall(r'(?i)',
ofx_string)]
# close all tags that don't have closing tags and
# leave all other data intact
last_open_tag = None
tokens = re.split(r'(?i)()', ofx_string)
new_fh = StringIO()
for token in tokens:
statement class and continue to run. Note: the library does not
guarantee that no exceptions will be raised to the caller, only
that statements will include bad transactions (which are marked).
'''
cls.fail_fast = fail_fast
cls.custom_date_format = custom_date_format
if not hasattr(file_handle, 'seek'):
raise TypeError(six.u('parse() accepts a seek-able file handle\
, not %s' % type(file_handle).__name__))
ofx_obj = Ofx()
# Store the headers
ofx_file = OfxPreprocessedFile(file_handle)
ofx_obj.headers = ofx_file.headers
ofx_obj.accounts = []
ofx_obj.signon = None
ofx = soup_maker(ofx_file.fh)
if ofx.find('ofx') is None:
raise OfxParserException('The ofx file is empty!')
sonrs_ofx = ofx.find('sonrs')
if sonrs_ofx:
ofx_obj.signon = cls.parseSonrs(sonrs_ofx)
stmttrnrs = ofx.find('stmttrnrs')
if stmttrnrs:
stmttrnrs_trnuid = stmttrnrs.find('trnuid')
if stmttrnrs_trnuid: