Skip to content

Commit

Permalink
TC_EXTRA_CMAP_FOLDER now works as intended (#217) (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
dionhaefner authored Jun 30, 2021
1 parent 9bd31a0 commit f698207
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions terracotta/cmaps/get_cmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ def _get_cmap_files() -> Dict[str, str]:
return cmap_files


CMAP_FILES = _get_cmap_files()
AVAILABLE_CMAPS = sorted(CMAP_FILES.keys())


def _read_cmap(path: str) -> np.ndarray:
with open(path, 'rb') as f:
cmap_data = np.load(f)
Expand All @@ -70,6 +66,10 @@ def _read_cmap(path: str) -> np.ndarray:
return cmap_data


CMAP_FILES = _get_cmap_files()
AVAILABLE_CMAPS = sorted(CMAP_FILES.keys())


def get_cmap(name: str) -> np.ndarray:
"""Retrieve the given colormap and return RGBA values as a uint8 NumPy array of
shape (255, 4)
Expand Down
12 changes: 8 additions & 4 deletions terracotta/drivers/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ def user(self) -> Optional[str]:
return self._user or get_settings().MYSQL_USER

@property
def password(self) -> Optional[str]:
return self._password or get_settings().MYSQL_PASSWORD
def password(self) -> str:
pw = self._password or get_settings().MYSQL_PASSWORD

if pw is None:
pw = ''

return pw


class MySQLDriver(RasterDriver):
Expand Down Expand Up @@ -219,7 +224,7 @@ def _connect(self, check: bool = True) -> Iterator:
write_timeout=self.DB_CONNECTION_TIMEOUT,
binary_prefix=True, charset='utf8mb4'
)
self._cursor = cast(DictCursor, self._connection.cursor(DictCursor))
self._cursor = self._connection.cursor(DictCursor)
self._connected = close = True

if check:
Expand Down Expand Up @@ -360,7 +365,6 @@ def keytuple(row: Dict[str, Any]) -> Tuple[str, ...]:

datasets = {}
for row in cursor:
row = cast(Dict[str, Any], row)
datasets[keytuple(row)] = row['filepath']

return datasets
Expand Down
2 changes: 1 addition & 1 deletion terracotta/scripts/click_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def convert(self, value: str, *args: Any) -> List[pathlib.Path]:
class PathlibPath(click.Path):
"""Converts a string to a pathlib.Path object"""

def convert(self, *args: Any) -> pathlib.Path: # type: ignore
def convert(self, *args: Any) -> pathlib.Path:
return pathlib.Path(super().convert(*args))


Expand Down
8 changes: 4 additions & 4 deletions tests/drivers/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

TEST_CASES = {
'mysql://root@localhost:5000/test': dict(
user='root', host='localhost', port=5000, db='test'
user='root', password='', host='localhost', port=5000, db='test'
),
'root@localhost:5000/test': dict(
user='root', host='localhost', port=5000, db='test'
user='root', password='', host='localhost', port=5000, db='test'
),
'mysql://root:foo@localhost/test': dict(
user='root', password='foo', host='localhost', port=3306, db='test'
),
'mysql://localhost/test': dict(
host='localhost', port=3306, db='test'
password='', host='localhost', port=3306, db='test'
),
'localhost/test': dict(
host='localhost', port=3306, db='test'
password='', host='localhost', port=3306, db='test'
)
}

Expand Down

0 comments on commit f698207

Please sign in to comment.