def getChapterData(chapterFileName, isBootcampEnabled, bootcampRunCount):
    _logger.debug('ManualXMLDataReader: requested chapter data: %s',
                  chapterFileName)
    chapterPath = _CHAPTERS_DATA_PATH + chapterFileName
    with resource_helper.root_generator(chapterPath) as ctx, root:
        chapter = __readChapter(ctx, root, isBootcampEnabled, bootcampRunCount)
    return chapter
Beispiel #2
0
def readConfig(path, forced=False):
    global _cache
    if not forced and path in _cache:
        return _cache[path]
    scenes, items, commands = (None, None, None)
    with resource_helper.root_generator(path) as ctx, root:
        scenes = _readConfig(ctx, root, "scenes", "scene", _SceneConfig)
        items = _readConfig(ctx, root, "gui-items", "item", _ItemConfig)
        commands = _readConfig(ctx, root, "gui-commands", "command", _CommandData)
    _cache[path] = _TutorialConfig(scenes, items, commands)
    return _cache[path]
Beispiel #3
0
def readConfig(path, forced = False):
    global _cache
    if not forced and path in _cache:
        return _cache[path]
    else:
        scenes, items, commands = (None, None, None)
        with resource_helper.root_generator(path) as ctx, root:
            scenes = _readConfig(ctx, root, 'scenes', 'scene', _SceneConfig)
            items = _readConfig(ctx, root, 'gui-items', 'item', _ItemConfig)
            commands = _readConfig(ctx, root, 'gui-commands', 'command', _CommandData)
        _cache[path] = _TutorialConfig(scenes, items, commands)
        return _cache[path]
Beispiel #4
0
def __getChaptersTitlesList(chapterFileName, isBootcampEnabled):
    chaptersTitles = []
    chapterPath = _CHAPTERS_DATA_PATH + chapterFileName
    with resource_helper.root_generator(chapterPath) as ctx, root:
        ctx, section = resource_helper.getSubSection(ctx, root, 'lessons')
        for lessonCtx, lessonSection in resource_helper.getIterator(ctx, section):
            title = translation(__getCustomSectionValue(lessonCtx, lessonSection, 'title'))
            template = __getCustomSectionValue(lessonCtx, lessonSection, 'template')
            if template is _BOOTCAMP_PAGE and not isBootcampEnabled:
                continue
            chaptersTitles.append(title)

    return chaptersTitles
def __getChapterAttributes(chapterFileName, filterFunction):
    chaptersTitles = []
    ids = []
    newIds = []
    chapterPath = _CHAPTERS_DATA_PATH + chapterFileName
    with resource_helper.root_generator(chapterPath) as ctx, root:
        ctx, section = resource_helper.getSubSection(ctx, root, 'lessons')
        for lessonCtx, lessonSection in resource_helper.getIterator(ctx, section):
            template = __getCustomSectionValue(lessonCtx, lessonSection, 'template')
            if not filterFunction(template):
                continue
            lessonId = int(__getCustomSectionValue(lessonCtx, lessonSection, 'id'))
            ids.append(lessonId)
            if __getCustomSectionValue(lessonCtx, lessonSection, 'new', safe=True):
                newIds.append(lessonId)
            chaptersTitles.append(translation(__getCustomSectionValue(lessonCtx, lessonSection, 'title')))

    return {'ids': ids,
     'newIds': newIds,
     'chaptersTitles': chaptersTitles}
Beispiel #6
0
def getChapters(isBootcampEnabled):
    chaptersListPath = _CHAPTERS_DATA_PATH + _CHAPTERS_LIST_XML
    with resource_helper.root_generator(chaptersListPath) as ctx, root:
        chapters = __readChapters(ctx, root, isBootcampEnabled)
    return chapters
def _readXML(path):
    with resource_helper.root_generator(path) as ctx, root:
        settings = _readSettings(ctx, root)
        messages = _readMessages(ctx, root)
    return (settings, messages)
Beispiel #8
0
def _readXML(path):
    with resource_helper.root_generator(path) as ctx, root:
        settings = _readSettings(ctx, root)
        messages = _readMessages(ctx, root)
    return (settings, messages)
def getChapters(filterFunction):
    chaptersListPath = _CHAPTERS_DATA_PATH + _CHAPTERS_LIST_XML
    with resource_helper.root_generator(chaptersListPath) as ctx, root:
        chapters = __readChapters(ctx, root, filterFunction)
    return chapters