Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/setup/profile.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup/profile.py')
-rw-r--r--src/setup/profile.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/setup/profile.py b/src/setup/profile.py
new file mode 100644
index 0000000..96b4caf
--- /dev/null
+++ b/src/setup/profile.py
@@ -0,0 +1,69 @@
+'''
+
+'''
+
+from lxml import etree # using lxml for XML processing
+from utils import strs # string constants
+from utils import utils # some XML utilities
+
+# setup logging
+import logging
+logging.basicConfig(filename=strs.LoggingFile,level=logging.DEBUG)
+log = logging.getLogger('setup.profile')
+
+class Profile(object):
+ '''
+ '''
+
+ def __init__(self, path=None, name=None ):
+ '''
+ Constructor
+ '''
+
+ # new profiles have a name instead of a path
+ if path != None:
+ #open up the mpro file and read in its basic properties
+ root = utils.getXMLRoot(path)
+ self.name = root.xpath(strs.XP_ProfileName)[0]
+ self.path = path
+ else:
+ # there is no XML representation of this Profile, so just store its name
+ self.name = name
+ self.path = None
+ pass
+
+ def getName(self):
+ '''Returns the name of the profile's user'''
+ return self.name
+
+ def getMaxScore(self, level=None, skill=None):
+ '''Returns the player's max score corresponding to the given filters'''
+
+ # if no path, then no XML to read for the max score
+ if self.path == None:
+ return 0
+
+ # TODO read in/calculate the max score of this player. Need to take into account the level and skill parameters
+ log.debug('getMaxScore() is stubbed to return 1')
+ return 1
+
+ def getMaxDuration(self, level=None, skill=None):
+ '''Returns the player's max playing duration corresponding to the given filters'''
+
+ # if no path, then no XML to read for the max duration
+ if self.path == None:
+ return 0
+
+ # TODO read in/calculate the max duration of this player. Need to take into account the level and skill parameters
+ log.debug('getMaxDuration() is stubbed to return 1')
+ return 1
+
+ def getLastTimePlayed(self, level=None, skill=None):
+ '''Returns the player's max last time played corresponding to the given filters'''
+ # if no path, then no XML to read for the last time played
+ if self.path == None:
+ return 0
+
+ # TODO read in/calculate the last time played for this player. Need to take into account the level and skill parameters
+ log.debug('getLastTimePlayed() is stubbed to return "06-21-2009.12:59"')
+ return '06-21-2009.12:59'