fixed automatic model generation inheretence

This commit is contained in:
Binh 2013-02-19 16:06:11 -06:00
parent b40e736ae0
commit afc4138898

View file

@ -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')