Skip to content

Commit

Permalink
drop unicodecsv package (#1805)
Browse files Browse the repository at this point in the history
* remove unicodecsv (#1804)

* add test
  • Loading branch information
tomkralidis authored Sep 9, 2024
1 parent 1429a81 commit 6ad14a6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ ENV TZ=${TZ} \
python3-greenlet \
python3-pip \
python3-tz \
python3-unicodecsv \
python3-yaml \
${ADD_DEB_PACKAGES}"

Expand Down
8 changes: 4 additions & 4 deletions pygeoapi/formatter/csv_.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
#
# =================================================================

import csv
import io
import logging

import unicodecsv as csv

from pygeoapi.formatter.base import BaseFormatter, FormatterSerializationError

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -83,10 +82,11 @@ def write(self, options: dict = {}, data: dict = None) -> str:
# TODO: implement wkt geometry serialization
LOGGER.debug('not a point geometry, skipping')

print("JJJ", fields)
LOGGER.debug(f'CSV fields: {fields}')

try:
output = io.BytesIO()
output = io.StringIO()
writer = csv.DictWriter(output, fields)
writer.writeheader()

Expand All @@ -101,7 +101,7 @@ def write(self, options: dict = {}, data: dict = None) -> str:
LOGGER.error(err)
raise FormatterSerializationError('Error writing CSV output')

return output.getvalue()
return output.getvalue().encode('utf-8')

def __repr__(self):
return f'<CSVFormatter> {self.name}'
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ requests
shapely
SQLAlchemy<2.0.0
tinydb
unicodecsv
7 changes: 7 additions & 0 deletions tests/api/test_itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,13 @@ def test_get_collection_item(config, api_):
assert 'prev' not in feature['links']
assert 'next' not in feature['links']

req = mock_api_request()
rsp_headers, code, response = get_collection_item(api_, req, 'norway_pop',
'790')
feature = json.loads(response)

assert feature['properties']['name'] == 'Ålesund'


def test_get_collection_item_json_ld(config, api_):
req = mock_api_request({'f': 'jsonld'})
Expand Down

0 comments on commit 6ad14a6

Please sign in to comment.