Files
fachschaften/dump_articles.py
Andreas Stephanides 0c1b586962 loaddump_Articles
2017-02-08 07:14:36 +01:00

24 lines
527 B
Python

import sys
import json
from src.articles.model import Article, FullArticleSchema
from src.sections.model import Section,FullSectionSchema
if len(sys.argv) <= 1:
raise Error("Kein Zieldateiname angegeben")
def dump_article(a):
return FullArticleSchema().dump(a)
def dump_section(s):
return FullSectionSchema().dump(s)
file = open(sys.argv[1], "w+")
data={}
data["articles"] = map(dump_article,Article.query.all())
data["sections"] = map(dump_section,Section.query.all())
json.dump (data, file)
file.close()