Skip to content
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

Add Vocabulary class #258

Open
wants to merge 245 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
fea5aee
Remove unnecessary variable
orviz May 21, 2024
7d09b7b
Use logging.info instead of print()
orviz May 21, 2024
66ccfc9
Search option available also for epos prod
orviz May 21, 2024
8ac821e
First implementation (copy from EPOS) of EPOS prod plugin
orviz May 21, 2024
54ee186
Fix: remove unnecessary local 'eml_schema' var
orviz May 21, 2024
a8eb6e1
Initial config.ini for epos_prod plugin
orviz May 21, 2024
2231cc7
Minimum implementation & config for EPOS prod API
orviz May 21, 2024
fac54d0
Align ID term list for both EPOS plugins
orviz May 21, 2024
18d873e
Avoid re-implementations on EPOS prod side
orviz May 21, 2024
56ce714
Reuse 'terms_cv', so terms_vocabularies -> terms_cv
orviz May 21, 2024
d944c68
Separate metadata value parsing in a individual class PluginUtils
orviz May 21, 2024
341b4a0
Different implementations to ge the IDs for the data in EPOS prod and…
orviz May 22, 2024
c3d3352
Basic structure for metadata value gathering and validation
orviz May 22, 2024
c1ebb24
Reimplement i1_01m with PluginUtils (leaving commented code).
orviz May 22, 2024
4086b8b
Support for gathering list of file formats from metadata
orviz May 22, 2024
1aa6e99
Support for gathering list of temporal coverage from metadata
orviz May 22, 2024
f7e30b2
Support for gathering list of licenses from metadata
orviz May 22, 2024
e17d9bf
Implementation of metadata value validation (incl. licensing) as part…
orviz May 22, 2024
851b66d
Add new attributes for CVs
orviz May 22, 2024
dfd5365
Common way to gather non-validated results
orviz May 22, 2024
b8583ae
Fix: method naming
orviz May 22, 2024
6a5f245
Minor comment
orviz May 22, 2024
0a3aedd
Fix: docstrings
orviz May 22, 2024
60860e5
Fix: duplicate config
orviz May 22, 2024
a296dc5
Implement MetadataValuesBase as parent class
orviz May 22, 2024
471d5d4
Include identifiers in the gathering process
orviz May 22, 2024
7cc1de0
Typo
orviz May 22, 2024
f161484
Sort elements
orviz May 22, 2024
90bbaab
Methods from MetadataValuesBase class that shall be implemented by ch…
orviz May 22, 2024
1ca1395
Fix: get config value
orviz May 23, 2024
36ad4af
Moved general evalaution functions to evaluator.py
PalomoIFCA May 23, 2024
5089a6f
Merge branch 'main' into generalisation/eval
PalomoIFCA May 23, 2024
eb04c34
Extend ConfigTerms to return customised (per-plugin) list of values
orviz May 24, 2024
f400441
Mapping between plugin term keys and standard keys used by the app
orviz May 24, 2024
225daf7
Improved logging
orviz May 24, 2024
89b2dff
Individual methods for data and metadata IDs
orviz May 24, 2024
0d5f93c
Remove duplicate entry for rda_f1_01d
orviz May 24, 2024
2645e14
Fix rda_f1_02m
orviz May 24, 2024
df6aa78
Fix identifier-related indicators
orviz May 24, 2024
0244771
Improve logging message
orviz May 27, 2024
d239a50
Fix single term value gathering
orviz May 27, 2024
ccb4573
Support for gathering person identifiers
orviz May 27, 2024
3946bf6
Fix licensing gathering
orviz May 27, 2024
9920eaf
Improve logging message
orviz May 27, 2024
1e94d54
Gather elements for provenance
orviz May 27, 2024
7442072
Get normalised data for metadata element & values
orviz Jun 19, 2024
fdb1783
Do not fail when no metadata values are defined
orviz Jun 19, 2024
8546a3c
Use normalised metadata terms to access required identifiers
orviz Jun 21, 2024
d5facc6
Add custom property 'metadata_utils'
orviz Jun 24, 2024
36c2201
Improve logging
orviz Jun 24, 2024
d1592fd
Fix: update, not overwrite metadata elements
orviz Jun 24, 2024
1d65bf4
Improve comments
orviz Jun 24, 2024
c59ca22
Adapt rda_a1_04d to new ConfigTerms
orviz Jun 24, 2024
95673dc
Fix for rda_a1_1_01d
orviz Jun 24, 2024
8c61926
Adapt rda_f2_01m to new ConfigTerms
orviz Jun 24, 2024
98cff69
Adapt rda_f3_01m to new ConfigTerms
orviz Jun 24, 2024
151ca33
Fix sorting
orviz Jul 3, 2024
546a695
Validate i1-02m according to the serialization format
orviz Jul 3, 2024
d30175c
Use one method for all FAIRsharing requests
orviz Jul 3, 2024
8045e07
Option to search within fairsharing by domain='resource metadata'
orviz Jul 4, 2024
e181ce7
Fix method naem
orviz Jul 4, 2024
905008f
Rely on FAIRsharing cache if not specific query is needed
orviz Jul 4, 2024
152cce1
Change username/pass type from list to string
orviz Jul 4, 2024
feaf496
Use @property decorator to obtain FAIRsharing records
orviz Jul 8, 2024
18472c0
Turn FAIRsharing config from lists to strings
orviz Jul 8, 2024
ea4d4a7
Fix: return results
orviz Jul 9, 2024
09f0897
Improve reporting
orviz Jul 9, 2024
b3ac2b3
Use FAIRsharingAPIUtils class to get metadata standards and formats
orviz Jul 9, 2024
b1f9af9
Fix in search_item
orviz Jul 9, 2024
e5901d6
Return empty content when 'local' is not defined
orviz Jul 9, 2024
d7b5266
New proposal for tracking validation checks (e.g. IANA media types) u…
orviz Jul 12, 2024
1fa6c4d
Implement VocabularyBase
orviz Jul 17, 2024
0871bdd
Add vocabulary classes in a individual file
orviz Jul 19, 2024
825e93e
Use Vocabulary class
orviz Jul 19, 2024
5ebbb9d
Fix: module file name
orviz Jul 19, 2024
43bb7d0
Fix imports
orviz Aug 14, 2024
576a3dd
Fix: use logger
orviz Aug 14, 2024
13c1f7f
Move call to get_metadata() to the end of __init__ method
orviz Aug 19, 2024
f2f71dc
Increase logging
orviz Aug 19, 2024
00ab2a8
Return check data in raw format
orviz Aug 19, 2024
6307025
Turn VocabularyConnection.collect as classmethod
orviz Aug 19, 2024
d636180
Define common set of properties for VocabularyConnection class
orviz Aug 19, 2024
a04fcd8
Fix: missing imports
orviz Aug 19, 2024
8f469f0
IANA media types gathering from local cache/file
orviz Aug 19, 2024
2d15372
Merge branch 'main' into feature/i1_02m
orviz Aug 19, 2024
eeb5848
Disable by default remote checking for gathering IANA media types
orviz Aug 19, 2024
f25429f
Docstring for _remote_collect(), including expected return
orviz Aug 20, 2024
314215b
Use logger
orviz Aug 20, 2024
88855bd
FAIRsharing vocabulary implementation
orviz Aug 20, 2024
c34fb8e
Fix style
orviz Aug 20, 2024
8a63c7d
Config parameters for 'vocabularies:fairsharing'
orviz Aug 20, 2024
af7feb9
Fix: do not track logs through 'evaluator_logs' property
orviz Aug 20, 2024
83d8790
Use Vocabulary.get_fairsharing() for retrieving FAIRsharing content
orviz Aug 20, 2024
a51e7e0
Add static content of FAIRsharing registry
orviz Aug 20, 2024
dac3286
Change static path to IANA media types info
orviz Aug 20, 2024
4c76902
Fix: remove HTML headers from JSON
orviz Aug 20, 2024
326b25b
Fix: 'True' and 'False' values are required in config.ini so to be su…
orviz Aug 20, 2024
49314f3
Get _config_items in FAIRsharingRegistry.collect()
orviz Aug 20, 2024
aec1950
Get _config_items in IANAMediaTypes.collect()
orviz Aug 20, 2024
7a48e4f
Implement _local_collect for FAIRsharing
orviz Aug 20, 2024
6a24368
Fix: variable name
orviz Aug 20, 2024
cf1e2fd
Set _config_items as class property
orviz Aug 20, 2024
96f5738
Implement XML parsing from string
orviz Aug 20, 2024
1d7291a
Reuse logger from plugins
orviz Aug 21, 2024
281343f
Improve logging
orviz Aug 21, 2024
c191ea0
Lint & reorganize
orviz Jun 25, 2024
4082d47
Fix: normalize Handle-compliant IDs before resolving
orviz Jun 25, 2024
978b73a
Adapt rda_a1_03d to new ConfigTerms
orviz Jun 25, 2024
28b0dfd
No need for 'else' with the previuos 'return'
orviz Jun 25, 2024
8ed629a
Adapt rda_a1_01m to new ConfigTerms
orviz Jun 25, 2024
5e49639
Adapt license gathering according to new ConfigTerms
orviz Jun 25, 2024
0cd688e
Adapt rda_a1_05d to new ConfigTerms
orviz Jun 26, 2024
9025f01
Adapt rda_a2_01m to new ConfigTerms
orviz Jun 26, 2024
32730b6
Implement 'temporal coverage' for EPOS
orviz Jun 26, 2024
07bd2d8
Fix when 'Temporal Coverage' is empty
orviz Jun 27, 2024
d93e98f
Fix: _get_temporal_coverage() shall return a list
orviz Jun 27, 2024
52b361e
Argument of check_link() to allow returning HTTP codes
orviz Jun 27, 2024
b15e46d
Fix: normalised temporal coverage
orviz Jun 27, 2024
9af3a4c
Bump to pre-commit/[email protected]
orviz Jun 25, 2024
7cfcaa3
Merge branch 'main' into feature/epos_prod_2
orviz Aug 21, 2024
ed36d01
Raise NotImplementedError when no specific gather() method is defined…
orviz Aug 21, 2024
b6d347c
Improve logging
orviz Aug 21, 2024
24a0e20
Temporarily comment variable 'terms_cv_map'
orviz Aug 21, 2024
9308009
ConfigTerms support validation
orviz Aug 21, 2024
9aa85d7
Fix: normalization -> harmonization of metadata terms (step #1)
orviz Aug 21, 2024
6b0665c
Fix: harmonization -> homogenization of format and type for the metad…
orviz Aug 21, 2024
4381478
Docstring for ConfigTerms
orviz Aug 21, 2024
107703d
Improve logging
orviz Aug 21, 2024
2fa3070
Document ConfigTerms' expected input and outputs
orviz Aug 21, 2024
7c38e59
Fix: format gathering
orviz Aug 21, 2024
6118255
Accommodate _validate_license() to match the new format of the return…
orviz Aug 21, 2024
fe21bfe
Fix: MetadataValues shall use the same logger as the Plugin class
orviz Aug 21, 2024
a4e2954
Fix: itemize metadata element in docstring
orviz Aug 21, 2024
70bf46c
Define specific formats for the outputs of ConfigTerms depending on t…
orviz Aug 21, 2024
99b0722
Accommodate _validate_format() to match the new format of the returne…
orviz Aug 21, 2024
a918bfb
Fix: set harmonization > homogenization > validation as a conditional…
orviz Aug 22, 2024
a3eb757
Do not consider only DOIs as data identifiers
orviz Aug 22, 2024
eaddece
Back to printing metadata as dataframe
orviz Aug 22, 2024
8e88413
Implement rda_i1_01m with ConfigTerms(validate=True)
orviz Aug 22, 2024
d1bac60
Use 'plugin.py' logger for the evaluator
orviz Aug 22, 2024
939b03c
Disable call to parent Evaluator's class
orviz Aug 22, 2024
1a30fef
Merge branch 'main' into feature/epos_prod
orviz Aug 22, 2024
42266ea
Fix: remove unnecesary logging
orviz Aug 22, 2024
5032adf
Fix: missing interpolation
orviz Aug 22, 2024
8fcf92f
Create additional logger for API-side-only messages (do not show them…
orviz Aug 22, 2024
9467770
Fix comment
orviz Aug 22, 2024
10354f3
Raise exception if no metadata can be gathered
orviz Aug 22, 2024
e7ddd8f
Remove unnecessary variable
orviz Aug 22, 2024
3bea536
Use additional logger for API messages & filter those for the evaluat…
orviz Aug 22, 2024
0024ff5
Filter message logs to existing loggers
orviz Aug 22, 2024
66855f1
Better reporting for I1_01M
orviz Aug 22, 2024
f0ad503
Fix message
orviz Aug 22, 2024
c7d6f09
Merge branch 'main' into generalisation/eval
PalomoIFCA Aug 26, 2024
d5afde6
Report indicator as INFO
orviz Sep 11, 2024
65b6497
Call parent method for gathering data ids
orviz Sep 11, 2024
c0e2667
Report about kwargs before handing over to wrapped method
orviz Sep 11, 2024
74ce2af
Add condition for 'Person Identifier'
orviz Sep 11, 2024
4fd1f0b
_get_person method for EPOS prod
orviz Sep 11, 2024
5a35ba3
Fix: metadata element for person id
orviz Sep 11, 2024
0968b76
Fix indent
orviz Sep 12, 2024
6e8e95b
Fix rda_r1_01m
orviz Sep 12, 2024
ae909c8
Fix: report kwargs once all metadata has been processed
orviz Sep 12, 2024
c8ba5e4
Report when metadata element will not be validated
orviz Sep 12, 2024
5251637
Simplify calls to plugin's gather methods
orviz Sep 12, 2024
f62eb51
Fix: catch all exception and log the traceback
orviz Sep 12, 2024
d45ce9a
Merge previous gathered values if multiple metadata elements are mapp…
orviz Sep 12, 2024
949f479
Fix: duplication of term_key_harmonized in the resultant payload
orviz Sep 12, 2024
996566a
Basic evaluation of validated metadata elements resulting from Config…
orviz Sep 12, 2024
b68bae9
Updated config.ini
orviz Sep 12, 2024
62f6013
Load both main & plugin's config.ini (latter have precedence)
orviz Sep 12, 2024
74b490d
Adapt new config to epos plugins
orviz Sep 12, 2024
e841fd5
Fix missing options
orviz Sep 12, 2024
c225589
Exit gracefully if request to API fails
orviz Sep 16, 2024
1375512
Option for printing out evaluation logs
orviz Sep 16, 2024
d89dd6c
Merge pull request #211 from EOSC-synergy/feature/improve_client
orviz Sep 16, 2024
e2139f4
Merge branch 'main' into generalisation/eval
orviz Sep 16, 2024
397fb2c
Merge pull request #202 from EOSC-synergy/generalisation/eval
orviz Sep 16, 2024
c7b1a95
Load both main & plugin's config.ini (latter have precedence)
orviz Sep 12, 2024
374f83a
Adapt new config to epos plugins
orviz Sep 12, 2024
3b851dc
Adapt new config reqs in missing plugins
orviz Sep 13, 2024
54c6c9d
Fix: remove single quotes on endpoint
orviz Sep 13, 2024
de2b2cc
Fix: variable name
orviz Sep 13, 2024
56eb2f4
Fix isort
orviz Sep 13, 2024
0278a7c
Fixes in EPOS plugin
orviz Sep 16, 2024
9dc53cf
Merge branch 'feature/i1_02m' into release/3.0.0
orviz Sep 16, 2024
e380a06
Pass config to IANAMediaTypes
orviz Sep 16, 2024
0aca6bb
Pass config to FAIRSharing vocabulary
orviz Sep 16, 2024
fdfd9a0
Support for dict-based output messages
orviz Sep 16, 2024
a4834d9
Merge branch 'feature/i1_02m' into release/3.0.0
orviz Sep 16, 2024
809b1ce
Merge branch 'feature/epos_prod' into release/3.0.0
orviz Sep 17, 2024
e31dcd2
Fix: avoid IANA media types loading in plugin.
orviz Sep 17, 2024
9fb6b4c
Fix: rda_all working for EPOS prod
orviz Sep 17, 2024
c603990
Fix conflict
orviz Sep 17, 2024
d93a5de
Fix: black & isort
orviz Sep 17, 2024
dab5a03
Fix: remove print
orviz Sep 17, 2024
c085d04
Fix: inherit eval_persistency() and eval_uniqueness() methods
orviz Sep 18, 2024
23510ab
Merge branch 'fix/evaluator_methods' into release/3.0.0
orviz Sep 18, 2024
cc9b950
Bump tqdm from 4.66.1 to 4.66.3
dependabot[bot] Sep 18, 2024
08a47f2
Table reports FAIR ID and indicator's purpose
orviz Sep 18, 2024
f7db793
Merge pull request #214 from EOSC-synergy/dependabot/pip/tqdm-4.66.3
orviz Sep 18, 2024
f2a5538
Bump tqdm from 4.66.1 to 4.66.3
dependabot[bot] Sep 18, 2024
db0b2b4
Sort indicators in the FAIR order
orviz Sep 18, 2024
7a0cc44
Merge branch 'feature/client_improvements' into release/3.0.0
orviz Sep 18, 2024
c244912
New implementation of A1-01M that scores according to completion of '…
orviz Sep 18, 2024
ddd7789
Merge pull request #216 from EOSC-synergy/feature/a1_01m
orviz Sep 18, 2024
639314c
Protocol in uppercase
orviz Sep 19, 2024
2eb4594
Improve messages
orviz Sep 19, 2024
e4f4ef6
Report values gathered
orviz Sep 19, 2024
dd26d19
Report message
orviz Sep 19, 2024
ed70dd2
Get person data through 'person:uid' property
orviz Sep 19, 2024
23fe07e
Improve messages
orviz Sep 19, 2024
c42d30c
Implement generic validation for 'Person Identifier'
orviz Sep 19, 2024
a7b28d2
Get ORCID value from 'person:uid' property in prototype API
orviz Sep 19, 2024
19b1f7a
Improve qualified references gathering and reporting
orviz Sep 19, 2024
af0ce80
Improve rda_r1_3_02d
orviz Sep 19, 2024
0337c21
Add 'source-name' to the XML properties returned by ORCID API
orviz Sep 19, 2024
2870913
Merge branch 'fix/orcid_validation' into release/3.0.0
orviz Sep 19, 2024
ef499f6
Remove duplicated var
orviz Sep 19, 2024
e286af8
Improve --json help
orviz Sep 19, 2024
ebd90f6
Merge branch 'feature/client_improvements' into release/3.0.0
orviz Sep 19, 2024
880f8ba
Raise exception if given argument is not an orcid
orviz Oct 3, 2024
5ee64d8
Raise exception if 'controlled_vocabularies' is not defined in config…
orviz Oct 3, 2024
e8e820e
Fix: remove not used imported module
orviz Oct 3, 2024
f86d90a
Move 'dublin-core' section to main config.ini
orviz Oct 3, 2024
004325d
Fix: evaluation_logs logger
orviz Oct 3, 2024
1ceb52c
Fix temporary elements for 'terms_access'
orviz Oct 3, 2024
6375966
Return 100 points in ANY of the (identifier, downloadURL) resolves to…
orviz Oct 3, 2024
8eb93fa
Fix in class method call
orviz Oct 4, 2024
902f8b4
Clean up unused config parameters & duplicated code
orviz Oct 4, 2024
0187a5e
Merge branch 'release/3.0.0' of github.com:eosc-synergy/FAIR_eva into…
orviz Oct 4, 2024
29e2cb5
Merge pull request #212 from EOSC-synergy/release/3.0.0
orviz Oct 15, 2024
a185da0
Fix: temporary coverage
orviz Oct 15, 2024
e962727
Fix: warning in pre-commit
orviz Oct 15, 2024
c1f61ad
Temporarily comment docformatter check
orviz Oct 15, 2024
7289736
Remove old isort
orviz Oct 15, 2024
15d483c
Format fix
orviz Oct 15, 2024
5e5ecb0
Merge pull request #225 from EOSC-synergy/release/3.0.1
orviz Oct 15, 2024
56ccf24
Use docformatter last master version that fixes https://github.com/Py…
orviz Oct 16, 2024
6619716
Merge pull request #226 from EOSC-synergy/release/3.0.2
orviz Oct 16, 2024
a4fd79b
Fix: gather 'start_date' and 'end_date' as part of temporal coverage …
orviz Oct 16, 2024
64709c8
Fix: exception catched when attempting to request an external resource
orviz Oct 16, 2024
072be11
Fix: better handling of non-URI values
orviz Oct 16, 2024
d0c24ef
Do not fail when TimeoutError exception is raised
orviz Oct 16, 2024
0115207
Merge pull request #227 from EOSC-synergy/release/3.0.3
orviz Oct 16, 2024
7097d03
Merge last version of main branch (version 3.0.3) & Fix isort issue
orviz Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
# - id: check-added-large-files
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
Expand All @@ -22,8 +22,3 @@ repos:
hooks:
- id: isort
additional_dependencies: [toml]
# - repo: https://github.com/pycqa/isort
# rev: 5.11.2
# hooks:
# - id: isort
# name: isort (python)
444 changes: 432 additions & 12 deletions api/evaluator.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/rda.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ def rda_all(body, eva):
try:
with open(api_config, "r") as f:
documents = yaml.full_load(f)
logging.debug("API configuration successfully loaded: %s" % api_config)
logger.debug("API configuration successfully loaded: %s" % api_config)
except Exception as e:
message = "Could not find API config file: %s" % api_config
logger.error(message)
Expand All @@ -1357,7 +1357,7 @@ def rda_all(body, eva):
if documents["paths"][e]["x-indicator"]:
indi_code = e.split("/")
indi_code = indi_code[len(indi_code) - 1]
logger.debug("Running - %s" % indi_code)
logger.info("Running - %s" % indi_code)
points, msg = getattr(eva, indi_code)()
x_principle = documents["paths"][e]["x-principle"]
if "Findable" in x_principle:
Expand Down
100 changes: 22 additions & 78 deletions api/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import os
import re
import sys
import urllib
Expand Down Expand Up @@ -571,12 +572,15 @@ def orcid_basic_info(orcid):
"Authorization": "Bearer a354d82e-37fa-47de-b4a2-740dbe90f355",
}
try:
if not idutils.is_orcid(orcid):
raise Exception("Malformed ORCID value: %s" % orcid)
url = "https://pub.orcid.org/v3.0/" + orcid
r = requests.get(url, verify=False, headers=headers) # GET with headers
xmlTree = ET.fromstring(r.text)
item = xmlTree.findall(
".//{http://www.orcid.org/ns/common}assertion-origin-name"
)
for prop in ["assertion-origin-name", "source-name"]:
item = xmlTree.findall(".//{http://www.orcid.org/ns/common}%s" % prop)
if item:
break
except Exception as e:
logging.error(e)
return basic_info
Expand Down Expand Up @@ -878,13 +882,23 @@ def resolve_handle(handle_id):
return resolves, msg, values


def check_link(address):
def check_link(address, return_http_code=False):
resolves = False
req = urllib.request.Request(url=address)
resp = urllib.request.urlopen(req)
if resp.status in [400, 404, 403, 408, 409, 501, 502, 503]:
return False
try:
resp = urllib.request.urlopen(req, timeout=15)
except urllib.error.URLError as e:
logging.warning("Timeout reached while trying to connect to '%s'" % address)
except urllib.error.HTTPError as e:
logging.warning("Could not access to resource: %s" % address)
else:
return True
http_code = resp.status
logging.debug("Returned HTTP status from '%s': %s" % (address, http_code))
if return_http_code:
return http_code
if http_code not in ["400", "404", "403", "408", "409", "501", "502", "503"]:
resolves = True
return resolves


def get_protocol_scheme(url):
Expand Down Expand Up @@ -913,76 +927,6 @@ def make_http_request(url, request_type="GET", verify=False):
return payload


def get_fairsharing_metadata(offline=True, username="", password="", path=""):
if offline == True:
f = open(path)
fairlist = json.load(f)
f.close()

else:
url = "https://api.fairsharing.org/users/sign_in"
payload = {"user": {"login": username, "password": password}}
headers = {"Accept": "application/json", "Content-Type": "application/json"}

response = requests.request(
"POST", url, headers=headers, data=json.dumps(payload)
)

# Get the JWT from the response.text to use in the next part.
data = response.json()
jwt = data["jwt"]

url = "https://api.fairsharing.org/search/fairsharing_records?page[size]=2500&fairsharing_registry=standard&user_defined_tags=metadata standardization"

headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer {0}".format(jwt),
}

response = requests.request("POST", url, headers=headers)
fairlist = response.json()
user = open(path, "w")
json.dump(fairlist, user)
user.close()
return fairlist


def get_fairsharing_formats(offline=True, username="", password="", path=""):
if offline == True:
f = open(path)
fairlist = json.load(f)
f.close()

else:
url = "https://api.fairsharing.org/users/sign_in"
payload = {"user": {"login": username, "password": password}}
headers = {"Accept": "application/json", "Content-Type": "application/json"}

response = requests.request(
"POST", url, headers=headers, data=json.dumps(payload)
)

# Get the JWT from the response.text to use in the next part.
data = response.json()
jwt = data["jwt"]

url = "https://api.fairsharing.org/search/fairsharing_records?page[size]=2500&user_defined_tags=Geospatial data"

headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer {0}".format(jwt),
}

response = requests.request("POST", url, headers=headers)
fairlist = response.json()
user = open(path, "w")
json.dump(fairlist, user)
user.close()
return fairlist


def check_fairsharing_abbreviation(fairlist, abreviation):
for standard in fairlist["data"]:
if abreviation == standard["attributes"]["abbreviation"]:
Expand Down
Loading
Loading