Updating error message in xproto
Change-Id: I21ff9746e61f83d83c7cc64c452913d1299b49f9
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/base.py b/lib/xos-genx/xosgenx/jinja2_extensions/base.py
index dd19bd8..1293863 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/base.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/base.py
@@ -176,7 +176,7 @@
else:
return tuple([xproto_tuplify(i) for i in nested_list_or_set])
-def xproto_field_graph_components(fields, tag='unique_with'):
+def xproto_field_graph_components(fields, model, tag='unique_with'):
def find_components(graph):
pending = set(graph.keys())
components = []
@@ -188,10 +188,10 @@
while front:
node = front.pop()
neighbours = graph[node]
- neighbours-=component # These we have already visited
+ neighbours -= component # These we have already visited
front |= neighbours
- pending-=neighbours
+ pending -= neighbours
component |= neighbours
components.append(component)
@@ -208,15 +208,14 @@
for uf in tagged_fields:
if uf not in field_names:
- raise FieldNotFound('Field %s not found'%uf)
+ raise FieldNotFound('Field "%s" not found in model "%s", referenced from field "%s" by option "%s"' % (uf, model['name'], f['name'], tag))
- field_graph.setdefault(f['name'],set()).add(uf)
- field_graph.setdefault(uf,set()).add(f['name'])
+ field_graph.setdefault(f['name'], set()).add(uf)
+ field_graph.setdefault(uf, set()).add(f['name'])
except KeyError:
pass
- components = find_components(field_graph)
- return components
+ return find_components(field_graph)
def xproto_api_opts(field):
options = []
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py b/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py
index 9e3b4a8..996d63d 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/tosca.py
@@ -33,11 +33,11 @@
else:
return type
-def xproto_fields_to_tosca_keys(fields):
+def xproto_fields_to_tosca_keys(fields, m):
keys = []
# look for one_of keys
- _one_of = xproto_field_graph_components(fields, 'tosca_key_one_of')
+ _one_of = xproto_field_graph_components(fields, m, 'tosca_key_one_of')
one_of = [list(i) for i in _one_of]
# look for explicit keys
diff --git a/lib/xos-genx/xosgenx/targets/django-split.xtarget b/lib/xos-genx/xosgenx/targets/django-split.xtarget
index 60cf9de..200a29f 100644
--- a/lib/xos-genx/xosgenx/targets/django-split.xtarget
+++ b/lib/xos-genx/xosgenx/targets/django-split.xtarget
@@ -38,7 +38,7 @@
{%- endfor %}
# Meta
- {%- set uniques = xproto_field_graph_components(m.fields) %}
+ {%- set uniques = xproto_field_graph_components(m.fields, m) %}
{%- if uniques %}
class Meta:
unique_together = {{ xproto_tuplify(uniques) }}
diff --git a/lib/xos-genx/xosgenx/targets/django.xtarget b/lib/xos-genx/xosgenx/targets/django.xtarget
index 13d37f9..631e8cd 100644
--- a/lib/xos-genx/xosgenx/targets/django.xtarget
+++ b/lib/xos-genx/xosgenx/targets/django.xtarget
@@ -76,7 +76,7 @@
# Meta
class Meta:
- {%- set uniques = xproto_field_graph_components(m.fields) %}
+ {%- set uniques = xproto_field_graph_components(m.fields, m) %}
{%- if uniques %}
unique_together = {{ xproto_tuplify(uniques) }}
{%- endif %}
diff --git a/lib/xos-genx/xosgenx/targets/service.xtarget b/lib/xos-genx/xosgenx/targets/service.xtarget
index 7b40110..e5816ab 100644
--- a/lib/xos-genx/xosgenx/targets/service.xtarget
+++ b/lib/xos-genx/xosgenx/targets/service.xtarget
@@ -56,7 +56,7 @@
app_label = {{ xproto_first_non_empty([m.options.app_label, options.app_label, options.name, "Set an app label in your xproto!"]) | lower}}
# name = {{ xproto_first_non_empty([m.options.name, options.name, "Set a name in your xproto!"]) }}
verbose_name = "{{ xproto_unquote(xproto_first_non_empty([m.options.verbose_name, m.name])) }}"
- {%- set uniques = xproto_field_graph_components(m.fields) %}
+ {%- set uniques = xproto_field_graph_components(m.fields, m) %}
{%- if uniques %}
unique_together = {{ xproto_tuplify(uniques) }}
{%- endif %}