• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

datajoint / datajoint-python / #12868

pending completion
#12868

push

travis-ci

web-flow
<a href="https://github.com/datajoint/datajoint-python/commit/<a class=hub.com/datajoint/datajoint-python/commit/<a class="double-link" href="https://git"><a class=hub.com/datajoint/datajoint-python/commit/<a class="double-link" href="https://git"><a class=hub.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5a3e2b7f7">555c2b6bd<a href="https://github.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5a3e2b7f7">&quot;&gt;&amp;lt;a href=&amp;quot;https://github.com/datajoint/datajoint-python/commit/&lt;/a&gt;&lt;a class=&quot;double-link&quot; href=&quot;https://github.com/datajoint/datajoint-python/commit/&amp;lt;a class=&amp;quot;double-link&amp;quot; href=&amp;quot;https://git&quot;&gt;&amp;lt;a class=&lt;/a&gt;hub.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5a3e2b7f7&quot;&gt;555c2b6bd&lt;/a&gt;&lt;a href=&quot;https://github.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5a3e2b7f7&quot;&gt;&amp;lt;a href=&amp;quot;https://github.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5&lt;/a&gt;a3e2b7f7&quot;>&quot;&gt;Merge &lt;/a&gt;&lt;a class=&quot;double-link&quot; href=&quot;https://github.com/datajoint/datajoint-python/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://github.com/datajoint/datajoint-python/commit/<a class="double-link" href="https://github.com/datajoint/datajoint-python/commit/94804352b336cfb4c047ecd4e687c9643a7b3e47">94804352b</a><a href="https://github.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5a3e2b7f7">&amp;quot;&amp;gt;94804352b&amp;lt;/a&amp;gt;&amp;quot;&amp;gt;94804352b&amp;lt;/a&amp;gt;&amp;lt;a href=&amp;quot;https://github.com/datajoint/datajoint-python/commit/555c2b6bdb9d08610421002657528ac5a3e2b&lt;/a&gt;7f7&quot;&gt; into &lt;/a&gt;&lt;a class=&quot;double-link&quot; href=&quot;https://github.com/datajoint/datajoint-python/commit/<a class="double-link" href="https://github.com/datajoint/datajoint-python/commit/e339d465f">e339d465f">e339d465f</a>

29 of 29 new or added lines in 1 file covered. (100.0%)

3036 of 3358 relevant lines covered (90.41%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.22
/datajoint/attribute_adapter.py
1
import re
1✔
2
from .errors import DataJointError, _support_adapted_types
1✔
3
from .plugin import type_plugins
1✔
4

5

6
class AttributeAdapter:
1✔
7
    """
8
    Base class for adapter objects for user-defined attribute types.
9
    """
10

11
    @property
1✔
12
    def attribute_type(self):
13
        """
14
        :return: a supported DataJoint attribute type to use; e.g. "longblob", "blob@store"
15
        """
16
        raise NotImplementedError("Undefined attribute adapter")
×
17

18
    def get(self, value):
1✔
19
        """
20
        convert value retrieved from the the attribute in a table into the adapted type
21

22
        :param value: value from the database
23

24
        :return: object of the adapted type
25
        """
26
        raise NotImplementedError("Undefined attribute adapter")
×
27

28
    def put(self, obj):
1✔
29
        """
30
        convert an object of the adapted type into a value that DataJoint can store in a table attribute
31

32
        :param obj: an object of the adapted type
33
        :return: value to store in the database
34
        """
35
        raise NotImplementedError("Undefined attribute adapter")
×
36

37

38
def get_adapter(context, adapter_name):
1✔
39
    """
40
    Extract the AttributeAdapter object by its name from the context and validate.
41
    """
42
    if not _support_adapted_types():
1✔
43
        raise DataJointError("Support for Adapted Attribute types is disabled.")
×
44
    adapter_name = adapter_name.lstrip("<").rstrip(">")
1✔
45
    try:
1✔
46
        adapter = (
1✔
47
            context[adapter_name]
48
            if adapter_name in context
49
            else type_plugins[adapter_name]["object"].load()
50
        )
51
    except KeyError:
×
52
        raise DataJointError(
×
53
            "Attribute adapter '{adapter_name}' is not defined.".format(
54
                adapter_name=adapter_name
55
            )
56
        )
57
    if not isinstance(adapter, AttributeAdapter):
1✔
58
        raise DataJointError(
×
59
            "Attribute adapter '{adapter_name}' must be an instance of datajoint.AttributeAdapter".format(
60
                adapter_name=adapter_name
61
            )
62
        )
63
    if not isinstance(adapter.attribute_type, str) or not re.match(
1✔
64
        r"^\w", adapter.attribute_type
65
    ):
66
        raise DataJointError(
×
67
            "Invalid attribute type {type} in attribute adapter '{adapter_name}'".format(
68
                type=adapter.attribute_type, adapter_name=adapter_name
69
            )
70
        )
71
    return adapter
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc