orcli 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {orcli-0.1.0 → orcli-0.1.2}/PKG-INFO +25 -23
- {orcli-0.1.0 → orcli-0.1.2}/README.md +24 -22
- {orcli-0.1.0 → orcli-0.1.2}/pyproject.toml +1 -1
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli/client.py +4 -25
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli.egg-info/PKG-INFO +25 -23
- {orcli-0.1.0 → orcli-0.1.2}/LICENSE.md +0 -0
- {orcli-0.1.0 → orcli-0.1.2}/setup.cfg +0 -0
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli/__init__.py +0 -0
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli.egg-info/SOURCES.txt +0 -0
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli.egg-info/dependency_links.txt +0 -0
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli.egg-info/requires.txt +0 -0
- {orcli-0.1.0 → orcli-0.1.2}/src/orcli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: orcli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python client for interacting with OpenRefine
|
|
5
5
|
Requires-Python: >=3.9
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -11,12 +11,14 @@ Requires-Dist: pytest; extra == "test"
|
|
|
11
11
|
Dynamic: license-file
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
# refine
|
|
14
|
+
# orcli -- open-refine client
|
|
15
15
|
|
|
16
16
|
A Python client library for interacting with [OpenRefine](https://openrefine.org/) via its REST API.
|
|
17
17
|
|
|
18
18
|
For simple project creation, data transformation, metadata management and export operations.
|
|
19
19
|
|
|
20
|
+
Find the [orcli package](https://pypi.org/project/orcli/) on PyPI.
|
|
21
|
+
|
|
20
22
|
## Features
|
|
21
23
|
|
|
22
24
|
- Create and delete projects from local files.
|
|
@@ -35,25 +37,25 @@ Requires Python 3.10+ and a running OpenRefine server instance.
|
|
|
35
37
|
|
|
36
38
|
### Quick Start
|
|
37
39
|
|
|
38
|
-
1.
|
|
40
|
+
1. Download:
|
|
41
|
+
|
|
42
|
+
Clone the repository (see below).
|
|
39
43
|
|
|
40
44
|
```bash
|
|
41
45
|
git clone https://github.com/rkraasch/refine-client.git
|
|
42
46
|
cd refine-client
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
Or download from [orcli from PyPI](https://pypi.org/project/orcli/). (see below).
|
|
46
50
|
|
|
47
51
|
```bash
|
|
48
|
-
python -m venv
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
python -m pip list
|
|
53
|
-
deactivate
|
|
52
|
+
python -m venv ./venv
|
|
53
|
+
./venv/bin/python -m pip install --upgrade pip
|
|
54
|
+
./venv/bin/python -m pip install orcli
|
|
55
|
+
./venv/bin/python -c "from orcli import Refine; print(Refine)"
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
2. Optionally run tests:
|
|
57
59
|
|
|
58
60
|
[Download](https://openrefine.org/download) and run OpenRefine, then run the tests as shown below.
|
|
59
61
|
|
|
@@ -63,10 +65,10 @@ python -m pytest tests/ -v
|
|
|
63
65
|
This creates temporary test projects in OpenRefine which should be cleaned up automatically.
|
|
64
66
|
If a project prefixed `pytest_refine-client-integration_` remains visible in the Open project tab (under [#open-project](http://127.0.0.1:3333/#open-project)), something went wrong.
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
3. Basic usage:
|
|
67
69
|
|
|
68
70
|
```python
|
|
69
|
-
from
|
|
71
|
+
from orcli import Refine
|
|
70
72
|
|
|
71
73
|
# Initialize the client
|
|
72
74
|
refine = Refine(base_url="http://127.0.0.1:3333")
|
|
@@ -93,7 +95,9 @@ refine.export_data("output_file.tsv", fmt="tsv", project_id=project_id)
|
|
|
93
95
|
refine.delete_project(project_id)
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
### Example 1: Access Project Metadata
|
|
97
101
|
|
|
98
102
|
```python
|
|
99
103
|
# Set metadata
|
|
@@ -108,7 +112,7 @@ for pid, metadata in projects.items():
|
|
|
108
112
|
project_id = refine.get_project_id_by_name("Project Name")
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
### Example 2: Do Batch Operations
|
|
112
116
|
|
|
113
117
|
```python
|
|
114
118
|
# Apply multiple operations
|
|
@@ -122,12 +126,10 @@ refine.apply_operations(operations, project_id)
|
|
|
122
126
|
refine.apply_operations_from_file("operations.json", project_id, wait=True)
|
|
123
127
|
```
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### Example 1: Data Pipeline
|
|
129
|
+
### Example 3: Data Pipeline
|
|
128
130
|
|
|
129
131
|
```python
|
|
130
|
-
from
|
|
132
|
+
from orcli import Refine
|
|
131
133
|
|
|
132
134
|
refine = Refine(verbose=True)
|
|
133
135
|
|
|
@@ -149,11 +151,11 @@ refine.export_data("processed_data.csv", fmt="csv", project_id=project_id)
|
|
|
149
151
|
refine.delete_project(project_id)
|
|
150
152
|
```
|
|
151
153
|
|
|
152
|
-
### Example
|
|
154
|
+
### Example 4: Batch Processing
|
|
153
155
|
|
|
154
156
|
```python
|
|
155
157
|
import os
|
|
156
|
-
from
|
|
158
|
+
from orcli import Refine
|
|
157
159
|
|
|
158
160
|
refine = Refine()
|
|
159
161
|
|
|
@@ -198,7 +200,7 @@ Parameters:
|
|
|
198
200
|
|
|
199
201
|
## Configuration
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
Logging:
|
|
202
204
|
|
|
203
205
|
```python
|
|
204
206
|
# Verbose mode
|
|
@@ -208,7 +210,7 @@ refine = Refine(verbose=True)
|
|
|
208
210
|
refine = Refine(silent=True)
|
|
209
211
|
```
|
|
210
212
|
|
|
211
|
-
|
|
213
|
+
Custom server:
|
|
212
214
|
|
|
213
215
|
```python
|
|
214
216
|
refine = Refine(base_url="http://example.com:3333")
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
# refine
|
|
2
|
+
# orcli -- open-refine client
|
|
3
3
|
|
|
4
4
|
A Python client library for interacting with [OpenRefine](https://openrefine.org/) via its REST API.
|
|
5
5
|
|
|
6
6
|
For simple project creation, data transformation, metadata management and export operations.
|
|
7
7
|
|
|
8
|
+
Find the [orcli package](https://pypi.org/project/orcli/) on PyPI.
|
|
9
|
+
|
|
8
10
|
## Features
|
|
9
11
|
|
|
10
12
|
- Create and delete projects from local files.
|
|
@@ -23,25 +25,25 @@ Requires Python 3.10+ and a running OpenRefine server instance.
|
|
|
23
25
|
|
|
24
26
|
### Quick Start
|
|
25
27
|
|
|
26
|
-
1.
|
|
28
|
+
1. Download:
|
|
29
|
+
|
|
30
|
+
Clone the repository (see below).
|
|
27
31
|
|
|
28
32
|
```bash
|
|
29
33
|
git clone https://github.com/rkraasch/refine-client.git
|
|
30
34
|
cd refine-client
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Or download from [orcli from PyPI](https://pypi.org/project/orcli/). (see below).
|
|
34
38
|
|
|
35
39
|
```bash
|
|
36
|
-
python -m venv
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
python -m pip list
|
|
41
|
-
deactivate
|
|
40
|
+
python -m venv ./venv
|
|
41
|
+
./venv/bin/python -m pip install --upgrade pip
|
|
42
|
+
./venv/bin/python -m pip install orcli
|
|
43
|
+
./venv/bin/python -c "from orcli import Refine; print(Refine)"
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
2. Optionally run tests:
|
|
45
47
|
|
|
46
48
|
[Download](https://openrefine.org/download) and run OpenRefine, then run the tests as shown below.
|
|
47
49
|
|
|
@@ -51,10 +53,10 @@ python -m pytest tests/ -v
|
|
|
51
53
|
This creates temporary test projects in OpenRefine which should be cleaned up automatically.
|
|
52
54
|
If a project prefixed `pytest_refine-client-integration_` remains visible in the Open project tab (under [#open-project](http://127.0.0.1:3333/#open-project)), something went wrong.
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
3. Basic usage:
|
|
55
57
|
|
|
56
58
|
```python
|
|
57
|
-
from
|
|
59
|
+
from orcli import Refine
|
|
58
60
|
|
|
59
61
|
# Initialize the client
|
|
60
62
|
refine = Refine(base_url="http://127.0.0.1:3333")
|
|
@@ -81,7 +83,9 @@ refine.export_data("output_file.tsv", fmt="tsv", project_id=project_id)
|
|
|
81
83
|
refine.delete_project(project_id)
|
|
82
84
|
```
|
|
83
85
|
|
|
84
|
-
|
|
86
|
+
## Examples
|
|
87
|
+
|
|
88
|
+
### Example 1: Access Project Metadata
|
|
85
89
|
|
|
86
90
|
```python
|
|
87
91
|
# Set metadata
|
|
@@ -96,7 +100,7 @@ for pid, metadata in projects.items():
|
|
|
96
100
|
project_id = refine.get_project_id_by_name("Project Name")
|
|
97
101
|
```
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
### Example 2: Do Batch Operations
|
|
100
104
|
|
|
101
105
|
```python
|
|
102
106
|
# Apply multiple operations
|
|
@@ -110,12 +114,10 @@ refine.apply_operations(operations, project_id)
|
|
|
110
114
|
refine.apply_operations_from_file("operations.json", project_id, wait=True)
|
|
111
115
|
```
|
|
112
116
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
### Example 1: Data Pipeline
|
|
117
|
+
### Example 3: Data Pipeline
|
|
116
118
|
|
|
117
119
|
```python
|
|
118
|
-
from
|
|
120
|
+
from orcli import Refine
|
|
119
121
|
|
|
120
122
|
refine = Refine(verbose=True)
|
|
121
123
|
|
|
@@ -137,11 +139,11 @@ refine.export_data("processed_data.csv", fmt="csv", project_id=project_id)
|
|
|
137
139
|
refine.delete_project(project_id)
|
|
138
140
|
```
|
|
139
141
|
|
|
140
|
-
### Example
|
|
142
|
+
### Example 4: Batch Processing
|
|
141
143
|
|
|
142
144
|
```python
|
|
143
145
|
import os
|
|
144
|
-
from
|
|
146
|
+
from orcli import Refine
|
|
145
147
|
|
|
146
148
|
refine = Refine()
|
|
147
149
|
|
|
@@ -186,7 +188,7 @@ Parameters:
|
|
|
186
188
|
|
|
187
189
|
## Configuration
|
|
188
190
|
|
|
189
|
-
|
|
191
|
+
Logging:
|
|
190
192
|
|
|
191
193
|
```python
|
|
192
194
|
# Verbose mode
|
|
@@ -196,7 +198,7 @@ refine = Refine(verbose=True)
|
|
|
196
198
|
refine = Refine(silent=True)
|
|
197
199
|
```
|
|
198
200
|
|
|
199
|
-
|
|
201
|
+
Custom server:
|
|
200
202
|
|
|
201
203
|
```python
|
|
202
204
|
refine = Refine(base_url="http://example.com:3333")
|
|
@@ -2,21 +2,17 @@
|
|
|
2
2
|
# client.py
|
|
3
3
|
# (c) 2025 RK, Lic. CC-0
|
|
4
4
|
|
|
5
|
-
import json, time,
|
|
5
|
+
import json, time, requests
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from urllib.parse import urlparse, parse_qs
|
|
8
|
+
import logging
|
|
8
9
|
|
|
9
10
|
logger = logging.getLogger(__name__)
|
|
10
|
-
|
|
11
|
-
if not logger.hasHandlers():
|
|
12
|
-
null_handler = logging.NullHandler()
|
|
13
|
-
logger.addHandler(null_handler)
|
|
11
|
+
logger.addHandler(logging.NullHandler())
|
|
14
12
|
|
|
15
13
|
class Refine:
|
|
16
14
|
"""Client interface for interacting with an OpenRefine server through its REST API."""
|
|
17
|
-
|
|
18
15
|
DEFAULT_BASE_URL = "http://127.0.0.1:3333"
|
|
19
|
-
|
|
20
16
|
def __init__(self, base_url: str | None = None, verbose: bool = False, silent: bool = False) -> None:
|
|
21
17
|
self.base_url: str = (base_url or self.DEFAULT_BASE_URL).rstrip("/")
|
|
22
18
|
self.session = requests.Session()
|
|
@@ -24,19 +20,6 @@ class Refine:
|
|
|
24
20
|
self.project_id: str | None = None
|
|
25
21
|
self.silent: bool = silent
|
|
26
22
|
self.verbose: bool = verbose
|
|
27
|
-
logger.setLevel(logging.INFO)
|
|
28
|
-
if silent:
|
|
29
|
-
logger.setLevel(logging.ERROR)
|
|
30
|
-
elif verbose:
|
|
31
|
-
logger.setLevel(logging.DEBUG)
|
|
32
|
-
logger.debug("Verbose logging enabled.")
|
|
33
|
-
stream_handler = logging.StreamHandler()
|
|
34
|
-
stream_handler.setLevel(logging.DEBUG)
|
|
35
|
-
formatter = logging.Formatter(
|
|
36
|
-
"%(asctime)s - %(levelname)s - %(name)s - %(message)s"
|
|
37
|
-
)
|
|
38
|
-
stream_handler.setFormatter(formatter)
|
|
39
|
-
logger.addHandler(stream_handler)
|
|
40
23
|
try:
|
|
41
24
|
response = self.session.get(f"{self.base_url}")
|
|
42
25
|
response.raise_for_status()
|
|
@@ -45,7 +28,6 @@ class Refine:
|
|
|
45
28
|
logger.error(f"Failed to connect to OpenRefine server at {self.base_url}: {e}")
|
|
46
29
|
raise ConnectionError(f"Could not connect to OpenRefine server at {self.base_url}") from e
|
|
47
30
|
|
|
48
|
-
|
|
49
31
|
def _get_csrf_token(self) -> str:
|
|
50
32
|
"""Fetch CSRF token from server and cache it."""
|
|
51
33
|
if not self.csrf_token:
|
|
@@ -261,7 +243,4 @@ class Refine:
|
|
|
261
243
|
|
|
262
244
|
if __name__ == "__main__":
|
|
263
245
|
refine = Refine(verbose=True)
|
|
264
|
-
|
|
265
|
-
# project_id = refine.create_project("data.csv", "My Project")
|
|
266
|
-
# refine.apply_operations_from_file("operations.json", project_id, wait=True)
|
|
267
|
-
# refine.export_data("output.tsv", "tsv", project_id)
|
|
246
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: orcli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python client for interacting with OpenRefine
|
|
5
5
|
Requires-Python: >=3.9
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -11,12 +11,14 @@ Requires-Dist: pytest; extra == "test"
|
|
|
11
11
|
Dynamic: license-file
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
# refine
|
|
14
|
+
# orcli -- open-refine client
|
|
15
15
|
|
|
16
16
|
A Python client library for interacting with [OpenRefine](https://openrefine.org/) via its REST API.
|
|
17
17
|
|
|
18
18
|
For simple project creation, data transformation, metadata management and export operations.
|
|
19
19
|
|
|
20
|
+
Find the [orcli package](https://pypi.org/project/orcli/) on PyPI.
|
|
21
|
+
|
|
20
22
|
## Features
|
|
21
23
|
|
|
22
24
|
- Create and delete projects from local files.
|
|
@@ -35,25 +37,25 @@ Requires Python 3.10+ and a running OpenRefine server instance.
|
|
|
35
37
|
|
|
36
38
|
### Quick Start
|
|
37
39
|
|
|
38
|
-
1.
|
|
40
|
+
1. Download:
|
|
41
|
+
|
|
42
|
+
Clone the repository (see below).
|
|
39
43
|
|
|
40
44
|
```bash
|
|
41
45
|
git clone https://github.com/rkraasch/refine-client.git
|
|
42
46
|
cd refine-client
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
Or download from [orcli from PyPI](https://pypi.org/project/orcli/). (see below).
|
|
46
50
|
|
|
47
51
|
```bash
|
|
48
|
-
python -m venv
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
python -m pip list
|
|
53
|
-
deactivate
|
|
52
|
+
python -m venv ./venv
|
|
53
|
+
./venv/bin/python -m pip install --upgrade pip
|
|
54
|
+
./venv/bin/python -m pip install orcli
|
|
55
|
+
./venv/bin/python -c "from orcli import Refine; print(Refine)"
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
2. Optionally run tests:
|
|
57
59
|
|
|
58
60
|
[Download](https://openrefine.org/download) and run OpenRefine, then run the tests as shown below.
|
|
59
61
|
|
|
@@ -63,10 +65,10 @@ python -m pytest tests/ -v
|
|
|
63
65
|
This creates temporary test projects in OpenRefine which should be cleaned up automatically.
|
|
64
66
|
If a project prefixed `pytest_refine-client-integration_` remains visible in the Open project tab (under [#open-project](http://127.0.0.1:3333/#open-project)), something went wrong.
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
3. Basic usage:
|
|
67
69
|
|
|
68
70
|
```python
|
|
69
|
-
from
|
|
71
|
+
from orcli import Refine
|
|
70
72
|
|
|
71
73
|
# Initialize the client
|
|
72
74
|
refine = Refine(base_url="http://127.0.0.1:3333")
|
|
@@ -93,7 +95,9 @@ refine.export_data("output_file.tsv", fmt="tsv", project_id=project_id)
|
|
|
93
95
|
refine.delete_project(project_id)
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
### Example 1: Access Project Metadata
|
|
97
101
|
|
|
98
102
|
```python
|
|
99
103
|
# Set metadata
|
|
@@ -108,7 +112,7 @@ for pid, metadata in projects.items():
|
|
|
108
112
|
project_id = refine.get_project_id_by_name("Project Name")
|
|
109
113
|
```
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
### Example 2: Do Batch Operations
|
|
112
116
|
|
|
113
117
|
```python
|
|
114
118
|
# Apply multiple operations
|
|
@@ -122,12 +126,10 @@ refine.apply_operations(operations, project_id)
|
|
|
122
126
|
refine.apply_operations_from_file("operations.json", project_id, wait=True)
|
|
123
127
|
```
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### Example 1: Data Pipeline
|
|
129
|
+
### Example 3: Data Pipeline
|
|
128
130
|
|
|
129
131
|
```python
|
|
130
|
-
from
|
|
132
|
+
from orcli import Refine
|
|
131
133
|
|
|
132
134
|
refine = Refine(verbose=True)
|
|
133
135
|
|
|
@@ -149,11 +151,11 @@ refine.export_data("processed_data.csv", fmt="csv", project_id=project_id)
|
|
|
149
151
|
refine.delete_project(project_id)
|
|
150
152
|
```
|
|
151
153
|
|
|
152
|
-
### Example
|
|
154
|
+
### Example 4: Batch Processing
|
|
153
155
|
|
|
154
156
|
```python
|
|
155
157
|
import os
|
|
156
|
-
from
|
|
158
|
+
from orcli import Refine
|
|
157
159
|
|
|
158
160
|
refine = Refine()
|
|
159
161
|
|
|
@@ -198,7 +200,7 @@ Parameters:
|
|
|
198
200
|
|
|
199
201
|
## Configuration
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
Logging:
|
|
202
204
|
|
|
203
205
|
```python
|
|
204
206
|
# Verbose mode
|
|
@@ -208,7 +210,7 @@ refine = Refine(verbose=True)
|
|
|
208
210
|
refine = Refine(silent=True)
|
|
209
211
|
```
|
|
210
212
|
|
|
211
|
-
|
|
213
|
+
Custom server:
|
|
212
214
|
|
|
213
215
|
```python
|
|
214
216
|
refine = Refine(base_url="http://example.com:3333")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|