Commit 691ee0979b808ebfa535a5f42d06d3349f028a93
1 parent
b9094cfb
Exists in
master
and in
1 other branch
fixed: now logs an error when topic/questions.yaml is not found
Showing
4 changed files
with
10 additions
and
11 deletions
Show diff stats
BUGS.md
| 1 | 1 | |
| 2 | 2 | BUGS: |
| 3 | 3 | |
| 4 | -- se refs de um topic estao invalidos, nao carrega esse topico. devia haver um error nos logs a indicar qual o ref invalido. | |
| 5 | 4 | - forçar reload das perguntas sem ter de deitar abaixo o servidor. |
| 6 | 5 | - topicos virtuais nao deveriam aparecer. na construção da árvore os sucessores seriam ligados directamente aos predecessores. |
| 7 | 6 | - Criar outra estrutura organizada em capítulos (conjuntos de tópicos). Permitir capítulos de capítulos, etc. talvez usar grafos de grafos... |
| ... | ... | @@ -34,6 +33,7 @@ TODO: |
| 34 | 33 | |
| 35 | 34 | FIXED: |
| 36 | 35 | |
| 36 | +- se refs de um topic estao invalidos, nao carrega esse topico. devia haver um error nos logs a indicar qual o ref invalido. | |
| 37 | 37 | - link directo para topico nao valida se topico esta unlocked. |
| 38 | 38 | - templates not working: quesntion-information, question-warning (remove all informative panels??) |
| 39 | 39 | - enderecos errados dao internal error. | ... | ... |
demo/demo.yaml
learnapp.py
| ... | ... | @@ -297,7 +297,7 @@ def build_dependency_graph(config={}): |
| 297 | 297 | # if questions not in configuration then load all, preserving order |
| 298 | 298 | if not tnode['questions']: |
| 299 | 299 | tnode['questions'] = [q['ref'] for q in loaded_questions] |
| 300 | - | |
| 300 | + | |
| 301 | 301 | # make questions factory (without repeating same question) |
| 302 | 302 | tnode['factory'] = {} |
| 303 | 303 | for q in loaded_questions: | ... | ... |
tools.py
| ... | ... | @@ -133,25 +133,24 @@ def md_to_html(text, q=None): |
| 133 | 133 | # load data from yaml file |
| 134 | 134 | # --------------------------------------------------------------------------- |
| 135 | 135 | def load_yaml(filename, default=None): |
| 136 | + filename = path.expanduser(filename) | |
| 136 | 137 | try: |
| 137 | - f = open(path.expanduser(filename), 'r', encoding='utf-8') | |
| 138 | + f = open(filename, 'r', encoding='utf-8') | |
| 138 | 139 | except FileNotFoundError: |
| 139 | - logger.error(f'Can\'t open "{script}": not found.') | |
| 140 | - return default | |
| 140 | + logger.error(f'Can\'t open "{filename}": not found.') | |
| 141 | 141 | except PermissionError: |
| 142 | - logger.error(f'Can\'t open "{script}": no permission.') | |
| 143 | - return default | |
| 142 | + logger.error(f'Can\'t open "{filename}": no permission.') | |
| 144 | 143 | except IOError: |
| 145 | 144 | logger.error(f'Can\'t open file "{filename}".') |
| 146 | - return default | |
| 147 | 145 | else: |
| 148 | 146 | with f: |
| 149 | 147 | try: |
| 150 | - return yaml.load(f) | |
| 148 | + default = yaml.load(f) | |
| 151 | 149 | except yaml.YAMLError as e: |
| 152 | 150 | mark = e.problem_mark |
| 153 | 151 | logger.error(f'In YAML file "{filename}" near line {mark.line}, column {mark.column+1}.') |
| 154 | - return default | |
| 152 | + finally: | |
| 153 | + return default | |
| 155 | 154 | |
| 156 | 155 | # --------------------------------------------------------------------------- |
| 157 | 156 | # Runs a script and returns its stdout parsed as yaml, or None on error. | ... | ... |