generated from linz/template-python-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: account for strs that start with [ but are not json
- Loading branch information
1 parent
f7c02d7
commit eca71e4
Showing
2 changed files
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import json | ||
from typing import List, cast | ||
|
||
from linz_logger import get_log | ||
|
||
|
||
def format_source(source: List[str]) -> List[str]: | ||
"""Due to Argo constraints if using the basemaps cli the source has a string that contains a list that needs to be split. | ||
example: ["[\"s3://test/image_one.tiff, \"s3://test/image_two.tiff\"]"] | ||
"""Due to Argo constraints if using the basemaps cli list command the source has a string that contains a list that needs to be split. | ||
example: ["[\"s3://test/image_one.tiff\", \"s3://test/image_two.tiff\"]"] | ||
""" | ||
if len(source) == 1 and source[0].startswith("["): | ||
return cast(List[str], json.loads(source[0])) | ||
try: | ||
return cast(List[str], json.loads(source[0])) | ||
except ValueError as e: | ||
get_log().debug("Decoding Json Failed", source=source, msg=e) | ||
return source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters