Exemple #1
0
def change_note(args, current_note, data_file):
	filename = '~/.quicknote/.notes/.'
	note_name = hf.parse_unary_args(args)
	filename += note_name
	filename = path.expanduser(filename)
	# stop if the note to be changed to is the current note	
	if current_note == filename:
		print('The note you are trying to change to is already the current note.')
		return
	# stop if the user is trying to change to the default note
	if note_name == 'default':
		print_default_error()
		return
	if not path.isfile(filename):
		print('Hmmm. The note you entered doesn\'t seem to exist. Please try again.')
		return
	if current_note[-7:] == 'default':
		new_name = input('The current note must be named before changing notes. Please enter a name (ENTER to delete the current note): ')
		if new_name != '':
			dot_name = path.expanduser('~/.quicknote/.notes/.' + new_name)
			return_value = hf.make_note(dot_name, new_name)
			if return_value == None:
				return
			shutil.copyfile(current_note, dot_name)
		open(current_note, 'w').close()	
	hf.write_to_data_file(data_file, filename)
	print('Changed current note to \'' + note_name + '\'')
Exemple #2
0
def archive_note(args, current_note, data_file):
    note_to_archive = hf.parse_unary_args(args)
    note_path = path.expanduser('~/.quicknote/.notes/.' + note_to_archive)

    if not path.isfile(note_path):
        print(
            'The note you are trying to archive does not exist. Please try again.'
        )
        return
    # prevent the user from archiving 'archive' or 'default'
    if note_to_archive == 'archive' or note_to_archive == 'default':
        print(
            '\'archive\' and \'default\' may not be archived. Please try again.'
        )
        return
    new_path = path.expanduser('~/.quicknote/.archive_notes/.' +
                               note_to_archive)
    if path.isfile(new_path):
        print('You already have an archived note named \'' + note_to_archive +
              '\'. Please try again. (hint: rename something)')
        return
    os.rename(note_path, new_path)
    print('Archived \'' + note_to_archive + '\'')
    if current_note != 'default':
        hf.write_to_data_file(data_file,
                              path.expanduser('~/.quicknote/.notes/.default'))
Exemple #3
0
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.'
            )
Exemple #4
0
def add_note(args):
    note_name = hf.parse_unary_args(args)
    dot_name = path.expanduser('~/.quicknote/.notes/.' + note_name)
    return_value = hf.make_note(dot_name, note_name)
    if return_value == None:
        return
    print('Added new note \'' + note_name + '\'')
def move_memory(current_note, row, args):
    note = hf.parse_unary_args(args)
    note_path = path.expanduser('~/.quicknote/.notes/.' + note)
    if not path.isfile(note_path):
        print(
            'The note you are trying to add to does not exist. Please try again.'
        )
        return
    memory_to_move = change_memory(current_note, row)
    if memory_to_move == None:
        return
    append_memory(memory_to_move, note_path)
    print('Moved \'' + memory_to_move + '\' to \'' + note + '\'')
Exemple #6
0
def un_archive_note(args):
	note_to_un_archive = hf.parse_unary_args(args)
	note_path = path.expanduser('~/.quicknote/.archive_notes/.' + note_to_un_archive)
	
	if not path.isfile(note_path):
		print('The note you are trying to un-archive does not exist. Please try again.')	
		return
	new_path = path.expanduser('~/.quicknote/.notes/.' + note_to_un_archive)
	if path.isfile(new_path):
		print('You already have a note named \'' + note_to_un_archive + '\'. Please try again. (hint: rename something)')
		return
	os.rename(note_path, new_path) 
	print('Un-archived \'' + note_to_un_archive + '\'')
def copy_memory(current_note, row, args):
    note = hf.parse_unary_args(args)
    note_path = path.expanduser('~/.quicknote/.notes/.' + note)
    if not path.isfile(note_path):
        print(
            'The note you are trying to add to does not exist. Please try again.'
        )
        return
    memories = hf.check_row(current_note, row)
    if memories == None:
        return
    row = int(row)
    memory_to_copy = memories[row - 1].strip('\n')
    append_memory(memory_to_copy, note_path)
    print('Copied \'' + memory_to_copy + '\' to \'' + note + '\'')
Exemple #8
0
def change_note(args, current_note, data_file):
    filename = '~/.quicknote/.notes/.'
    note_name = hf.parse_unary_args(args)
    filename += note_name
    filename = path.expanduser(filename)
    # stop if the note to be changed to is the current note
    if current_note == filename:
        print(
            'The note you are trying to change to is already the current note.'
        )
        return

    if not path.isfile(filename):
        print(
            'Hmmm. The note you entered doesn\'t seem to exist. Please try again.'
        )
        return

    hf.write_to_data_file(data_file, filename)
    print('Changed current note to \'' + note_name + '\'')
def add_memory(note, args):
    memory = hf.parse_unary_args(args)
    append_memory(memory, note)
    print('Remembered \'' + memory + '\'')