Repository: pyout/pyout

Issue:
"label" -> "enum" or alike?
Although originally `enum` is for enumerating and in our case to assign arbitrary style values, I feel that it might be a better fit instead of a `label`. just an idea, feel free to close

Discussion:
kyleam: Woops, tests failing because I didn't account for the merge #47.  Will
rebase.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58115f6..1942ecc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,8 @@ TODO Summary
   The only associated user-facing change is the rename of
   `pyout.SCHEMA` to `pyout.schema`.
 
+- The style attribute "label" has been renamed to "lookup".
+
 ### Deprecated
 ### Fixed
 ### Removed
diff --git a/pyout/elements.py b/pyout/elements.py
index 700f53d..d88c4b8 100644
--- a/pyout/elements.py
+++ b/pyout/elements.py
@@ -15,7 +15,7 @@ schema = {
         "bold": {
             "description": "Whether text is bold",
             "oneOf": [{"type": "boolean"},
-                      {"$ref": "#/definitions/label"},
+                      {"$ref": "#/definitions/lookup"},
                       {"$ref": "#/definitions/interval"}],
             "default": False,
             "scope": "field"},
@@ -24,7 +24,7 @@ schema = {
             "oneOf": [{"type": "string",
                        "enum": ["black", "red", "green", "yellow",
                                 "blue", "magenta", "cyan", "white"]},
-                      {"$ref": "#/definitions/label"},
+                      {"$ref": "#/definitions/lookup"},
                       {"$ref": "#/definitions/interval"}],
             "default": "black",
             "scope": "field"},
@@ -37,7 +37,7 @@ schema = {
         "underline": {
             "description": "Whether text is underlined",
             "oneOf": [{"type": "boolean"},
-                      {"$ref": "#/definitions/label"},
+                      {"$ref": "#/definitions/lookup"},
                       {"$ref": "#/definitions/interval"}],
             "default": False,
             "scope": "field"},
@@ -76,10 +76,10 @@ schema = {
                                            {"type": ["string", "boolean"]}],
                                  "additionalItems": False}]}},
             "additionalProperties": False},
-        "label": {
+        "lookup": {
             "description": "Map a value to a style",
             "type": "object",
-            "properties": {"label": {"type": "object"}},
+            "properties": {"lookup": {"type": "object"}},
             "additionalProperties": False},
         "transform": {
             "description": """An arbitrary function.
diff --git a/pyout/field.py b/pyout/field.py
index 3b0664c..12cc4a7 100644
--- a/pyout/field.py
+++ b/pyout/field.py
@@ -360,13 +360,13 @@ class StyleProcessors(object):
 
         Returns
         -------
-        str, {"simple", "label", "interval"}
+        str, {"simple", "lookup", "interval"}
         """
         try:
             keys = list(value.keys())
         except AttributeError:
             return "simple"
-        if keys in [["label"], ["interval"]]:
+        if keys in [["lookup"], ["interval"]]:
             return keys[0]
         raise ValueError("Type of `value` could not be determined")
 
@@ -412,7 +412,7 @@ class StyleProcessors(object):
                         yield self.by_key(key)
                 elif key_type is str:
                     yield self.by_key(column_style[key])
-            elif vtype == "label":
+            elif vtype == "lookup":
                 yield self.by_lookup(column_style[key][vtype], attr_key)
             elif vtype == "interval":
                 yield self.by_interval_lookup(column_style[key][vtype],


Test patch:
diff --git a/pyout/tests/test_field.py b/pyout/tests/test_field.py
index 0c1f9fa..b4d72a1 100644
--- a/pyout/tests/test_field.py
+++ b/pyout/tests/test_field.py
@@ -82,7 +82,7 @@ def test_style_value_type():
 
     assert fn(True) == "simple"
     assert fn("red") == "simple"
-    assert fn({"label": {"BAD": "red"}}) == "label"
+    assert fn({"lookup": {"BAD": "red"}}) == "lookup"
 
     interval = {"interval": [(0, 50, "red"), (50, 80, "yellow")]}
     assert fn(interval) == "interval"
diff --git a/pyout/tests/test_tabular.py b/pyout/tests/test_tabular.py
index 49affe1..aa342e8 100644
--- a/pyout/tests/test_tabular.py
+++ b/pyout/tests/test_tabular.py
@@ -517,10 +517,10 @@ def test_tabular_repaint_with_header():
 
 
 @patch("pyout.tabular.Terminal", TestTerminal)
-def test_tabular_write_label_color():
+def test_tabular_write_lookup_color():
     fd = StringIO()
     out = Tabular(style={"name": {"width": 3},
-                         "status": {"color": {"label": {"BAD": "red"}},
+                         "status": {"color": {"lookup": {"BAD": "red"}},
                                     "width": 6}},
                   stream=fd, force_styling=True)
     out(OrderedDict([("name", "foo"),
@@ -535,10 +535,10 @@ def test_tabular_write_label_color():
 
 
 @patch("pyout.tabular.Terminal", TestTerminal)
-def test_tabular_write_label_bold():
+def test_tabular_write_lookup_bold():
     fd = StringIO()
     out = Tabular(style={"name": {"width": 3},
-                         "status": {"bold": {"label": {"BAD": True}},
+                         "status": {"bold": {"lookup": {"BAD": True}},
                                     "width": 6}},
                   stream=fd, force_styling=True)
     out(OrderedDict([("name", "foo"),
@@ -553,10 +553,10 @@ def test_tabular_write_label_bold():
 
 
 @patch("pyout.tabular.Terminal", TestTerminal)
-def test_tabular_write_label_bold_false():
+def test_tabular_write_lookup_bold_false():
     fd = StringIO()
     out = Tabular(style={"name": {"width": 3},
-                         "status": {"bold": {"label": {"BAD": False}},
+                         "status": {"bold": {"lookup": {"BAD": False}},
                                     "width": 6}},
                   stream=fd, force_styling=True)
     out(OrderedDict([("name", "foo"),
@@ -570,9 +570,9 @@ def test_tabular_write_label_bold_false():
 
 
 @patch("pyout.tabular.Terminal", TestTerminal)
-def test_tabular_write_label_non_hashable():
+def test_tabular_write_lookup_non_hashable():
     fd = StringIO()
-    out = Tabular(style={"status": {"color": {"label": {"BAD": "red"}}}},
+    out = Tabular(style={"status": {"color": {"lookup": {"BAD": "red"}}}},
                   stream=fd)
     out(OrderedDict([("status", [0, 1])]))
     expected = ("[0, 1]\n")