Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _find_segment_for_reference(self, name, ref):
segs = self._find_segments(name)
for seg in segs:
segsplit = split_for_data_elements(split_for_data_groups(seg)[0])
if segsplit[3] == str(ref.segmentno):
return seg
def get_touchdowns(self, msg: FinTSMessage):
touchdown = {}
for msgseg in msg.encrypted_segments:
seg = self._find_segment_for_reference('HIRMS', msgseg)
if seg:
parts = split_for_data_groups(seg)[1:]
for p in parts:
psplit = split_for_data_elements(p)
if psplit[0] == "3040":
td = psplit[3]
touchdown[msgseg.type] = fints_unescape(td)
return touchdown
def _get_segment_max_version(self, name):
v = 3
segs = self._find_segments(name)
for s in segs:
parts = split_for_data_groups(s)
segheader = split_for_data_elements(parts[0])
curver = int(segheader[2])
if curver > v:
v = curver
return v
def get_summary_by_segment(self, name=None):
if name and name not in ('HIRMS', 'HIRMG'):
raise ValueError('Unsupported segment for message summary')
if name:
names = [name]
else:
names = ('HIRMS', 'HIRMG')
res = {}
for name in names:
seg = self._find_segment(name)
parts = split_for_data_groups(seg)[1:]
for de in parts:
de = split_for_data_elements(de)
res[de[0]] = de[2]
return res
def get_supported_tan_mechanisms(self):
segs = self._find_segments('HIRMS')
tan_methods = []
for seg in segs:
deg = split_for_data_groups(seg)
for de in deg:
if de[0:4] == '3920':
d = split_for_data_elements(de)
for i in range(3, len(d)):
tan_methods.append(d[i])
# Get parameters for tan methods
seg = self._find_segments('HITANS')
methods = []
for s in seg:
spl = split_for_data_elements(s)
if spl[2] == '1':
model = TANMethod1
elif spl[2] == '2':
model = TANMethod2
elif spl[2] == '3':
model = TANMethod3
elif spl[2] == '4':
model = TANMethod4
def get_supported_tan_mechanisms(self):
segs = self._find_segments('HIRMS')
tan_methods = []
for seg in segs:
deg = split_for_data_groups(seg)
for de in deg:
if de[0:4] == '3920':
d = split_for_data_elements(de)
for i in range(3, len(d)):
tan_methods.append(d[i])
# Get parameters for tan methods
seg = self._find_segments('HITANS')
methods = []
for s in seg:
spl = split_for_data_elements(s)
if spl[2] == '1':
model = TANMethod1
elif spl[2] == '2':
model = TANMethod2
elif spl[2] == '3':
model = TANMethod3
elif spl[2] == '4':
model = TANMethod4
elif spl[2] == '5':
model = TANMethod5
elif spl[2] == '6':
model = TANMethod6
else:
raise NotImplementedError(
"HITANS segment version {} is currently not implemented".format(
spl[2]