roifile 2024.1.10__tar.gz → 2024.5.24__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.
Potentially problematic release.
This version of roifile might be problematic. Click here for more details.
- {roifile-2024.1.10 → roifile-2024.5.24}/CHANGES.rst +8 -0
- {roifile-2024.1.10/roifile.egg-info → roifile-2024.5.24}/PKG-INFO +15 -22
- {roifile-2024.1.10 → roifile-2024.5.24}/README.rst +47 -43
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile/roifile.py +31 -27
- {roifile-2024.1.10 → roifile-2024.5.24/roifile.egg-info}/PKG-INFO +15 -22
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile_demo.py +1 -2
- {roifile-2024.1.10 → roifile-2024.5.24}/setup.py +22 -4
- {roifile-2024.1.10 → roifile-2024.5.24}/LICENSE +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/MANIFEST.in +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile/__init__.py +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile/__main__.py +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile/py.typed +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile.egg-info/SOURCES.txt +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile.egg-info/dependency_links.txt +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile.egg-info/entry_points.txt +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile.egg-info/requires.txt +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/roifile.egg-info/top_level.txt +0 -0
- {roifile-2024.1.10 → roifile-2024.5.24}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: roifile
|
|
3
|
-
Version: 2024.
|
|
3
|
+
Version: 2024.5.24
|
|
4
4
|
Summary: Read and write ImageJ ROI format
|
|
5
5
|
Home-page: https://www.cgohlke.com
|
|
6
6
|
Author: Christoph Gohlke
|
|
@@ -38,7 +38,7 @@ interest, geometric shapes, paths, text, and whatnot for image overlays.
|
|
|
38
38
|
|
|
39
39
|
:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
|
|
40
40
|
:License: BSD 3-Clause
|
|
41
|
-
:Version: 2024.
|
|
41
|
+
:Version: 2024.5.24
|
|
42
42
|
:DOI: `10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>`_
|
|
43
43
|
|
|
44
44
|
Quickstart
|
|
@@ -47,7 +47,7 @@ Quickstart
|
|
|
47
47
|
Install the roifile package and all dependencies from the
|
|
48
48
|
`Python Package Index <https://pypi.org/project/roifile/>`_::
|
|
49
49
|
|
|
50
|
-
python -m pip install -U roifile[all]
|
|
50
|
+
python -m pip install -U "roifile[all]"
|
|
51
51
|
|
|
52
52
|
View overlays stored in a ROI, ZIP, or TIFF file::
|
|
53
53
|
|
|
@@ -64,14 +64,22 @@ Requirements
|
|
|
64
64
|
This revision was tested with the following requirements and dependencies
|
|
65
65
|
(other versions may work):
|
|
66
66
|
|
|
67
|
-
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.
|
|
68
|
-
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.
|
|
69
|
-
- `Tifffile <https://pypi.org/project/tifffile/>`_
|
|
70
|
-
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.
|
|
67
|
+
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3
|
|
68
|
+
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.4
|
|
69
|
+
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2024.5.22 (optional)
|
|
70
|
+
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.4 (optional)
|
|
71
71
|
|
|
72
72
|
Revisions
|
|
73
73
|
---------
|
|
74
74
|
|
|
75
|
+
2024.5.24
|
|
76
|
+
|
|
77
|
+
- Fix GitHub not correctly rendering docstring examples.
|
|
78
|
+
|
|
79
|
+
2024.3.20
|
|
80
|
+
|
|
81
|
+
- Fix writing generator of ROIs (#9).
|
|
82
|
+
|
|
75
83
|
2024.1.10
|
|
76
84
|
|
|
77
85
|
- Support text rotation.
|
|
@@ -101,21 +109,6 @@ Revisions
|
|
|
101
109
|
|
|
102
110
|
2022.7.29
|
|
103
111
|
|
|
104
|
-
- Update metadata.
|
|
105
|
-
|
|
106
|
-
2022.3.18
|
|
107
|
-
|
|
108
|
-
- Fix creating ROIs from float coordinates exceeding int16 range (#7).
|
|
109
|
-
- Fix bottom-right bounds in ImagejRoi.frompoints.
|
|
110
|
-
|
|
111
|
-
2022.2.2
|
|
112
|
-
|
|
113
|
-
- Add type hints.
|
|
114
|
-
- Change ImagejRoi to dataclass.
|
|
115
|
-
- Drop support for Python 3.7 and numpy < 1.19 (NEP29).
|
|
116
|
-
|
|
117
|
-
2021.6.6
|
|
118
|
-
|
|
119
112
|
- …
|
|
120
113
|
|
|
121
114
|
Refer to the CHANGES file for older revisions.
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
..
|
|
2
|
+
This file is generated by setup.py
|
|
3
|
+
|
|
1
4
|
Read and write ImageJ ROI format
|
|
2
5
|
================================
|
|
3
6
|
|
|
@@ -9,7 +12,7 @@ interest, geometric shapes, paths, text, and whatnot for image overlays.
|
|
|
9
12
|
|
|
10
13
|
:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
|
|
11
14
|
:License: BSD 3-Clause
|
|
12
|
-
:Version: 2024.
|
|
15
|
+
:Version: 2024.5.24
|
|
13
16
|
:DOI: `10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>`_
|
|
14
17
|
|
|
15
18
|
Quickstart
|
|
@@ -18,7 +21,7 @@ Quickstart
|
|
|
18
21
|
Install the roifile package and all dependencies from the
|
|
19
22
|
`Python Package Index <https://pypi.org/project/roifile/>`_::
|
|
20
23
|
|
|
21
|
-
python -m pip install -U roifile[all]
|
|
24
|
+
python -m pip install -U "roifile[all]"
|
|
22
25
|
|
|
23
26
|
View overlays stored in a ROI, ZIP, or TIFF file::
|
|
24
27
|
|
|
@@ -35,14 +38,22 @@ Requirements
|
|
|
35
38
|
This revision was tested with the following requirements and dependencies
|
|
36
39
|
(other versions may work):
|
|
37
40
|
|
|
38
|
-
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.
|
|
39
|
-
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.
|
|
40
|
-
- `Tifffile <https://pypi.org/project/tifffile/>`_
|
|
41
|
-
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.
|
|
41
|
+
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3
|
|
42
|
+
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.4
|
|
43
|
+
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2024.5.22 (optional)
|
|
44
|
+
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.4 (optional)
|
|
42
45
|
|
|
43
46
|
Revisions
|
|
44
47
|
---------
|
|
45
48
|
|
|
49
|
+
2024.5.24
|
|
50
|
+
|
|
51
|
+
- Fix GitHub not correctly rendering docstring examples.
|
|
52
|
+
|
|
53
|
+
2024.3.20
|
|
54
|
+
|
|
55
|
+
- Fix writing generator of ROIs (#9).
|
|
56
|
+
|
|
46
57
|
2024.1.10
|
|
47
58
|
|
|
48
59
|
- Support text rotation.
|
|
@@ -72,21 +83,6 @@ Revisions
|
|
|
72
83
|
|
|
73
84
|
2022.7.29
|
|
74
85
|
|
|
75
|
-
- Update metadata.
|
|
76
|
-
|
|
77
|
-
2022.3.18
|
|
78
|
-
|
|
79
|
-
- Fix creating ROIs from float coordinates exceeding int16 range (#7).
|
|
80
|
-
- Fix bottom-right bounds in ImagejRoi.frompoints.
|
|
81
|
-
|
|
82
|
-
2022.2.2
|
|
83
|
-
|
|
84
|
-
- Add type hints.
|
|
85
|
-
- Change ImagejRoi to dataclass.
|
|
86
|
-
- Drop support for Python 3.7 and numpy < 1.19 (NEP29).
|
|
87
|
-
|
|
88
|
-
2021.6.6
|
|
89
|
-
|
|
90
86
|
- …
|
|
91
87
|
|
|
92
88
|
Refer to the CHANGES file for older revisions.
|
|
@@ -112,37 +108,45 @@ Examples
|
|
|
112
108
|
|
|
113
109
|
Create a new ImagejRoi instance from an array of x, y coordinates:
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
>>> roi.
|
|
111
|
+
.. code-block:: python
|
|
112
|
+
|
|
113
|
+
>>> roi = ImagejRoi.frompoints([[1.1, 2.2], [3.3, 4.4], [5.5, 6.6]])
|
|
114
|
+
>>> roi.roitype = ROI_TYPE.POINT
|
|
115
|
+
>>> roi.options |= ROI_OPTIONS.SHOW_LABELS
|
|
118
116
|
|
|
119
117
|
Export the instance to an ImageJ ROI formatted byte string or file:
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
>>>
|
|
119
|
+
.. code-block:: python
|
|
120
|
+
|
|
121
|
+
>>> out = roi.tobytes()
|
|
122
|
+
>>> out[:4]
|
|
123
|
+
b'Iout'
|
|
124
|
+
>>> roi.tofile('_test.roi')
|
|
125
125
|
|
|
126
126
|
Read the ImageJ ROI from the file and verify the content:
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
>>>
|
|
132
|
-
True
|
|
133
|
-
>>> roi.
|
|
134
|
-
True
|
|
135
|
-
>>> roi.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
128
|
+
.. code-block:: python
|
|
129
|
+
|
|
130
|
+
>>> roi2 = ImagejRoi.fromfile('_test.roi')
|
|
131
|
+
>>> roi2 == roi
|
|
132
|
+
True
|
|
133
|
+
>>> roi.roitype == ROI_TYPE.POINT
|
|
134
|
+
True
|
|
135
|
+
>>> roi.subpixelresolution
|
|
136
|
+
True
|
|
137
|
+
>>> roi.coordinates()
|
|
138
|
+
array([[1.1, 2.2],
|
|
139
|
+
[3.3, 4.4],
|
|
140
|
+
[5.5, 6.6]], dtype=float32)
|
|
141
|
+
>>> roi.left, roi.top, roi.right, roi.bottom
|
|
142
|
+
(1, 2, 7, 8)
|
|
141
143
|
|
|
142
144
|
Plot the ROI using matplotlib:
|
|
143
145
|
|
|
144
|
-
|
|
146
|
+
.. code-block:: python
|
|
147
|
+
|
|
148
|
+
>>> roi.plot()
|
|
145
149
|
|
|
146
150
|
View the overlays stored in a ROI, ZIP, or TIFF file from a command line::
|
|
147
151
|
|
|
148
|
-
python -m roifile _test.roi
|
|
152
|
+
python -m roifile _test.roi
|
|
@@ -39,7 +39,7 @@ interest, geometric shapes, paths, text, and whatnot for image overlays.
|
|
|
39
39
|
|
|
40
40
|
:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
|
|
41
41
|
:License: BSD 3-Clause
|
|
42
|
-
:Version: 2024.
|
|
42
|
+
:Version: 2024.5.24
|
|
43
43
|
:DOI: `10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>`_
|
|
44
44
|
|
|
45
45
|
Quickstart
|
|
@@ -48,7 +48,7 @@ Quickstart
|
|
|
48
48
|
Install the roifile package and all dependencies from the
|
|
49
49
|
`Python Package Index <https://pypi.org/project/roifile/>`_::
|
|
50
50
|
|
|
51
|
-
python -m pip install -U roifile[all]
|
|
51
|
+
python -m pip install -U "roifile[all]"
|
|
52
52
|
|
|
53
53
|
View overlays stored in a ROI, ZIP, or TIFF file::
|
|
54
54
|
|
|
@@ -65,14 +65,22 @@ Requirements
|
|
|
65
65
|
This revision was tested with the following requirements and dependencies
|
|
66
66
|
(other versions may work):
|
|
67
67
|
|
|
68
|
-
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.
|
|
69
|
-
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.
|
|
70
|
-
- `Tifffile <https://pypi.org/project/tifffile/>`_
|
|
71
|
-
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.
|
|
68
|
+
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3
|
|
69
|
+
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.4
|
|
70
|
+
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2024.5.22 (optional)
|
|
71
|
+
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.4 (optional)
|
|
72
72
|
|
|
73
73
|
Revisions
|
|
74
74
|
---------
|
|
75
75
|
|
|
76
|
+
2024.5.24
|
|
77
|
+
|
|
78
|
+
- Fix GitHub not correctly rendering docstring examples.
|
|
79
|
+
|
|
80
|
+
2024.3.20
|
|
81
|
+
|
|
82
|
+
- Fix writing generator of ROIs (#9).
|
|
83
|
+
|
|
76
84
|
2024.1.10
|
|
77
85
|
|
|
78
86
|
- Support text rotation.
|
|
@@ -102,21 +110,6 @@ Revisions
|
|
|
102
110
|
|
|
103
111
|
2022.7.29
|
|
104
112
|
|
|
105
|
-
- Update metadata.
|
|
106
|
-
|
|
107
|
-
2022.3.18
|
|
108
|
-
|
|
109
|
-
- Fix creating ROIs from float coordinates exceeding int16 range (#7).
|
|
110
|
-
- Fix bottom-right bounds in ImagejRoi.frompoints.
|
|
111
|
-
|
|
112
|
-
2022.2.2
|
|
113
|
-
|
|
114
|
-
- Add type hints.
|
|
115
|
-
- Change ImagejRoi to dataclass.
|
|
116
|
-
- Drop support for Python 3.7 and numpy < 1.19 (NEP29).
|
|
117
|
-
|
|
118
|
-
2021.6.6
|
|
119
|
-
|
|
120
113
|
- …
|
|
121
114
|
|
|
122
115
|
Refer to the CHANGES file for older revisions.
|
|
@@ -181,7 +174,7 @@ View the overlays stored in a ROI, ZIP, or TIFF file from a command line::
|
|
|
181
174
|
|
|
182
175
|
from __future__ import annotations
|
|
183
176
|
|
|
184
|
-
__version__ = '2024.
|
|
177
|
+
__version__ = '2024.5.24'
|
|
185
178
|
|
|
186
179
|
__all__ = [
|
|
187
180
|
'roiread',
|
|
@@ -253,14 +246,20 @@ def roiwrite(
|
|
|
253
246
|
if mode is None:
|
|
254
247
|
mode = 'a' if os.path.exists(filename) else 'w'
|
|
255
248
|
|
|
256
|
-
if name is None:
|
|
257
|
-
|
|
258
|
-
|
|
249
|
+
if name is not None:
|
|
250
|
+
if isinstance(name, str):
|
|
251
|
+
raise ValueError("'name' is not an iterable of str")
|
|
252
|
+
name = iter(name)
|
|
259
253
|
|
|
260
254
|
import zipfile
|
|
261
255
|
|
|
262
256
|
with zipfile.ZipFile(filename, mode) as zf:
|
|
263
|
-
for
|
|
257
|
+
for r in roi:
|
|
258
|
+
if name is None:
|
|
259
|
+
n = r.name if r.name else r.autoname
|
|
260
|
+
else:
|
|
261
|
+
n = next(name)
|
|
262
|
+
n = n if n[-4:].lower() == '.roi' else n + '.roi'
|
|
264
263
|
with zf.open(n, 'w') as fh:
|
|
265
264
|
fh.write(r.tobytes())
|
|
266
265
|
return None
|
|
@@ -1272,7 +1271,12 @@ def test(verbose: bool = False) -> None:
|
|
|
1272
1271
|
os.remove('_test.zip')
|
|
1273
1272
|
except OSError:
|
|
1274
1273
|
pass
|
|
1275
|
-
|
|
1274
|
+
|
|
1275
|
+
def roi_iter():
|
|
1276
|
+
# issue #9
|
|
1277
|
+
yield from rois
|
|
1278
|
+
|
|
1279
|
+
roiwrite('_test.zip', roi_iter())
|
|
1276
1280
|
assert roiread('_test.zip') == rois
|
|
1277
1281
|
|
|
1278
1282
|
# verify box_combined
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: roifile
|
|
3
|
-
Version: 2024.
|
|
3
|
+
Version: 2024.5.24
|
|
4
4
|
Summary: Read and write ImageJ ROI format
|
|
5
5
|
Home-page: https://www.cgohlke.com
|
|
6
6
|
Author: Christoph Gohlke
|
|
@@ -38,7 +38,7 @@ interest, geometric shapes, paths, text, and whatnot for image overlays.
|
|
|
38
38
|
|
|
39
39
|
:Author: `Christoph Gohlke <https://www.cgohlke.com>`_
|
|
40
40
|
:License: BSD 3-Clause
|
|
41
|
-
:Version: 2024.
|
|
41
|
+
:Version: 2024.5.24
|
|
42
42
|
:DOI: `10.5281/zenodo.6941603 <https://doi.org/10.5281/zenodo.6941603>`_
|
|
43
43
|
|
|
44
44
|
Quickstart
|
|
@@ -47,7 +47,7 @@ Quickstart
|
|
|
47
47
|
Install the roifile package and all dependencies from the
|
|
48
48
|
`Python Package Index <https://pypi.org/project/roifile/>`_::
|
|
49
49
|
|
|
50
|
-
python -m pip install -U roifile[all]
|
|
50
|
+
python -m pip install -U "roifile[all]"
|
|
51
51
|
|
|
52
52
|
View overlays stored in a ROI, ZIP, or TIFF file::
|
|
53
53
|
|
|
@@ -64,14 +64,22 @@ Requirements
|
|
|
64
64
|
This revision was tested with the following requirements and dependencies
|
|
65
65
|
(other versions may work):
|
|
66
66
|
|
|
67
|
-
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.
|
|
68
|
-
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.
|
|
69
|
-
- `Tifffile <https://pypi.org/project/tifffile/>`_
|
|
70
|
-
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.
|
|
67
|
+
- `CPython <https://www.python.org>`_ 3.9.13, 3.10.11, 3.11.9, 3.12.3
|
|
68
|
+
- `Numpy <https://pypi.org/project/numpy/>`_ 1.26.4
|
|
69
|
+
- `Tifffile <https://pypi.org/project/tifffile/>`_ 2024.5.22 (optional)
|
|
70
|
+
- `Matplotlib <https://pypi.org/project/matplotlib/>`_ 3.8.4 (optional)
|
|
71
71
|
|
|
72
72
|
Revisions
|
|
73
73
|
---------
|
|
74
74
|
|
|
75
|
+
2024.5.24
|
|
76
|
+
|
|
77
|
+
- Fix GitHub not correctly rendering docstring examples.
|
|
78
|
+
|
|
79
|
+
2024.3.20
|
|
80
|
+
|
|
81
|
+
- Fix writing generator of ROIs (#9).
|
|
82
|
+
|
|
75
83
|
2024.1.10
|
|
76
84
|
|
|
77
85
|
- Support text rotation.
|
|
@@ -101,21 +109,6 @@ Revisions
|
|
|
101
109
|
|
|
102
110
|
2022.7.29
|
|
103
111
|
|
|
104
|
-
- Update metadata.
|
|
105
|
-
|
|
106
|
-
2022.3.18
|
|
107
|
-
|
|
108
|
-
- Fix creating ROIs from float coordinates exceeding int16 range (#7).
|
|
109
|
-
- Fix bottom-right bounds in ImagejRoi.frompoints.
|
|
110
|
-
|
|
111
|
-
2022.2.2
|
|
112
|
-
|
|
113
|
-
- Add type hints.
|
|
114
|
-
- Change ImagejRoi to dataclass.
|
|
115
|
-
- Drop support for Python 3.7 and numpy < 1.19 (NEP29).
|
|
116
|
-
|
|
117
|
-
2021.6.6
|
|
118
|
-
|
|
119
112
|
- …
|
|
120
113
|
|
|
121
114
|
Refer to the CHANGES file for older revisions.
|
|
@@ -9,11 +9,10 @@ segmentation from/to ImageJ TIFF files.
|
|
|
9
9
|
|
|
10
10
|
import numpy
|
|
11
11
|
from matplotlib import pyplot
|
|
12
|
+
from roifile import ImagejRoi
|
|
12
13
|
from skimage.measure import find_contours, label, regionprops
|
|
13
14
|
from tifffile import TiffFile, imwrite
|
|
14
15
|
|
|
15
|
-
from roifile import ImagejRoi
|
|
16
|
-
|
|
17
16
|
|
|
18
17
|
def plot_image_overlays(image, overlays, **kwargs):
|
|
19
18
|
"""Plot image and overlays (bytes) using matplotlib."""
|
|
@@ -8,14 +8,32 @@ import sys
|
|
|
8
8
|
from setuptools import setup
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def search(pattern,
|
|
12
|
-
|
|
13
|
-
match = re.search(pattern,
|
|
11
|
+
def search(pattern, string, flags=0):
|
|
12
|
+
"""Return first match of pattern in string."""
|
|
13
|
+
match = re.search(pattern, string, flags)
|
|
14
14
|
if match is None:
|
|
15
15
|
raise ValueError(f'{pattern!r} not found')
|
|
16
16
|
return match.groups()[0]
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def fix_docstring_examples(docstring):
|
|
20
|
+
"""Return docstring with examples fixed for GitHub."""
|
|
21
|
+
start = True
|
|
22
|
+
indent = False
|
|
23
|
+
lines = ['..', ' This file is generated by setup.py', '']
|
|
24
|
+
for line in docstring.splitlines():
|
|
25
|
+
if not line.strip():
|
|
26
|
+
start = True
|
|
27
|
+
indent = False
|
|
28
|
+
if line.startswith('>>> '):
|
|
29
|
+
indent = True
|
|
30
|
+
if start:
|
|
31
|
+
lines.extend(['.. code-block:: python', ''])
|
|
32
|
+
start = False
|
|
33
|
+
lines.append((' ' if indent else '') + line)
|
|
34
|
+
return '\n'.join(lines)
|
|
35
|
+
|
|
36
|
+
|
|
19
37
|
with open('roifile/roifile.py', encoding='utf-8') as fh:
|
|
20
38
|
code = fh.read().replace('\r\n', '\n').replace('\r', '\n')
|
|
21
39
|
|
|
@@ -36,7 +54,7 @@ if 'sdist' in sys.argv:
|
|
|
36
54
|
# update README, LICENSE, and CHANGES files
|
|
37
55
|
|
|
38
56
|
with open('README.rst', 'w', encoding='utf-8') as fh:
|
|
39
|
-
fh.write(readme)
|
|
57
|
+
fh.write(fix_docstring_examples(readme))
|
|
40
58
|
|
|
41
59
|
license = search(
|
|
42
60
|
r'(# Copyright.*?(?:\r\n|\r|\n))(?:\r\n|\r|\n)+""',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|