Skip to content

Commit be9f457

Browse files
committed
Bug fixes.
1 parent d8e2469 commit be9f457

File tree

7 files changed

+49
-21
lines changed

7 files changed

+49
-21
lines changed

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ No version is currently supported as this package is for experimentation.
66

77
| Version | Supported |
88
|---------|-----------------------|
9-
| 1.0.1 | In development |
9+
| 1.0.2 | In development |
1010

1111
## Reporting a Vulnerability
1212

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
project = "Extraction Methods"
1414
copyright = "2025, Rhys Evans"
1515
author = "Rhys Evans"
16-
release = "1.0.1"
16+
release = "1.0.2"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extraction_methods/plugins/general_function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ def run(self, body: dict[str, Any]) -> dict[str, Any]:
108108

109109
function = getattr(module, function_name)
110110

111-
result = function(*self.input.args, **self.input.kwargs)
111+
result = function(*self.input.function.args, **self.input.function.kwargs)
112112

113113
if self.input.output_key:
114-
output_body[self.input.output_term] = result
114+
output_body[self.input.output_key] = result
115115

116116
elif isinstance(result, dict):
117117
output_body |= result

extraction_methods/plugins/netcdf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import logging
1616
from typing import Any
1717

18+
import cf_xarray
1819
import xarray
1920
from pydantic import Field
2021

extraction_methods/plugins/regex_rename.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ def matching_keys(self, keys: KeysView[str], key_regex: str) -> list[str]:
9898

9999
return list(filter(regex.match, keys))
100100

101-
def rename(
102-
self, body: dict[str, Any], key_parts: list[str], output_key: str
103-
) -> dict[str, Any]:
101+
def find(
102+
self, body: dict[str, Any], key_parts: list[str]
103+
) -> tuple[dict[str, Any], Any]:
104104
"""
105105
Rename terms
106106
@@ -112,16 +112,37 @@ def rename(
112112
:return: dict
113113
:rtype: update body
114114
"""
115-
115+
value = None
116116
for key in self.matching_keys(body.keys(), key_parts[0]):
117-
118117
if len(key_parts) > 1:
119-
body[key] = self.rename(body[key], key_parts[1:], output_key)
118+
body[key], value = self.find(body[key], key_parts[1:])
120119

121120
else:
122-
body[output_key] = body[key]
121+
value = body[key]
123122
del body[key]
124123

124+
return body, value
125+
126+
def add(
127+
self, body: dict[str, Any], key_parts: list[str], value: Any
128+
) -> dict[str, Any]:
129+
"""
130+
Rename terms
131+
132+
:param body: current body
133+
:type body: dict
134+
:param key_parts: key parts seperated by delimiter
135+
:type key_parts: list
136+
137+
:return: dict
138+
:rtype: update body
139+
"""
140+
if len(key_parts) > 1:
141+
body[key_parts[0]] = self.add(body[key_parts[0]], key_parts[1:], value)
142+
143+
else:
144+
body[key_parts[0]] = value
145+
125146
return body
126147

127148
@update_input
@@ -134,6 +155,13 @@ def run(self, body: dict[str, Any]) -> dict[str, Any]:
134155
else [swap.regex]
135156
)
136157

137-
body = self.rename(body, key_parts, swap.output_key)
158+
output_key_parts = (
159+
swap.output_key.split(self.input.delimiter)
160+
if self.input.delimiter
161+
else [swap.output_key]
162+
)
163+
164+
body, value = self.find(body, key_parts)
165+
body = self.add(body, output_key_parts, value)
138166

139167
return body

poetry.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "extraction-methods"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
description = "Methods to enable the extraction of metadata"
55
authors = [
66
{"name" = "rhysrevans3", "email" = "<[email protected]>"},
@@ -29,14 +29,14 @@ dependencies = [
2929
"idna == 2.10",
3030
"imagesize == 1.3.0",
3131
"intake-esm (>=2025.2.3,<2026.0.0)",
32-
"jinja2 == 3.1.3",
32+
"jinja2 (>=3.1.5,<4.0.0)",
3333
"jmespath == 0.10.0",
3434
"jsonschema (>=4.23.0,<5.0.0)",
3535
"lxml (>=5.3.1,<6.0.0)",
3636
"multidict == 5.1.0",
3737
"packaging == 24.1",
3838
"pika == 1.2.0",
39-
"pydantic == 2.1.1",
39+
"pydantic (>=2.1.1,<3.0.0)",
4040
"pygments == 2.17.0",
4141
"pyparsing == 2.4.7",
4242
"python-dateutil == 2.8.2",
@@ -49,7 +49,7 @@ dependencies = [
4949
"six == 1.16.0",
5050
"snowballstemmer == 2.2.0",
5151
"tqdm == 4.62.3",
52-
"typing-extensions == 4.7.1",
52+
"typing-extensions (>=4.7.1,<5.0.0)",
5353
"urllib3 == 1.26.18",
5454
]
5555

0 commit comments

Comments
 (0)