Cli
add_dataset_category(name)
¶
Adds the given name as a new category into the dataset categories vocabulary.
Note that duplicate names aren't allowed and will be rejected (by CKAN).
Source code in ckanext/nhm/cli.py
116 117 118 119 120 121 122 123 124 125 126 127 128 | |
create_context()
¶
Creates a new context dict with the site user set as the user and returns it.
Returns:
| Type | Description |
|---|---|
|
a new context dict |
Source code in ckanext/nhm/cli.py
38 39 40 41 42 43 44 45 | |
create_dataset_vocabulary()
¶
Creates the dataset categories vocabulary and ensures it has the default tags in it.
This command also updates any tags that have the same name as one of the default categories but differ in case (this is old behaviour that we probably don't need to have but has been carried over just in case).
Source code in ckanext/nhm/cli.py
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 | |
delete_dataset_category(name)
¶
Deletes the given name from the dataset categories vocabulary.
Source code in ckanext/nhm/cli.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_commands()
¶
Returns the list of commands the nhm plugin exposes.
Returns:
| Type | Description |
|---|---|
|
a list of click commands |
Source code in ckanext/nhm/cli.py
21 22 23 24 25 26 27 | |
get_vocabulary(context, create_if_missing=True)
¶
Retrieves the dataset categories vocabulary if one exists and returns it. If it doesn't exist, optionally creates it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
the context dict to use when calling actions |
required | |
create_if_missing
|
whether to create the vocabulary if it doesn't exists, default: True. |
True
|
Returns:
| Type | Description |
|---|---|
|
the vocabulary dict or None if it doesn't exist and create_if_missing is False |
Source code in ckanext/nhm/cli.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
nhm()
¶
The NHM CLI.
Source code in ckanext/nhm/cli.py
71 72 73 74 75 76 | |
replace_resource_file(resource_id, path)
¶
Replace the file associated with the given RESOURCE_ID with the file at PATH.
If you have a file that is to big to upload, you can use this to replace a small dummy file with the large file.
Source code in ckanext/nhm/cli.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
success(message, *args, **kwargs)
¶
Helper function that just formats the message with the given args and kwargs and then using click to print out the result in green.
Source code in ckanext/nhm/cli.py
30 31 32 33 34 35 | |