Utils¶
Twitter API. |
|
HEPData user queries. |
hepdata.utils.file_extractor¶
hepdata.utils.miscellaneous¶
- hepdata.utils.miscellaneous.splitter(data, predicate)[source]¶
Split a list according to a given predicate (lambda).
- hepdata.utils.miscellaneous.sanitize_html(value, tags=None, attributes=None, strip=False)[source]¶
Sanitize HTML.
- Parameters:
tags – Allowed HTML
tags
. Configuration set by Invenio-Config.attributes – Allowed HTML
attributes
. Configuration set by Invenio-Config.strip – Whether to strip tags that are not allowed. Defaults to False (escapes rather than strips disallowed tags).
Use this function when you need to include unescaped HTML that contains user provided data.
- hepdata.utils.miscellaneous.generate_resource_url(resource)[source]¶
Uses the file_location/ID of a submission object to generate a resource url. If “http” is at the beginning, will return file_location Otherwise, will generate a HEPData resource URL
- Parameters:
resource – DataResource object for generation
- Returns:
The generated URL string
- hepdata.utils.miscellaneous.get_resource_data(submission)[source]¶
Function to create a dictionary of description, type and url for resources objects. This dictionary is to be added to the OpenSearch index. Uses either a DataSubmission, or HEPSubmission, which both contain resource objects.
- Parameters:
submission – HEPSubmission/DataSubmission object
- Returns:
The resources list (of dictionaries)
hepdata.utils.session¶
hepdata.utils.twitter¶
Twitter API.
- hepdata.utils.twitter.tweet(title, collaborations, url, version=1)[source]¶
Announce addition or revision of a HEPData record on Twitter.
- Parameters:
title
collaborations
url
version
- Returns:
hepdata.utils.url¶
- hepdata.utils.url.modify_query(path, **new_values)[source]¶
Fetch the query arguments, update them and generate a new URL.
- Parameters:
path – [string] endpoint function name. Should contain the blueprint name or just a dot at the beginning for the same blueprint
**new_values – [string] dictionary containing parameters to update. When a parameter value is None, it is removed from the URL.
- Returns:
[string] generated URL
hepdata.utils.users¶
HEPData user queries.
- hepdata.utils.users.get_user_from_id(user_id)[source]¶
Returns a user object from their id.
- Parameters:
user_id – <int>
- Returns:
User object if found, else None