Exemplo n.º 1
0
    def sync_event_file(self, event):
        renamed = False
        file_info = self.db.find_event(event['id'])
        if file_info:
            if file_info['title'] != event['title']:
                renamed = True
                (file_date, title) = FileWriter.split_filename(
                    file_info['filename'])
                filename = FileWriter.create_filename(file_date, event['title'])
            else:
                filename = file_info['filename']
        else:
            filename = FileWriter.create_filename(event['time'], event['title'])

        if renamed:
            self.writer.delete(file_info['filename'])

        self.writer.write(MeetupEvent(event), filename)
Exemplo n.º 2
0
 def test_split_filename(self):
     self.assertEqual(
         FileWriter.split_filename('2017-01-30-another-event.md'),
         (date(2017, 1, 30), 'another-event'))