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

Move argparse object setup out of pdf2txt.py main to separate function. #173

Merged
merged 1 commit into from
Aug 21, 2018

Conversation

wlbentley
Copy link
Contributor

As preparation for implementing Sphinx documentation, create a
separate maketheparser() function that builds and returns the
argparse.ArgumentParser() object.

Move import argparse out of main to the top of the file.

Add add_help=True to the parser.

The updated script parsed the samples/simple1.pdf file correctly,
as a basic test.

As preparation for implementing Sphinx documentation, create a
separate function that builds and returns the argparse parser.
Move import argparse out of main to the top of the file.
@wlbentley wlbentley changed the title Move argparse object setup out of main to separate function. Move argparse object setup out of pdf2txt.py main to separate function. Aug 13, 2018
@tataganesh
Copy link
Member

If this has been tested, I can merge it, since the main was already using Argparse.

@wlbentley
Copy link
Contributor Author

  1. Running pdf2txt.py outputs the short help, as expected, and throws an error for the missing filename:
pdf2txt.py: error: the following arguments are required: files
  1. Running pdf2txt.py -h outputs the full help, as expected, without errors.
  2. Running pdf2txt.py samples/simple1.pdf works as expected.
  3. Running pdf2txt.py -o tempout samples/simple1.pdf places the output as text in the file tempout, as expected.

The automated tests in tests/test_tools_pdf2txt.py don't seem to test any more options than that.

To the best of my knowledge, the Argparse code now under the maketheparser() function was not altered while moving it outside of main().

So, I think it's ready to merge.

@tataganesh tataganesh merged commit 1ea9446 into pdfminer:master Aug 21, 2018
@tataganesh
Copy link
Member

Looks good!

@wlbentley wlbentley deleted the pdf2txt-maketheparser branch November 13, 2018 03:41
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.

2 participants