Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Rename "None*" types to "Nullable*"
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jul 28, 2015
1 parent 072aecb commit a700b18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
10 changes: 7 additions & 3 deletions yorm/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions yorm/converters/extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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 ''

Expand Down

0 comments on commit a700b18

Please sign in to comment.