Skip to content

Commit

Permalink
pre-commit: add ruff format to the pre-commit files
Browse files Browse the repository at this point in the history
  • Loading branch information
whot committed Oct 23, 2024
1 parent 6816a1d commit c8cd827
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ repos:
hooks:
- id: ruff
args: ['--ignore=E741,E501']
- id: ruff-format
4 changes: 3 additions & 1 deletion test/test_libwacom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def add_to_config(self, config: ConfigParser):

@classmethod
def generic_pen(cls) -> "StylusEntry":
return cls(id="0x0:0xfffff", name="General Pen", paired_stylus_ids=["0x0:0xffffe"])
return cls(
id="0x0:0xfffff", name="General Pen", paired_stylus_ids=["0x0:0xffffe"]
)

@classmethod
def generic_eraser(cls) -> "StylusEntry":
Expand Down
15 changes: 9 additions & 6 deletions tools/clean_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,12 @@ def clean_svg(root, tabletname):
if __name__ == "__main__":
parser = ArgumentParser(description="Clean SVG files for libwacom")
parser.add_argument(
"--ignore-missing", action="store_true", default=False, help="Ignore .tablet files without a Layout"
)
parser.add_argument(
"filename", type=str, help="SVG file to clean", metavar="FILE"
"--ignore-missing",
action="store_true",
default=False,
help="Ignore .tablet files without a Layout",
)
parser.add_argument("filename", type=str, help="SVG file to clean", metavar="FILE")
parser.add_argument(
"tabletname",
type=str,
Expand All @@ -321,17 +322,19 @@ def clean_svg(root, tabletname):
tabletname = args.tabletname
if args.filename.endswith(".tablet"):
import configparser

config = configparser.ConfigParser()
config.read(args.filename)
try:
svgname = config["Device"]["Layout"]
except KeyError:
print(f"{args.filename} does not specify a layout, skipping", file=sys.stderr)
print(
f"{args.filename} does not specify a layout, skipping", file=sys.stderr
)
sys.exit(0 if args.ignore_missing else 77)
svgfile = Path(args.filename).parent / "layouts" / svgname
tabletname = config["Device"]["Name"]


ET.register_namespace("", NAMESPACE)
try:
tree = ET.parse(svgfile)
Expand Down
12 changes: 6 additions & 6 deletions tools/show-stylus.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@


class Ansi:
clearline = "\x1B[K"
clearline = "\x1b[K"

@classmethod
def up(cls, count):
return f"\x1B[{count}A"
return f"\x1b[{count}A"

@classmethod
def down(cls, count):
return f"\x1B[{count}B"
return f"\x1b[{count}B"

@classmethod
def right(cls, count):
return f"\x1B[{count}C"
return f"\x1b[{count}C"

@classmethod
def left(cls, count):
return f"\x1B[{count}D"
return f"\x1b[{count}D"


def die(msg):
Expand Down Expand Up @@ -161,7 +161,7 @@ def load_data_files():
if len(ids) > 1:
_, sid = map(lambda x: int(x, 16), ids)
else:
_ = 0x56a # vid
_ = 0x56A # vid
sid = int(ids[0], 16)
# FIXME: vendor should be used here, let's do that when we figure out
# who needs it.
Expand Down

0 comments on commit c8cd827

Please sign in to comment.