提交 d137d3bd 编写于 作者: A Alessio Sergi

Unconditionally use statistics module since we support Python 3.4+ now

上级 7e70b36f
......@@ -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)"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册