summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth M Morton <seth.m.morton@gmail.com>2015-01-22 20:51:18 -0800
committerSeth M Morton <seth.m.morton@gmail.com>2015-01-22 20:51:18 -0800
commit3bc8ae9116d1de40904dc510c2a90cfd65b5ebf7 (patch)
tree5dde13c0a65f4792c56459c61c27ed00cdf0da20
parent3736dcd56b5b0bda9781e5c95a96c4123d7f3c98 (diff)
parent8fdf546ab0e774c423044c5c806288f9210312d8 (diff)
downloadnatsort-3bc8ae9116d1de40904dc510c2a90cfd65b5ebf7.tar.gz
Incorporated pull requests from msabramo.
Added code blocks in README.rst, and fixed some grammar.
-rw-r--r--README.rst26
-rw-r--r--docs/source/changelog.rst4
-rw-r--r--natsort/natsort.py44
-rw-r--r--natsort/utils.py10
-rw-r--r--test_natsort/test_natsort.py4
5 files changed, 49 insertions, 39 deletions
diff --git a/README.rst b/README.rst
index 9998c87..31f9166 100644
--- a/README.rst
+++ b/README.rst
@@ -18,7 +18,9 @@ Quick Description
When you try to sort a list of strings that contain numbers, the normal python
sort algorithm sorts lexicographically, so you might not get the results that you
-expect::
+expect:
+
+.. code-block:: python
>>> a = ['a2', 'a9', 'a1', 'a4', 'a10']
>>> sorted(a)
@@ -30,7 +32,9 @@ letters (i.e. 'b', 'ba', 'c').
``natsort`` provides a function ``natsorted`` that helps sort lists "naturally",
either as real numbers (i.e. signed/unsigned floats or ints), or as versions.
-Using ``natsorted`` is simple::
+Using ``natsorted`` is simple:
+
+.. code-block:: python
>>> from natsort import natsorted
>>> a = ['a2', 'a9', 'a1', 'a4', 'a10']
@@ -40,7 +44,9 @@ Using ``natsorted`` is simple::
``natsorted`` identifies real numbers anywhere in a string and sorts them
naturally.
-Sorting version numbers is just as easy with the ``versorted`` function::
+Sorting version numbers is just as easy with the ``versorted`` function:
+
+.. code-block:: python
>>> from natsort import versorted
>>> a = ['version-1.9', 'version-2.0', 'version-1.11', 'version-1.10']
@@ -51,7 +57,9 @@ Sorting version numbers is just as easy with the ``versorted`` function::
You can also perform locale-aware sorting (or "human sorting"), where the
non-numeric characters are ordered based on their meaning, not on their
-ordinal value; this can be achieved with the ``humansorted`` function::
+ordinal value; this can be achieved with the ``humansorted`` function:
+
+.. code-block:: python
>>> a = ['Apple', 'Banana', 'apple', 'banana']
>>> natsorted(a)
@@ -70,7 +78,9 @@ and the "Optional Dependencies" section
below before using the ``humansorted`` function.
You can mix and match ``int``, ``float``, and ``str`` (or ``unicode``) types
-when you sort::
+when you sort:
+
+.. code-block:: python
>>> a = ['4.5', 6, 2.0, '5', 'a']
>>> natsorted(a)
@@ -127,8 +137,8 @@ on your computer; this will give more reliable results. ``natsort`` will not
require (or check) that `PyICU <https://pypi.python.org/pypi/PyICU>`_ is installed
at installation.
-Depreciation Notices
---------------------
+Deprecation Notices
+-------------------
- In ``natsort`` version 4.0.0, the ``number_type``, ``signed``, ``exp``,
``as_path``, and ``py3_safe`` options will be removed from the (documented)
@@ -176,7 +186,7 @@ for the complete `changelog <http://pythonhosted.org//natsort/changelog.html>`_.
- Added the 'alg' argument to the 'natsort' functions. This argument
accepts an enum that is used to indicate the options the user wishes
to use. The 'number_type', 'signed', 'exp', 'as_path', and 'py3_safe'
- options are being depreciated and will become (undocumented)
+ options are being deprecated and will become (undocumented)
keyword-only options in natsort version 4.0.0.
- The user can now modify how 'natsort' handles the case of non-numeric
characters.
diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst
index 3a15079..ea05e70 100644
--- a/docs/source/changelog.rst
+++ b/docs/source/changelog.rst
@@ -25,7 +25,7 @@ Changelog
- Added the 'alg' argument to the 'natsort' functions. This argument
accepts an enum that is used to indicate the options the user wishes
to use. The 'number_type', 'signed', 'exp', 'as_path', and 'py3_safe'
- options are being depreciated and will become (undocumented)
+ options are being deprecated and will become (undocumented)
keyword-only options in natsort version 4.0.0.
- The user can now modify how 'natsort' handles the case of non-numeric
characters.
@@ -53,7 +53,7 @@ Changelog
passed on to recursive calls of 'natsort_key'.
- Added a 'natsort_keygen' function that will generate a wrapped version
of 'natsort_key' that is easier to call. 'natsort_key' is now set to
- depreciate at natsort version 4.0.0.
+ deprecate at natsort version 4.0.0.
- Added an 'as_path' option to 'natsorted' & co. that will try to treat
input strings as filepaths. This will help yield correct results for
OS-generated inputs like
diff --git a/natsort/natsort.py b/natsort/natsort.py
index d3d6f8a..3407982 100644
--- a/natsort/natsort.py
+++ b/natsort/natsort.py
@@ -39,7 +39,7 @@ def natsort_key(val, key=None, number_type=float, signed=None, exp=None,
It is designed for use in passing to the 'sorted' builtin or
'sort' attribute of lists.
- .. note:: Depreciated since version 3.4.0.
+ .. note:: Deprecated since version 3.4.0.
This function remains in the publicly exposed API for
backwards-compatibility reasons, but future development
should use the newer `natsort_keygen` function. It is
@@ -60,31 +60,31 @@ def natsort_key(val, key=None, number_type=float, signed=None, exp=None,
It should accept a single argument and return a single value.
number_type : {{None, float, int}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
signed : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
exp : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
as_path : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
py3_safe : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -149,7 +149,7 @@ def natsort_key(val, key=None, number_type=float, signed=None, exp=None,
({u}'', 43.0, {u}'h', 7.0, {u}'', 3.0)
"""
- msg = "natsort_key is depreciated as of 3.4.0, please use natsort_keygen"
+ msg = "natsort_key is deprecated as of 3.4.0, please use natsort_keygen"
warn(msg, DeprecationWarning)
alg = _args_to_enum(number_type, signed, exp, as_path, py3_safe) | alg
return _natsort_key(val, key, alg)
@@ -177,31 +177,31 @@ def natsort_keygen(key=None, number_type=float, signed=None, exp=None,
It should accept a single argument and return a single value.
number_type : {{None, float, int}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
signed : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
exp : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
as_path : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
py3_safe : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -269,19 +269,19 @@ def natsorted(seq, key=None, number_type=float, signed=None, exp=None,
It should accept a single argument and return a single value.
number_type : {{None, float, int}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
signed : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
exp : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -291,7 +291,7 @@ def natsorted(seq, key=None, number_type=float, signed=None, exp=None,
`False`.
as_path : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -361,7 +361,7 @@ def versorted(seq, key=None, reverse=False, as_path=None, alg=0):
`False`.
as_path : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -495,19 +495,19 @@ def index_natsorted(seq, key=None, number_type=float, signed=None, exp=None,
It should accept a single argument and return a single value.
number_type : {{None, float, int}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
signed : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
exp : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -517,7 +517,7 @@ def index_natsorted(seq, key=None, number_type=float, signed=None, exp=None,
`False`.
as_path : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
@@ -606,7 +606,7 @@ def index_versorted(seq, key=None, reverse=False, as_path=None, alg=0):
`False`.
as_path : {{True, False}}, optional
- Depreciated as of version 3.5.0 and will become an undocumented
+ Deprecated as of version 3.5.0 and will become an undocumented
keyword-only argument in 4.0.0. Please use the `alg` argument
for all future development. See :class:`ns` class documentation for
details.
diff --git a/natsort/utils.py b/natsort/utils.py
index 046f4ca..4b580bd 100644
--- a/natsort/utils.py
+++ b/natsort/utils.py
@@ -82,28 +82,28 @@ def _args_to_enum(number_type, signed, exp, as_path, py3_safe):
"""A function to convert input booleans to an enum-type argument."""
alg = 0
if number_type is not float:
- msg = "The 'number_type' argument is depreciated as of 3.5.0, "
+ msg = "The 'number_type' argument is deprecated as of 3.5.0, "
msg += "please use 'alg=ns.FLOAT', 'alg=ns.INT', or 'alg=ns.VERSION'"
warn(msg, DeprecationWarning)
alg |= (_nsdict['INT'] * bool(number_type in (int, None)))
alg |= (_nsdict['UNSIGNED'] * (number_type is None))
if signed is not None:
- msg = "The 'signed' argument is depreciated as of 3.5.0, "
+ msg = "The 'signed' argument is deprecated as of 3.5.0, "
msg += "please use 'alg=ns.UNSIGNED'."
warn(msg, DeprecationWarning)
alg |= (_nsdict['UNSIGNED'] * (not signed))
if exp is not None:
- msg = "The 'exp' argument is depreciated as of 3.5.0, "
+ msg = "The 'exp' argument is deprecated as of 3.5.0, "
msg += "please use 'alg=ns.NOEXP'."
warn(msg, DeprecationWarning)
alg |= (_nsdict['NOEXP'] * (not exp))
if as_path is not None:
- msg = "The 'as_path' argument is depreciated as of 3.5.0, "
+ msg = "The 'as_path' argument is deprecated as of 3.5.0, "
msg += "please use 'alg=ns.PATH'."
warn(msg, DeprecationWarning)
alg |= (_nsdict['PATH'] * as_path)
if py3_safe is not None:
- msg = "The 'py3_safe' argument is depreciated as of 3.5.0, "
+ msg = "The 'py3_safe' argument is deprecated as of 3.5.0, "
msg += "please use 'alg=ns.TYPESAFE'."
warn(msg, DeprecationWarning)
alg |= (_nsdict['TYPESAFE'] * py3_safe)
diff --git a/test_natsort/test_natsort.py b/test_natsort/test_natsort.py
index 670050f..d89730c 100644
--- a/test_natsort/test_natsort.py
+++ b/test_natsort/test_natsort.py
@@ -16,12 +16,12 @@ from natsort.utils import _natsort_key
def test_natsort_key_public():
# Identical to _natsort_key
- # But it raises a depreciation warning
+ # But it raises a deprecation warning
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
assert natsort_key('a-5.034e2') == _natsort_key('a-5.034e2', key=None, alg=ns.F)
assert len(w) == 1
- assert "natsort_key is depreciated as of 3.4.0, please use natsort_keygen" in str(w[-1].message)
+ assert "natsort_key is deprecated as of 3.4.0, please use natsort_keygen" in str(w[-1].message)
assert natsort_key('a-5.034e2', number_type=float, signed=False, exp=False) == _natsort_key('a-5.034e2', key=None, alg=ns.F | ns.U | ns.N)
assert natsort_key('a-5.034e2', alg=ns.F | ns.U | ns.N) == _natsort_key('a-5.034e2', key=None, alg=ns.F | ns.U | ns.N)