Closed nbehrnd closed 2 years ago
En route to extend the test script's scope (there is revised deposit in the pull request), the scene is more complex than anticipated earlier.
2022-01-07T18.48_test.txt
, 2022-01-07_test.txt
, or test.txt
manually on the CLI, no problem to run all the automated tests. To select only those about --smart-prepend
, either one of the two instructions below work well:pytest-3 test_appendfilename.py -m "smart"
pytest-3 test_appendfilename.py -m "smart" -v # a more verbose report to the CLI
--withtime
time stamp. Perhaps the appendfilename's log when in the verbose mode helps to narrow the cause? If relevant, this session with Python 3.9.9 and bash 5.1.12.norwid@carnot2:~/Desktop/test_debian$ appendfilename 2022-01-07_ping.txt --smart-prepend -t echo --verbose
DEBUG 2022-01-07 11:51:56,593 text found: [echo]
DEBUG 2022-01-07 11:51:56,593 extracting list of files ...
DEBUG 2022-01-07 11:51:56,593 len(args) [1]
DEBUG 2022-01-07 11:51:56,593 1 filenames found: [2022-01-07_ping.txt]
DEBUG 2022-01-07 11:51:56,593 iterate over files ...
DEBUG 2022-01-07 11:51:56,594 date/time-stamp found, insert text between date/time-stamp and rest
ERROR 2022-01-07 11:51:56,594 Error while trying to build new filename: <class 'TypeError'>
ERROR 2022-01-07 11:51:56,594 1 error(s) occurred. Please check output above.
norwid@carnot2:~/Desktop/test_debian$ ls
2022-01-07_ping.txt 2022-01-07T11.48.38_ping.txt 'echo ping.txt'
Hi @nbehrnd, Unfortunately, I can't reproduce the issue at my side and the debug output is not showing me something that helps me here.
I just committed a more verbose debug output for that use-case. For comparison, this is my output:
vk@sting ..lename/manualtests/2022-01-07-issue-13 (git)-[master] % appendfilename 2022-01-07_ping.txt --smart-prepend -t echo --verbose --dryrun
DEBUG 2022-01-07 17:04:35,268 text found: [echo]
DEBUG 2022-01-07 17:04:35,268 extracting list of files ...
DEBUG 2022-01-07 17:04:35,268 len(args) [1]
DEBUG 2022-01-07 17:04:35,268 1 filenames found: [2022-01-07_ping.txt]
DEBUG 2022-01-07 17:04:35,269 iterate over files ...
DEBUG 2022-01-07 17:04:35,269 options.smartprepend is set with ||echo| |2022-01-07_ping|.txt
DEBUG 2022-01-07 17:04:35,269 options.smartprepend is set with |<class 'str'>|<class 'str'>|<class 'str'>|<class 'str'>|<class 'str'>
DEBUG 2022-01-07 17:04:35,269 date/time-stamp found, insert text between date/time-stamp and rest
DEBUG 2022-01-07 17:10:30,808 options.smartprepend is set with ||2022-01-07|ping.txt|
DEBUG 2022-01-07 17:10:30,808 options.smartprepend is set with |<class 'str'>|<class 'str'>|<class 'str'>|
DEBUG 2022-01-07 17:10:30,808 new_filename is now: 2022-01-07 echo ping.txt
INFO 2022-01-07 17:04:35,269
INFO 2022-01-07 17:04:35,269 renaming "2022-01-07_ping.txt"
INFO 2022-01-07 17:04:35,269 ⤷ "2022-01-07 echo ping.txt"
DEBUG 2022-01-07 17:04:35,269 successfully finished.
Please press <Enter> for finishing...
vk@sting ..lename/manualtests/2022-01-07-issue-13 (git)-[master] %
Can you please re-run your test and post here the output? Thank you very much!
By observation, now the manual conversion works (both on Xubuntu 20.04.2 LTS Fossa, as well as on Debian 12/book worm [testing]). Conceptually, the extended log to the CLI matches yours:
norwid@carnot2:~/Desktop/2022-01-07T18.51.32_appendfilename/appendfilename/appendfilename$ python __init__.py 2022-01-07_ping.txt --smart-prepend -t echo --verbose --dryrun
DEBUG 2022-01-07 19:12:09,498 text found: [echo]
DEBUG 2022-01-07 19:12:09,498 extracting list of files ...
DEBUG 2022-01-07 19:12:09,499 len(args) [1]
DEBUG 2022-01-07 19:12:09,499 1 filenames found: [2022-01-07_ping.txt]
DEBUG 2022-01-07 19:12:09,499 iterate over files ...
DEBUG 2022-01-07 19:12:09,499 options.smartprepend is set with ||echo| |2022-01-07_ping|.txt
DEBUG 2022-01-07 19:12:09,499 options.smartprepend is set with |<class 'str'>|<class 'str'>|<class 'str'>|<class 'str'>|<class 'str'>
DEBUG 2022-01-07 19:12:09,499 date/time-stamp found, insert text between date/time-stamp and rest
DEBUG 2022-01-07 19:12:09,499 options.smartprepend is set with ||2022-01-07|ping.txt|
DEBUG 2022-01-07 19:12:09,499 options.smartprepend is set with |<class 'str'>|<class 'str'>|<class 'str'>|
DEBUG 2022-01-07 19:12:09,499 new_filename is now: 2022-01-07 echo ping.txt
INFO 2022-01-07 19:12:09,499
INFO 2022-01-07 19:12:09,499 renaming "2022-01-07_ping.txt"
INFO 2022-01-07 19:12:09,499 ⤷ "2022-01-07 echo ping.txt"
DEBUG 2022-01-07 19:12:09,500 successfully finished.
Please press <Enter> for finishing...
norwid@carnot2:~/Desktop/2022-01-07T18.51.32_appendfilename/appendfilename/appendfilename$
So, this obstacle is out of the way. Thank you!
Weird.
Well, thanks for your effort in any case. Let me know when this reappears. I keep the additional debug code for now.
appendfilename
functions differently for files stamped bydate2name
in either default, or--withtime
time stamp.Manual replication:
to yield
An analogue programmatic replication with the test script approach (just submitted, incomplete coverage, under construction) with
pytest
/pytest-3
for Python3:File
2021-12-31T18.48.22_test.txt
is processed as2021-12-31T18.48.22 book test.txt
and thus successfully removed by the test script. However, test file2021-12-31.txt
is processed to2021-12-31 book txt
loosing the period en face of the file extension. (Filetest.txt
is processed by appendfilename tobook test.txt
, thus indicating appendfilename works fine on this one.).