-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add destination folder #13
Comments
@davidverweij -- I agree that a result folder (or "output"?) in the root directory would be ideal, but imho should not be committed to the repo (so added to the git ignore), and also agree that adding an argument is required. As for implementation, have you tried updating Let me know if that works for you too -- it requires that the directory For path creation etc, we should use python's pathlib: docs and demo. |
I've added a draft demo for you to test/review of outputting the files to any given path that uses pathlib (from python 3.4). |
Ah yes, I see now that ZipFile takes paths or pathlike objects as a parameter. Still, wondering why a 'quick' path string didn't work before - perhaps due to Python 2.7? Either way, I'll have a look at the demo soon. Regarding the .gitignore, perhaps we can (for now) set an output folder, and add that to the .git ignore. Then, for each use, a subfolder can be created in that output folder - perhaps using a timestamp in combination with the name of the .csv or .docx file used. This could be default behaviour. A parameter could allow an alternative path. |
re:why ZipFile may not have worked -- yes, and likely because we are using an F string and those I realised that we ignore |
Actually, we are ignoring numbered .docx - so if we were to explore #16 we might need to add any .docx and except the example.docx in tests/data |
I am done with this. but i have a question what to do if specified directory is not available?? |
@salmannotkhan , we are working on this in the master/output branch, see the PR #18 . Feel free to add your suggestion in the discussion there. Also, if you find any potential hazards, such as the availability of a custom directory - which is a good point, please do add these in the discussion at #18. @jawrainey currently implemented the use of |
should we create the directory or throw an error?? |
What do you reckon? Any pro/cons to either approach? |
i guess we should create directory to make hassle free experience |
@salmannotkhan -- the hassle free experience of creating a directory (including nested directories) is implemented in #18. This also means we don't have to concern ourselves with throw/catching issues. Maybe you can pull down those changes to verify that they're working? |
i guess we don't that userdefined function instead of that we can use os library if not os.path.isdir(output):
os.makedirs(output) |
@salmannotkhan -- have you had a look at the implementation in #18 PR see it here. It uses the |
ok then that's good also i didn't knew about pathlib library that's why |
As is, I couldn't find a way to add a destination folder, as docx-mailmerge requires a ZipFile destination. A quick test showed that it doesn't bite on a given path. Hence, I suggest we post-processes the output, by - once it is generated - moving it to a specific subfolder. We can use shutil for this.
Actually, I would argue we create a 'result' folder by default to keep the directory clean (expecting more than 1 .docx to be created). We could add an argument if a different folder is preferred to be used.
Thoughts?
The text was updated successfully, but these errors were encountered: