From a700b18eeed83198fce0f811b0379e5d17454a22 Mon Sep 17 00:00:00 2001 From: Jace Browning Date: Tue, 28 Jul 2015 11:11:37 -0400 Subject: [PATCH] Rename "None*" types to "Nullable*" --- yorm/converters/__init__.py | 10 +++++++--- yorm/converters/extended.py | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/yorm/converters/__init__.py b/yorm/converters/__init__.py index a33e69c..04f6bb7 100644 --- a/yorm/converters/__init__.py +++ b/yorm/converters/__init__.py @@ -1,7 +1,11 @@ """Converters for attributes.""" from .standard import Object, match -from .standard import String, Integer, Float, Boolean +from .standard import Integer, Boolean, String, Float + from .containers import Dictionary, List -from .extended import NoneString, NoneInteger, NoneFloat, NoneBoolean -from .extended import Markdown, AttributeDictionary, SortedList + +from .extended import NullableInteger, NullableBoolean +from .extended import NullableString, NullableFloat +from .extended import Markdown +from .extended import AttributeDictionary, SortedList diff --git a/yorm/converters/extended.py b/yorm/converters/extended.py index 5f82097..4368119 100644 --- a/yorm/converters/extended.py +++ b/yorm/converters/extended.py @@ -11,28 +11,28 @@ # standard types with None as a default ####################################### -class NoneString(String): +class NullableString(String): """Converter for the `str` type with `None` as default.""" DEFAULT = None -class NoneInteger(Integer): +class NullableInteger(Integer): """Converter for the `int` type with `None` as default.""" DEFAULT = None -class NoneFloat(Float): +class NullableFloat(Float): """Converter for the `float` type with `None` as default.""" DEFAULT = None -class NoneBoolean(Boolean): +class NullableBoolean(Boolean): """Converter for the `bool` type with `None` as default.""" @@ -100,10 +100,10 @@ class Markdown(String): def to_value(cls, obj): """Join non-meaningful line breaks.""" value = String.to_value(obj) - return Markdown.join(value) + return cls.join(value) - @staticmethod - def join(text): + @classmethod + def join(cls, text): r"""Convert single newlines (ignored by Markdown) to spaces. >>> Markdown.join("abc\n123") @@ -116,18 +116,18 @@ def join(text): 'abc 123' """ - return Markdown.REGEX_MARKDOWN_SPACES.sub(r'\1 \3', text).strip() + return cls.REGEX_MARKDOWN_SPACES.sub(r'\1 \3', text).strip() @classmethod def to_data(cls, obj): """Break a string at sentences and dump as a literal string.""" value = String.to_value(obj) data = String.to_data(value) - split = Markdown.split(data) + split = cls.split(data) return _Literal(split) - @staticmethod - def split(text, end='\n'): + @classmethod + def split(cls, text, end='\n'): r"""Replace sentence boundaries with newlines and append a newline. :param text: string to line break at sentences @@ -142,7 +142,7 @@ def split(text, end='\n'): """ stripped = text.strip() if stripped: - return Markdown.REGEX_SENTENCE_BOUNDARIES.sub('\n', stripped) + end + return cls.REGEX_SENTENCE_BOUNDARIES.sub('\n', stripped) + end else: return ''