Skip to content

Commit

Permalink
Merge pull request #78 from rowingdude/rowingdude/issue71
Browse files Browse the repository at this point in the history
Attribute list and list-compression to replace multitude of "Ifs"
  • Loading branch information
rowingdude authored Aug 3, 2024
2 parents a6be7d1 + 9c962a4 commit 4aa75a0
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions analyzemft/mft.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,17 @@ def mft_to_csv(record: Dict[str, Any], ret_header: bool) -> List[str]:

csv_string.extend(tmp_string)

# One darned big if statement, alas.
csv_string.append('True') if 'si' in record else csv_string.append('False')
csv_string.append('True') if 'al' in record else csv_string.append('False')
csv_string.append('True') if record['fncnt'] > 0 else csv_string.append('False')
csv_string.append('True') if 'objid' in record else csv_string.append('False')
csv_string.append('True') if 'volname' in record else csv_string.append('False')
csv_string.append('True') if 'volinfo' in record else csv_string.append('False')
csv_string.append('True') if 'data' in record else csv_string.append('False')
csv_string.append('True') if 'indexroot' in record else csv_string.append('False')
csv_string.append('True') if 'indexallocation' in record else csv_string.append('False')
csv_string.append('True') if 'bitmap' in record else csv_string.append('False')
csv_string.append('True') if 'reparse' in record else csv_string.append('False')
csv_string.append('True') if 'eainfo' in record else csv_string.append('False')
csv_string.append('True') if 'ea' in record else csv_string.append('False')
csv_string.append('True') if 'propertyset' in record else csv_string.append('False')
csv_string.append('True') if 'loggedutility' in record else csv_string.append('False')

attributes = ['si', 'al', 'objid', 'volname', 'volinfo', 'data', 'indexroot',
'indexallocation', 'bitmap', 'reparse', 'eainfo', 'ea',
'propertyset', 'loggedutility']

csv_string.extend(
['True' if attr in record else 'False' for attr in attributes]
)

# Special case for 'fncnt'
csv_string.append('True' if record.get('fncnt', 0) > 0 else 'False')

if 'notes' in record: # Log of abnormal activity related to this record
csv_string.append(record['notes'])
Expand Down

0 comments on commit 4aa75a0

Please sign in to comment.