diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-16 17:48:30 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-16 18:06:38 +0200 |
commit | 6cdb1ae0fe8f4faf897220d0520ca3e753e9f3e4 (patch) | |
tree | 24a8d6e3c2e62597b6cd3a75b77bf1a6470bd702 /pyload/plugin/addon | |
parent | Fix lib import (diff) | |
download | pyload-6cdb1ae0fe8f4faf897220d0520ca3e753e9f3e4.tar.xz |
[config] Use get method instead dict access
Diffstat (limited to 'pyload/plugin/addon')
-rw-r--r-- | pyload/plugin/addon/Checksum.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/ClickNLoad.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/ExternalScripts.py | 36 | ||||
-rw-r--r-- | pyload/plugin/addon/ExtractArchive.py | 14 | ||||
-rw-r--r-- | pyload/plugin/addon/MergeFiles.py | 4 | ||||
-rw-r--r-- | pyload/plugin/addon/MultiHome.py | 2 |
6 files changed, 32 insertions, 32 deletions
diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py index 53b9b4e9f..ed50b0f5e 100644 --- a/pyload/plugin/addon/Checksum.py +++ b/pyload/plugin/addon/Checksum.py @@ -105,7 +105,7 @@ class Checksum(Addon): self.checkFailed(pyfile, None, "No file downloaded") local_file = fs_encode(pyfile.plugin.lastDownload) - #download_folder = self.config['general']['download_folder'] + #download_folder = self.config.get("general", "download_folder") #local_file = fs_encode(fs_join(download_folder, pyfile.package().folder, pyfile.name)) if not isfile(local_file): @@ -166,7 +166,7 @@ class Checksum(Addon): def packageFinished(self, pypack): - download_folder = fs_join(self.config['general']['download_folder'], pypack.folder, "") + download_folder = fs_join(self.config.get("general", "download_folder"), pypack.folder, "") for link in pypack.getChildren().itervalues(): file_type = splitext(link['name'])[1][1:].lower() diff --git a/pyload/plugin/addon/ClickNLoad.py b/pyload/plugin/addon/ClickNLoad.py index b6448598a..4e1be807d 100644 --- a/pyload/plugin/addon/ClickNLoad.py +++ b/pyload/plugin/addon/ClickNLoad.py @@ -37,11 +37,11 @@ class ClickNLoad(Addon): def activate(self): - if not self.core.config['webui']['activated']: + if not self.core.config.get("webui", "activated"): return ip = "" if self.getConfig('extern') else "127.0.0.1" - webport = self.core.config['webui']['port'] + webport = self.core.config.get("webui", "port") cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py index 19d5202fd..341dd6dcd 100644 --- a/pyload/plugin/addon/ExternalScripts.py +++ b/pyload/plugin/addon/ExternalScripts.py @@ -122,10 +122,10 @@ class ExternalScripts(Addon): def downloadFailed(self, pyfile): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['download_failed']: file = fs_join(download_folder, pyfile.name) @@ -133,10 +133,10 @@ class ExternalScripts(Addon): def downloadFinished(self, pyfile): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pyfile.package().folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pyfile.package().folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['download_finished']: file = fs_join(download_folder, pyfile.name) @@ -154,10 +154,10 @@ class ExternalScripts(Addon): def packageFinished(self, pypack): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_finished']: self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) @@ -166,30 +166,30 @@ class ExternalScripts(Addon): def packageDeleted(self, pid): pack = self.core.api.getPackageInfo(pid) - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_deleted']: self.callScript(script, pack.id, pack.name, download_folder, pack.password) def package_extract_failed(self, pypack): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_extract_failed']: self.callScript(script, pypack.id, pypack.name, download_folder, pypack.password) def package_extracted(self, pypack): - if self.core.config['general']['folder_per_package']: - download_folder = fs_join(self.core.config['general']['download_folder'], pypack.folder) + if self.core.config.get("general", "folder_per_package"): + download_folder = fs_join(self.core.config.get("general", "download_folder"), pypack.folder) else: - download_folder = self.core.config['general']['download_folder'] + download_folder = self.core.config.get("general", "download_folder") for script in self.scripts['package_extracted']: self.callScript(script, pypack.id, pypack.name, download_folder) diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index a4a28ab32..26d3f07d9 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -264,7 +264,7 @@ class ExtractArchive(Addon): # reload from txt file self.reloadPasswords() - download_folder = self.config['general']['download_folder'] + download_folder = self.config.get("general", "download_folder") # iterate packages -> extractors -> targets for pid in ids: @@ -551,16 +551,16 @@ class ExtractArchive(Addon): continue try: - if self.config['permission']['change_file']: + if self.config.get("permission", "change_file"): if os.path.isfile(f): - os.chmod(f, int(self.config['permission']['file'], 8)) + os.chmod(f, int(self.config.get("permission", "file"), 8)) elif os.path.isdir(f): - os.chmod(f, int(self.config['permission']['folder'], 8)) + os.chmod(f, int(self.config.get("permission", "folder"), 8)) - if self.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.config['permission']['user'])[2] - gid = getgrnam(self.config['permission']['group'])[2] + if self.config.get("permission", "change_dl") and os.name != "nt": + uid = getpwnam(self.config.get("permission", "user"))[2] + gid = getgrnam(self.config.get("permission", "group"))[2] os.chown(f, uid, gid) except Exception, e: diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py index dfc5f41d4..4f95ef9d7 100644 --- a/pyload/plugin/addon/MergeFiles.py +++ b/pyload/plugin/addon/MergeFiles.py @@ -37,9 +37,9 @@ class MergeFiles(Addon): files[data['name'][:-4]].sort() fid_dict[data['name']] = fid - download_folder = self.config['general']['download_folder'] + download_folder = self.config.get("general", "download_folder") - if self.config['general']['folder_per_package']: + if self.config.get("general", "folder_per_package"): download_folder = fs_join(download_folder, pack.folder) for name, file_list in files.iteritems(): diff --git a/pyload/plugin/addon/MultiHome.py b/pyload/plugin/addon/MultiHome.py index 057764a1e..bca6493db 100644 --- a/pyload/plugin/addon/MultiHome.py +++ b/pyload/plugin/addon/MultiHome.py @@ -24,7 +24,7 @@ class MultiHome(Addon): self.parseInterfaces(self.getConfig('interfaces').split(";")) if not self.interfaces: - self.parseInterfaces([self.config['download']['interface']]) + self.parseInterfaces([self.config.get("download", "interface")]) self.setConfig("interfaces", self.toConfig()) |