Some code improvements:

- __slug__ is now a @property
- Reading from binary PList files in another try-except block
- Removed print() statements
- __slug__ now return the id property of a class, instead of reslugify based in values
- Added __slug__ to GUISection (not sure if needed though)
This commit is contained in:
Felipe Martín 2013-11-26 15:05:08 +01:00
parent c20f0dc316
commit e6ffc2f9b5
3 changed files with 20 additions and 6 deletions

View File

@ -113,5 +113,10 @@ class Backup(object):
file_path = self.get_file(filename)
try:
self._plist[filename] = readPlist(file_path)
except Exception as error:
self._plist[filename] = readBinaryPlist(file_path)
except:
# Is binaryPlist?
try:
self._plist[filename] = readBinaryPlist(file_path)
except:
# What is it?
pass

View File

@ -14,9 +14,6 @@ controller = GUIController()
controller.load_from_library(library)
print(controller._panels)
@server.route("/")
def main():
result = """

View File

@ -27,8 +27,9 @@ class GUIPanel(GUIComponent):
if not self.id and self.name:
self.id = slugify(self.name)
@property
def __slug__(self):
return slugify(self.name)
return self.id
class GUISection(GUIComponent):
@ -36,9 +37,20 @@ class GUISection(GUIComponent):
Pene
"""
_type = 'section'
id = None
# A GUIPanel ID
panel = None
# Name of the section
name = None
def __init__(self):
if not self.id and (self.name and self.panel):
self.id = "{}.{}".format(
slugify(self.panel), slugify(self.name)
)
@property
def __slug__(self):
return self.id