Python Sample Identification ETL

From truxwiki.com
Revision as of 14:12, 12 June 2020 by Sam (talk | contribs) (Created page with "This sample shows the steps needed to implement a byte identifier ETL in Python. <syntaxhighlight line lang="python"> import truxton def main(): etl = truxton.etl() etl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This sample shows the steps needed to implement a byte identifier ETL in Python.

 1 import truxton
 2 
 3 def main():
 4 
 5   etl = truxton.etl()
 6   etl.name = "Acme Identifier"
 7   etl.description = "This ETL identifies files using the Acme method"
 8   etl.queue = "acme"
 9   etl.stage = 2
10   etl.id = 26572
11   etl.addtype(truxton.Type_Unknown)
12 
13   message = etl.getmessage()
14 
15   while message is not None:
16     if message.length >= 16:
17       if message.signature == 0x55667788:
18         file_in_truxton = message.file()
19 
20         file_in_truxton.seek(4)
21 
22         if file_in_truxton.read(1) == 0:
23           file_in_truxton.changetype(10111)
24           message.file_type = 10111
25           message.route()
26 
27     message = etl.getmessage()
28 
29 if __name__ == "__main__":
30     main()

Code Walkthrough