forked from Github/guess-filename.py
added PDF file patterns for Boox Max 2 exports
This commit is contained in:
parent
9c7ff7f86a
commit
9a0499b90f
2 changed files with 29 additions and 2 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
PROG_VERSION = u"Time-stamp: <2019-09-30 10:04:46 vk>"
|
||||
PROG_VERSION = u"Time-stamp: <2019-10-10 13:33:37 vk>"
|
||||
|
||||
|
||||
# TODO:
|
||||
|
|
@ -1049,6 +1049,25 @@ class GuessFilename(object):
|
|||
return datetimestr + ' ' + self.config.SALARY_DESCRIPTION + ' MONTH - SALARY' + \
|
||||
'€ -- detego private.pdf'
|
||||
|
||||
# 2019-10-10: '2019-10-10 a file exported by Boox Max 2-Exported.pdf' or
|
||||
# '2019-10-10 a file exported by Boox Max 2 -- notes-Exported.pdf' become
|
||||
# -> '2019-10-10 a file exported by Boox Max 2 -- notes.pdf'
|
||||
if extension.upper() == "PDF" and oldfilename.upper().endswith('-EXPORTED.PDF'):
|
||||
if self.contains_all_of(oldfilename, [" -- ", " notes"]):
|
||||
# FIXXME: assumption is that "notes" is within the
|
||||
# filetags and not anywhere else:
|
||||
# '2019-10-10 a file exported by Boox Max 2 -- notes-Exported.pdf'
|
||||
return oldfilename[:-13] + '.pdf'
|
||||
else:
|
||||
if ' -- ' in oldfilename:
|
||||
# filetags found but not containing "notes":
|
||||
# '2019-10-10 a file exported by Boox Max 2 -- draft-Exported.pdf'
|
||||
return oldfilename[:-13] + ' notes.pdf'
|
||||
else:
|
||||
# no filetags found so far:
|
||||
# '2019-10-10 a file exported by Boox Max 2-Exported.pdf'
|
||||
return oldfilename[:-13] + ' -- notes.pdf'
|
||||
|
||||
# FIXXME: more cases!
|
||||
|
||||
return False # no new filename found
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8; mode: python; -*-
|
||||
# Time-stamp: <2019-09-30 10:08:44 vk>
|
||||
# Time-stamp: <2019-10-10 13:30:31 vk>
|
||||
|
||||
import unittest
|
||||
import logging
|
||||
|
|
@ -220,6 +220,14 @@ class TestGuessFilename(unittest.TestCase):
|
|||
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('IMG_20190118_133928_Bokeh This is a note.jpg'),
|
||||
'2019-01-18T13.39.28 Bokeh This is a note.jpg')
|
||||
|
||||
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-10-10 a file exported by Boox Max 2-Exported.pdf'),
|
||||
'2019-10-10 a file exported by Boox Max 2 -- notes.pdf')
|
||||
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-10-10 a file exported by Boox Max 2 -- notes-Exported.pdf'),
|
||||
'2019-10-10 a file exported by Boox Max 2 -- notes.pdf')
|
||||
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-10-10 a file exported by Boox Max 2 -- draft-Exported.pdf'),
|
||||
'2019-10-10 a file exported by Boox Max 2 -- draft notes.pdf')
|
||||
|
||||
|
||||
# self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename(''),
|
||||
# '')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue