lesana.command module

class lesana.command.Command(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

add_arguments(parser: ArgumentParser)[source]

Add argparse arguments to an existing parser.

Override this method to add arguments to a subcommand.

class lesana.command.Edit(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command, ExternalEditorMixin

Edit a lesana entry

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--no-git'], {'help': "Don't add the new entry to git", 'action': 'store_false', 'dest': 'git'}), (['eid'], {'help': 'eid of an entry to edit'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.Export(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

Export entries to a different collection

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--query', '-q'], {'help': 'Xapian query to search in the collection'}), (['destination'], {'help': 'The collection to export entries to'}), (['template'], {'help': 'Template to convert entries'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.GetValues(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

List all values for one field, with entry counts.

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--field', '-f'], {'help': 'Name of the field', 'required': True}), (['--template', '-t'], {'help': 'Template to use when displaying results'}), (['query'], {'help': 'Xapian query to limit the count search "                       + "in the collection', 'nargs': '*', 'default': '*'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

name: Optional[str] = 'get-values'

The name used to call this subcommand from the command line.

If this property is none, the default is the name of the class set to lowercase.

class lesana.command.Index(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

Index entries in a lesana collection

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--reset'], {'action': 'store_true', 'help': 'Delete the existing index and reindex from scratch.'}), (['files'], {'help': 'List of files to index (default: everything)', 'default': None, 'nargs': '*'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.Init(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command, ExternalEditorMixin

Initialize a lesana collection

arguments = [(['--collection', '-c'], {'help': 'The directory to work on (default .)', 'default': '.'}), (['--no-git'], {'help': 'Skip setting up git in this directory', 'action': 'store_false', 'dest': 'git'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.Lesana[source]

Bases: MainCommand

Manage collections

commands: Iterable['Command'] = (<lesana.command.New object>, <lesana.command.Edit object>, <lesana.command.Show object>, <lesana.command.Index object>, <lesana.command.Search object>, <lesana.command.GetValues object>, <lesana.command.Update object>, <lesana.command.Export object>, <lesana.command.Init object>, <lesana.command.Remove object>)

The subcommands: a tuple of Command subclasses.

class lesana.command.New(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command, ExternalEditorMixin

Create a new entry

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--no-git'], {'help': "Don't add the new entry to git", 'action': 'store_false', 'dest': 'git'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.Remove(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

Remove an entry from a collection

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['entries'], {'help': 'List of entries to remove', 'nargs': '+'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

name: Optional[str] = 'rm'

The name used to call this subcommand from the command line.

If this property is none, the default is the name of the class set to lowercase.

class lesana.command.Search(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

Search for entries

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--template', '-t'], {'help': 'Template to use when displaying results'}), (['--offset'], {'type': <class 'int'>}), (['--pagesize'], {'type': <class 'int'>}), (['--all'], {'action': 'store_true', 'help': 'Return all available results'}), (['--sort'], {'action': 'append', 'help': 'Sort results by a sortable field'}), (['--expand-query-template', '-e'], {'action': 'store_true', 'help': 'Render search_aliases in the query as a jinja2 template'}), (['query'], {'help': 'Xapian query to search in the collection', 'nargs': '*', 'default': '*'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.Show(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

Show a lesana entry

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--template', '-t'], {'help': 'Use the specified template to display results.'}), (['eid'], {'help': 'eid of an entry to edit'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

class lesana.command.Update(collection_class=<class 'lesana.collection.Collection'>, entry_class=<class 'lesana.collection.Entry'>)[source]

Bases: Command

Update a field in multiple entries

arguments = [(['--collection', '-c'], {'help': 'The collection to work on (default .)'}), (['--field', '-f'], {'help': 'The field to change'}), (['--value', '-t'], {'help': 'The value to set'}), (['query'], {'help': 'Xapian query to search in the collection', 'nargs': '+'})]
main()[source]

Main code of this subcommand.

Override this method to implement the actual program.

lesana.command.main()[source]