bring back templating
This commit is contained in:
parent
c64b2c2044
commit
4ed9804405
3 changed files with 25 additions and 2 deletions
|
@ -14,12 +14,14 @@ from argparse import ArgumentParser
|
||||||
import os,sys
|
import os,sys
|
||||||
import yaml
|
import yaml
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from string import Template
|
||||||
|
|
||||||
from tablegenerator import TableGenerator
|
from tablegenerator import TableGenerator
|
||||||
from markdowngenerator import MarkdownGenerator
|
from markdowngenerator import MarkdownGenerator
|
||||||
from templategenerator import TemplateGenerator
|
from templategenerator import TemplateGenerator
|
||||||
from schema import Schema
|
from schema import Schema
|
||||||
|
|
||||||
|
|
||||||
class CourseBuilder:
|
class CourseBuilder:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -107,8 +109,24 @@ class CourseBuilder:
|
||||||
|
|
||||||
# print(df_q.head())
|
# print(df_q.head())
|
||||||
|
|
||||||
|
# set value transforms
|
||||||
|
if args.query_template:
|
||||||
|
|
||||||
|
ww = 'written'
|
||||||
|
#df_q['form-of-exam'] = 'Schriftlich' if df_q.loc[:,'form-of-exam'] == 'written' else 'was anderes'
|
||||||
|
# mm = Template("{'written':'S','oral':'mündlich'}[${v}]")?
|
||||||
|
# print(mm.format(v=mm))
|
||||||
|
|
||||||
|
# set labels
|
||||||
|
if args.query_labels:
|
||||||
|
df_q.columns = args.query_labels
|
||||||
|
|
||||||
q_as_md = df_q.to_markdown(tablefmt='grid',index=False)
|
q_as_md = df_q.to_markdown(tablefmt='grid',index=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(q_as_md)
|
print(q_as_md)
|
||||||
|
|
||||||
# # lets get crazy to create a summary table!
|
# # lets get crazy to create a summary table!
|
||||||
|
@ -136,6 +154,8 @@ class CourseBuilder:
|
||||||
parser.add_argument('-qs','--query-sort',type=str,default=None,help="sort query with a min/max over a column like min:credits")
|
parser.add_argument('-qs','--query-sort',type=str,default=None,help="sort query with a min/max over a column like min:credits")
|
||||||
parser.add_argument('-qc','--query-compound',type=str,default=None,help="create a compound from a column with multiple values/dictionaries in cells")
|
parser.add_argument('-qc','--query-compound',type=str,default=None,help="create a compound from a column with multiple values/dictionaries in cells")
|
||||||
parser.add_argument('-qf','--query-filter',type=str,default=[],action="extend", nargs="+",help="filter final list of columns for output")
|
parser.add_argument('-qf','--query-filter',type=str,default=[],action="extend", nargs="+",help="filter final list of columns for output")
|
||||||
|
parser.add_argument('-ql','--query-labels',type=str,default=[],action="extend", nargs="+",help="new labels for query like")
|
||||||
|
parser.add_argument('-qt','--query-template',type=str,default=[],action="extend", nargs="+",help="templates for values in the form of {value}")
|
||||||
|
|
||||||
|
|
||||||
# create pagebreaks
|
# create pagebreaks
|
||||||
|
|
|
@ -5,6 +5,9 @@ class Schema:
|
||||||
def __init__(self,schema) -> None:
|
def __init__(self,schema) -> None:
|
||||||
self.__schema = schema
|
self.__schema = schema
|
||||||
|
|
||||||
|
def __getitem__(self, field):
|
||||||
|
return self.__schema[field]
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
return self.__schema.keys()
|
return self.__schema.keys()
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ debug:
|
||||||
# | pandoc ${target_flags} -V lang:de -o ${target_de}
|
# | pandoc ${target_flags} -V lang:de -o ${target_de}
|
||||||
|
|
||||||
debug-query:
|
debug-query:
|
||||||
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml -q "kind=='compulsory'" -qs min:credits -qc form-of-instruction -qf name id credits
|
python ${coursebuilder} -s schema.yaml -m mod.cg.yaml mod.interactsys.yaml -q "kind=='compulsory'" -qs min:credits -qc form-of-instruction -qf name credits form-of-exam -ql Modulname Kreditpunkte Prüfungsart -qt quatsch
|
||||||
|
|
||||||
debug-query-book:
|
debug-query-book:
|
||||||
python ${coursebuilder} -s schema.yaml -b book.yaml -q "kind=='compulsory'" -qs min:credits -qc form-of-instruction -qf name id credits
|
python ${coursebuilder} -s schema.yaml -b book.yaml -q "kind=='compulsory'" -qs min:credits -qc form-of-instruction -qf name credits form-of-instruction -ql Modulname Kürzel Kreditpunkte
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
Loading…
Add table
Add a link
Reference in a new issue