Skip to content

Commit

Permalink
Merge pull request #19 from PyICe-ADI/fix_lab_utils_in_stdf
Browse files Browse the repository at this point in the history
Fix unused/untested lab_utils use-case change languishing from the or…
  • Loading branch information
xenomorphxx131 authored Apr 12, 2024
2 parents 9b1f7d0 + b1c9449 commit c9bc0ae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions PyICe/data_utils/stdf_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pystdf.IO import Parser
import pystdf.V4, time, math
from .. import lab_utils
from ..lab_utils.banners import print_banner
# ENUMS for fields by position within STDF record to make this code more readable.
# See: http://www.kanwoda.com/wp-content/uploads/2015/05/std-spec.pdf
# Return value is always in the form of the tuple: [RECORDTYPE, DATAOBJECT]
Expand Down Expand Up @@ -56,15 +56,15 @@ def scan_file(self, filename):
# self.metadata["BINCOUNT"][line[DATAOBJECT][SBIN_NUM]] = line[DATAOBJECT][SBIN_CNT] # Anyone care about this record, seems redundant?
if record_type is pystdf.V4.Mir: # Master information record
if state not in [None]:
lab_utils.print_banner(f'Corrupted STDF File: {filename}!', f'Got an MIR but not as the first Field. Last record type is "{state}".', length=160)
print_banner(f'Corrupted STDF File: {filename}!', f'Got an MIR but not as the first Field. Last record type is "{state}".', length=160)
if self.exit_if_malformed:
raise Exception("\n\nSet exit_if_malformed to False if you want to push on.")
self.metadata["SETUPTIME"] = {"UNIX": line[DATAOBJECT][SETUPTIME], "HUMAN": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(line[DATAOBJECT][SETUPTIME]))}
self.metadata["STARTTIME"] = {"UNIX": line[DATAOBJECT][STARTTIME], "HUMAN": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(line[DATAOBJECT][STARTTIME]))}
state = "MIR"
if record_type is pystdf.V4.Pir: # Product Information record - New Part Found!
if state not in ["MIR", "PRR"]:
lab_utils.print_banner(f'Corrupted STDF File: {filename}', f'Got a PIR but not after an MIR or after a PRR. Last record type is "{state}".', length=160)
print_banner(f'Corrupted STDF File: {filename}', f'Got a PIR but not after an MIR or after a PRR. Last record type is "{state}".', length=160)
if self.exit_if_malformed:
raise Exception("\n\nSet exit_if_malformed to False if you want to push on.")
this_part = {} # Each unit gets a fresh dictionary.
Expand All @@ -73,14 +73,14 @@ def scan_file(self, filename):
state = "PIR"
if record_type is pystdf.V4.Ptr: # Parametric Test Record - This is a test within this part.
if state not in ["PIR", "PTR"]:
lab_utils.print_banner(f'Corrupted STDF File: {filename}', f'Got a PTR but not at after a PIR or another PTR. Last record type is "{state}".', length=160)
print_banner(f'Corrupted STDF File: {filename}', f'Got a PTR but not at after a PIR or another PTR. Last record type is "{state}".', length=160)
if self.exit_if_malformed:
raise Exception("\n\nSet exit_if_malformed to False if you want to push on.")
this_part["TESTS"].append(line[DATAOBJECT]) # Grab the test data.
state = "PTR"
if record_type is pystdf.V4.Prr: # Product Results record - End of this part.
if state not in ["PIR", "PTR"]:
lab_utils.print_banner(f'Corrupted STDF File: {filename}', f'Got a PRR but not at after a PIR or a PTR. Last record type is "{state}".', length=160)
print_banner(f'Corrupted STDF File: {filename}', f'Got a PRR but not at after a PIR or a PTR. Last record type is "{state}".', length=160)
if self.exit_if_malformed:
raise Exception("\n\nSet exit_if_malformed to False if you want to push on.")
this_part["XLOC"] = line[DATAOBJECT][XLOC]
Expand All @@ -93,7 +93,7 @@ def scan_file(self, filename):
state = "PRR"
if record_type is pystdf.V4.Mrr: # Master information record
if state not in ["PRR"]:
lab_utils.print_banner(f'Corrupted STDF File: {filename}', f'Got an MRR but not after a PRR. Last record type is "{state}".', length=160)
print_banner(f'Corrupted STDF File: {filename}', f'Got an MRR but not after a PRR. Last record type is "{state}".', length=160)
if self.exit_if_malformed:
raise Exception("\n\nSet exit_if_malformed to False if you want to push on.")
state = "MRR"
Expand Down

0 comments on commit c9bc0ae

Please sign in to comment.