Skip to main content

Python toolkit for the ZWO minilang

Project description

ZWO

PyPI - Python Version PyPI PyPI - License pre-commit.ci status Code style: black Open in Visual Studio Code

Python toolkit for the ZWO minilang.

Installation

Install from PyPi with your favorite pip invocation:

$ pip install zwolang

The ZWO File Specification

The primary purpose of this package is to provide a simple, human-readable format for constructing Zwift workouts that can be used to generate the actual workout XML.

ZWO files are parsed using a Parsimonious grammar, as specified below:

workout   = (block elws*)+ emptyline*
block     = tag ws "{" (((message / value) ","?) / elws)+ "}"
value     = tag ws (string / range / rangeval)

message   = "@" ws duration ws string
range     = rangeval ws "->" ws rangeval
rangeval  = (duration / numeric)

duration  = number ":" number
percent   = number "%"
numeric   = (percent / number)
elws      = (ws / emptyline)

tag       = ~"[A-Z]+"
string    = ~'"[^\"]+"'
number    = ~"\d+"
ws        = ~"\s*"
emptyline = ws+

Syntax & Keywords

Like Zwift's built-in workout builder, the ZWO minilang is a block-based system. Blocks are specified using a <tag> {<block contents>} format supporting arbitrary whitespace.

Each ZWO file must begin with a META block containing comma-separated parameters:

Keyword Description Accepted Inputs Optional?
NAME Displayed workout name str No
AUTHOR Workout author str No
DESCRIPTION Workout description str No
TAGS Workout tags String of comma separated values Yes
FTP Rider's FTP1 int Yes
  1. If specified, the rider's FTP is not used by Zwift directly. It is instead used to optionally normalize the workout's target power percentages to watts

Following the META block are your workout blocks:

Keyword Description
FREE Free ride
INTERVALS Intervals
RAMP Ramp
SEGMENT Steady segment
WARMUP Warmup1
  1. I believe Zwift considers these the same as Ramp intervals, so the ZWO package does the same

Workout blocks can contain the following comma-separated parameters:

Keyword Description Accepted Inputs Optional?
DURATION Block duration MM:SS1 No
CADENCE Target cadence int1 Yes
COUNT Number of intervals int Only valid for intervals
POWER Target power int or int%1 Mostly no2
@ Display a message @ MM:SS str3 Yes
  1. For Interval & Ramp segments, the range syntax can be used to set values for the work/rest segments (e.g. 65% -> 120%)
  2. Power is optional for Free segments
  3. Message timestamps are relative to their containing block

Sample Workout

META {
    NAME "My Workout",
    AUTHOR "Some Author",
    DESCRIPTION "Here's a description!",
    TAGS "super, sweet, workout",
    FTP 270,
}
FREE {DURATION 10:00}
INTERVALS {
    COUNT 3,
    DURATION 1:00 -> 0:30,
    POWER 55% -> 78%,
    CADENCE 85 -> 110,
}
SEGMENT {DURATION 2:00, POWER 65%}
RAMP {
    DURATION 2:00,
    POWER 120% -> 140%,
    @ 0:00 "Here goes the ramp!",
    @ 1:50 "10 seconds left!",
}
FREE {DURATION 10:00}

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

zwolang-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

zwolang-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: zwolang-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Windows/10

File hashes

Hashes for zwolang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 643b4ec6be3fe08a574bad9e6fc710163482f2b5d953f7d51170fcb63e90e074
MD5 0a95b7c00811b70059eb3d6527a310a3
BLAKE2b-256 4318d07a0705cf59466ff3dcf3df2d392bc0edf60781548057fc2636f8acf0a5

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: zwolang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Windows/10

File hashes

Hashes for zwolang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97dd54dab48e141d4d99a89baeaa685891275d34ff2439629edf7e68d915ca88
MD5 76f5fe34a5952a25e64977a85dd78057
BLAKE2b-256 4e9c2f6a2324dd4abb0de5e7126aa21b442cee32f7eea3e573be15a7db6184e3

See more details on using hashes here.

Provenance

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