summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Rix <phrkonaleash@gmail.com>2009-12-05 00:32:34 -0700
committerRyan Rix <phrkonaleash@gmail.com>2009-12-05 00:32:34 -0700
commitb42c845b57512ea1c8126d29f87518ea5cc26479 (patch)
treef4542f9283e8f85da92c70b1056d0919b081e452
parentfab7d56593afe9114b927759f56ab6d3ca2f7301 (diff)
downloadfedora-tour-b42c845b57512ea1c8126d29f87518ea5cc26479.tar.gz
fedora-tour-b42c845b57512ea1c8126d29f87518ea5cc26479.tar.xz
fedora-tour-b42c845b57512ea1c8126d29f87518ea5cc26479.zip
Commenting my code and fixing some broken stufg
-rw-r--r--backend/tour_menuobject.py46
1 files changed, 38 insertions, 8 deletions
diff --git a/backend/tour_menuobject.py b/backend/tour_menuobject.py
index 2a6a67e..ddfa14e 100644
--- a/backend/tour_menuobject.py
+++ b/backend/tour_menuobject.py
@@ -22,15 +22,33 @@ import os.path
import xml.parsers.expat
import sys
+
+'''
+This will be expanded
+'''
class MenuNode:
- parent = 0
+ parent = False
+ nodes = list()
+ nodeType = False
+
+ def __init__(self, nodeType):
+ self.nodeType = nodeType
+
+'''
+Each one of these objects represents one section of Fedora-tour and all of the content
+which exists below it. The frontend should keep these in a list, ordered by MenuObject.Priority
+What this sort of does is create a lazy DOM of menuNode objects
+'''
class MenuObject:
isValid = True
currenElement = False
rootNode = False
activeNode = False
+ """
+ These Objects are representations of the <Icon> <DocRoot> <Locale> and <Priority> tags.
+ """
Icon = False
IconID = False
DocRoot = False
@@ -38,10 +56,22 @@ class MenuObject:
Priority = False
def __init__(self,package):
+ """
+ Check if the file exists. When calling the constructor from the front end, the absolute path
+ will have to be passed as an argument; this should probably change in the future.
+ TODO: add code to support automatic generation of absolute URL when front end passes a package name
+ """
if not os.path.isfile(package):
self.isValid = False
return None
+ """
+ Create a parser as outlined at http://docs.python.org/library/pyexpat.html
+ Basically, the parse has three functions in which it uses, CharacterDataHandler,
+ StartElementHandler, and EndElementHandler. These functions take, for example, "<Icon>",
+ "fedora-logo-sprite", and "</Icon>" respectively as arguments and these are used to
+ create the object.
+ """
self.parser = xml.parsers.expat.ParserCreate()
self.parser.CharacterDataHandler = self.parserCharData
self.parser.StartElementHandler = self.parserStartElement
@@ -49,14 +79,14 @@ class MenuObject:
self.parser.ParseFile(open(package,"r"))
- self.Icon = makeIcon(IconID)
+ '''
+ The contents of IconID specify only the short name of an icon, not the full path; this
+ function finds the full path of an icon and stores it in self.Icon
+ '''
+ self.Icon = self.makeIcon(self.IconID)
def addNode(self,parent,nodeType):
- node = MenuNode()
-
- node.nodes = list()
- node.parent = False
- node.nodeType = nodeType
+ node = MenuNode(nodeType)
if parent != False:
node.parent = parent
@@ -117,6 +147,6 @@ class MenuObject:
self.activeNode = self.activeNode.parent
def makeIcon(self, iconID):
-
+ pass
print MenuObject("../data/package.xml").isValid \ No newline at end of file