commit 29b3bd2fcbdfae2e08abeae0786766222a2c3e9e Author: Damian Johnson atagar@torproject.org Date: Thu Jan 18 09:55:28 2018 -0800
Revert "Add an IntString class"
Nah. This was an interesting idea and would indeed make usage a tad nicer but it violates the principal of least surprise.
This reverts commit 3f8493851bd538bc4aa3d868b880271697ecf516. --- docs/change_log.rst | 4 ---- stem/util/str_tools.py | 26 -------------------------- test/unit/doctest.py | 1 - test/unit/util/str_tools.py | 6 ------ 4 files changed, 37 deletions(-)
diff --git a/docs/change_log.rst b/docs/change_log.rst index ebdf8e3e..fcfc0115 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -56,10 +56,6 @@ The following are only available within Stem's `git repository * `Fallback directory v2 support https://lists.torproject.org/pipermail/tor-dev/2017-December/012721.html`_, which adds *nickname* and *extrainfo* * Reduced maximum descriptors fetched by the remote module to match tor's new limit (:trac:`24743`)
- * **Utilities** - - * Added :class:`~stem.util.str_tools.IntString` - * **Website**
* Added `terminal styling <tutorials/east_of_the_sun.html#terminal-styling>`_ to our utilities tutorial diff --git a/stem/util/str_tools.py b/stem/util/str_tools.py index 108d21ea..bc0446fa 100644 --- a/stem/util/str_tools.py +++ b/stem/util/str_tools.py @@ -12,8 +12,6 @@ Toolkit for various string activity.
::
- IntString - string that can also be used as an integer - crop - shortens string to a given length
size_label - human readable label for a number of bytes @@ -187,30 +185,6 @@ def _split_by_length(msg, size): Ending = stem.util.enum.Enum('ELLIPSE', 'HYPHEN')
-class IntString(str): - """ - String that can be used as an integer as well... - - :: - - >>> s = IntString('me', 5) - >>> print('hi %s, the number is %i' % (s, s)) - hi me, the number is 5 - - .. versionadded:: 1.7.0 - """ - - def __new__(self, str_value, int_value): - return str.__new__(self, str_value) - - def __init__(self, str_value, int_value): - self._str_value = str_value - self._int_value = int_value - - def __int__(self): - return self._int_value - - def crop(msg, size, min_word_length = 4, min_crop = 0, ending = Ending.ELLIPSE, get_remainder = False): """ Shortens a string to a given length. diff --git a/test/unit/doctest.py b/test/unit/doctest.py index 9dda1422..7e40e873 100644 --- a/test/unit/doctest.py +++ b/test/unit/doctest.py @@ -67,7 +67,6 @@ class TestDocumentation(unittest.TestCase): args['globs'] = { '_to_camel_case': stem.util.str_tools._to_camel_case, '_split_by_length': stem.util.str_tools._split_by_length, - 'IntString': stem.util.str_tools.IntString, 'crop': stem.util.str_tools.crop, 'size_label': stem.util.str_tools.size_label, 'time_label': stem.util.str_tools.time_label, diff --git a/test/unit/util/str_tools.py b/test/unit/util/str_tools.py index 7349bd56..ee270717 100644 --- a/test/unit/util/str_tools.py +++ b/test/unit/util/str_tools.py @@ -50,12 +50,6 @@ class TestStrTools(unittest.TestCase): self.assertEqual(['hello'], str_tools._split_by_length('hello', 5)) self.assertEqual(['hello'], str_tools._split_by_length('hello', 6))
- def test_int_string(self): - s = str_tools.IntString('me', 5) - self.assertEqual('me', s) - self.assertEqual(5, int(s)) - self.assertEqual('hi me, the number is 5', 'hi %s, the number is %i' % (s, s)) - def test_crop(self): # test the pydoc examples self.assertEqual('This is a looo...', str_tools.crop('This is a looooong message', 17))
tor-commits@lists.torproject.org