-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from pepkit/dev
0.12.1
- Loading branch information
Showing
13 changed files
with
65 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.12" | ||
__version__ = "0.12.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,23 @@ | |
|
||
from .pathex_attmap import PathExAttMap | ||
|
||
__author__ = "Vince Reuter" | ||
__email__ = "[email protected]" | ||
|
||
class AttMapEcho(PathExAttMap): | ||
__all__ = ["AttMapEcho", "EchoAttMap"] | ||
|
||
|
||
class EchoAttMap(PathExAttMap): | ||
""" An AttMap that returns key/attr if it has no set value. """ | ||
|
||
def __getattr__(self, item, default=None): | ||
def __getattr__(self, item, default=None, expand=True): | ||
""" | ||
Fetch the value associated with the provided identifier. | ||
:param int | str item: identifier for value to fetch | ||
:param object default: default return value | ||
:param bool expand: whether to attempt variable expansion of string | ||
value, in case it's a path | ||
:return object: whatever value corresponds to the requested key/item | ||
:raises AttributeError: if the requested item has not been set, | ||
no default value is provided, and this instance is not configured | ||
|
@@ -21,7 +29,7 @@ def __getattr__(self, item, default=None): | |
to be indicative of the intent of protection. | ||
""" | ||
try: | ||
return super(self.__class__, self).__getattr__(item, default) | ||
return super(self.__class__, self).__getattr__(item, default, expand) | ||
except (AttributeError, TypeError): | ||
# If not, triage and cope accordingly. | ||
if self._is_od_member(item) or \ | ||
|
@@ -35,3 +43,6 @@ def __getattr__(self, item, default=None): | |
def _lower_type_bound(self): | ||
""" Most specific type to which an inserted value may be converted """ | ||
return AttMapEcho | ||
|
||
|
||
AttMapEcho = EchoAttMap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Types of maps | ||
- [`AttMapLike`](autodoc_build/attmap.md#Class-AttMapLike) (abstract) | ||
- [`AttMap`](autodoc_build/attmap.md#Class-AttMap) | ||
- [`OrdAttMap`](autodoc_build/attmap.md#Class-OrdAttMap) | ||
- [`PathExAttMap`](autodoc_build/attmap.md#Class-PathExAttMap) | ||
- [`EchoAttMap`](autodoc_build/attmap.md#Class-EchoAttMap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
__email__ = "[email protected]" | ||
|
||
|
||
ALL_ATTMAPS = [AttributeDict, AttributeDictEcho, AttMap, OrdAttMap, AttMapEcho, | ||
PathExAttMap] | ||
ALL_ATTMAPS = [AttributeDict, AttributeDictEcho, AttMap, AttMapEcho, | ||
EchoAttMap, OrdAttMap, PathExAttMap] | ||
|
||
|
||
@pytest.fixture(scope="function", params=ALL_ATTMAPS) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ | |
__email__ = "[email protected]" | ||
|
||
|
||
ALL_ATTMAPS = [AttributeDict, AttributeDictEcho] | ||
NULLABLE_ATTMAPS = ALL_ATTMAPS | ||
OLD_ATTMAPS = [AttributeDict, AttributeDictEcho] | ||
NULLABLE_ATTMAPS = OLD_ATTMAPS | ||
|
||
|
||
@pytest.fixture(scope="function", params=["arbitrary", "random"]) | ||
|
@@ -22,7 +22,7 @@ class UniversalMutabilityTests: | |
""" Tests of attmap behavior with respect to mutability """ | ||
|
||
@staticmethod | ||
@pytest.fixture(scope="function", params=ALL_ATTMAPS) | ||
@pytest.fixture(scope="function", params=OLD_ATTMAPS) | ||
def m(request): | ||
""" Provide a test case with a fresh empty data object. """ | ||
return get_att_map(request.param) | ||
|