Skip to main content

A Python implementation of a Regex Crossword in the terminal.

Project description

Regex Crossword

License: MIT PyPI pyversions PyPI version fury.io Code style: black

Terminal Freaks rejoice!

Based on the Regex Crossword, this is an implementation written in pure python using only the standard library to play the game offline entirely from your shell.

If you aren't familiar with the concpet of a regex crossword, it's a blank crossword grid that you need to fill so that each row and column will match the specified regex. It's a fun exercise to your regex abilities and an interactive way to learn about them and practice while playing.

I'm a bit of a terminal freak myself and so the moment I started playing the wonderful online version it seemed so natural to me that there needs to be a version of the concept playable from the shell, so I made one using nothing but Python's curses module.

Installation

Use the Python package manager pip to install regex_crossword.

pip install regex_crossword

To install the scraper functionality as well (more on this below) use:

pip install regex_crossword[scraper]

Note: the scraper uses the Selenium 3rd party package that might need extra setup to be used (specifically the Chrome WebDriver). If you encounter any problems I advise you to check out their installation guide.

Usage

Once installed in your environment, simply type regex_crossword from your terminal and start playing!

Loading level packs

When the game starts it will attempt to load "level packs" for it to use. It looks for them in the following places in descending order:

  1. First, it will look wherever the --level-packs option was pointing when invoking the game command (for a full list of all commands use the -h or --help flag).
  2. If no option was specified, it will look wherever the REGEXCW_LEVEL_PACKS environment variable is pointing, if it exists.
  3. Lastly and by default, it will search for a directory called level_packs in the current working directory.

If all of this fails (or the directory has no packs), an error will pop up informing you no level packs were found.

Getting level packs

When trying to get level packs you have several options:

  • Use the --scrape flag (this requires you to install the scraper extra). This will scrape some online resources and create level packs based on them for you to load into the offline version.
  • Create your own level packs!

Creating your own level packs

Level packs are simply JSON files who follow this format:

[
    {
        "title": "Beatles",
        "up_to_down": [
            "[^SPEAK]+",
            "EP|IP|EF"
        ],
        "left_to_right": [
            "HE|LL|O+",
            "[PLEASE]+"
        ],
    },
    {
        "title": "Pisco Sour",
        "up_to_down": [
            "(MA|LM)",
            "[^MESH]+"
        ],
        "left_to_right": [
            "[LINE]+",
            "[LAM]+"
        ],
        "right_to_left": [
            "[ISLE]+",
            "[MALE]+"
        ],
        "down_to_up": [
            "[LAME]*",
            "[^LES]+"
        ]
    },
]

The main file json is a list of smaller dictionaries who each implement a "level" format:

  • title - the title of the level.
  • up_to_down - the regexes who will attempt to match the columns from top to bottom (specified from left to right)
  • left_to_right - the regexes who will attempt to match the rows from left to right (specified from top to bottom)
  • down_to_up - same as up_to_down but will attempt to match the columns from bottom to top.
  • right_to_left - same as left_to_right but will attempt to match the rows from right to left.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

regex_crossword-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

regex_crossword-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file regex_crossword-0.1.0.tar.gz.

File metadata

  • Download URL: regex_crossword-0.1.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8

File hashes

Hashes for regex_crossword-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12a64b5e0f1a2a78793707d8fb65184be6908f5c8b81f3602925892dfaa761ba
MD5 44e50fe32cd43bd7c58f8fd96d652d3e
BLAKE2b-256 6c8c9ad49310099099c5ecb5d70a39f66161a9eea9d0699b226c442bb3f48cab

See more details on using hashes here.

File details

Details for the file regex_crossword-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: regex_crossword-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.8

File hashes

Hashes for regex_crossword-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3687eb3040de38920fa95139b0811038caf83aa176900c2ec59c0beb68e61848
MD5 222e5325bba75d777a967470243ef75f
BLAKE2b-256 a35b884afcb245013b80fad21368593f1a65046b6c6e0d5900ce63a935103280

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page