Passed
Push — master ( cf4bc8...273399 )
by Stefan
04:24
created

spaceweather.core.update_data()   A

Complexity

Conditions 3

Size

Total Lines 54
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 16
nop 5
dl 0
loc 54
rs 9.6
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
# Copyright (c) 2020--2022 Stefan Bender
2
#
3
# This module is part of pyspaceweather.
4
# pyspaceweather is free software: you can redistribute it or modify
5
# it under the terms of the GNU General Public License as published
6
# by the Free Software Foundation, version 2.
7
# See accompanying COPYING.GPLv2 file or http://www.gnu.org/licenses/gpl-2.0.html.
8
"""Python interface for space weather indices
9
10
General file handling functions for space weather data
11
"""
12
import requests
13
14
15
def _dl_file(swpath, url):
16
	with requests.get(url, stream=True) as r:
17
		if r.status_code != requests.codes.ok:
18
			return
19
		with open(swpath, 'wb') as fd:
20
			for chunk in r.iter_content(chunk_size=1024):
21
				fd.write(chunk)
22