|
26 | 26 | SAMPLES_URL, |
27 | 27 | _check_profiles, |
28 | 28 | _default_headers, |
| 29 | + _get_args, |
29 | 30 | get_ogc_data, |
30 | 31 | get_stats_data, |
31 | 32 | ) |
@@ -208,11 +209,7 @@ def get_daily( |
208 | 209 | output_id = "daily_id" |
209 | 210 |
|
210 | 211 | # Build argument dictionary, omitting None values |
211 | | - args = { |
212 | | - k: v |
213 | | - for k, v in locals().items() |
214 | | - if k not in {"service", "output_id"} and v is not None |
215 | | - } |
| 212 | + args = _get_args(locals()) |
216 | 213 |
|
217 | 214 | return get_ogc_data(args, output_id, service) |
218 | 215 |
|
@@ -378,11 +375,7 @@ def get_continuous( |
378 | 375 | output_id = "continuous_id" |
379 | 376 |
|
380 | 377 | # Build argument dictionary, omitting None values |
381 | | - args = { |
382 | | - k: v |
383 | | - for k, v in locals().items() |
384 | | - if k not in {"service", "output_id"} and v is not None |
385 | | - } |
| 378 | + args = _get_args(locals()) |
386 | 379 |
|
387 | 380 | return get_ogc_data(args, output_id, service) |
388 | 381 |
|
@@ -673,11 +666,7 @@ def get_monitoring_locations( |
673 | 666 | output_id = "monitoring_location_id" |
674 | 667 |
|
675 | 668 | # Build argument dictionary, omitting None values |
676 | | - args = { |
677 | | - k: v |
678 | | - for k, v in locals().items() |
679 | | - if k not in {"service", "output_id"} and v is not None |
680 | | - } |
| 669 | + args = _get_args(locals()) |
681 | 670 |
|
682 | 671 | return get_ogc_data(args, output_id, service) |
683 | 672 |
|
@@ -893,11 +882,7 @@ def get_time_series_metadata( |
893 | 882 | output_id = "time_series_id" |
894 | 883 |
|
895 | 884 | # Build argument dictionary, omitting None values |
896 | | - args = { |
897 | | - k: v |
898 | | - for k, v in locals().items() |
899 | | - if k not in {"service", "output_id"} and v is not None |
900 | | - } |
| 885 | + args = _get_args(locals()) |
901 | 886 |
|
902 | 887 | return get_ogc_data(args, output_id, service) |
903 | 888 |
|
@@ -1069,11 +1054,7 @@ def get_latest_continuous( |
1069 | 1054 | output_id = "latest_continuous_id" |
1070 | 1055 |
|
1071 | 1056 | # Build argument dictionary, omitting None values |
1072 | | - args = { |
1073 | | - k: v |
1074 | | - for k, v in locals().items() |
1075 | | - if k not in {"service", "output_id"} and v is not None |
1076 | | - } |
| 1057 | + args = _get_args(locals()) |
1077 | 1058 |
|
1078 | 1059 | return get_ogc_data(args, output_id, service) |
1079 | 1060 |
|
@@ -1247,11 +1228,7 @@ def get_latest_daily( |
1247 | 1228 | output_id = "latest_daily_id" |
1248 | 1229 |
|
1249 | 1230 | # Build argument dictionary, omitting None values |
1250 | | - args = { |
1251 | | - k: v |
1252 | | - for k, v in locals().items() |
1253 | | - if k not in {"service", "output_id"} and v is not None |
1254 | | - } |
| 1231 | + args = _get_args(locals()) |
1255 | 1232 |
|
1256 | 1233 | return get_ogc_data(args, output_id, service) |
1257 | 1234 |
|
@@ -1424,11 +1401,7 @@ def get_field_measurements( |
1424 | 1401 | output_id = "field_measurement_id" |
1425 | 1402 |
|
1426 | 1403 | # Build argument dictionary, omitting None values |
1427 | | - args = { |
1428 | | - k: v |
1429 | | - for k, v in locals().items() |
1430 | | - if k not in {"service", "output_id"} and v is not None |
1431 | | - } |
| 1404 | + args = _get_args(locals()) |
1432 | 1405 |
|
1433 | 1406 | return get_ogc_data(args, output_id, service) |
1434 | 1407 |
|
@@ -1735,11 +1708,8 @@ def get_samples( |
1735 | 1708 |
|
1736 | 1709 | _check_profiles(service, profile) |
1737 | 1710 |
|
1738 | | - params = { |
1739 | | - k: v |
1740 | | - for k, v in locals().items() |
1741 | | - if k not in ["ssl_check", "service", "profile"] and v is not None |
1742 | | - } |
| 1711 | + # Build argument dictionary, omitting None values |
| 1712 | + params = _get_args(locals(), exclude={"ssl_check", "profile"}) |
1743 | 1713 |
|
1744 | 1714 | params.update({"mimeType": "text/csv"}) |
1745 | 1715 |
|
@@ -1879,11 +1849,8 @@ def get_stats_por( |
1879 | 1849 | ... end_date="01-31", |
1880 | 1850 | ... ) |
1881 | 1851 | """ |
1882 | | - params = { |
1883 | | - k: v |
1884 | | - for k, v in locals().items() |
1885 | | - if k not in ["expand_percentiles"] and v is not None |
1886 | | - } |
| 1852 | + # Build argument dictionary, omitting None values |
| 1853 | + params = _get_args(locals(), exclude={"expand_percentiles"}) |
1887 | 1854 |
|
1888 | 1855 | return get_stats_data( |
1889 | 1856 | args=params, service="observationNormals", expand_percentiles=expand_percentiles |
@@ -2011,11 +1978,8 @@ def get_stats_date_range( |
2011 | 1978 | ... computation_type=["minimum", "maximum"], |
2012 | 1979 | ... ) |
2013 | 1980 | """ |
2014 | | - params = { |
2015 | | - k: v |
2016 | | - for k, v in locals().items() |
2017 | | - if k not in ["expand_percentiles"] and v is not None |
2018 | | - } |
| 1981 | + # Build argument dictionary, omitting None values |
| 1982 | + params = _get_args(locals(), exclude={"expand_percentiles"}) |
2019 | 1983 |
|
2020 | 1984 | return get_stats_data( |
2021 | 1985 | args=params, |
|
0 commit comments