Fix code generation and tests after reorganization

This commit is contained in:
Vincent Jacques
2012-05-10 18:26:18 +02:00
parent 595e88cd55
commit 283da5e7de
4 changed files with 23 additions and 18 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
#!/bin/env python
import os
import json
import itertools
@@ -9,12 +10,12 @@ import django.template.loader
django.conf.settings.configure(
TEMPLATE_DIRS = (
"CodeGenerator/templates",
os.path.join( os.path.dirname( __file__ ), "templates" ),
),
TEMPLATE_STRING_IF_INVALID = "We have a logic error in our template or API description",
)
description = json.load( open( "JsonDescriptionOfGithubApiV3/description.001.normalized.json" ) )
description = json.load( open( os.path.join( os.path.dirname( __file__ ), "JsonDescriptionOfGithubApiV3", "description.001.normalized.json" ) ) )
for class_ in description[ "classes" ]:
dependencies = set()
@@ -32,7 +33,7 @@ for class_ in description[ "classes" ]:
githubObjectTemplate = django.template.loader.get_template( "GithubObject.py" )
for class_ in description[ "classes" ]:
with open( "github/GithubObjects/" + class_[ "name" ] + ".py", "w" ) as f:
with open( os.path.join( os.path.dirname( __file__ ), "..", "src", "github", class_[ "name" ] + ".py" ), "w" ) as f:
f.write( "# WARNING: this file is generated automaticaly.\n" )
f.write( "# Do not modify it manually, your work would be lost.\n" )
f.write( "\n" )
@@ -50,7 +51,7 @@ for class_ in description[ "classes" ]:
f.write( "\n".join( code ) + "\n" )
referenceOfClassesTemplate = django.template.loader.get_template( "ReferenceOfClasses.md" )
with open( "ReferenceOfClasses.md", "w" ) as f:
with open( os.path.join( os.path.dirname( __file__ ), "..", "doc", "ReferenceOfClasses.md" ), "w" ) as f:
rawCode = referenceOfClassesTemplate.render( django.template.Context( description ) ).split( "\n" )
code = list()
for line in rawCode: