mirror of
https://github.com/novoid/guess-filename.py.git
synced 2026-02-16 13:24:15 +00:00
added wav/mp3 recording patterns
This commit is contained in:
parent
f829acda80
commit
83bdf8d62a
2 changed files with 29 additions and 2 deletions
15
guessfilename.py
Executable file → Normal file
15
guessfilename.py
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
PROG_VERSION = u"Time-stamp: <2017-11-05 11:58:26 vk>"
|
PROG_VERSION = u"Time-stamp: <2017-11-29 19:13:06 vk>"
|
||||||
|
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
|
|
@ -158,6 +158,8 @@ class GuessFilename(object):
|
||||||
BANKAUSTRIA_BANK_TRANSACTIONS_REGEX = re.compile('^' + DAYTIME_REGEX + '_IKS-(\d{29}).csv$', re.UNICODE)
|
BANKAUSTRIA_BANK_TRANSACTIONS_REGEX = re.compile('^' + DAYTIME_REGEX + '_IKS-(\d{29}).csv$', re.UNICODE)
|
||||||
BANKAUSTRIA_BANK_TRANSACTIONS_INDEXGROUPS = [1, ' Bank Austria Umsatzliste IKS-', 4, '.csv']
|
BANKAUSTRIA_BANK_TRANSACTIONS_INDEXGROUPS = [1, ' Bank Austria Umsatzliste IKS-', 4, '.csv']
|
||||||
|
|
||||||
|
RECORDER_REGEX = re.compile('rec_([12]\d{3})([01]\d)([0123]\d)-([012]\d)([012345]\d)(.+)?.(wav|mp3)')
|
||||||
|
|
||||||
logger = None
|
logger = None
|
||||||
config = None
|
config = None
|
||||||
|
|
||||||
|
|
@ -506,6 +508,17 @@ class GuessFilename(object):
|
||||||
if regex_match:
|
if regex_match:
|
||||||
return self.build_string_via_indexgroups(regex_match, self.VID_INDEXGROUPS)
|
return self.build_string_via_indexgroups(regex_match, self.VID_INDEXGROUPS)
|
||||||
|
|
||||||
|
# rec_20171129-0902 A nice recording .wav -> 2017-11-29T09.02 A nice recording.wav
|
||||||
|
# rec_20171129-0902 A nice recording.wav -> 2017-11-29T09.02 A nice recording.wav
|
||||||
|
# rec_20171129-0902.wav -> 2017-11-29T09.02.wav
|
||||||
|
# rec_20171129-0902.mp3 -> 2017-11-29T09.02.mp3
|
||||||
|
regex_match = re.match(self.RECORDER_REGEX, oldfilename)
|
||||||
|
if regex_match:
|
||||||
|
result = self.build_string_via_indexgroups(regex_match, [1, '-', 2, '-', 3, 'T', 4, '.', 5])
|
||||||
|
if regex_match.group(6):
|
||||||
|
result += ' ' + regex_match.group(6).strip()
|
||||||
|
return result + '.' + regex_match.group(7)
|
||||||
|
|
||||||
# 2015-11-24 Rechnung A1 Festnetz-Internet 12,34€ -- scan bill.pdf
|
# 2015-11-24 Rechnung A1 Festnetz-Internet 12,34€ -- scan bill.pdf
|
||||||
if self.contains_one_of(oldfilename, [" A1 ", " a1 "]) and self.has_euro_charge(oldfilename) and datetimestr:
|
if self.contains_one_of(oldfilename, [" A1 ", " a1 "]) and self.has_euro_charge(oldfilename) and datetimestr:
|
||||||
return datetimestr + \
|
return datetimestr + \
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8; mode: python; -*-
|
# -*- coding: utf-8; mode: python; -*-
|
||||||
# Time-stamp: <2017-09-23 11:13:42 vk>
|
# Time-stamp: <2017-11-29 19:07:42 vk>
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -117,6 +117,20 @@ class TestGuessFilename(unittest.TestCase):
|
||||||
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-03-12-2017-09-23 Hipster.png"),
|
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-03-12-2017-09-23 Hipster.png"),
|
||||||
"2017-03-12-2017-09-23 Hipster-PDA vollgeschrieben -- scan notes.png")
|
"2017-03-12-2017-09-23 Hipster-PDA vollgeschrieben -- scan notes.png")
|
||||||
|
|
||||||
|
# rec_20171129-0902 A nice recording .wav -> 2017-11-29T09.02 A nice recording.wav
|
||||||
|
# rec_20171129-0902 A nice recording.wav -> 2017-11-29T09.02 A nice recording.wav
|
||||||
|
# rec_20171129-0902.wav -> 2017-11-29T09.02.wav
|
||||||
|
# rec_20171129-0902.mp3 -> 2017-11-29T09.02.mp3
|
||||||
|
# import pdb; pdb.set_trace()
|
||||||
|
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902 A nice recording .wav"),
|
||||||
|
"2017-11-29T09.02 A nice recording.wav")
|
||||||
|
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902 A nice recording.wav"),
|
||||||
|
"2017-11-29T09.02 A nice recording.wav")
|
||||||
|
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902.wav"),
|
||||||
|
"2017-11-29T09.02.wav")
|
||||||
|
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902.mp3"),
|
||||||
|
"2017-11-29T09.02.mp3")
|
||||||
|
|
||||||
def test_contains_one_of(self):
|
def test_contains_one_of(self):
|
||||||
|
|
||||||
self.assertTrue(self.guess_filename.contains_one_of("foo bar baz", ['foo']))
|
self.assertTrue(self.guess_filename.contains_one_of("foo bar baz", ['foo']))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue