Skip to content

Commit

Permalink
Merge pull request #72 from magmax/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
magmax authored Feb 4, 2022
2 parents 7d60cbf + c8c9d5c commit ece56e0
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 166 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: pre-commit

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# This workflow will upload a Python Package using Twine when a release is
# created
# For more information see:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
31 changes: 0 additions & 31 deletions .github/workflows/python-publish.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/python-test.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# This workflow will install Python dependencies, run tests and lint with a
# variety of Python versions
# For more information see:
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-test.txt
- name: Test with pytest
run: |
pytest
35 changes: 24 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
---
repos:
- repo: https://github.com/PyCQA/isort.git
rev: 5.7.0
- repo: https://github.com/adrienverge/yamllint
rev: v1.26.3
hooks:
- id: isort
- name: check YAML format
id: yamllint
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.1.0
hooks:
- id: black
language_version: python3
args:
- -l
- "119"
- name: re-format with black
id: black
language_version: python3

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- name: remove whitespaces
id: trailing-whitespace

- repo: https://gitlab.com/pycqa/flake8
rev: 6de8252c035844f1e679f509b5f37340b44d5c39
rev: 21d3c70d676007470908d39b73f0521d39b3b997
hooks:
- id: flake8
- name: check-format with flake8
id: flake8
args:
- --show-source
- --statistics
- --count
- --max-complexity=12
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extends: default

rules:
truthy:
ignore: |
.github/workflows/*
indentation:
spaces: 2
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
all: flakes test
all: precommit test

test:
python setup.py test

analysis:: flakes

flakes:
@echo Searching for static errors...
@flake8 --statistics --count readchar

coveralls::
coveralls
precommit::
pre-commit run -a

publish:
@python setup.py bdist_wheel upload
52 changes: 26 additions & 26 deletions readchar/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
ESC = "\x1b"

# CTRL
CTRL_A = '\x01'
CTRL_B = '\x02'
CTRL_C = '\x03'
CTRL_D = '\x04'
CTRL_E = '\x05'
CTRL_F = '\x06'
CTRL_G = '\x07'
CTRL_H = '\x08'
CTRL_I = '\t'
CTRL_J = '\n'
CTRL_K = '\x0b'
CTRL_L = '\x0c'
CTRL_M = '\r'
CTRL_N = '\x0e'
CTRL_O = '\x0f'
CTRL_P = '\x10'
CTRL_Q = '\x11'
CTRL_R = '\x12'
CTRL_S = '\x13'
CTRL_T = '\x14'
CTRL_U = '\x15'
CTRL_V = '\x16'
CTRL_W = '\x17'
CTRL_X = '\x18'
CTRL_Y = '\x19'
CTRL_Z = '\x1a'
CTRL_A = "\x01"
CTRL_B = "\x02"
CTRL_C = "\x03"
CTRL_D = "\x04"
CTRL_E = "\x05"
CTRL_F = "\x06"
CTRL_G = "\x07"
CTRL_H = "\x08"
CTRL_I = "\t"
CTRL_J = "\n"
CTRL_K = "\x0b"
CTRL_L = "\x0c"
CTRL_M = "\r"
CTRL_N = "\x0e"
CTRL_O = "\x0f"
CTRL_P = "\x10"
CTRL_Q = "\x11"
CTRL_R = "\x12"
CTRL_S = "\x13"
CTRL_T = "\x14"
CTRL_U = "\x15"
CTRL_V = "\x16"
CTRL_W = "\x17"
CTRL_X = "\x18"
CTRL_Y = "\x19"
CTRL_Z = "\x1a"

# ALT
ALT_A = "\x1b\x61"
Expand Down
9 changes: 4 additions & 5 deletions readchar/readchar.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
20960: key.PAGE_DOWN,
18400: key.HOME,
20448: key.END,
18432: key.UP, # 72 * 256
20480: key.DOWN, # 80 * 256
19200: key.LEFT, # 75 * 256
19712: key.RIGHT, # 77 * 256
18432: key.UP, # 72 * 256
20480: key.DOWN, # 80 * 256
19200: key.LEFT, # 75 * 256
19712: key.RIGHT, # 77 * 256
}

def readkey(getchar_fn=None):
Expand All @@ -79,7 +79,6 @@ def readkey(getchar_fn=None):
else:
return ch.decode()


else:

def readkey(getchar_fn=None):
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand

version = "2.0.1"
github_ref = os.getenv("GITHUB_REF")
if github_ref and github_ref.startswith("refs/tags"):
version = github_ref[10:]
else:
version = "0.0.0-local"


def read_description():
Expand Down Expand Up @@ -81,7 +82,5 @@ def run_tests(self):
"wheel",
],
install_requires=[],
setup_requires=[
"flake8",
],
setup_requires=[],
)

0 comments on commit ece56e0

Please sign in to comment.