1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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'
|