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

Check for too recent of pandoc version #814

Merged
merged 3 commits into from
May 16, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions nbconvert/utils/pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .exceptions import ConversionException

_minimal_version = "1.12.1"
_maximal_version = "2.0.0"

def pandoc(source, fmt, to, extra_args=None, encoding='utf-8'):
"""Convert an input string using pandoc.
Expand Down Expand Up @@ -100,11 +101,12 @@ def check_pandoc_version():
"output of pandoc --version.\nContinuing...",
RuntimeWarning, stacklevel=2)
return False
ok = check_version(v , _minimal_version )
ok = check_version(v, _minimal_version, _maximal_version)
if not ok:
warnings.warn( "You are using an old version of pandoc (%s)\n" % v +
"Recommended version is %s.\nTry updating." % _minimal_version +
"http://pandoc.org/installing.html.\nContinuing with doubts...",
warnings.warn( "You are using an unsupported version of pandoc (%s).\n" % v +
"Your version must be at least (%s) " % _minimal_version +
"but less than (%s).\n" % _maximal_version +
"Refer to http://pandoc.org/installing.html.\nContinuing with doubts...",
RuntimeWarning, stacklevel=2)
return ok

Expand Down
13 changes: 8 additions & 5 deletions nbconvert/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@
from distutils.version import LooseVersion


def check_version(v, check):
"""check version string v >= check
def check_version(v, min_v, max_v):
"""check version string v >= min_v and v < max_v

Parameters
----------
v : str
version of the package
check : str
minimal version required
min_v : str
minimal version supported
max_v : str
earliest version not supported

Note: If dev/prerelease tags result in TypeError for string-number
comparison, it is assumed that the check passes and the version dependency
is satisfied. Users on dev branches are responsible for keeping their own
packages up to date.
"""

try:
return LooseVersion(v) >= LooseVersion(check)
return LooseVersion(v) >= LooseVersion(min_v) and LooseVersion(v) < LooseVersion(max_v)
except TypeError:
return True