def backup(self):
dsecs = self.data_file.stat().st_mtime
meta_file = Path(self.bits["metadata"])
msecs = meta_file.stat().st_mtime
secs = max(dsecs, msecs)
suffix = filename_iso_time(secs)
backup_data = self.data_file.with_name("{}-{}{}".format(self.data_file.stem, suffix, self.data_file.suffix))
backup_meta = meta_file.with_name("{}-{}{}".format(meta_file.stem, suffix, meta_file.suffix))
with backup_data.open("w", newline='') as csvfile:
fieldnames = ['location', 'lyric', 'mark', 'track-change', "chord-change", "chord-selection", "note"]
writer = csv.DictWriter(csvfile, fieldnames=fieldnames, extrasaction='ignore', dialect=ImportCsvDialect)
writer.writeheader()
for location in self.order:
writer.writerow(self.data[location])
with backup_meta.open('w') as meta:
self.metadata.write(meta)
评论列表
文章目录