Skip to content

Commit

Permalink
Say it with me - linter and stuff!
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rn3j committed Sep 17, 2024
1 parent 7c17048 commit 6b98df9
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 39 deletions.
20 changes: 10 additions & 10 deletions scc/lib/daemon.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/usr/bin/env python3

"""Generic linux daemon base class"""
"""Generic linux daemon base class."""

# Adapted from http://www.jejik.com/files/examples/daemon3x.py
# thanks to the original author

import sys
import os
import time
import atexit
import os
import signal
import sys
import syslog
import time


class Daemon(object):
"""A generic daemon class.
Usage: subclass the daemon class and override the run() method."""
Usage: subclass the daemon class and override the run() method.
"""

def __init__(self, pidfile):
self.pidfile = pidfile

def daemonize(self):
"""Deamonize class. UNIX double fork mechanism."""

try:
pid = os.fork()
if pid > 0:
Expand Down Expand Up @@ -115,7 +114,7 @@ def start(self):

def on_start(self):
pass

def stop(self, once=False):
"""Stop the daemon."""

Expand Down Expand Up @@ -162,4 +161,5 @@ def run(self):
"""You should override this method when you subclass Daemon.
It will be called after the process has been daemonized by
start() or restart()."""
start() or restart().
"""
4 changes: 1 addition & 3 deletions scc/lib/jsonencoder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Copied directly from python because I can't find way how to override
_iterencode_list, function burried in 7th level of hell.
"""Copied directly from python because I can't find way how to override _iterencode_list, function burried in 7th level of hell.
Only idea here is to have lists encoded in single line.
"""
Expand Down
11 changes: 5 additions & 6 deletions scc/lib/vdf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
"""
VDF file reader
"""VDF file reader.
Copyright (C) 2017 Kozec
This program is free software; you can redistribute it and/or modify
Expand All @@ -16,16 +15,16 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
import os, sys, importlib
import vdf


def parse_vdf(file):
return vdf.parse(file, mapper=vdf.VDFDict, merge_duplicate_keys=False)


def ensure_list(value):
"""
If value is list, returns same value.
"""If value is list, returns same value.
Otherwise, returns [ value ]
"""
return value if type(value) == list else [ value ]
Expand Down
5 changes: 1 addition & 4 deletions scc/lib/xinput.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
XInput tools
"""XInput tools.
Interfaces with XInput by calling `xinput` command.
Currently allows only querying list of xinput devices and floating them.
Expand Down
32 changes: 22 additions & 10 deletions scc/lib/xwrappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python3
"""
Python wrapper for some X-related stuff.
"""Python wrapper for some X-related stuff.
Copyright (C) 2017 Kozec
Expand All @@ -18,9 +16,23 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""

from ctypes import CDLL, POINTER, c_void_p, Structure, byref, cast
from ctypes import c_long, c_ulong, c_int, c_uint, c_short
from ctypes import c_ushort, c_ubyte, c_char_p, c_bool
from ctypes import (
CDLL,
POINTER,
Structure,
byref,
c_bool,
c_char_p,
c_int,
c_long,
c_short,
c_ubyte,
c_uint,
c_ulong,
c_ushort,
c_void_p,
cast,
)


def _load_lib(*names):
Expand Down Expand Up @@ -308,7 +320,7 @@ def get_mouse_pos(dpy, relative_to=None):
x, y = c_int(), c_int()
child_x, child_y = c_int(), c_int()
mask = c_uint()

query_pointer(dpy, relative_to, byref(root_return), byref(child),
byref(x), byref(y),
byref(child_x), byref(child_y), byref(mask))
Expand Down Expand Up @@ -338,7 +350,7 @@ def get_window_prop(dpy, window, prop_name, max_size=2):
type_return, format_return = Atom(), Atom()
nitems, bytes_after = c_ulong(), c_ulong()
prop = c_void_p()

if SUCCESS == get_window_property(dpy, window,
prop_atom, 0, max_size, False, ANYPROPERTYTYPE,
byref(type_return), byref(format_return), byref(nitems),
Expand All @@ -358,7 +370,7 @@ def get_current_window(dpy):
rv = cast(prop, POINTER(Atom)).contents.value
free(prop)
return rv

# Fall-back to something what probably can't work anyway
win, revert_to = XID(), c_int()
get_input_focus(dpy, byref(win), byref(revert_to))
Expand Down Expand Up @@ -407,7 +419,7 @@ def get_window_class(dpy, window):
free(s)
return value
free(s)

return None, None


Expand Down
4 changes: 3 additions & 1 deletion scc/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
from math import pi as PI, sqrt, copysign, atan2, sin, cos
from collections import OrderedDict, deque

import time, logging, inspect
import time
import logging
import inspect
import itertools
log = logging.getLogger("Modifiers")
_ = lambda x : x
Expand Down
5 changes: 1 addition & 4 deletions scc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ def _parse_parameter(self):
t = self._next_token()
if not hasattr(parameter, t.value):
raise ParseError("%s has no attribute '%s'" % (parameter, t.value,))
if type(parameter) is EnumType:
parameter = parameter[t.value]
else: # This will never happen -> why?
raise ParseError("This should not have happened, how did we get here?")
parameter = getattr(parameter, t.value)

# Check for ranges (<, >, <=, >=)
if self._tokens_left() and self._peek_token().type == TokenType.OP:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_profile/test_modeshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_146_2(self):
},
})

assert a.to_string() == test_string
assert isinstance(a, ModeModifier)
assert a.to_string() == test_string
assert isinstance(a.default, RotateInputModifier)
sens = a.default.action
assert isinstance(sens, SensitivityModifier)
Expand Down

0 comments on commit 6b98df9

Please sign in to comment.