From bd8259220ab4d56ab419b7b32045b08cc9b0a7c8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 9 Nov 2014 03:08:19 +0100 Subject: Use with statement instead open method when accessing fod + handle i/o error --- module/plugins/hoster/PremiumTo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/PremiumTo.py') diff --git a/module/plugins/hoster/PremiumTo.py b/module/plugins/hoster/PremiumTo.py index 183182689..beab4391e 100644 --- a/module/plugins/hoster/PremiumTo.py +++ b/module/plugins/hoster/PremiumTo.py @@ -54,9 +54,8 @@ class PremiumTo(Hoster): lastDownload = fs_encode(self.lastDownload) if exists(lastDownload): - f = open(lastDownload, "rb") - err = f.read(256).strip() - f.close() + with open(lastDownload, "rb") as f: + err = f.read(256).strip() remove(lastDownload) else: err = _('File does not exist') -- cgit v1.2.3