Regex rename
RegexOutputKey
Bases: Input
Model for Regex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regex
|
str
|
Regex to test against. |
required |
output_key
|
str
|
Term for method to output to. |
required |
Source code in extraction_methods/plugins/regex_rename.py
24 25 26 27 28 29 30 31 32 33 34 | |
RegexRenameExtract
Bases: ExtractionMethod
Takes a list of regex and output key combinations. Any existing properties that full match a regex are rename to the output key. Later regex take precedence.
Method name: regex_rename
Example configuration
.. code-block:: yaml
- method: regex_rename
inputs:
regex_swaps:
- regex: README
output_key: metadata
noqa: W605
Source code in extraction_methods/plugins/regex_rename.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
add(body, key_parts, value)
Rename terms
:param body: current body :type body: dict :param key_parts: key parts seperated by delimiter :type key_parts: list
:return: dict :rtype: update body
Source code in extraction_methods/plugins/regex_rename.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
find(body, key_parts)
Rename terms
:param body: current body :type body: dict :param key_parts: key parts seperated by delimiter :type key_parts: list
:return: dict :rtype: update body
Source code in extraction_methods/plugins/regex_rename.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
matching_keys(keys, key_regex)
Find all keys that match regex
:param keys: dictionary keys to test :type keys: KeysView :param key_regex: regex to test against :type key_regex: str
:return: matching keys :rtype: list
Source code in extraction_methods/plugins/regex_rename.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
RegexRenameInput
Bases: Input
Model for Regex Rename Input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regex_swaps
|
list[RegexOutputKey]
|
Regex and output key combinations. |
required |
delimiter
|
str
|
delimiter for nested term. |
''
|
Source code in extraction_methods/plugins/regex_rename.py
37 38 39 40 41 42 43 44 45 46 47 48 | |