Changeset - 74f583113b37
[Not reviewed]
0 2 0
Lance Edgar (lance) - 3 months ago 2024-08-04 14:37:51
lance@edbob.org
fix: invoke wuttjamaican logic for `rattail.util.prettify()`

eventually should deprecate that altogether since callers can now just
use app handler method
2 files changed with 18 insertions and 9 deletions:
0 comments (0 inline, 0 general)
rattail/util.py
Show inline comments
 
@@ -36,7 +36,8 @@ import warnings
 

	
 
from wuttjamaican.util import (UNSPECIFIED,
 
                               load_entry_points as wutta_load_entry_points,
 
                               load_object as wutta_load_object)
 
                               load_object as wutta_load_object,
 
                               make_title as wutta_make_title)
 

	
 

	
 
# TODO: deprecate / remove this
 
@@ -274,14 +275,14 @@ def get_pkg_version(name):
 
    return version(name)
 

	
 

	
 
# TODO: deprecate / remove this
 
def prettify(text):
 
    """
 
    Return a "prettified" version of text.
 
    DEPRECATED - use
 
    :meth:`wuttjamaican:wuttjamaican.app.AppHandler.make_title()`
 
    instead.
 
    """
 
    text = text.replace('_', ' ')
 
    text = text.replace('-', ' ')
 
    words = text.split()
 
    return ' '.join([x.capitalize() for x in words])
 
    return wutta_make_title(text)
 

	
 

	
 
def pretty_boolean(value):
 
@@ -306,7 +307,10 @@ def hours_as_decimal(hours, places=2):
 

	
 

	
 
def pretty_hours(hours=None, seconds=None):
 
    """ DEPRECATED """
 
    """
 
    DEPRECATED - use :meth:`rattail.app.AppHandler.render_duration()`
 
    instead.
 
    """
 
    warnings.warn("pretty_hours() function is deprecated; please "
 
                  "use AppHandler.render_duration() insted",
 
                  DeprecationWarning, stacklevel=2)
tests/test_util.py
Show inline comments
 
# -*- coding: utf-8; -*-
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
import os
 
import shutil
 
from unittest import TestCase
 
@@ -60,3 +58,10 @@ class ImportTests(TestCase):
 

	
 
#         somefunc = util.load_object('tests.foo.baz:somefunc')
 
#         self.assertEqual(somefunc(), 420)
 

	
 

	
 
class TestPrettify(TestCase):
 

	
 
    def test_basic(self):
 
        text = util.prettify('foo_bar')
 
        self.assertEqual(text, "Foo Bar")
0 comments (0 inline, 0 general)