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

Support for multiple files - input as a file list - using -f flag #21

Closed
wants to merge 3 commits into from

Conversation

cibinjoseph
Copy link

@cibinjoseph cibinjoseph commented Feb 1, 2018

Added -f or --filelist flag that accepts filename to be a file containing list of file names to be converted to pdf format.
Usage: code2pdf -f list_of_files
where the file list_of_files contains file names of files to be converted to pdf format.
Caveats: This will not work if QT pops segfault

@cibinjoseph cibinjoseph changed the title Support for multiple files input as a file list Support for multiple files - input as a file list Feb 1, 2018
@cibinjoseph cibinjoseph changed the title Support for multiple files - input as a file list Support for multiple files - input as a file list - using -f flag Feb 1, 2018
pdf_file = get_output_file(args.filename, args.outputfile)
pdf = Code2pdf(args.filename, pdf_file, args.size)
pdf.init_print(linenos=args.linenos, style=args.style)
else:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cibinjoseph Hi! Can we add a test suite for your changes before we merge? Also, update the usage/argparser instructions accordingly. Thanks! :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(On the test suite) Sure! How do you wanna go about it?
And I had already updated the argparser instructions in the commit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll edit the 'usage' section in a while!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cibinjoseph You may find some test suit written under tests/test.py. You may add yours there as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, got it!

@cibinjoseph
Copy link
Author

I'd also like to add a flag (later) for the pdf document-created from multiple file sources-to be a single file. Would be useful for creating documentation type pdfs. Something similar to example.pdf provided by lucascaton/code2pdf

Copy link
Owner

@tushar-rishav tushar-rishav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the changes and add a test suite.

pdf = Code2pdf(args.filename, pdf_file, args.size)
pdf.init_print(linenos=args.linenos, style=args.style)
else:
with open(args.filename) as filelist:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cibinjoseph I doubt here with open would work this way. It expects a string or buffer and not a list. Even if type of filename is not a list but a string, you may still want to split the filenames and feed to open separately.

Anyway, that's why I asked for a test suite. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work for me.
open(args.filename) as filelist: opens the file that contains the list of file names.
The next line filenames=filelist.read().splitlines() would parse filelist for the names of the files and then store it as a list in filenames.

And yes, I did want to finish the test suite but got caught up with some work. Don't accept without the test suite! :D

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember getting a segmentation fault from PyQT after the program run (for the copy in your repo too). That seemed to deter me from working on the test suite. Have to check if it still exists when PyQT is compiled from scratch.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cibinjoseph Cool! I misunderstood filename being comma separated list of file names passed as a console arg. :)

Please feel free to look into the seg fault issue as I've not been able to investigate myself due to work commitments. I believe there is already an issue created by you for this.
Also, to be consistent, I will go ahead with your current PR once you've added the suite. Thanks!

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.

None yet

2 participants