Skip to content

Commit c143baf

Browse files
authored
Merge pull request #39 from ssmssam/quick_start_fixes
Quick start fixes
2 parents 4a48ab6 + b9771f9 commit c143baf

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

pvoutput/consts.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
22
from datetime import timedelta
3-
3+
from urllib.parse import urljoin
44

55
BASE_URL = 'https://pvoutput.org'
6-
MAP_URL = os.path.join(BASE_URL, 'map.jsp')
6+
MAP_URL = urljoin(BASE_URL, 'map.jsp')
77

88
# Country codes used by PVOutput.org on, for example,
99
# https://pvoutput.org/map.jsp. Taken from

pvoutput/pvoutput.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import tables
1010
import numpy as np
1111
import pandas as pd
12+
from urllib.parse import urljoin
1213

1314
from pvoutput.exceptions import NoStatusFound, RateLimitExceeded
1415
from pvoutput.utils import _get_response, _get_param_from_config_file
@@ -85,6 +86,8 @@ def __init__(self,
8586
'data_service_url', config_filename)
8687
except KeyError:
8788
pass
89+
except FileNotFoundError:
90+
pass
8891

8992
if self.data_service_url is not None:
9093
if not self.data_service_url.strip('/').endswith('.org'):
@@ -816,8 +819,7 @@ def _get_api_response(self,
816819
'X-Pvoutput-Apikey': self.api_key,
817820
'X-Pvoutput-SystemId': self.system_id}
818821

819-
api_url = os.path.join(
820-
BASE_URL, 'service/r2/{}.jsp'.format(service))
822+
api_url = urljoin(BASE_URL, 'service/r2/{}.jsp'.format(service))
821823

822824
return _get_response(api_url, api_params, headers)
823825

@@ -840,7 +842,7 @@ def _get_data_service_response(self,
840842
api_params['key'] = self.api_key
841843
api_params['sid'] = self.system_id
842844

843-
api_url = os.path.join(
845+
api_url = urljoin(
844846
self.data_service_url, 'service/r2/{}.jsp'.format(service))
845847

846848
return _get_response(api_url, api_params, headers)

pvoutput/tests/test_pvoutput.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ def test_convert_consecutive_dates_to_date_ranges():
88
missing_dates = dr1 + dr2
99
date_ranges = pvoutput._convert_consecutive_dates_to_date_ranges(
1010
missing_dates)
11-
11+
columns = ['missing_start_date_PV_localtime',
12+
'missing_end_date_PV_localtime']
1213
pd.testing.assert_frame_equal(
13-
date_ranges,
14+
date_ranges[columns],
1415
pd.DataFrame(
1516
[
1617
[dr1[0], dr1[-1]],
1718
[dr2[0], dr2[-1]],
1819
],
19-
columns=[
20-
'missing_start_date_PV_localtime',
21-
'missing_end_date_PV_localtime'
22-
]))
20+
columns=columns))

0 commit comments

Comments
 (0)