Skip to content

Overview

This is a command line tool used for retrieving images from various image search backends (e.g. Unsplash, Google). This tool is primarily developed for educational purposes to show people how to develop plugin friendly Python applications. Furthermore, it is an example project that shows how to effectively pair a handful of popular Python libraries to write command line applications.

To facilitate our plugin architecture, the pluggy library is used. Other libraries used include the following:

  • click: used for structuring the command line application ๐Ÿ–ฑ ๐Ÿ’ป
  • pydantic: used for handling configuration file validation ๐Ÿ—ƒ
  • rich: used for UX/UI elements and generally making the application more pretty ๐ŸŒˆ

Why "latz"

"latz" is short and easy to type! This is super important when writing CLI programs. I also might add a geolocation search feature, so it is a reference to the word "latitude".

Quick Start

Installation

latz is available for install either on PyPI:

# Run from a new virtual environment
$ pip install latz

or my own anaconda.org channel:

$ conda create -n latz 'thath::latz'

If you are interested in tinkering around with the code yourself, you can also run it locally:

$ git clone git@github.com:/travishathaway/latz.git
$ cd latz
# Create a virtual environment however you like..
$ pip install -e .

Usage

Latz comes initially configured with the "unsplash" image search backend. To use this, you will need to create an Unsplash account and create a test application. After getting your "access_key", you can set this value by running this command:

$ latz config set search_backend_settings.unsplash.access_key=<YOUR_ACCESS_KEY>

Once this is configured, you can search Unsplash for bunny pictures:

$ latz search "bunny"
โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ #  โ”ƒ Link                                                โ”ƒ  Backend โ”ƒ
โ”กโ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ 1  โ”‚ https://unsplash.com/photos/hcxqLJjI99E/download?iโ€ฆ โ”‚ unsplash โ”‚
โ””โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Configuring

The configuration for latz is stored in your home direct and is in the JSON format. Below is a what a default version of this configuration looks like:

{
  "search_backends": [
    "unsplash"
  ],
  "search_backend_settings": {
    "placeholder": {
      "type": "kitten"
    },
    "unsplash": {
      "access_key": "your-access-key"
    }
  }
}

Latz will also search in your current working directory for a .latz.json file and use this in your configuration. Files in the current working directory will be prioritized over your home directory location.

To see other available image search backends, see Available image search backends below.

Available image search backends

Here are a list of the available search backends:

Built-in

  • "unsplash"
  • "placeholder"

Third-party

How to extend and write your own image search backend

Please see the creating plugins guide in the documentation.