@@ -14,7 +14,7 @@ def current_kernel_version():
""" Returns the current kernel version as an integer you can
compare.
"""
- with open("/proc/version", "r") as fh:
+ with open("/proc/version") as fh:
current = fh.read().split()[2].split("-")[0].split(".")
return version_to_int(int(current[0]), int(current[1]), int(current[2]))
@@ -116,7 +116,7 @@ def is_feature_supported(feature):
cmd.insize = sizeof(response)
cmd.outsize = 0
- with open("/dev/cros_ec", "r") as fh:
+ with open("/dev/cros_ec") as fh:
fcntl.ioctl(fh, EC_DEV_IOCXCMD, cmd)
memmove(addressof(response), addressof(cmd.data), cmd.insize)
@@ -156,7 +156,7 @@ def mcu_hello(s, name):
cmd.outsize = sizeof(response)
memmove(addressof(cmd.data), addressof(param), cmd.insize)
- with open("/dev/" + name, "r") as fh:
+ with open("/dev/" + name) as fh:
fcntl.ioctl(fh, EC_DEV_IOCXCMD, cmd)
memmove(addressof(response), addressof(cmd.data), cmd.outsize)
@@ -174,7 +174,7 @@ def mcu_get_version(name):
cmd.insize = sizeof(response)
cmd.outsize = 0
- with open("/dev/" + name, "r") as fh:
+ with open("/dev/" + name) as fh:
fcntl.ioctl(fh, EC_DEV_IOCXCMD, cmd)
memmove(addressof(response), addressof(cmd.data), cmd.insize)
@@ -188,7 +188,7 @@ def mcu_reboot(name):
cmd.insize = 0
cmd.outsize = 0
try:
- with open("/dev/" + name, "r") as fh:
+ with open("/dev/" + name) as fh:
fcntl.ioctl(fh, EC_DEV_IOCXCMD, cmd)
except IOError:
pass
@@ -6,7 +6,7 @@ import os
def read_file(name):
""" Returns the content of the file named 'name'."""
- with open(name, "r") as fh:
+ with open(name) as fh:
contents = fh.read()
return contents
@@ -20,7 +20,7 @@ def sysfs_check_attributes_exists(s, path, name, files, check_devtype):
try:
for devname in os.listdir(path):
if check_devtype:
- with open(path + "/" + devname + "/name", "r") as fh:
+ with open(path + "/" + devname + "/name") as fh:
devtype = fh.read()
if not devtype.startswith(name):
continue
@@ -57,7 +57,7 @@ class TestCrosECAccel(unittest.TestCase):
try:
for devname in os.listdir("/sys/bus/iio/devices"):
base_path = "/sys/bus/iio/devices/" + devname + "/"
- with open(base_path + "name", "r") as fh:
+ with open(base_path + "name") as fh:
devtype = fh.read()
if devtype.startswith("cros-ec-accel"):
location = read_file(base_path + "location")
@@ -14,19 +14,19 @@ class TestCrosECPWM(unittest.TestCase):
"""
if not os.path.exists("/sys/class/backlight/backlight/max_brightness"):
self.skipTest("No backlight pwm found, skipping")
- with open("/sys/kernel/debug/pwm", "r") as fh:
+ with open("/sys/kernel/debug/pwm") as fh:
pwm = fh.read()
for s in pwm.split('\n\n'):
if re.match(r'.*:ec-pwm.*backlight', s, re.DOTALL):
break
else:
self.skipTest("No EC backlight pwm found, skipping")
- with open("/sys/class/backlight/backlight/max_brightness", "r") as fh:
+ with open("/sys/class/backlight/backlight/max_brightness") as fh:
brightness = int(int(fh.read()) / 2)
with open("/sys/class/backlight/backlight/brightness", "w") as fh:
fh.write(str(brightness))
- with open("/sys/kernel/debug/pwm", "r") as fh:
+ with open("/sys/kernel/debug/pwm") as fh:
for line in fh:
if "backlight" in line:
start = line.find("duty") + 6
@@ -14,7 +14,7 @@ class TestCrosECRTC(unittest.TestCase):
match = 0
try:
for devname in os.listdir("/sys/class/rtc"):
- with open("/sys/class/rtc/" + devname + "/name", "r") as fh:
+ with open("/sys/class/rtc/" + devname + "/name") as fh:
devtype = fh.read()
if devtype.startswith("cros-ec-rtc"):
files = [
@@ -3,7 +3,7 @@
import setuptools
-with open("README.md", "r") as fh:
+with open("README.md") as fh:
long_description = fh.read()
setuptools.setup(
open()'s default mode is "r". To simplify, remove them if reading mode. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> --- cros/helpers/kernel.py | 2 +- cros/helpers/mcu.py | 8 ++++---- cros/helpers/sysfs.py | 4 ++-- cros/tests/cros_ec_accel.py | 2 +- cros/tests/cros_ec_pwm.py | 6 +++--- cros/tests/cros_ec_rtc.py | 2 +- setup.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-)