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

Download Folder, #167, fixes: https://github.com/bebraw/pypandoc/issu… #184

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ Note that for citeproc tests to pass you'll need to have [pandoc-citeproc](https
* [Felix Yan](https://github.com/felixonmars) - Added installation instructions for Arch Linux.
* [Kolen Cheung](https://github.com/ickc) - Implement `_get_pandoc_urls` for installing arbitrary version as well as the latest version of pandoc. Minor: README, Travis, setup.py.
* [Rebecca Heineman](https://github.com/burgerbecky) - Added scanning code for finding pandoc in Windows
* [Andrew Barraford](https://github.com/abarrafo) - Download destination.

## License

Expand Down
14 changes: 12 additions & 2 deletions pypandoc/pandoc_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _handle_win32(filename, targetfolder):
print("* Done.")


def download_pandoc(url=None, targetfolder=None, version="latest", quiet=False, delete_installer=False):
def download_pandoc(url=None, targetfolder=None, version="latest", quiet=False, delete_installer=False, download_folder=None):
"""Download and unpack pandoc

Downloads prebuild binaries for pandoc from `url` and unpacks it into
Expand All @@ -160,9 +160,12 @@ def download_pandoc(url=None, targetfolder=None, version="latest", quiet=False,
the latest available release at the time pypandoc was released.

:param str targetfolder: directory, where the binaries should be installed
to. If no `targetfolder` is give, uses a platform specific user
to. If no `targetfolder` is given, uses a platform specific user
location: `~/bin` on Linux, `~/Applications/pandoc` on Mac OS X, and
`~\\AppData\\Local\\Pandoc` on Windows.

:param str download_folder: Directory, where the installer should download files before unpacking
to the target folder. If no `download_folder` is given, uses the current directory. example: `/tmp/`, `/tmp`
"""
if quiet:
sys.stdout = open(os.devnull, 'w')
Expand All @@ -184,6 +187,13 @@ def download_pandoc(url=None, targetfolder=None, version="latest", quiet=False,
url = pandoc_urls[pf]

filename = url.split("/")[-1]

if download_folder is not None:
if download_folder.endswith('/'):
download_folder = download_folder[:-1]

filename = os.path.expanduser(download_folder) + '/' + filename

if os.path.isfile(filename):
print("* Using already downloaded file %s" % (filename))
else:
Expand Down