Skip to content

Commit e629d37

Browse files
authored
Merge pull request #14 from AtlasOfLivingAustralia/release/0.2.0
Release v0.2.0
2 parents 4f8af59 + ad453cc commit e629d37

21 files changed

+932
-354
lines changed

.flake8

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
max-line-length = 120
3+
max-complexity = 19
4+
select = C,E,F,W,B,B950
5+
ignore = E126,E203,E501,W503,W504
6+
exclude =
7+
.git,
8+
__pycache__,
9+
*.egg-info,
10+
.pytest_cache,
11+
.mypy_cache

.github/workflows/publish-release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
# stop the build if there are Python syntax errors or undefined names
2727
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
2828
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
29+
flake8 . --count --exit-zero --statistics
3030
- name: Install poetry and project dependencies
3131
run: |
3232
python -m pip install poetry
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
echo ${{ github.workspace }}
3737
cd ${{ github.workspace }}/tests
38-
poetry run pytest
38+
poetry run pytest --github-action-run=True
3939
- name: Build
4040
id: build-step
4141
run: |

.github/workflows/publish-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
# stop the build if there are Python syntax errors or undefined names
2525
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
2626
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
27-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
27+
flake8 . --count --exit-zero --statistics
2828
- name: Install poetry and project dependencies
2929
run: |
3030
python -m pip install poetry
@@ -33,7 +33,7 @@ jobs:
3333
run: |
3434
echo ${{ github.workspace }}
3535
cd ${{ github.workspace }}/tests
36-
poetry run pytest
36+
poetry run pytest --github-action-run=True
3737
- name: Build
3838
id: build-step
3939
run: |

.github/workflows/run-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
# stop the build if there are Python syntax errors or undefined names
4040
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
4141
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
42-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
42+
flake8 . --count --exit-zero --statistics
4343
- name: Install project dependencies
4444
run: |
4545
python -m pip install poetry
@@ -48,5 +48,5 @@ jobs:
4848
run: |
4949
echo ${{ github.workspace }}
5050
cd ${{ github.workspace }}/tests
51-
poetry run pytest
51+
poetry run pytest --cov=dwcahandler --github-action-run=True
5252

README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,33 @@ poetry build
4343
 
4444
### Installation
4545

46-
To use locally built package in a virtual environment for eg in preingestion or galaxias:
46+
Install published package
47+
```bash
48+
pip install dwcahandler
49+
```
50+
51+
To use locally built package in a virtual environment:
4752
```bash
4853
pip install <folder>/dwcahandler/dist/dwcahandler-<version>.tar.gz
4954
```
5055

51-
However, to install published package from testpypi
56+
To install published package from testpypi
5257
```bash
5358
pip install -i https://test.pypi.org/simple/ dwcahandler
5459
```
5560
&nbsp;
5661
### Examples of dwcahandler usages:
5762

5863
* Create Darwin Core Archive from csv file
64+
* In creating a dwca with multimedia extension, provide format and type values in the Simple Multimedia extension, otherwise, dwcahandler will attempt to fill these info by guessing the mimetype from url.
65+
5966
```python
6067
from dwcahandler import CsvFileType
6168
from dwcahandler import DwcaHandler
6269
from dwcahandler import Eml
6370

64-
core_csv = CsvFileType(files=['/tmp/occurrence.csv'], type='occurrence', keys='occurrenceID')
65-
ext_csvs = [CsvFileType(files=['/tmp/multimedia.csv'], type='multimedia')]
71+
core_csv = CsvFileType(files=['/tmp/occurrence.csv'], type='occurrence', keys=['occurrenceID'])
72+
ext_csvs = [CsvFileType(files=['/tmp/multimedia.csv'], type='multimedia', keys=['occurrenceID'])]
6673

6774
eml = Eml(dataset_name='Test Dataset',
6875
description='Dataset description',
@@ -74,6 +81,8 @@ DwcaHandler.create_dwca(core_csv=core_csv, ext_csv_list=ext_csvs, eml_content=em
7481
```
7582
&nbsp;
7683
* Create Darwin Core Archive from pandas dataframe
84+
* In creating a dwca with multimedia extension, provide format and type values in the Simple Multimedia extension, otherwise, dwcahandler will attempt to fill these info by guessing the mimetype from url.
85+
7786
```python
7887
from dwcahandler import DwcaHandler
7988
from dwcahandler.dwca import DataFrameType
@@ -84,7 +93,7 @@ core_df = pd.read_csv("/tmp/occurrence.csv")
8493
core_frame = DataFrameType(df=core_df, type='occurrence', keys=['occurrenceID'])
8594

8695
ext_df = pd.read_csv("/tmp/multimedia.csv")
87-
ext_frame = [DataFrameType(df=ext_df, type='multimedia')]
96+
ext_frame = [DataFrameType(df=ext_df, type='multimedia', keys=['occurrenceID'])]
8897

8998
eml = Eml(dataset_name='Test Dataset',
9099
description='Dataset description',
@@ -93,6 +102,7 @@ eml = Eml(dataset_name='Test Dataset',
93102
rights="test rights")
94103

95104
DwcaHandler.create_dwca(core_csv=core_frame, ext_csv_list=ext_frame, eml_content=eml, output_dwca_path='/tmp/dwca.zip')
105+
96106
```
97107
&nbsp;
98108
* Merge Darwin Core Archive
@@ -109,7 +119,7 @@ DwcaHandler.merge_dwca(dwca_file='/tmp/dwca.zip', delta_dwca_file='/tmp/delta-dw
109119
from dwcahandler import CsvFileType
110120
from dwcahandler import DwcaHandler
111121

112-
delete_csv = CsvFileType(files=['/tmp/old-records.csv'], type='occurrence', keys='occurrenceID')
122+
delete_csv = CsvFileType(files=['/tmp/old-records.csv'], type='occurrence', keys=['occurrenceID'])
113123

114124
DwcaHandler.delete_records(dwca_file='/tmp/dwca.zip',
115125
records_to_delete=delete_csv,
@@ -118,7 +128,7 @@ DwcaHandler.delete_records(dwca_file='/tmp/dwca.zip',
118128
&nbsp;
119129
* List darwin core terms that is supported in dwcahandler package
120130
```python
121-
from dwca import DwcaHandler
131+
from dwcahandler import DwcaHandler
122132

123133
df = DwcaHandler.list_dwc_terms()
124134
print(df)
@@ -132,7 +142,7 @@ class DerivedDwca(Dwca):
132142
"""
133143
Derived class to perform other custom operations that is not included as part of the core operations
134144
"""
135-
def _drop_columns(self):
145+
def drop_columns(self):
136146
"""
137147
Drop existing column in the core content
138148
"""
@@ -141,10 +151,10 @@ class DerivedDwca(Dwca):
141151

142152

143153
dwca = DerivedDwca(dwca_file_loc='/tmp/dwca.zip')
144-
dwca._extract_dwca()
145-
dwca._drop_columns()
146-
dwca._generate_eml()
147-
dwca._generate_meta()
148-
dwca._write_dwca('/tmp/newdwca.zip')
154+
dwca.extract_dwca()
155+
dwca.drop_columns()
156+
dwca.generate_eml()
157+
dwca.generate_meta()
158+
dwca.write_dwca('/tmp/newdwca.zip')
149159

150160
```

0 commit comments

Comments
 (0)