Skip to content

Commit

Permalink
Merge pull request #673 from girder/style-cleanup
Browse files Browse the repository at this point in the history
Fix a few style issues.
  • Loading branch information
manthey authored Oct 29, 2021
2 parents 4fc7f55 + 09853b9 commit 052b0c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
4 changes: 1 addition & 3 deletions sources/deepzoom/large_image_source_deepzoom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import PIL.Image

from large_image import config
from large_image.cache_util import LruCacheMetaclass, methodcache
from large_image.constants import TILE_FORMAT_NUMPY, SourcePriority
from large_image.exceptions import TileSourceError, TileSourceFileNotFoundError
Expand Down Expand Up @@ -37,10 +36,9 @@ def __init__(self, path, **kwargs):
:param path: a filesystem path for the tile source.
"""
super(DeepzoomFileTileSource, self).__init__(path, **kwargs)
super().__init__(path, **kwargs)

self._largeImagePath = self._getLargeImagePath()
self._logger = config.getConfig('logger')
# Read the root dzi file and check that the expected image files exist
try:
with builtins.open(self._largeImagePath) as fptr:
Expand Down
20 changes: 10 additions & 10 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from large_image.constants import (TILE_FORMAT_IMAGE, TILE_FORMAT_NUMPY,
TILE_FORMAT_PIL, SourcePriority,
TileInputUnits, TileOutputMimeTypes)
from large_image.exceptions import TileSourceException, TileSourceFileNotFoundError
from large_image.exceptions import TileSourceError, TileSourceFileNotFoundError
from large_image.tilesource import FileTileSource

try:
Expand Down Expand Up @@ -114,7 +114,7 @@ def __init__(self, path, projection=None, unitsPerPixel=None, **kwargs):
except RuntimeError:
if not os.path.isfile(self._path):
raise TileSourceFileNotFoundError(self._path) from None
raise TileSourceException('File cannot be opened via GDAL')
raise TileSourceError('File cannot be opened via GDAL')
self._getDatasetLock = threading.RLock()
self.tileSize = 256
self.tileWidth = self.tileSize
Expand All @@ -132,16 +132,16 @@ def __init__(self, path, projection=None, unitsPerPixel=None, **kwargs):
except AttributeError:
if not os.path.isfile(self._path):
raise TileSourceFileNotFoundError(self._path) from None
raise TileSourceException('File cannot be opened via GDAL.')
raise TileSourceError('File cannot be opened via GDAL.')
is_netcdf = self._checkNetCDF()
try:
scale = self.getPixelSizeInMeters()
except RuntimeError:
raise TileSourceException('File cannot be opened via GDAL.')
raise TileSourceError('File cannot be opened via GDAL.')
if (self.projection or self._getDriver() in {
'PNG',
}) and not scale and not is_netcdf:
raise TileSourceException(
raise TileSourceError(
'File does not have a projected scale, so will not be '
'opened via GDAL with a projection.')
self.sourceLevels = self.levels = int(max(0, math.ceil(max(
Expand Down Expand Up @@ -300,7 +300,7 @@ def _initWithProjection(self, unitsPerPixel=None):
# Since we already converted to bytes decoding is safe here
outProj = self._proj4Proj(self.projection)
if outProj.crs.is_geographic:
raise TileSourceException(
raise TileSourceError(
'Projection must not be geographic (it needs to use linear '
'units, not longitude/latitude).')
if unitsPerPixel:
Expand All @@ -316,7 +316,7 @@ def _initWithProjection(self, unitsPerPixel=None):
[-180, 180], [0, 0])
self.unitsAcrossLevel0 = abs(equator[0][1] - equator[0][0])
if not self.unitsAcrossLevel0:
raise TileSourceException(
raise TileSourceError(
'unitsPerPixel must be specified for this projection')
if len(ProjUnitsAcrossLevel0) >= ProjUnitsAcrossLevel0_MaxSize:
ProjUnitsAcrossLevel0.clear()
Expand Down Expand Up @@ -355,7 +355,7 @@ def getHexColors(palette):
try:
return attrgetter(palette)(palettable).hex_colors
except AttributeError:
raise TileSourceException('Palette is not a valid palettable path.')
raise TileSourceError('Palette is not a valid palettable path.')

def getProj4String(self):
"""
Expand Down Expand Up @@ -690,7 +690,7 @@ def _bandNumber(self, band, exc=True):
band = int(band)
if band != -1 and band not in bands:
if exc:
raise TileSourceException(
raise TileSourceError(
'Band has to be a positive integer, -1, or a band '
'interpretation found in the source.')
return None
Expand Down Expand Up @@ -805,7 +805,7 @@ def _convertProjectionUnits(self, left, top, right, bottom, width, height,
if bottom is None and top is not None and height is not None:
bottom = top + height
if (left is None and right is None) or (top is None and bottom is None):
raise TileSourceException(
raise TileSourceError(
'Cannot convert from projection unless at least one of '
'left and right and at least one of top and bottom is '
'specified.')
Expand Down

0 comments on commit 052b0c6

Please sign in to comment.