diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-12-19 02:12:57 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-12-19 02:12:57 +0000 |
| commit | ed40f6f85c9c07c3c1224ae20601082c0309a631 (patch) | |
| tree | 4082515a3e85107bd4a278b6613857b58da1770f /lib/python/Plugins | |
| parent | b3658b04216ed3974047b4c4ec885ee0161d9267 (diff) | |
| download | enigma2-ed40f6f85c9c07c3c1224ae20601082c0309a631.tar.gz enigma2-ed40f6f85c9c07c3c1224ae20601082c0309a631.zip | |
some python import cleanups
lesser swig overhead
Diffstat (limited to 'lib/python/Plugins')
13 files changed, 54 insertions, 98 deletions
diff --git a/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py b/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py index e074aeec..dae4d4ab 100644 --- a/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py +++ b/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py @@ -1,17 +1,13 @@ -from enigma import * from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ActionMap import NumberActionMap from Components.Label import Label from Components.Input import Input -from Components.GUIComponent import * from Components.Pixmap import Pixmap from Components.FileList import FileEntryComponent, FileList from Screens.ChoiceBox import ChoiceBox from Plugins.Plugin import PluginDescriptor -import os - class Test(Screen): skin = """ <screen position="100,100" size="550,400" title="Test" > diff --git a/lib/python/Plugins/Extensions/CutListEditor/plugin.py b/lib/python/Plugins/Extensions/CutListEditor/plugin.py index 28ed7d64..ba946f98 100644 --- a/lib/python/Plugins/Extensions/CutListEditor/plugin.py +++ b/lib/python/Plugins/Extensions/CutListEditor/plugin.py @@ -5,11 +5,11 @@ from Screens.MessageBox import MessageBox from Components.ServicePosition import ServicePositionGauge from Components.ActionMap import HelpableActionMap from Components.MenuList import MenuList -from Components.MultiContent import MultiContentEntryText, RT_HALIGN_RIGHT +from Components.MultiContent import MultiContentEntryText from Components.ServiceEventTracker import ServiceEventTracker from Screens.InfoBarGenerics import InfoBarSeek, InfoBarCueSheetSupport from Components.GUIComponent import GUIComponent -from enigma import eListboxPythonMultiContent, eListbox, gFont, iPlayableService +from enigma import eListboxPythonMultiContent, eListbox, gFont, iPlayableService, RT_HALIGN_RIGHT from Screens.FixedMenu import FixedMenu import bisect diff --git a/lib/python/Plugins/Extensions/FileManager/plugin.py b/lib/python/Plugins/Extensions/FileManager/plugin.py index d2b19719..3cbef343 100644 --- a/lib/python/Plugins/Extensions/FileManager/plugin.py +++ b/lib/python/Plugins/Extensions/FileManager/plugin.py @@ -1,16 +1,9 @@ -from enigma import * from Screens.Screen import Screen -from Screens.MessageBox import MessageBox from Components.ActionMap import NumberActionMap -from Components.Label import Label -from Components.Input import Input -from Components.GUIComponent import * from Components.Pixmap import Pixmap from Components.FileList import FileEntryComponent, FileList from Plugins.Plugin import PluginDescriptor -import os - class FileManager(Screen): skin = """ <screen position="100,100" size="550,400" title="Test" > @@ -52,7 +45,7 @@ class FileManager(Screen): self["text"].right() def ok(self): - + if self["list"].canDescent(): # isDir self["list"].descent() else: diff --git a/lib/python/Plugins/Extensions/MediaScanner/plugin.py b/lib/python/Plugins/Extensions/MediaScanner/plugin.py index 5fc35ee1..71f2f1c8 100644 --- a/lib/python/Plugins/Extensions/MediaScanner/plugin.py +++ b/lib/python/Plugins/Extensions/MediaScanner/plugin.py @@ -1,6 +1,6 @@ from Plugins.Plugin import PluginDescriptor -import os -import string +from os import path as os_path, walk as os_walk +from string import lower def getExtension(file): p = file.rfind('.') @@ -9,7 +9,7 @@ def getExtension(file): else: ext = file[p+1:] - return string.lower(ext) + return lower(ext) class Scanner: def __init__(self, name, extensions = [], paths_to_scan = [], description = "", openfnc = None): @@ -128,12 +128,12 @@ def ScanDevice(mountpoint): # now scan the paths for p in paths_to_scan: - path = os.path.join(mountpoint, p.path) + path = os_path.join(mountpoint, p.path) - for root, dirs, files in os.walk(path): + for root, dirs, files in os_walk(path): for f in files: ext = getExtension(f) - pathname = os.path.join(root, f) + pathname = os_path.join(root, f) for s in scanner: s.handleFile(res, pathname, ext) diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index 8db85ced..34e8c10f 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -1,5 +1,4 @@ -from enigma import * - +from enigma import eTimer, loadPic, getExif from Screens.Screen import Screen from Screens.ServiceInfo import ServiceInfoList, ServiceInfoListEntry from Components.ActionMap import ActionMap, NumberActionMap @@ -15,7 +14,6 @@ from Components.AVSwitch import AVSwitch from Plugins.Plugin import PluginDescriptor - config.pic = ConfigSubsection() config.pic.slidetime = ConfigInteger(default=10, limits=(5, 60)) config.pic.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))]) diff --git a/lib/python/Plugins/Extensions/SimpleRSS/plugin.py b/lib/python/Plugins/Extensions/SimpleRSS/plugin.py index 88db4857..49da5e63 100644 --- a/lib/python/Plugins/Extensions/SimpleRSS/plugin.py +++ b/lib/python/Plugins/Extensions/SimpleRSS/plugin.py @@ -6,9 +6,9 @@ from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap from Components.GUIComponent import GUIComponent from Components.Label import Label -from Components.MultiContent import MultiContentEntryText, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_WRAP +from Components.MultiContent import MultiContentEntryText from Plugins.Plugin import PluginDescriptor -from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation +from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_WRAP from twisted.web import server from twisted.web.resource import Resource diff --git a/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py b/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py index 8d4e1581..5142d16b 100644 --- a/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py +++ b/lib/python/Plugins/Extensions/TuxboxPlugins/plugin.py @@ -1,14 +1,9 @@ # must be fixed for the new plugin interface -from enigma import * -from Screens.Screen import Screen -from Screens.MessageBox import MessageBox -from Components.ActionMap import ActionMap -from Components.Label import Label from Tools.BoundFunction import boundFunction from Tools.Directories import pathExists from Plugins.Plugin import PluginDescriptor -import os +from os import listdir TUXBOX_PLUGINS_PATH = "/usr/lib/tuxbox/plugins/" @@ -16,7 +11,7 @@ def getPlugins(): pluginlist = [] if pathExists(TUXBOX_PLUGINS_PATH): - dir = os.listdir(TUXBOX_PLUGINS_PATH) + dir = listdir(TUXBOX_PLUGINS_PATH) for x in dir: if x[-3:] == "cfg": diff --git a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py index fae1f26d..05a2824a 100644 --- a/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/ConfigurationBackup/plugin.py @@ -1,9 +1,7 @@ -from enigma import * from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Screens.Console import Console from Components.ActionMap import ActionMap, NumberActionMap -from Components.Pixmap import * from Components.Pixmap import Pixmap from Components.Label import Label from Components.MenuList import MenuList @@ -13,10 +11,9 @@ from Plugins.Plugin import PluginDescriptor from Tools.NumericalTextInput import * from Tools.Directories import * -import os -import string -import time -import datetime +from os import path, makedirs, listdir +from time import localtime +from datetime import date plugin_path = "" @@ -116,8 +113,8 @@ class BackupSetup(Screen): def createBackupfolders(self): self.path = BackupPath[self.backup.location.value] print "Creating Backup Folder if not already there..." - if (os.path.exists(self.path) == False): - os.makedirs(self.path) + if (path.exists(self.path) == False): + makedirs(self.path) def Backup(self): print "this will start the backup now!" @@ -129,10 +126,10 @@ class BackupSetup(Screen): def runBackup(self, result): if result: - if os.path.ismount(MountPoints[self.backup.location.value]): + if path.ismount(MountPoints[self.backup.location.value]): self.createBackupfolders() - d = time.localtime() - dt = datetime.date(d.tm_year, d.tm_mon, d.tm_mday) + d = localtime() + dt = date(d.tm_year, d.tm_mon, d.tm_mday) self.path = BackupPath[self.backup.location.value] if self.backup.type.value == "full": print "Backup Mode: Full" @@ -194,9 +191,9 @@ class RestoreMenu(Screen): def fill_list(self): self.flist = [] self.path = BackupPath[self.backup.location.value] - if (os.path.exists(self.path) == False): - os.makedirs(self.path) - for file in os.listdir(self.path): + if (path.exists(self.path) == False): + makedirs(self.path) + for file in listdir(self.path): if (file.endswith(".tar.gz")): self.flist.append((file)) self.entry = True diff --git a/lib/python/Plugins/SystemPlugins/OldSoftwareUpdate/plugin.py b/lib/python/Plugins/SystemPlugins/OldSoftwareUpdate/plugin.py index 72279c1a..0f6c4e84 100644 --- a/lib/python/Plugins/SystemPlugins/OldSoftwareUpdate/plugin.py +++ b/lib/python/Plugins/SystemPlugins/OldSoftwareUpdate/plugin.py @@ -1,4 +1,4 @@ -from enigma import * +from enigma import RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, eTimer, gFont from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap, NumberActionMap @@ -10,7 +10,7 @@ from Components.Input import Input from Screens.Console import Console from Plugins.Plugin import PluginDescriptor -import os +from os import popen class Upgrade(Screen): skin = """ @@ -43,7 +43,7 @@ class Upgrade(Screen): self.close() def doUpdateDelay(self): - lines = os.popen("ipkg update && ipkg upgrade -force-defaults -force-overwrite", "r").readlines() + lines = popen("ipkg update && ipkg upgrade -force-defaults -force-overwrite", "r").readlines() string = "" for x in lines: string += x @@ -58,15 +58,6 @@ class Upgrade(Screen): else: self.close() -RT_HALIGN_LEFT = 0 -RT_HALIGN_RIGHT = 1 -RT_HALIGN_CENTER = 2 -RT_HALIGN_BLOCK = 4 - -RT_VALIGN_TOP = 0 -RT_VALIGN_CENTER = 8 -RT_VALIGN_BOTTOM = 16 - def PacketEntryComponent(packet): res = [ packet ] @@ -122,13 +113,13 @@ class Ipkg(Screen): def fillPacketList(self): - lines = os.popen("ipkg list", "r").readlines() + lines = popen("ipkg list", "r").readlines() packetlist = [] for x in lines: split = x.split(' - ') packetlist.append([split[0].strip(), split[1].strip()]) - lines = os.popen("ipkg list_installed", "r").readlines() + lines = popen("ipkg list_installed", "r").readlines() installedlist = {} for x in lines: @@ -151,7 +142,7 @@ class Ipkg(Screen): self.close() def doUpdateDelay(self): - lines = os.popen("ipkg update && ipkg upgrade", "r").readlines() + lines = popen("ipkg update && ipkg upgrade", "r").readlines() string = "" for x in lines: string += x diff --git a/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py b/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py index 4d9e611d..db16f77f 100644 --- a/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py +++ b/lib/python/Plugins/SystemPlugins/PositionerSetup/plugin.py @@ -1,4 +1,4 @@ -from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBResourceManagerPtr, iDVBChannelPtr, iDVBFrontendPtr, iDVBFrontend, eDVBFrontendParametersSatellite, eDVBFrontendParameters +from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBFrontendParametersSatellite, eDVBFrontendParameters from Screens.Screen import Screen from Screens.ScanSetup import ScanSetup from Screens.MessageBox import MessageBox @@ -140,12 +140,12 @@ class PositionerSetup(Screen): return self.frontend def openFrontend(self): - res_mgr = eDVBResourceManagerPtr() - if eDVBResourceManager.getInstance(res_mgr) == 0: - self.raw_channel = iDVBChannelPtr() - if res_mgr.allocateRawChannel(self.raw_channel, self.feid) == 0: - self.frontend = iDVBFrontendPtr() - if self.raw_channel.getFrontend(self.frontend) == 0: + res_mgr = eDVBResourceManager.getInstance() + if res_mgr: + self.raw_channel = res_mgr.allocateRawChannel(self.feid) + if self.raw_channel: + self.frontend = self.raw_channel.getFrontend(self.frontend) + if self.frontend: return True else: print "getFrontend failed" @@ -446,8 +446,8 @@ class TunerScreen(ScanSetup): self.createSetup() def createConfig(self, foo): + global tuning if not tuning: - global tuning tuning = ConfigSubsection() tuning.type = ConfigSelection( default = "manual_transponder", diff --git a/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py b/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py index 6325a82f..89fbc4bb 100644 --- a/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Satfinder/plugin.py @@ -1,4 +1,4 @@ -from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBResourceManagerPtr, iDVBChannelPtr, iDVBFrontendPtr, iDVBFrontend, eDVBFrontendParametersSatellite, eDVBFrontendParameters +from enigma import eTimer, eDVBSatelliteEquipmentControl, eDVBResourceManager, eDVBDiseqcCommand, eDVBFrontendParametersSatellite, eDVBFrontendParameters from Screens.Screen import Screen from Screens.ScanSetup import ScanSetup from Screens.MessageBox import MessageBox @@ -56,12 +56,12 @@ class Satfinder(ScanSetup): </screen>""" def openFrontend(self): - res_mgr = eDVBResourceManagerPtr() - if eDVBResourceManager.getInstance(res_mgr) == 0: - self.raw_channel = iDVBChannelPtr() - if res_mgr.allocateRawChannel(self.raw_channel, self.feid) == 0: - self.frontend = iDVBFrontendPtr() - if self.raw_channel.getFrontend(self.frontend) == 0: + res_mgr = eDVBResourceManager.getInstance() + if res_mgr: + self.raw_channel = res_mgr.allocateRawChannel(self.feid) + if self.raw_channel: + self.frontend = self.raw_channel.getFrontend() + if self.frontend: return True else: print "getFrontend failed" diff --git a/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py b/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py index 844b75f9..18ffd994 100755 --- a/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SkinSelector/plugin.py @@ -1,22 +1,17 @@ # -*- coding: iso-8859-1 -*- # (c) 2006 Stephan Reichholf # This Software is Free, use it where you want, when you want for whatever you want and modify it if you want but don't remove my copyright! - -from enigma import * from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ActionMap import NumberActionMap from Components.Pixmap import Pixmap -from Components.GUIComponent import * from Components.MenuList import MenuList from Plugins.Plugin import PluginDescriptor - from Components.config import config from Tools.Directories import SCOPE_SKIN - from Components.config import config -import os, sys +from os import path, walk class SkinSelector(Screen): # for i18n: @@ -40,7 +35,7 @@ class SkinSelector(Screen): self.session = session self.previewPath = "" - os.path.walk(self.root, self.find, "") + path.walk(self.root, self.find, "") self.skinlist.sort() self["SkinList"] = MenuList(self.skinlist) @@ -107,7 +102,7 @@ class SkinSelector(Screen): else: pngpath = self.root+self["SkinList"].getCurrent()+"/prev.png" - if not os.path.exists(pngpath): + if not path.exists(pngpath): # FIXME: don't use hardcoded path pngpath = "/usr/lib/enigma2/python/Plugins/SystemPlugins/SkinSelector/noprev.png" diff --git a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py index dc494e6f..b5034b63 100644 --- a/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareUpdate/plugin.py @@ -1,4 +1,4 @@ -from enigma import eTimer, quitMainloop +from enigma import eTimer, quitMainloop, RT_HALIGN_LEFT, RT_VALIGN_CENTER, eListboxPythonMultiContent, eListbox, gFont from Screens.Screen import Screen from Screens.MessageBox import MessageBox from Components.ActionMap import ActionMap, NumberActionMap @@ -14,7 +14,7 @@ from Components.Ipkg import Ipkg from Components.Slider import Slider from Components.Label import Label -import os +from os import popen class UpdatePluginMenu(Screen): skin = """ @@ -125,15 +125,6 @@ class IPKGSource(Screen): print "pressed", number self["text"].number(number) -RT_HALIGN_LEFT = 0 -RT_HALIGN_RIGHT = 1 -RT_HALIGN_CENTER = 2 -RT_HALIGN_BLOCK = 4 - -RT_VALIGN_TOP = 0 -RT_VALIGN_CENTER = 8 -RT_VALIGN_BOTTOM = 16 - def PacketEntryComponent(packet): res = [ packet ] @@ -189,13 +180,13 @@ class Ipkg2(Screen): def fillPacketList(self): - lines = os.popen("ipkg list", "r").readlines() + lines = popen("ipkg list", "r").readlines() packetlist = [] for x in lines: split = x.split(' - ') packetlist.append([split[0].strip(), split[1].strip()]) - lines = os.popen("ipkg list_installed", "r").readlines() + lines = popen("ipkg list_installed", "r").readlines() installedlist = {} for x in lines: @@ -218,7 +209,7 @@ class Ipkg2(Screen): self.close() def doUpdateDelay(self): - lines = os.popen("ipkg update && ipkg upgrade", "r").readlines() + lines = popen("ipkg update && ipkg upgrade", "r").readlines() string = "" for x in lines: string += x |
