added parent files
This commit is contained in:
29
_parent_files/dump_articles.py
Normal file
29
_parent_files/dump_articles.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import sys
|
||||
import json
|
||||
from src.articles.model import Article, FullArticleSchema
|
||||
from src.sections.model import Section,FullSectionSchema
|
||||
from src.organizations.model import Organization, FullOrganizationSchema
|
||||
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)
|
||||
|
||||
|
||||
def dump_organization(o):
|
||||
return FullOrganizationSchema().dump(o)
|
||||
|
||||
|
||||
file = open(sys.argv[1], "w+")
|
||||
data={}
|
||||
data["articles"] = map(dump_article,Article.query.all())
|
||||
data["sections"] = map(dump_section,Section.query.all())
|
||||
data["organizations"] = map(dump_organization,Organization.query.all())
|
||||
|
||||
json.dump (data, file)
|
||||
|
||||
file.close()
|
||||
Reference in New Issue
Block a user