Skip to content

Commit

Permalink
Merge pull request #2482 from Holzhaus/pre-commit-python
Browse files Browse the repository at this point in the history
pre-commit: Add hooks for Python
  • Loading branch information
daschuer authored Feb 13, 2020
2 parents a73cf04 + 0039095 commit 14615ee
Show file tree
Hide file tree
Showing 9 changed files with 1,133 additions and 496 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
# E203 is not PEP8 compliant and is not compatible with black:
# https://black.readthedocs.io/en/stable/the_black_code_style.html#slices
# W503 conflicts with black, too.
ignore = E203,W503
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ repos:
stages:
- commit
- manual
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
files: ^scripts/.*$
- repo: https://gitlab.com/pycqa/flake8
rev: '3.7.9'
hooks:
- id: flake8
files: ^scripts/.*$
- repo: local
hooks:
- id: qsscheck
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 79
28 changes: 15 additions & 13 deletions scripts/audioplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

def createSlice(columns):
"""convert an input string into a slice object"""
if columns == 'all':
if columns == "all":
return slice(None)
else:
# creates a numpy array
return np.int64(columns.split(','))
# creates a numpy array
return np.int64(columns.split(","))


def combine_files(files):
Expand All @@ -23,7 +22,7 @@ def combine_files(files):
raw = []
min_len = sys.maxsize # max integer
for fname in files:
raw.append(np.genfromtxt(fname, delimiter=','))
raw.append(np.genfromtxt(fname, delimiter=","))
min_len = min(len(raw[-1]), min_len)
data = raw[0][:min_len]

Expand All @@ -43,7 +42,7 @@ def AudioPlot(files, slice):

def parseArguments():
p = argparse.ArgumentParser(
prog='AudioPlot',
prog="AudioPlot",
formatter_class=argparse.RawDescriptionHelpFormatter,
description="""
Audioplot is a simple script for drawing graphs of values. It reads a simple
Expand All @@ -60,13 +59,16 @@ def parseArguments():
This script is useful to compare the sample files produced by the engine test
of mixxx-test with the golden sample files.
""")
p.add_argument('files', type=str, nargs='+', help='file to plot from')
p.add_argument('-c',
'--columns',
type=str,
default='all',
help='lines to plot separated by a comma, default "all"')
""",
)
p.add_argument("files", type=str, nargs="+", help="file to plot from")
p.add_argument(
"-c",
"--columns",
type=str,
default="all",
help='lines to plot separated by a comma, default "all"',
)
return p.parse_args()


Expand Down
Loading

0 comments on commit 14615ee

Please sign in to comment.