Unconditionally use statistics module since we support Python 3.4+ now

This commit is contained in:
Alessio Sergi 2018-01-29 20:42:29 +01:00
parent 7e70b36f91
commit d137d3bd26

View File

@ -31,16 +31,10 @@ from glances.logger import logger
PY3 = sys.version_info[0] == 3
try:
from statistics import mean
except ImportError:
# Statistics is only available for Python 3.4 or higher
def mean(numbers):
return float(sum(numbers)) / max(len(numbers), 1)
if PY3:
import queue
from configparser import ConfigParser, NoOptionError, NoSectionError
from statistics import mean
from xmlrpc.client import Fault, ProtocolError, ServerProxy, Transport, Server
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
from urllib.request import urlopen
@ -130,6 +124,9 @@ else:
viewvalues = operator.methodcaller('viewvalues')
viewitems = operator.methodcaller('viewitems')
def mean(numbers):
return float(sum(numbers)) / max(len(numbers), 1)
def to_ascii(s):
"""Convert the unicode 's' to a ASCII string
Usefull to remove accent (diacritics)"""