Skip to content

Commit

Permalink
Doc behavior/TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
clach04 committed Nov 17, 2024
1 parent 96f43ea commit 516acbf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion puren_tonbo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ def note_contents_load_filename(filename, get_pass=None, dos_newlines=True, retu

# note_contents_save_filename(note_text, filename=None, original_filename=None, folder=None, handler=None, dos_newlines=True, backup=True, use_tempfile=True, note_encoding='utf-8', filename_generator=FILENAME_FIRSTLINE):
# note_contents_save(self, note_text, filename=None, original_filename=None, folder=None, get_pass=None, dos_newlines=True, backup=True, filename_generator=FILENAME_FIRSTLINE, handler_class=None):
# TODO https://github.com/clach04/puren_tonbo/issues/173 allow warning to be disabled on duplicate derived filename
def note_contents_save_native_filename(note_text, filename=None, original_filename=None, folder=None, handler=None, dos_newlines=True, backup=True, use_tempfile=True, note_encoding='utf-8', filename_generator=FILENAME_FIRSTLINE):
"""Uses native/local file system IO api
@handler is the encryption file handler to use, that is already initialized with a password
Expand Down Expand Up @@ -1398,7 +1399,7 @@ def note_contents_save_native_filename(note_text, filename=None, original_filena
# now check if generated filename already exists, if so need to make unique
unique_counter = 1
while os.path.exists(filename):
log.warning('generated filename %r already exists, generating alternative', filename) # TODO consider making info?
log.warning('generated filename %r already exists, generating alternative', filename) # TODO consider making optional and also info instead of warning? Test suite triggers this which is simply not useful information as the test does it's own validation https://github.com/clach04/puren_tonbo/issues/173
unique_part = '(%d)' % unique_counter # match Tombo duplicate names avoidance
filename = os.path.join(folder, filename_without_path_and_extension + unique_part + file_extension)
unique_counter += 1
Expand Down
4 changes: 3 additions & 1 deletion puren_tonbo/tests/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ class TestFileSystemNotesWriteFunctionSaveRawPlainText(TestUtil):
def setUpClass(self):
self.data_folder = tempfile.mkdtemp(prefix='TestFileSystemNotesWrite_tmp')
#print('self.data_folder %s' % self.data_folder)
#input('pause, press enter')

@classmethod
def tearDownClass(self):
Expand Down Expand Up @@ -755,7 +756,7 @@ def test_filename_gen_one_rename_two_with_password_with_nobackup(self):

self.do_one_test(buffer_plain_str, original_filename='one' + file_extension, dos_newlines=False, test_password_bytes=self.test_password_bytes, backup=False, expected_filenames=['two' + file_extension])

def test_filename_gen_one_with_password_already_exist(self):
def test_filename_gen_one_with_password_already_exist(self): # test that if filename already exists, new derived filename is generated so as to avoid loosing original content
self.check_skip()
buffer_plain_str = '''one
Expand All @@ -768,6 +769,7 @@ def test_filename_gen_one_with_password_already_exist(self):
note_root = puren_tonbo.FileSystemNotes(folder, self.note_encoding)
note_root.note_contents_save('junk', filename='one' + file_extension, filename_generator=None, get_pass=self.test_password_bytes)

# NOTE this will trigger the note_contents_save_filename() / note_contents_save_native_filename() warning about generated filename already existing
self.do_one_test(buffer_plain_str, dos_newlines=False, test_password_bytes=self.test_password_bytes, expected_filenames=['one(1)' + file_extension, 'one' + file_extension])

def test_filename_gen_one_with_password(self):
Expand Down

0 comments on commit 516acbf

Please sign in to comment.