Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UmbrellaDish patch importable fido 1 #149

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

UmbrellaDish
Copy link

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.

*Not tested, yet* Take it as an issue with source code attachment ready to merge if error-free.

Moved argument processing and sys.argv checks out of main() into `if __name__ == '__main__'` clause.

Applied dest='other_name' for certain names that have reserved meaning in python or which are to short to be meaningful. `main()` accepts directly passed keyword arguments (in theory they may be positional, but rather don't), so the caller does not need argparse.
Spotted more left-overs to fix after lunch
@techmaurice
Copy link
Contributor

techmaurice commented Apr 11, 2019

No longer involved in this project (but still lurkin' tho'), and this is what I came up with back then:

http://wiki.opf-labs.org/display/KB/FIDO+Python+workflow+implementation+tips

HTH

@ablwr
Copy link
Contributor

ablwr commented Oct 1, 2019

Rebasing this should bring it up to date with the master code base and get the build tests passing.

@carlwilson
Copy link
Member

@adamfarquhar this is probably worth investigating at least. The OP makes some good points and it might be they could be addressed to some degree by refactoring toward an API and library.

@carlwilson carlwilson changed the base branch from master to main September 2, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants