コード例 #1
0
ファイル: note.py プロジェクト: jmprathab/homebrew-quicknote
def remove_note(args, current_note, data_file):
    note_to_remove = hf.parse_unary_args(args)
    if note_to_remove.lower() == 'archive' or note_to_remove.lower(
    ) == 'default':
        print(
            'Sorry. The \'default\' and \'archive\' notes cannot be removed. However, they can be cleared of their contents.'
        )
        return
    prompt = 'Are you sure you want to remove \'' + note_to_remove + '\'?' + BOLD + ' There is no going back (y/n): ' + RESET
    decision = hf.request_user_permission(prompt)
    if decision == 'n':
        print('Note removal aborted')
    elif decision == 'y':  # this probably isn't necessary (i.e. don't need to check, could be an else)
        note_path_to_remove = path.expanduser('~/.quicknote/.notes/.' +
                                              note_to_remove)
        if path.isfile(note_path_to_remove):
            os.remove(note_path_to_remove)
            if current_note == note_to_remove:
                hf.write_to_data_file(
                    data_file, path.expanduser('~/.quicknote/.notes/.default'))
            print('Removed note \'' + note_to_remove + '\'')
        else:
            print(
                'The note you are trying to remove does not exist. Please try again.'
            )
コード例 #2
0
def clear_memories(filename):
    prompt = 'Are you sure you want to clear your current memories on this note?' + BOLD + ' There is no going back (y/n): ' + RESET
    decision = hf.request_user_permission(prompt)
    if decision == 'y':
        open(filename, 'w').close()
        print('Memories cleared')
    elif decision == 'n':  # this probably isn't necessary (i.e. don't need to check, could be an else)
        print('Memory clearing aborted')
コード例 #3
0
ファイル: note.py プロジェクト: opritche/homebrew-quicknote
def clear_archive_notes(archive_notes):
	prompt = 'Are you sure you want to clear all of your archived notes?' + BOLD + ' There is no going back (y/n): ' + RESET
	decision = hf.request_user_permission(prompt)
	if decision == 'n':
		print('Clearing of archived notes aborted')
	elif decision == 'y':
		for note in archive_notes:
			note_path = path.expanduser('~/.quicknote/.archive_notes/.' + note)
			if path.isfile(note_path):
				os.remove(note_path)
		print('Cleared all archived user notes from Quick Note cache')
コード例 #4
0
ファイル: note.py プロジェクト: opritche/homebrew-quicknote
def clear_notes(notes, current_note, data_file):
	prompt = 'Are you sure you want to clear all of your notes?' + BOLD + ' There is no going back (y/n): ' + RESET
	decision = hf.request_user_permission(prompt)
	if decision == 'n':
		print('Clearing of notes aborted')
	elif decision == 'y':
		for note in notes:
			note_path = path.expanduser('~/.quicknote/.notes/.' + note)
			if path.isfile(note_path) and note != 'default':
				os.remove(note_path)
		if current_note != 'default':
			hf.write_to_data_file(data_file, path.expanduser('~/.quicknote/.notes/.default'))
		print('Cleared all user notes from Quick Note cache')