lnote

Write notes in LaTeX format, directly from the command line. Organize the notes in notebooks. Automatically create a notebook for the current day if no other notebook is selected. View and edit the notes of each day or notebook. Select one or more notebooks or a certain timerange and export them to a PDF file, or merge them into a new notebook.

For lnote to work, you need to create an executable script with the name “lnote”, which is calling the function call(), like this:

>>> import sys, lnote
>>> if __name__ == '__main__':
>>>     sys.exit(lnote.call())

The default data directory is “~/data/lnote”. It can be overwritten by setting the environment variable LNOTE_DIR.

Functions

lnote.create(*args)[source]

Create a notebook.

lnote.listn(*args)[source]

List notebooks.

lnote.rename(*args)[source]

Rename a notebook.

lnote.merge(*args)[source]

Merge several notebooks into another (append all source notebooks to the target notebook). If the target notebook does not exist, create it.

lnote.edit(*args)[source]

Open notebook in a text editor. If multiple notebooks are given, open them side by side.

lnote.delete(*args)[source]

Delete a notebook.

lnote.export(*args)[source]

Export a notebook or selection of notebooks (for now only to PDF format).

lnote.path(*args)[source]

Get path of the directory of a certain notebook.

lnote.view(*args)[source]

View a notebook or a selection of notebooks.

To do: –> add -l/–line option to select a line or a range of lines

lnote.text(*args)[source]

Add text to a notebook. This can be any LaTeX-compatible code.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

lnote.linebreak(*args)[source]

Add a linebreak (an empty line) to a notebook.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

lnote.section(*args)[source]

Add a section to a notebook.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

lnote.paragraph(*args)[source]

Add a titled paragraph to a notebook.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

lnote.equation(*args)[source]

Add an equation to a notebook.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

lnote.figure(*args)[source]

Add a figure to a notebook.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

To do: –> determine size of the graphics file and choose width and height

accordingly
–> do not overwrite existing graphics files (maybe only by option), instead
rename the file
lnote.prune(*args)[source]

Remove the last line of a notebook.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

To do: –> negative numbers remove lines from the beginning of the notebook

lnote.item(*args)[source]

Add a list item to a notebook. If the notebook ends with a list of the chosen type, continue that list.

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

lnote.marginnote(*args)[source]

Add a marginal note to the notebook (using the LaTeX command “marginpar”).

If the selected notebook does not exist, it is created. By default, today’s notebook is used.

Auxiliary functions

lnote.printcols(strlist, ret=False)[source]

Print the strings in the given list in column by column (similar the bash command “ls”), respecting the width of the shell window. If ret is True, give back the resulting string instead of printing it to stdout.

lnote.ceil(x)[source]

Return the ceiling of x. This exists as a substitute for numpy.ceil, to avoid importing the huge numpy module just for this function.

lnote.get_cols()[source]

Try to get the width of the shell window (will only work on Unix systems).

lnote.texpath(notebook)[source]

Return the path to the tex-file of the given notebook.

lnote.dirpath(notebook)[source]

Return the path to the directory of the given notebook.

lnote.append_text(notebook, text)[source]

Append text to the given notebook.

lnote.opt2day(opt)[source]

Convert option string to a certain date. Return as Julian day number (integer).

lnote.opt2days(opt)[source]

Convert option string to a list of dates. Return list of integers (Julian day numbers).

lnote.opt2dayrange(opt)[source]

Convert option string to a timerange. Return as tuple with two integers (JDN1, JDN2+1) (Julian day numbers).

lnote.opt2dayranges(opt)[source]

Convert option string to a list of timeranges. Return as list of tuples with two integers (JDN1, JDN2+1) (Julian day numbers).

lnote.greg2jdn(year, mon, mday)[source]

Convert Gregorian date to Julian day number. Reference: http://en.wikipedia.org/wiki/Julian_Date

lnote.jdn2greg(jdn)[source]

Convert Julian day number to Gregorian date. Reference: http://en.wikipedia.org/wiki/Julian_Date

lnote.date2filename(year, mon, mday)[source]

Convert Gregorian date to filename.

lnote.select_notebook(pattern, forgiving=False)[source]

Select a single notebook based on the given pattern. If forgiving is True, create a new notebook if the given one doesn’t exist. Otherwise, only create a new notebook if pattern is None or empty.

lnote.plural(number)[source]

If abs(number) == 1, return “”, otherwise return “s”. For conveniently appending the plural “s” to words depending on some number.

lnote.get_size(path)[source]

Return total size of a file or directory in bytes.

Reference: http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python

lnote.get_mtime(path)[source]

Return last modification time of a file or all files within a directory tree (in seconds since the epoch).

lnote.call()[source]

This function should be called by an executable file with the following content:

>>> import sys, lnote
>>> if __name__ == '__main__':
>>>     sys.exit(lnote.call())

Exceptions

exception lnote.DayFormatError[source]
exception lnote.DayRangeFormatError[source]
exception lnote.SelectNotebookError[source]

Indices and tables

Table Of Contents

This Page