[all] small fixed picked up by pytest
- unicode stuff - make all regexps regex strings
This commit is contained in:
parent
9cadcee844
commit
5e40dfb28a
9 changed files with 12 additions and 10 deletions
|
@ -220,7 +220,7 @@ class Config(util.store.Store):
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
log.info("loading {}".format(filename))
|
log.info("loading {}".format(filename))
|
||||||
tmp = RawConfigParser()
|
tmp = RawConfigParser()
|
||||||
tmp.read(filename)
|
tmp.read(u"{}".format(filename))
|
||||||
|
|
||||||
if tmp.has_section("module-parameters"):
|
if tmp.has_section("module-parameters"):
|
||||||
for key, value in tmp.items("module-parameters"):
|
for key, value in tmp.items("module-parameters"):
|
||||||
|
|
|
@ -24,7 +24,7 @@ def parse_result(to_parse):
|
||||||
# We want to line with the iforamtion about package upgrade
|
# We want to line with the iforamtion about package upgrade
|
||||||
line_to_parse = to_parse.split("\n")[-4]
|
line_to_parse = to_parse.split("\n")[-4]
|
||||||
result = re.search(
|
result = re.search(
|
||||||
"(.+) packages upgraded, (.+) newly installed, (.+) to remove", line_to_parse
|
r"(.+) packages upgraded, (.+) newly installed, (.+) to remove", line_to_parse
|
||||||
)
|
)
|
||||||
|
|
||||||
return int(result.group(1)), int(result.group(3))
|
return int(result.group(1)), int(result.group(3))
|
||||||
|
|
|
@ -66,10 +66,10 @@ class Module(core.module.Module):
|
||||||
# 6. speed
|
# 6. speed
|
||||||
# 7. time remaining
|
# 7. time remaining
|
||||||
extract_nospeed = re.compile(
|
extract_nospeed = re.compile(
|
||||||
"\[ *(\d*)\] ([a-zA-Z]*) (.*)\n\t(\d*\.*\d*)% \((.*)\)\n.*"
|
r"\[ *(\d*)\] ([a-zA-Z]*) (.*)\n\t(\d*\.*\d*)% \((.*)\)\n.*"
|
||||||
)
|
)
|
||||||
extract_wtspeed = re.compile(
|
extract_wtspeed = re.compile(
|
||||||
"\[ *(\d*)\] ([a-zA-Z]*) (.*)\n\t(\d*\.*\d*)% \((.*)\) (\d*\.\d .*) remaining (\d*:\d*:\d*)\n.*"
|
r"\[ *(\d*)\] ([a-zA-Z]*) (.*)\n\t(\d*\.*\d*)% \((.*)\) (\d*\.\d .*) remaining (\d*:\d*:\d*)\n.*"
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -122,7 +122,7 @@ class Module(core.module.Module):
|
||||||
return image if image else ""
|
return image if image else ""
|
||||||
|
|
||||||
def _remove_tags(self, txt):
|
def _remove_tags(self, txt):
|
||||||
return re.sub("<[^>]*>", "", txt)
|
return re.sub(r"<[^>]*>", "", txt)
|
||||||
|
|
||||||
def _create_item(self, entry, url, feed):
|
def _create_item(self, entry, url, feed):
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -46,7 +46,7 @@ def formatStringBuilder(s, json):
|
||||||
s -> format string
|
s -> format string
|
||||||
json -> the spaceapi response object
|
json -> the spaceapi response object
|
||||||
"""
|
"""
|
||||||
identifiers = re.findall("%%.*?%%", s)
|
identifiers = re.findall(r"%%.*?%%", s)
|
||||||
for i in identifiers:
|
for i in identifiers:
|
||||||
ic = i[2:-2] # Discard %%
|
ic = i[2:-2] # Discard %%
|
||||||
j = ic.split("%")
|
j = ic.split("%")
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Module(core.module.Module):
|
||||||
minwidth_str += graph_prefix
|
minwidth_str += graph_prefix
|
||||||
minwidth_str += "1000"
|
minwidth_str += "1000"
|
||||||
try:
|
try:
|
||||||
length = int(re.match("{:\.(\d+)f}", self._format).group(1))
|
length = int(re.match(r"{:\.(\d+)f}", self._format).group(1))
|
||||||
if length > 0:
|
if length > 0:
|
||||||
minwidth_str += "." + "0" * length
|
minwidth_str += "." + "0" * length
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Module(core.module.Module):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
output = util.cli.execute("watson status")
|
output = util.cli.execute("watson status")
|
||||||
if re.match("No project started", output):
|
if re.match(r"No project started", output):
|
||||||
self.__tracking = False
|
self.__tracking = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Module(core.module.Module):
|
||||||
return util.format.astemperature(self.__tempmax, self.__unit)
|
return util.format.astemperature(self.__tempmax, self.__unit)
|
||||||
|
|
||||||
def city(self):
|
def city(self):
|
||||||
city = re.sub("[_-]", " ", self.__city)
|
city = re.sub(r"[_-]", " ", self.__city)
|
||||||
return "{} ".format(city)
|
return "{} ".format(city)
|
||||||
|
|
||||||
def output(self, widget):
|
def output(self, widget):
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ def byte(val, fmt="{:.2f}"):
|
||||||
return "{}GiB".format(fmt).format(val * 1024.0)
|
return "{}GiB".format(fmt).format(val * 1024.0)
|
||||||
|
|
||||||
|
|
||||||
__seconds_pattern = re.compile("(([\d\.?]+)h)?(([\d\.]+)m)?([\d\.]+)?s?")
|
__seconds_pattern = re.compile(r"(([\d\.?]+)h)?(([\d\.]+)m)?([\d\.]+)?s?")
|
||||||
|
|
||||||
|
|
||||||
def seconds(duration):
|
def seconds(duration):
|
||||||
|
|
Loading…
Reference in a new issue