UmbrellaDish patch importable fido 1 #149
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the endeavor of integration in our python3-based preservation workflow, FIDO is a diva in need of extra treatment. It is at last the main() function that combines argument processing boilerplate as is to be done when called from the command line on one hand and purpose-specific things on the other.
Currently we need to redirect of sys.stdin and sys.stderr to an in-memory StringIO, shadow-resetting sys.argv to a bogus value in order to prevent print_help() from being called, and then feeding the StringIO thing to a csv reader instance. This makes our code gather pity when shown around, though it feels yet better in comparison to a plain sub-process (python calling python as a sub-process? Not quite easy to even type such a thought).
Maybe main() should even be a yielding generator when called without handle_matches argument. Everything needed in command-line tool mode should be restricted in scope, i.e. it belongs into the
if __name__ = '__main__'
clause.Even if you intended the Fido class to be used in any integrated environment, main() contains too much logic that one might want and would be required to re-implement.
The changes have not yet been tested as in the first place I would like to know if the direction of my proposal draws your accordance.