1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-11-22 14:25:01 +01:00

dspace_statistics_api/items.py: Fix flake8 warning

According to flake8 we need to use a different syntax for strings
with backslash escape sequences:

> As of Python 3.6, a backslash-character pair that is not a valid
> escape sequence now generates a DeprecationWarning. This will
> eventually become a SyntaxError.

The warning was:

    W605 invalid escape sequence '\-'

See: https://www.flake8rules.com/rules/W605.html
This commit is contained in:
Alan Orth 2020-09-26 12:11:04 +03:00
parent 946f0749e2
commit 3ceb9a6eb0
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -13,7 +13,7 @@ def get_views(solr_date_string: str, items: list):
:returns: A dict of item IDs and views :returns: A dict of item IDs and views
""" """
# Join the UUIDs with "OR" and escape the hyphens for Solr # Join the UUIDs with "OR" and escape the hyphens for Solr
solr_items_string: str = " OR ".join(items).replace("-", "\-") solr_items_string: str = " OR ".join(items).replace("-", r"\-")
solr_query_params = { solr_query_params = {
"q": f"id:({solr_items_string})", "q": f"id:({solr_items_string})",
@ -60,7 +60,7 @@ def get_downloads(solr_date_string: str, items: list):
:returns: A dict of item IDs and downloads :returns: A dict of item IDs and downloads
""" """
# Join the UUIDs with "OR" and escape the hyphens for Solr # Join the UUIDs with "OR" and escape the hyphens for Solr
solr_items_string: str = " OR ".join(items).replace("-", "\-") solr_items_string: str = " OR ".join(items).replace("-", r"\-")
solr_query_params = { solr_query_params = {
"q": f"owningItem:({solr_items_string})", "q": f"owningItem:({solr_items_string})",