Skip to content

Commit

Permalink
Fix issues reported by SonarCloud
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
  • Loading branch information
jeandet committed Jun 6, 2024
1 parent 139503b commit a417550
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 1 addition & 3 deletions speasy/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,7 @@ def progress_bar(leave=True, progress=False, desc=None, **kwargs):
return lambda x: tqdm(x, leave=leave, desc=desc)


class EnsureUTC_DateTime(object):
def __init__(self):
pass
class EnsureUTCDateTime(object):

def __call__(self, get_data: Callable):
@wraps(get_data)
Expand Down
4 changes: 2 additions & 2 deletions speasy/webservices/amda/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .inventory import to_xmlid
from .utils import get_parameter_args
from ...config import amda as amda_cfg
from ...core import AllowedKwargs, make_utc_datetime, EnsureUTC_DateTime
from ...core import AllowedKwargs, make_utc_datetime, EnsureUTCDateTime
from ...core.http import is_server_up
from ...core.cache import CACHE_ALLOWED_KWARGS, Cacheable, CacheCall
from ...core.dataprovider import (GET_DATA_ALLOWED_KWARGS, DataProvider,
Expand Down Expand Up @@ -394,7 +394,7 @@ def get_parameter(self, product, start_time, stop_time,

@AllowedKwargs(
PROXY_ALLOWED_KWARGS + CACHE_ALLOWED_KWARGS + GET_DATA_ALLOWED_KWARGS + ['output_format', 'restricted_period'])
@EnsureUTC_DateTime()
@EnsureUTCDateTime()
@ParameterRangeCheck()
@Cacheable(prefix="amda", version=product_version, fragment_hours=lambda x: 12, entry_name=_amda_cache_entry_name)
@Proxyfiable(GetProduct, get_parameter_args)
Expand Down
4 changes: 2 additions & 2 deletions speasy/webservices/cda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from datetime import datetime, timedelta
from typing import Dict, Optional, Tuple

from speasy.core import AllowedKwargs, EnsureUTC_DateTime
from speasy.core import AllowedKwargs, EnsureUTCDateTime
from speasy.core import http, url_utils
from speasy.core import cdf
from speasy.config import cdaweb as cda_cfg
Expand Down Expand Up @@ -218,7 +218,7 @@ def _get_data_with_direct_archive(self, product, start_time: datetime, stop_time

@AllowedKwargs(
PROXY_ALLOWED_KWARGS + CACHE_ALLOWED_KWARGS + GET_DATA_ALLOWED_KWARGS + ['if_newer_than', 'method'])
@EnsureUTC_DateTime()
@EnsureUTCDateTime()
@ParameterRangeCheck()
def get_data(self, product, start_time: datetime, stop_time: datetime, if_newer_than: datetime or None = None,
extra_http_headers: Dict or None = None, method: Optional[str] = None, **kwargs) -> Optional[
Expand Down
3 changes: 2 additions & 1 deletion speasy/webservices/csa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from astroquery.utils.tap.core import TapPlus

from speasy.core import any_files, AllowedKwargs, fix_name
from speasy.core import any_files, AllowedKwargs, fix_name, EnsureUTCDateTime
from speasy.core import cdf
from speasy.core.cache import Cacheable, CACHE_ALLOWED_KWARGS # _cache is used for tests (hack...)
from speasy.core.dataprovider import DataProvider, ParameterRangeCheck, GET_DATA_ALLOWED_KWARGS
Expand Down Expand Up @@ -223,6 +223,7 @@ def product_last_update(self, product: str or ParameterIndex):
return self.flat_inventory.datasets[dataset].date_last_update

@AllowedKwargs(PROXY_ALLOWED_KWARGS + CACHE_ALLOWED_KWARGS + GET_DATA_ALLOWED_KWARGS)
@EnsureUTCDateTime()
@ParameterRangeCheck()
@Cacheable(prefix="csa", fragment_hours=lambda x: 12, version=product_last_update)
@SplitLargeRequests(threshold=lambda x: timedelta(days=7))
Expand Down
4 changes: 2 additions & 2 deletions speasy/webservices/ssc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import numpy as np

from speasy.core import EnsureUTC_DateTime
from speasy.core import EnsureUTCDateTime
from speasy.core.cache import Cacheable, CacheCall, CACHE_ALLOWED_KWARGS
from speasy.core.dataprovider import DataProvider, ParameterRangeCheck, GET_DATA_ALLOWED_KWARGS
from speasy.core.datetime_range import DateTimeRange
Expand Down Expand Up @@ -144,7 +144,7 @@ def get_data(self, product: str, start_time: datetime, stop_time: datetime, coor
@AllowedKwargs(
PROXY_ALLOWED_KWARGS + CACHE_ALLOWED_KWARGS + GET_DATA_ALLOWED_KWARGS + ['coordinate_system',
'debug'])
@EnsureUTC_DateTime()
@EnsureUTCDateTime()
@ParameterRangeCheck()
@Cacheable(prefix="ssc_orbits", fragment_hours=lambda x: 24, version=version, entry_name=_make_cache_entry_name)
@SplitLargeRequests(threshold=lambda x: timedelta(days=60))
Expand Down

0 comments on commit a417550

Please sign in to comment.