-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Allow custom CF url (-d) #1066
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
41f221e
Allow specification of CF source by url
jr3cermak c17f5f6
Remove f-string specifier
jr3cermak e4f13f9
ruff recommended updates
jr3cermak a4819db
Updates with python black linter
jr3cermak b49f60f
Updates
jr3cermak 4ab682f
Updates
jr3cermak a6bb792
Removed items that pre-commit installs itself
jr3cermak 9069b06
Adjust workflow to use requirements-test.txt
jr3cermak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -199,9 +199,9 @@ | |
def _get(self, entrynode, attrname, required=False): | ||
vals = entrynode.xpath(attrname) | ||
if len(vals) > 1: | ||
raise Exception("Multiple attrs (%s) found" % attrname) | ||
raise Exception(f"Multiple attrs ({attrname}) found") | ||
elif required and len(vals) == 0: | ||
raise Exception("Required attr (%s) not found" % attrname) | ||
raise Exception(f"Required attr ({attrname}) not found") | ||
|
||
return vals[0].text | ||
|
||
|
@@ -236,22 +236,21 @@ | |
|
||
def __getitem__(self, key): | ||
if not (key in self._names or key in self._aliases): | ||
raise KeyError("%s not found in standard name table" % key) | ||
raise KeyError(f"{key} not found in standard name table") | ||
|
||
if key in self._aliases: | ||
idx = self._aliases.index(key) | ||
entryids = self._root.xpath("alias")[idx].xpath("entry_id") | ||
|
||
if len(entryids) != 1: | ||
raise Exception( | ||
"Inconsistency in standard name table, could not lookup alias for %s" | ||
% key, | ||
f"Inconsistency in standard name table, could not lookup alias for {key}", | ||
) | ||
|
||
key = entryids[0].text | ||
|
||
if key not in self._names: | ||
raise KeyError("%s not found in standard name table" % key) | ||
raise KeyError(f"{key} not found in standard name table") | ||
|
||
idx = self._names.index(key) | ||
entry = self.NameEntry(self._root.xpath("entry")[idx]) | ||
|
@@ -289,7 +288,11 @@ | |
if version == "latest": | ||
url = "http://cfconventions.org/Data/cf-standard-names/current/src/cf-standard-name-table.xml" | ||
else: | ||
url = f"http://cfconventions.org/Data/cf-standard-names/{version}/src/cf-standard-name-table.xml" | ||
if version.startswith("http"): | ||
url = version | ||
version = '"url specified"' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could say "custom URL"? Although, if this variable is not used anywhere we can probably remove it here. |
||
else: | ||
url = f"http://cfconventions.org/Data/cf-standard-names/{version}/src/cf-standard-name-table.xml" | ||
|
||
r = requests.get(url, allow_redirects=True) | ||
r.raise_for_status() | ||
|
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
flake8 | ||
flake8-builtins | ||
flake8-comprehensions | ||
flake8-mutable | ||
flake8-print | ||
httpretty | ||
pre-commit | ||
pytest | ||
pytest-flake8 | ||
requests-mock |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
myst-parser | ||
numpydoc | ||
pydata-sphinx-theme | ||
sphinx |
File renamed without changes.
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,18 +1,15 @@ | ||
cf-units>=2 | ||
cftime>=1.1.0 | ||
cf-units | ||
importlib-metadata # drop this when dropping Python 3.8 | ||
importlib-resources # drop this when dropping Python 3.8 | ||
isodate>=0.6.1 | ||
jinja2>=2.7.3 | ||
lxml>=3.2.1 | ||
netcdf4>=1.6.4 | ||
owsLib>=0.8.3 | ||
isodate | ||
lxml | ||
netcdf4 | ||
owslib | ||
packaging | ||
pendulum>=1.2.4 | ||
pygeoif>=0.6 | ||
pyproj>=2.2.1 | ||
regex>=2017.07.28 | ||
requests>=2.2.1 | ||
setuptools>=15.0 | ||
shapely>=1.7.1 | ||
validators>=0.14.2 | ||
pendulum | ||
pygeoif | ||
pyproj | ||
regex | ||
requests | ||
shapely | ||
validators |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes like this make it hard to follow the actual changes in the PR. While I personally prefer the
requirements-dev.txt
we are stuck with the original file name here and no need to change it now.PS: I'd welcome a change like this in its own PR, away from important code changes that require careful review.