marky module

marky.answerMenu(prompt, numOptions)

returns the response to a prompt that expects the user to choose a number between 1 and numOptions (reprompts until user provides a valid response). params:

prompt (string): prompt to show user before awaiting input numOptions (int): number of options user is being asked to choose from

return (int): number

marky.answerYesNo(prompt)

returns the response to a y/n question prompt (reprompts until user provides a valid response) params:

prompt (string): prompt to show user before awaiting input

return (bool): True if user responds yes, False if user responds no

marky.cIndexAdvance(cIndex, chapters, verbose=False, _tryDeeper=True)

helper function for iterating through a nested list of chapter dicts params:

cIndex: array of indices into chapters chapters: array of chapter dict objects (which individually may or may not have nested chapters

return (array or None): an updated cIndex that refers to the next chapter after the provided cIndex

(in depth first descent, BUT counting parent chapters as visited on the descent down) returns None if we finish traversing chapters

marky.getAvailableFname(prefix, ext)

returns a valid filename (to a file not already existing) that starts with prefix and ends with the provided extension (adds a number in between if needed) :param prefix: file prefix (e.g. “./out”) :type prefix: str :param ext: file extension including ‘.’ (e.g. “.json”) :type ext: str

return (str): file path to use

marky.getChapterAt(cur_cIndex, cur_chapters)

helper function for getting a chapter object at a desired location within a nested list of chapter dicts params:

cur_cIndex: array of indices into cur_chapters cur_chapters: array of chapter dict objects (which individually may or may not have nested chapters (i.e. store their own array of chaper dict objects (which are subchapters))

return: the chapter dict object found at provided cIndex (or None if not found)

marky.jsonToMarkdown(data, chapters=[], omitNotes=False)

creates a markdown representation of a book’s highlights/notes/bookmarks :param data: dict holding data about a book (created with Book.toDict()) :type data: dict :param chapters: (optional) array storing list of book chapters

e.g. [{“loc”: 248, “title”: “CHAPTER 1: The cult of the Head Start”}, …]

Returns

(str) markdown representation of provided book data

marky.main()
marky.updateSettings(bookList, settings=None, useDefaults=False)

ensures that every book in the provided list exists in the settings modifies existing settings if provided or creates default settings to modify params:

bookList: list of ClippyKindle.Book objects for settings to be created for useDefaults (bool): true when we want to default to outputting a md and csv file for each book

otherwise prompt user to choose the group for each book that needs to be added to settings. (Ignored if settings != None)

settings (dict): optional existing settings to modify. If not provided, default settings

are created and modified.

return (dict): settings to use for these books