summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth M Morton <seth.m.morton@gmail.com>2018-11-18 22:11:31 -0800
committerSeth Morton <seth.m.morton@gmail.com>2019-03-03 21:17:49 -0800
commit06719db445ea8642dcce49b99546e983971e7fda (patch)
treeb420d9d2871f5442560cbedc701e445117c3c961
parent44f54c05721f49964f1686416913730167e0815c (diff)
downloadnatsort-06719db445ea8642dcce49b99546e983971e7fda.tar.gz
Remove u_format decorator
Docstrings do not need support for "u" prefixes in results.
-rw-r--r--natsort/compat/py23.py44
-rw-r--r--natsort/utils.py7
2 files changed, 2 insertions, 49 deletions
diff --git a/natsort/compat/py23.py b/natsort/compat/py23.py
index 532ecf6..bac2781 100644
--- a/natsort/compat/py23.py
+++ b/natsort/compat/py23.py
@@ -54,47 +54,3 @@ else:
py23_zip = itertools.izip
py23_map = itertools.imap
py23_filter = itertools.ifilter
-
-
-# This function is intended to decorate other functions that will modify
-# either a string directly, or a function's docstring.
-def _modify_str_or_docstring(str_change_func):
- @functools.wraps(str_change_func)
- def wrapper(func_or_str):
- if isinstance(func_or_str, py23_basestring):
- func = None
- doc = func_or_str
- else:
- func = func_or_str
- doc = func.__doc__
-
- if doc is not None:
- doc = str_change_func(doc)
-
- if func:
- func.__doc__ = doc
- return func
- return doc
-
- return wrapper
-
-
-# Properly modify a doctstring to either have the unicode literal or not.
-if PY_VERSION >= 3:
- # Abstract u'abc' syntax:
- @_modify_str_or_docstring
- def u_format(s):
- """"{u}'abc'" --> "'abc'" (Python 3)
-
- Accepts a string or a function, so it can be used as a decorator."""
- return s.format(u="")
-
-
-else:
- # Abstract u'abc' syntax:
- @_modify_str_or_docstring
- def u_format(s):
- """"{u}'abc'" --> "u'abc'" (Python 2)
-
- Accepts a string or a function, so it can be used as a decorator."""
- return s.format(u="u")
diff --git a/natsort/utils.py b/natsort/utils.py
index e67913c..d062da2 100644
--- a/natsort/utils.py
+++ b/natsort/utils.py
@@ -54,7 +54,6 @@ from natsort.compat.py23 import (
py23_filter,
py23_map,
py23_str,
- u_format,
)
from natsort.ns_enum import NS_DUMB, ns
from natsort.unicode_numbers import digits_no_decimals, numeric_no_decimals
@@ -634,7 +633,6 @@ lower_function = methodcaller("casefold" if NEWPY else "lower")
# noinspection PyIncorrectDocstring
-@u_format
def groupletters(x, _low=lower_function):
"""
Double all characters, making doubled letters lowercase.
@@ -651,7 +649,7 @@ def groupletters(x, _low=lower_function):
--------
>>> groupletters("Apple")
- {u}'aAppppllee'
+ 'aAppppllee'
"""
return "".join(ichain.from_iterable((_low(y), y) for y in x))
@@ -718,7 +716,6 @@ def do_decoding(s, encoding):
# noinspection PyIncorrectDocstring
-@u_format
def path_splitter(s, _d_match=re.compile(r"\.\d").match):
"""
Split a string into its path components.
@@ -738,7 +735,7 @@ def path_splitter(s, _d_match=re.compile(r"\.\d").match):
--------
>>> tuple(path_splitter("this/thing.ext"))
- ({u}'this', {u}'thing', {u}'.ext')
+ ('this', 'thing', '.ext')
"""
if not isinstance(s, PurePath):