summaryrefslogtreecommitdiffstats
path: root/pyload/api
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/api')
-rw-r--r--pyload/api/__init__.py17
-rw-r--r--pyload/api/types.py1
2 files changed, 8 insertions, 10 deletions
diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py
index b5c1dfbf4..ab717525d 100644
--- a/pyload/api/__init__.py
+++ b/pyload/api/__init__.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
# @author: RaNaN
+from __future__ import with_statement
+
from base64 import standard_b64encode
from os.path import join
from time import time
@@ -265,9 +267,8 @@ class Api(Iface):
"""
filename = join(self.core.config.get("log", "log_folder"), 'log.txt')
try:
- fh = open(filename, "r")
- lines = fh.readlines()
- fh.close()
+ with open(filename, "r") as fh:
+ lines = fh.readlines()
if offset >= len(lines):
return []
return lines[offset:]
@@ -409,9 +410,8 @@ class Api(Iface):
:param data: file content
:return: online check
"""
- th = open(join(self.core.config.get("general", "download_folder"), "tmp_" + container), "wb")
- th.write(str(data))
- th.close()
+ with open(join(self.core.config.get("general", "download_folder"), "tmp_" + container), "wb") as th:
+ th.write(str(data))
return self.checkOnlineStatus(urls + [th.name])
@@ -707,9 +707,8 @@ class Api(Iface):
:param filename: filename, extension is important so it can correctly decrypted
:param data: file content
"""
- th = open(join(self.core.config.get("general", "download_folder"), "tmp_" + filename), "wb")
- th.write(str(data))
- th.close()
+ with open(join(self.core.config.get("general", "download_folder"), "tmp_" + filename), "wb") as th:
+ th.write(str(data))
self.addPackage(th.name, [th.name], Destination.Queue)
diff --git a/pyload/api/types.py b/pyload/api/types.py
index 2fd089333..9381df3c7 100644
--- a/pyload/api/types.py
+++ b/pyload/api/types.py
@@ -2,7 +2,6 @@
# Autogenerated by pyload
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
-
class BaseObject(object):
__slots__ = []