Skip to main content

Stroke handling helper library for Plover

Project description

Plover Stroke

Helper class for working with steno strokes.

Usage:

# Setup:

from plover_stroke import BaseStroke

class Stroke(BaseStroke):
     pass

Stroke.setup(
    # System keys.
    '''
    #
    S- T- K- P- W- H- R-
    A- O-
    *
    -E -U
    -F -R -P -B -L -G -T -S -D -Z
    '''.split(),
    # Implicit hyphen keys (optional, automatically
    # deduced from system keys if not passed).
    'A- O- * -E -U'.split(),
    # Number bar key and numbers keys (optional).
    '#', {
    'S-': '1-',
    'T-': '2-',
    'P-': '3-',
    'H-': '4-',
    'A-': '5-',
    'O-': '0-',
    '-F': '-6',
    '-P': '-7',
    '-L': '-8',
    '-T': '-9',
    })

# Creating strokes:

Stroke(56)
# => KPW
Stroke(('-F', 'S-', '-S', 'A-', '*')) 
# => SA*FS
Stroke('R-')
# => R
Stroke('L-')
# => invalid, raise a ValueError

# Methods:

s = Stroke('STK')

s.keys()
# => ('S-', 'T-', 'K-')
s.is_number()
# => False
int(s)
# => 14
s == 0b00000000000000000001110
# => True

# Strokes can be compared:
sorted(map(Stroke, 'AOE ST-PB *Z # R-R'.split()))
# => [#, ST-PB, R-R, AOE, *Z]

Release history

1.1.0

  • add feral_number_key support: when set to True, allow the number key letter anywhere when parsing steno (e.g. 18#, #18, and 1#8 are all valid and equivalent, as per the RTF/CRE spec).

1.0.1

  • fix exception in case of invalid keys mask

1.0.0

  • drop Stroke.xrange and Stroke.xsuffixes methods
  • Stroke.keys() now return a tuple
  • fix corner case when parsing steno (RR -> R-R)
  • fix RTFCRE when numbers are involved (align with Plover's behavior)
  • fix implicit hyphen handling when numbers are involved
  • renamed Stroke.isnumber to Stroke.is_number
  • speed up implementation through a C extension

0.4.0

  • fix stroke comparison

0.3.3

  • fix python_requires package metadata

0.3.2

  • first public release

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

plover_stroke-1.1.0.tar.gz (16.2 kB view hashes)

Uploaded Source

Built Distributions

plover_stroke-1.1.0-cp310-cp310-win_amd64.whl (16.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

plover_stroke-1.1.0-cp310-cp310-musllinux_1_1_x86_64.whl (18.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

plover_stroke-1.1.0-cp310-cp310-musllinux_1_1_i686.whl (20.9 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

plover_stroke-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

plover_stroke-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl (15.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

plover_stroke-1.1.0-cp39-cp39-win_amd64.whl (16.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

plover_stroke-1.1.0-cp39-cp39-musllinux_1_1_x86_64.whl (18.5 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

plover_stroke-1.1.0-cp39-cp39-musllinux_1_1_i686.whl (20.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

plover_stroke-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

plover_stroke-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl (15.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

plover_stroke-1.1.0-cp38-cp38-win_amd64.whl (17.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

plover_stroke-1.1.0-cp38-cp38-musllinux_1_1_x86_64.whl (18.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

plover_stroke-1.1.0-cp38-cp38-musllinux_1_1_i686.whl (21.1 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

plover_stroke-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

plover_stroke-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl (17.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

plover_stroke-1.1.0-cp37-cp37m-win_amd64.whl (17.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

plover_stroke-1.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl (18.8 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

plover_stroke-1.1.0-cp37-cp37m-musllinux_1_1_i686.whl (21.2 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

plover_stroke-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

plover_stroke-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (17.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

plover_stroke-1.1.0-cp36-cp36m-win_amd64.whl (17.5 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

plover_stroke-1.1.0-cp36-cp36m-musllinux_1_1_x86_64.whl (18.4 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ x86-64

plover_stroke-1.1.0-cp36-cp36m-musllinux_1_1_i686.whl (20.8 kB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ i686

plover_stroke-1.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

plover_stroke-1.1.0-cp36-cp36m-macosx_10_9_x86_64.whl (17.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

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