Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/setup/profile.py
blob: 3d45e9a178bc3a29b19ee0a5a0cdda0288501659 (plain)
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
'''

'''

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
        pass
    
    def getName(self):
        '''Returns the name of the profile's user'''
        return self.name

    def getMaxScore(self, level=None, skill=None):
        ''' '''
        
        # 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):
        ''' '''
        
        # 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):
        ''' '''
        # 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'