Skip to content

Commit 41311f3

Browse files
authored
Incorporate downstream CEGID changes. (#71)
* Correct GEOHAYSTACK removal. Fixes #65. * Version bump. * Version pin updates. * Namespace packaging change for Python 3. * Remove Python 2 stubs. * Compatibility module removals. * Remove Python 2 future-compatibility module preambles. * Python 3 typing module movement. * collections->typing module movement. * Clean up tests. * Add subclass derivation tests.
1 parent 1a8e5fe commit 41311f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+78
-402
lines changed

.travis.yml

-55
This file was deleted.

marrow/__init__.py

-1
This file was deleted.

marrow/mongo/core/document.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
5-
from collections import MutableMapping
1+
from collections import OrderedDict as odict
2+
from typing import MutableMapping
63

74
from bson import ObjectId
85
from bson.json_util import dumps, loads
96

107
from ...package.loader import load
118
from ...package.canonical import name as named
129
from ...schema import Attributes, Container
13-
from ...schema.compat import str, unicode, odict
1410
from ..util import SENTINEL
1511
from .field import Field
1612
from .field.alias import Alias
@@ -137,8 +133,8 @@ def __repr__(self, *args, **kw):
137133
pk = getattr(self, self.__pk__, None)
138134

139135
if isinstance(pk, ObjectId):
140-
pk = unicode(pk)
141-
elif isinstance(pk, (str, unicode)):
136+
pk = str(pk)
137+
elif isinstance(pk, str):
142138
pass
143139
else:
144140
pk = repr(pk)

marrow/mongo/core/field/alias.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from warnings import warn
62
from weakref import proxy
73

marrow/mongo/core/field/array.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
5-
from collections import Iterable, Mapping
1+
from typing import Iterable, Mapping
62

73
from ... import Field
84
from .base import _HasKind, _CastingKind

marrow/mongo/core/field/base.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from ....schema import Attribute
1111
from ....schema.transform import BaseTransform
1212
from ....schema.validate import Validator
13-
from ....schema.compat import str, unicode, py3
1413
from ...query import Q
1514
from ...util import adjust_attribute_sequence, SENTINEL
1615

@@ -192,13 +191,8 @@ def __delete__(self, obj):
192191

193192
# Other Python Protocols
194193

195-
def __unicode__(self):
194+
def __str__(self):
196195
return self.__name__
197-
198-
if py3:
199-
__str__ = __unicode__
200-
del __unicode__
201-
202196

203197

204198

@@ -229,12 +223,12 @@ def __fixup__(self, document):
229223
def _kind(self, document=None):
230224
kind = self.kind
231225

232-
if isinstance(kind, (str, unicode)):
226+
if isinstance(kind, str):
233227
if kind.startswith('.'):
234228
# This allows the reference to be dynamic.
235229
kind = traverse(document or self.__document__, kind[1:])
236230

237-
if not isinstance(kind, (str, unicode)):
231+
if not isinstance(kind, str):
238232
return kind
239233
else:
240234
kind = load(kind, 'marrow.mongo.document')

marrow/mongo/core/field/binary.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from .base import Field
62

73

marrow/mongo/core/field/boolean.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from .base import Field
62
from ....schema import Attribute
73

marrow/mongo/core/field/date.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
# encoding: utf-8
2-
31
"""Marrow Mongo Date field specialization.
42
53
Commentary on high-level management of timezone casting:
64
75
https://groups.google.com/forum/#!topic/mongodb-user/GOMjTJON4cg
86
"""
97

10-
from __future__ import unicode_literals
11-
12-
from datetime import datetime, timedelta, tzinfo
138
from bson import ObjectId as OID
14-
from collections import MutableMapping
159
from datetime import datetime, timedelta
10+
from datetime import datetime, timedelta, tzinfo
11+
from typing import MutableMapping
1612

1713
from .base import Field
1814
from ...util import utc, utcnow

marrow/mongo/core/field/decimal_.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from decimal import Decimal as dec, localcontext
62

73
from .number import Number

marrow/mongo/core/field/double.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from .number import Number
62

73

marrow/mongo/core/field/embed.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from .base import _HasKind, _CastingKind, Field
62

73

marrow/mongo/core/field/integer.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from .number import Number
62

73

marrow/mongo/core/field/link.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from uri import URI
62

73
from .string import String
84
from ....schema import Attribute
9-
from ....schema.compat import unicode
105

116

127
class Link(String):
@@ -34,13 +29,13 @@ class Link(String):
3429
def to_foreign(self, obj, name, value): # pylint:disable=unused-argument
3530
value = self.URI(value)
3631

37-
if self.protocols and unicode(value.scheme) not in self.protocols:
32+
if self.protocols and str(value.scheme) not in self.protocols:
3833
raise ValueError("Link utilizes invaid scheme: " + repr(value.scheme))
3934

4035
if self.absolute and value.relative:
4136
raise ValueError("Link must be absolute.")
4237

43-
return unicode(value)
38+
return str(value)
4439

4540
def to_native(self, obj, name, value): # pylint:disable=unused-argument
4641
return self.URI(value)

marrow/mongo/core/field/long_.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from bson.int64 import Int64
62

73
from .number import Number

marrow/mongo/core/field/mapping.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from collections import OrderedDict, Mapping as _Mapping
62

73
from ....schema import Attribute

marrow/mongo/core/field/md.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from misaka import Markdown, HtmlRenderer # , SmartyPants
62
from misaka import HTML_ESCAPE, HTML_HARD_WRAP
73
from misaka import EXT_FENCED_CODE, EXT_NO_INTRA_EMPHASIS, EXT_AUTOLINK, EXT_SPACE_HEADERS, EXT_STRIKETHROUGH, EXT_SUPERSCRIPT
84

95
from .string import String
10-
from ....schema.compat import unicode, py3
116

127

138
md = Markdown(
@@ -21,7 +16,7 @@
2116
)
2217

2318

24-
class MarkdownString(unicode):
19+
class MarkdownString(str):
2520
def __html__(self):
2621
return md(self)
2722

marrow/mongo/core/field/number.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from numbers import Number as NumberABC
62

73
from .base import Field
8-
from ....schema.compat import unicode
94

105

116
class Number(Field):
@@ -16,7 +11,7 @@ def to_foreign(self, obj, name, value): # pylint:disable=unused-argument
1611
if isinstance(value, NumberABC):
1712
return value
1813

19-
if isinstance(value, unicode):
14+
if isinstance(value, str):
2015
if value.isnumeric():
2116
return int(value)
2217
else:

marrow/mongo/core/field/oid.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from bson import ObjectId as OID
6-
from collections import MutableMapping
72
from datetime import datetime, timedelta
3+
from typing import MutableMapping
84

95
from .base import Field
106
from ....schema import Attribute
11-
from ....schema.compat import unicode
127

138

149
class ObjectId(Field):
@@ -39,4 +34,4 @@ def to_foreign(self, obj, name, value): # pylint:disable=unused-argument
3934
if isinstance(value, MutableMapping) and '_id' in value:
4035
return OID(value['_id'])
4136

42-
return OID(unicode(value))
37+
return OID(str(value))

marrow/mongo/core/field/path.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
1+
from pathlib import PurePosixPath as _Path
42

53
from .string import String
6-
from ....schema.compat import unicode, py3
7-
8-
try:
9-
from pathlib import PurePosixPath as _Path
10-
except ImportError:
11-
from pathlib2 import PurePosixPath as _Path
124

135

146
class Path(String):

marrow/mongo/core/field/period.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from datetime import timedelta
62

73
from .date import Date

marrow/mongo/core/field/plugin.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
# encoding: utf-8
2-
3-
from __future__ import unicode_literals
4-
51
from pkg_resources import iter_entry_points
62

73
from ....package.canonical import name as canon
84
from ....package.loader import load
95
from ....schema import Attribute
10-
from ....schema.compat import str, unicode
116

127
from .base import Field
138

@@ -52,7 +47,7 @@ def to_foreign(self, obj, name, value): # pylint:disable=unused-argument
5247
except AttributeError:
5348
explicit = not namespace
5449

55-
if not isinstance(value, (str, unicode)):
50+
if not isinstance(value, (str, bytes)):
5651
value = canon(value)
5752

5853
if namespace and ':' in value: # Try to reduce to a known plugin short name.

0 commit comments

Comments
 (0)