DESCRIPTION OF THE ISSUE
In run_filing of xml_runner.py, the final else clause, entered when there is a filing version not listed in ALLOWED_VERSIONSTRINGS or CSV_ALLOWED_VERSIONSTRINGS, has a print command not conditioned by the value of the verbose parameter, meaning the warning is printed when the OID is passed to run_filing and the Filing object instantiated. The Filing object is still returned by the function, so even though the version isn't allowed, the object is still instantiated and returned by the function but without the result attribute being set. Only then can the object be tested for its version.
This is true in run_sked where the final else statement contains the same code.
IMPACT
Print statements containing error information should be conditioned by the verbose flag for debugging purposes only so they can be suppressed in production code. Since this isn't passed as an exception, it can't be handled as an error when trying to access the Filling object with get_result and must be handled as a conditional on the Filing object's version_string. The possible workarounds include testing the first 4 characters for the version_string as an integer greater than 2012 or testing that Filing.result isn't None.
SUGGESTED CHANGES
- Suppress the
print statement if verbose = False in both run_filing and run_sked
- Raise an exception when the filing version isn't supported for the operation either in
get_result if there's a compelling reason to instantiate the Filing object when there is a filing version mismatch or in run_filing and run_sked if the Filing object shouldn't be instantiated when the filing version doesn't match the ALLOWED_VERSIONSTRINGS or CSV_ALLOWED_VERSIONSTRINGS
- Make the code more DRY by combining the functionality of
run_filing and run_sked so these functions don't repeat the same code.
JUSTIFICATION
Better error handling for this situation will help make this code work better without having to dive into the code internals to understand what versions are allowed and which aren't. Raising the exception allows the user to put this into a try-catch and figure out how they want to handle the program flow without having print statements that can't be suppressed. Consolidating the run_filing and run_sked functions will help improve the maintainability of this code going forward. Being able to process the schedules individually is a great feature but this could break if updates to one function aren't replicated in the other.
DESCRIPTION OF THE ISSUE
In
run_filingofxml_runner.py, the final else clause, entered when there is a filing version not listed inALLOWED_VERSIONSTRINGSorCSV_ALLOWED_VERSIONSTRINGS, has a print command not conditioned by the value of theverboseparameter, meaning the warning is printed when the OID is passed torun_filingand the Filing object instantiated. The Filing object is still returned by the function, so even though the version isn't allowed, the object is still instantiated and returned by the function but without theresultattribute being set. Only then can the object be tested for its version.This is true in
run_skedwhere the finalelsestatement contains the same code.IMPACT
Print statements containing error information should be conditioned by the verbose flag for debugging purposes only so they can be suppressed in production code. Since this isn't passed as an exception, it can't be handled as an error when trying to access the Filling object with
get_resultand must be handled as a conditional on the Filing object'sversion_string. The possible workarounds include testing the first 4 characters for theversion_stringas an integer greater than 2012 or testing thatFiling.resultisn't None.SUGGESTED CHANGES
printstatement ifverbose = Falsein bothrun_filingandrun_skedget_resultif there's a compelling reason to instantiate the Filing object when there is a filing version mismatch or inrun_filingandrun_skedif the Filing object shouldn't be instantiated when the filing version doesn't match theALLOWED_VERSIONSTRINGSorCSV_ALLOWED_VERSIONSTRINGSrun_filingandrun_skedso these functions don't repeat the same code.JUSTIFICATION
Better error handling for this situation will help make this code work better without having to dive into the code internals to understand what versions are allowed and which aren't. Raising the exception allows the user to put this into a try-catch and figure out how they want to handle the program flow without having print statements that can't be suppressed. Consolidating the
run_filingandrun_skedfunctions will help improve the maintainability of this code going forward. Being able to process the schedules individually is a great feature but this could break if updates to one function aren't replicated in the other.