Skip to content

Commit

Permalink
build: Upgrade ocdskit and ocdsextensionregistry
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Dec 15, 2024
1 parent 77140d0 commit 78724b2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 43 deletions.
4 changes: 2 additions & 2 deletions extension_explorer/templates/extension_schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h3 id="{{ definition|lower }}">
<tbody>
{% for field in properties.fields %}
<tr>
<td id="{{ field.definition_path }}.{{ field.path }}">
<td id="{{ field.definition }}.{{ field.path }}">
<code>
{{ field.path|replace('.', '.<wbr>'|safe) }}
</code>
Expand Down Expand Up @@ -117,7 +117,7 @@ <h3 id="{{ definition|lower }}">
<a href="{{ field.url }}">
{% endif %}
<code>
{{ field.definition_path }}{% if field.definition_path %}.<wbr>{% endif %}{{ field.path|replace('.', '.<wbr>'|safe) }}
{{ field.definition }}{% if field.definition %}.<wbr>{% endif %}{{ field.path|replace('.', '.<wbr>'|safe) }}
</code>
{% if field.url %}
</a>
Expand Down
21 changes: 11 additions & 10 deletions extension_explorer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,24 @@ def get_schema_tables(extension_version, lang):
if field.schema is None:
continue

key = field.definition_path
key = field.definition
if not key:
key = 'Release'

if key not in tables:
tables[key] = {'fields': []}
if field.definition_path in sources:
tables[key]['source'] = sources[field.definition_path]
if field.definition in sources:
tables[key]['source'] = sources[field.definition]

d = field.asdict(
sep='.', exclude=('name', 'deprecated', 'pointer', 'pattern', 'required', 'merge_by_id'),
)
with contextlib.suppress(jsonpointer.JsonPointerException):
_add_link_to_original_field(field, schema, sources)

d = field.asdict(sep='.', exclude=('definition_pointer', 'pointer', 'required', 'deprecated'))
_, d['url'] = _add_link_to_original_field(field, schema, sources)
d['title'] = field.schema.get('title', '')
d['description'] = markdown(field.schema.get('description', ''))
d['types'] = gettext(' or ').join(_get_types(field.schema, sources, extension_version, lang))

tables[key]['fields'].append(d)

return tables
Expand Down Expand Up @@ -351,11 +353,10 @@ def _get_types(value, sources, extension_version, lang, n=1, field=None):
def _add_link_to_original_field(field, schema, sources):
original_field = jsonpointer.resolve_pointer(schema, field.pointer)

field_url_prefix = sources[field.definition_path]['field_url_prefix']
if field_url_prefix:
field['url'] = field_url_prefix + field.pointer_components[-1]
field_url_prefix = sources[field.definition]['field_url_prefix']
url = field_url_prefix + field.name if field_url_prefix else None

return original_field
return original_field, url


def _codelist_url(basename, extension_version, lang):
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ myst-parser==2.0.0
# via ocdsextensionregistry
ocds-babel==0.3.5
# via ocdsextensionregistry
ocdsextensionregistry==0.5.0
ocdsextensionregistry==0.6.5
# via
# -r requirements.in
# ocdskit
ocdskit==1.2.0
ocdskit==1.3.0
# via -r requirements.in
ocdsmerge==0.6.4
# via ocdskit
Expand Down
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ myst-parser==2.0.0
# via -r requirements.txt
ocds-babel==0.3.5
# via -r requirements.txt
ocdsextensionregistry==0.5.0
ocdsextensionregistry==0.6.5
# via
# -r requirements.txt
# ocdskit
ocdskit==1.2.0
ocdskit==1.3.0
# via -r requirements.txt
ocdsmerge==0.6.4
# via
Expand Down
54 changes: 27 additions & 27 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def test_get_schema_tables(client):
'Asset': {
'fields': [
{
'definition_path': 'Asset',
'definition': 'Asset',
'path': 'field',
'schema': release_schema['definitions']['Asset']['properties']['field'],
'multilingual': False,
Expand All @@ -359,7 +359,7 @@ def test_get_schema_tables(client):
'Release': {
'fields': [
{
'definition_path': '',
'definition': '',
'path': 'titleOnly',
'schema': release_schema['properties']['titleOnly'],
'multilingual': True,
Expand All @@ -368,7 +368,7 @@ def test_get_schema_tables(client):
'types': '',
},
{
'definition_path': '',
'definition': '',
'path': 'descriptionOnly',
'schema': release_schema['properties']['descriptionOnly'],
'multilingual': True,
Expand All @@ -377,7 +377,7 @@ def test_get_schema_tables(client):
'types': '',
},
{
'definition_path': '',
'definition': '',
'path': 'typeOnly',
'schema': release_schema['properties']['typeOnly'],
'multilingual': False,
Expand All @@ -386,7 +386,7 @@ def test_get_schema_tables(client):
'types': 'string',
},
{
'definition_path': '',
'definition': '',
'path': 'ref',
'schema': release_schema['properties']['ref'],
'multilingual': False,
Expand All @@ -395,7 +395,7 @@ def test_get_schema_tables(client):
'types': '<a href="#asset">Asset</a> object',
},
{
'definition_path': '',
'definition': '',
'path': 'array',
'schema': release_schema['properties']['array'],
'multilingual': False,
Expand All @@ -404,7 +404,7 @@ def test_get_schema_tables(client):
'types': 'array of strings / integers',
},
{
'definition_path': '',
'definition': '',
'path': 'refArray',
'schema': release_schema['properties']['refArray'],
'multilingual': False,
Expand All @@ -413,7 +413,7 @@ def test_get_schema_tables(client):
'types': 'array of <a href="#asset">Asset</a> objects',
},
{
'definition_path': '',
'definition': '',
'path': 'null',
'schema': release_schema['properties']['null'],
'multilingual': False,
Expand All @@ -422,7 +422,7 @@ def test_get_schema_tables(client):
'types': '',
},
{
'definition_path': '',
'definition': '',
'path': 'external',
'schema': release_schema['properties']['external'],
'multilingual': False,
Expand All @@ -431,7 +431,7 @@ def test_get_schema_tables(client):
'types': '<a href="https://standard.open-contracting.org/1.1/en/schema/reference/#value">Value</a> object', # noqa: E501
},
{
'definition_path': '',
'definition': '',
'path': 'field',
'schema': release_schema['properties']['field'],
'multilingual': False,
Expand All @@ -440,7 +440,7 @@ def test_get_schema_tables(client):
'types': 'object',
},
{
'definition_path': '',
'definition': '',
'path': 'field.subfield',
'schema': release_schema['properties']['field']['properties']['subfield'],
'multilingual': False,
Expand All @@ -449,7 +449,7 @@ def test_get_schema_tables(client):
'types': 'object',
},
{
'definition_path': '',
'definition': '',
'path': 'field.subfield.subsubfield',
'schema': release_schema['properties']['field']['properties']['subfield']['properties']['subsubfield'], # noqa: E501
'multilingual': False,
Expand All @@ -458,7 +458,7 @@ def test_get_schema_tables(client):
'types': '',
},
{
'definition_path': '',
'definition': '',
'path': 'undeprecated',
'schema': release_schema['properties']['undeprecated'],
'multilingual': False,
Expand All @@ -467,7 +467,7 @@ def test_get_schema_tables(client):
'types': '',
},
{
'definition_path': '',
'definition': '',
'path': 'deprecated',
'schema': release_schema['properties']['deprecated'],
'multilingual': False,
Expand All @@ -476,35 +476,35 @@ def test_get_schema_tables(client):
'types': 'string',
},
{
'definition_path': '',
'path': '(.*)',
'definition': '',
'path': '.*',
'schema': release_schema['patternProperties']['.*'],
'multilingual': False,
'title': 'Title',
'description': '<p>Description</p>\n',
'types': 'string or integer',
},
{
'definition_path': '',
'path': '(^typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)))', # noqa: E501
'definition': '',
'path': '^typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))', # noqa: E501
'schema': {},
'multilingual': False,
'title': '',
'description': '',
'types': '',
},
{
'definition_path': '',
'path': '(typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$)', # noqa: E501
'definition': '',
'path': 'typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$', # noqa: E501
'schema': {},
'multilingual': False,
'title': '',
'description': '',
'types': '',
},
{
'definition_path': '',
'path': '(typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+)))', # noqa: E501
'definition': '',
'path': 'typeOnly_(((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))', # noqa: E501
'schema': {},
'multilingual': False,
'title': '',
Expand All @@ -521,7 +521,7 @@ def test_get_schema_tables(client):
'Tender': {
'fields': [
{
'definition_path': 'Tender',
'definition': 'Tender',
'path': 'field',
'schema': {},
'multilingual': False,
Expand All @@ -530,7 +530,7 @@ def test_get_schema_tables(client):
'types': '',
},
{
'definition_path': 'Tender',
'definition': 'Tender',
'path': 'title',
'schema': {'title': 'Replacement'},
'multilingual': False,
Expand All @@ -549,7 +549,7 @@ def test_get_schema_tables(client):
'Location': {
'fields': [
{
'definition_path': 'Location',
'definition': 'Location',
'path': 'field',
'schema': {'type': 'string'},
'multilingual': False,
Expand All @@ -558,7 +558,7 @@ def test_get_schema_tables(client):
'types': 'string',
},
{
'definition_path': 'Location',
'definition': 'Location',
'path': 'geometry',
'schema': {'title': 'Replacement'},
'multilingual': False,
Expand Down Expand Up @@ -604,7 +604,7 @@ def test_get_schema_tables_mixed_array_success(client):
'Release': {
'fields': [
{
'definition_path': '',
'definition': '',
'path': 'nullArray',
'schema': schema['properties']['nullArray'],
'multilingual': False,
Expand Down

0 comments on commit 78724b2

Please sign in to comment.