29 Check file exist or not. 31 msg =
" already exists. Overwrite or merge? (y/n/m)" 32 if (os.access(fname, os.F_OK)):
33 ans = raw_input(
"\"" + fname +
"\"" + msg)
34 if (ans ==
"y" or ans ==
"Y"):
35 return file(fname, wmode),
None 36 elif (ans ==
"m" or ans ==
"M"):
39 for l
in f.readlines():
40 lines.append(l.rstrip())
42 oldfname = fname +
".old." + time.strftime(
"%y%m%d%H%M%S")
43 os.rename(fname, oldfname)
44 return file(fname, wmode), lines
48 return file(fname, wmode),
None 57 m = re.search(
"<rtc-template block=\"(.*?)\">", l)
64 m = re.search(
"</rtc-template>", l)
67 if data.has_key(tag_name):
68 ret_lines += data[tag_name] +
"\n" 80 for key
in tags.keys():
82 text=t.generate(self.data)
86 def gen(self, fname, temp_txt, data, tags):
93 taged_txt = t.generate(self.data)
101 print " File \"" + fname +
"\"" " was generated."
def gen(self, fname, temp_txt, data, tags)
def check_overwrite(self, fname, wmode="w")
def replace_tags(self, lines, data)