fixed automatic model generation inheretence
This commit is contained in:
parent
b40e736ae0
commit
afc4138898
1 changed files with 2 additions and 7 deletions
|
@ -14,17 +14,12 @@ args = parser.parse_args()
|
||||||
|
|
||||||
def generate_imports():
|
def generate_imports():
|
||||||
return "\n".join([
|
return "\n".join([
|
||||||
"from pyaccuwage import model",
|
"from pyaccuwage import model as pyaccuwagemodel",
|
||||||
"from pyaccuwage.fields import *",
|
"from pyaccuwage.fields import *",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
])
|
])
|
||||||
|
|
||||||
def generate_class_begin(name):
|
|
||||||
name = re.sub(r"^[\d]*", "", name)
|
|
||||||
print name
|
|
||||||
return "class %s(mode.Model):\n" % name
|
|
||||||
|
|
||||||
if args.full:
|
if args.full:
|
||||||
sys.stdout.write(generate_imports())
|
sys.stdout.write(generate_imports())
|
||||||
|
|
||||||
|
@ -71,7 +66,7 @@ for rec in records:
|
||||||
if last_record_ends_at + 1 != begins_at:
|
if last_record_ends_at + 1 != begins_at:
|
||||||
name = re.sub('^[^a-zA-Z]*','',rec[0].split(':')[-1])
|
name = re.sub('^[^a-zA-Z]*','',rec[0].split(':')[-1])
|
||||||
name = re.sub('[^\w]*', '', name)
|
name = re.sub('[^\w]*', '', name)
|
||||||
sys.stdout.write("\nclass %s(object):\n" % name)
|
sys.stdout.write("\nclass %s(pyaccuwagemodel.Model):\n" % name)
|
||||||
|
|
||||||
for field in builder.load(map(lambda x:x.tuple, rec[1][0:])):
|
for field in builder.load(map(lambda x:x.tuple, rec[1][0:])):
|
||||||
sys.stdout.write('\t' + field + '\n')
|
sys.stdout.write('\t' + field + '\n')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue