Skip to content

Commit

Permalink
Merge pull request #169 from SharonGoliath/CADC-12637
Browse files Browse the repository at this point in the history
CADC-12637 - make contentType definition more flexible for text/plain.
  • Loading branch information
SharonGoliath committed Jul 20, 2023
2 parents 5735d35 + 4be9574 commit d6374b2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Install hdf5 library
run: sudo apt-get install -y libhdf5-dev
uses: actions/checkout@v3

egginfo:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install tox
Expand All @@ -49,16 +47,15 @@ jobs:
package: caom2utils
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
# pytest-runner required to support deprecated Python3.5
run: python -m pip install --upgrade tox pytest-runner
run: python -m pip install --upgrade tox
- name: Test ${{ matrix.package }}
run: |
# add py and remove the "." from python-version in order to get the tox_target
Expand All @@ -70,9 +67,9 @@ jobs:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup Graphviz
Expand All @@ -96,9 +93,9 @@ jobs:
runs-on: ubuntu-latest
if: contains(github.ref, '=')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Determine the package
Expand Down
10 changes: 5 additions & 5 deletions caom2utils/caom2utils/caom2blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,7 @@ def augment_custom(self, chunk):
return
try:
custom_axis_length = self._get_axis_length(custom_axis_index + 1)
except ValueError as e:
except ValueError:
self.logger.debug('No WCS Custom axis.function')
return

Expand Down Expand Up @@ -3972,7 +3972,7 @@ def augment_energy(self, chunk):
return
try:
energy_axis_length = self._get_axis_length(energy_axis_index + 1)
except ValueError as e:
except ValueError:
self.logger.debug('No WCS Energy axis.function')
return

Expand Down Expand Up @@ -4070,7 +4070,7 @@ def augment_temporal(self, chunk):

try:
axis_length = self._get_axis_length(time_axis_index + 1)
except ValueError as e:
except ValueError:
self.logger.debug('No WCS Temporal axis.function')
return

Expand Down Expand Up @@ -4111,7 +4111,7 @@ def augment_polarization(self, chunk):

try:
axis_length = self._get_axis_length(polarization_axis_index + 1)
except ValueError as e:
except ValueError:
self.logger.debug('No WCS Polarization axis.function')
return

Expand Down Expand Up @@ -4216,7 +4216,7 @@ def _get_dimension(self, xindex, yindex):
try:
xindex_axis_length = self._get_axis_length(xindex + 1)
yindex_axis_length = self._get_axis_length(yindex + 1)
except ValueError as e:
except ValueError:
self.logger.debug('No WCS Energy axis.function')
return None
aug_dim1 = _to_int(xindex_axis_length)
Expand Down
20 changes: 10 additions & 10 deletions caom2utils/caom2utils/data_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,23 @@ def get_file_encoding(fqn):

def get_file_type(fqn):
"""Basic header extension to content_type lookup."""
if (fqn.endswith('.header') or fqn.endswith('.txt') or
fqn.endswith('.cat') or fqn.endswith('.dat')):
return 'text/plain'
elif fqn.endswith('.gif'):
lower_fqn = fqn.lower()
if (lower_fqn.endswith('.fits') or lower_fqn.endswith('.fits.fz')):
return 'application/fits'
elif lower_fqn.endswith('.gif'):
return 'image/gif'
elif fqn.endswith('.png'):
elif lower_fqn.endswith('.png'):
return 'image/png'
elif fqn.endswith('.jpg'):
elif lower_fqn.endswith('.jpg'):
return 'image/jpeg'
elif fqn.endswith('.tar.gz'):
elif lower_fqn.endswith('.tar.gz'):
return 'application/x-tar'
elif fqn.endswith('.csv'):
elif lower_fqn.endswith('.csv'):
return 'text/csv'
elif fqn.endswith('.hdf5') or fqn.endswith('.h5'):
elif lower_fqn.endswith('.hdf5') or fqn.endswith('.h5'):
return 'application/x-hdf5'
else:
return 'application/fits'
return 'text/plain'


def make_headers_from_string(fits_header):
Expand Down
5 changes: 4 additions & 1 deletion caom2utils/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ url = https://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2
edit_on_github = False
github_project = opencadc/caom2tools
# version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
version = 1.7
version = 1.7.1

[options]
install_requires =
Expand All @@ -52,6 +52,9 @@ test =
flake8>=3.9
xml-compare>=1.0.5

[flake8]
max-line-length = 120

[entry_points]
fits2caom2 = caom2utils.legacy:main_app
caom2gen = caom2utils.caom2blueprint:caom2gen

0 comments on commit d6374b2

Please sign in to comment.