summaryrefslogtreecommitdiffstats
path: root/pyload/config
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/config')
-rw-r--r--pyload/config/Parser.py27
-rw-r--r--pyload/config/Setup.py6
-rw-r--r--pyload/config/default.conf2
3 files changed, 15 insertions, 20 deletions
diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py
index 1d76c0164..45fb1c8d0 100644
--- a/pyload/config/Parser.py
+++ b/pyload/config/Parser.py
@@ -52,29 +52,26 @@ class ConfigParser(object):
copy(join(pypath, "pyload", "config", "default.conf"), "pyload.conf")
if not exists("plugin.conf"):
- f = open("plugin.conf", "wb")
- f.write("version: " + str(CONF_VERSION))
- f.close()
+ with open("plugin.conf", "wb") as f:
+ f.write("version: " + str(CONF_VERSION))
- f = open("pyload.conf", "rb")
- v = f.readline()
- f.close()
+ with open("pyload.conf", "rb") as f:
+ v = f.readline()
v = v[v.find(":") + 1:].strip()
if not v or int(v) < CONF_VERSION:
copy(join(pypath, "pyload", "config", "default.conf"), "pyload.conf")
print "Old version of config was replaced"
- f = open("plugin.conf", "rb")
- v = f.readline()
- f.close()
+ with open("plugin.conf", "rb") as f:
+ v = f.readline()
v = v[v.find(":") + 1:].strip()
if not v or int(v) < CONF_VERSION:
- f = open("plugin.conf", "wb")
- f.write("version: " + str(CONF_VERSION))
- f.close()
+ with open("plugin.conf", "wb") as f:
+ f.write("version: " + str(CONF_VERSION))
print "Old version of plugin-config replaced"
+
except Exception:
if n >= 3:
raise
@@ -104,9 +101,8 @@ class ConfigParser(object):
def parseConfig(self, config):
"""parses a given configfile"""
- f = open(config)
-
- config = f.read()
+ with open(config) as f:
+ config = f.read()
config = config.splitlines()[1:]
@@ -183,7 +179,6 @@ class ConfigParser(object):
print "Config Warning"
print_exc()
- f.close()
return conf
diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py
index ce5a5fb88..bae75fea4 100644
--- a/pyload/config/Setup.py
+++ b/pyload/config/Setup.py
@@ -32,9 +32,9 @@ class SetupAssistant(object):
load_translation("setup", self.lang)
- #Input shorthand for yes
+ # Input shorthand for yes
self.yes = _("y")
- #Input shorthand for no
+ # Input shorthand for no
self.no = _("n")
# print
@@ -261,7 +261,7 @@ class SetupAssistant(object):
web = sqlite and beaker
- js = True if JsEngine.find() else False
+ js = bool(JsEngine.find())
self.print_dep(_("JS engine"), js)
if not python:
diff --git a/pyload/config/default.conf b/pyload/config/default.conf
index e07b92f68..b36ed6c9c 100644
--- a/pyload/config/default.conf
+++ b/pyload/config/default.conf
@@ -1,4 +1,4 @@
-version: 2
+version: 1
remote - "Remote":
bool activated : "Activated" = True