Esempio n. 1
0
    def getAchievements(self, isInDossier=None):
        result = defaultdict(list)
        for record in layouts.getAchievementsLayout(
                self.__dossier.getDossierType()):
            try:
                if self.__isAchieveValid(*record):
                    factory = getAchievementFactory(record, self.__dossier)
                    if (factory and factory.isValid() and isInDossier is None
                            or factory.isInDossier() and isInDossier
                            or not factory.isInDossier()
                            and not isInDossier) and factory.isValid():
                        achieve = factory.create()
                        if achieve is not None:
                            if not isinstance(factory,
                                              _SequenceAchieveFactory):
                                achieve = {achieve.getName(): achieve}
                            for a in achieve.itervalues():
                                section = a.getSection()
                                if section is None:
                                    section = getAchieveSection(record)
                                result[section].append(a)

            except Exception:
                LOG_ERROR('There is exception while achievement creating',
                          record)
                LOG_CURRENT_EXCEPTION()
                continue

        return tuple((sorted(result[section])
                      for section in ACHIEVEMENT_SECTIONS_ORDER))
Esempio n. 2
0
    def getAchievements(self, isInDossier=None):
        result = defaultdict(list)
        for record in layouts.getAchievementsLayout(self.__dossier.getDossierType()):
            try:
                if self.__isAchieveValid(*record):
                    factory = getAchievementFactory(record, self.__dossier)
                    if (
                        factory
                        and factory.isValid()
                        and isInDossier is None
                        or factory.isInDossier()
                        and isInDossier
                        or not factory.isInDossier()
                        and not isInDossier
                    ) and factory.isValid():
                        achieve = factory.create()
                        if achieve is not None:
                            if not isinstance(factory, _SequenceAchieveFactory):
                                achieve = {achieve.getName(): achieve}
                            for a in achieve.itervalues():
                                section = a.getSection()
                                if section is None:
                                    section = getAchieveSection(record)
                                result[section].append(a)

            except Exception:
                LOG_ERROR("There is exception while achievement creating", record)
                LOG_CURRENT_EXCEPTION()
                continue

        return tuple((sorted(result[section]) for section in ACHIEVEMENT_SECTIONS_ORDER))
Esempio n. 3
0
 def isAchievementInLayout(self, record):
     return record in layouts.getAchievementsLayout(self.__dossier.getDossierType())
Esempio n. 4
0
 def isAchievementInLayout(self, record):
     return record in layouts.getAchievementsLayout(
         self.__dossier.getDossierType())