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
Conversation
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: |
There was a problem hiding this comment.
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! :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, got it!
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 |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
Added
-f
or--filelist
flag that acceptsfilename
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