def saveInit(self): tmp = getfile(self.project,'__init__.py') tmp2 = 'from ' + self.file.replace(' ','_')[:-3] + ' import *' o = tmp.find(tmp2) if o == -1: tmp = tmp.replace('# to be imported','# to be imported\n' + tmp2) writefile(self.project,'__init__.py',tmp)
def __init__(self, db, tbl_list): self.imp = 'import datetime\nfrom django.db import models\nfrom django.utils import timezone\nfrom django.forms import ModelForm\nfrom django.core.validators import MaxValueValidator, MinValueValidator\nfrom django.db.models import F,Sum,Avg,Max,Min\n\n' self.project = db[tbl_list.index('project')] self.filename = db[tbl_list.index('model file name')] self.existing = getfile(self.project, self.filename) self.script = self.imp
def clearInit(self): tmp = getfile(self.project, '__init__.py') o = tmp.find('# to be imported') p = tmp.find('# end of import') tmp = tmp[:o] + '# to be imported\n' + tmp[p:] writefile(self.project, '__init__.py', tmp)
def __init__(self,db,tbl_list): self.project = db[tbl_list.index('project')] self.file = db[tbl_list.index('model file name')] self.table = db[tbl_list.index('table name')] self.existing = getfile(self.project,self.file) self.script = self.existing