Skip to content

Commit dcdfbb3

Browse files
committed
Use ruff format across files
1 parent 248f89b commit dcdfbb3

File tree

9 files changed

+184
-105
lines changed

9 files changed

+184
-105
lines changed

Makefile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
NAME = $(shell basename $(CURDIR))
22
PYNAME = $(subst -,_,$(NAME))
3+
PYFILES = $(PYNAME)/*.py $(PYNAME)/*/*.py
34

45
check:
5-
ruff check .
6-
vermin -vv --exclude importlib.metadata --no-tips -i */*.py */*/*.py
7-
8-
build:
9-
rm -rf dist
10-
python3 -m build
6+
ruff check $(PYFILES)
7+
mypy $(PYFILES)
8+
vermin -vv --exclude importlib.metadata --exclude tomllib \
9+
--no-tips -i $(PYFILES)
1110

1211
upload: build
1312
twine3 upload dist/*
1413

14+
build:
15+
rm -rf dist
16+
python3 -m build --sdist --wheel
17+
1518
doc:
1619
update-readme-usage
1720

21+
format:
22+
ruff check --select I --fix $(PYFILES) && ruff format $(PYFILES)
23+
1824
clean:
19-
@rm -vrf *.egg-info */*.egg-info .venv/ build/ dist/ __pycache__/ \
20-
*/__pycache__ */*/__pycache__
25+
@rm -vrf *.egg-info build/ dist/ __pycache__/ \
26+
*/__pycache__ */*/__pycache__

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ See the [current parsers](pkglog/parsers) for example code.
8383
Type `pkglog -h` to view the usage summary:
8484

8585
```
86-
usage: pkglog [-h] [-u | -i | -I | -n] [-N INSTALLED_NET_DAYS]
87-
[-d DAYS | -a | -b] [-j] [-v] [-c]
88-
[-p {pacman,zypper,apt,dnf} | -f PARSER_PLUGIN]
89-
[-t TIMEGAP] [-P PATH] [-g | -r] [-V]
86+
usage: pkglog [-h] [-u | -i | -I | -n] [-N INSTALLED_NET_DAYS] [-d DAYS |
87+
-a | -b] [-j] [-v] [-c] [-p {pacman,zypper,apt,dnf} |
88+
-f PARSER_PLUGIN] [-t TIMEGAP] [-P PATH] [-g | -r] [-V]
9089
[package ...]
9190
9291
Reports concise log of package changes.
@@ -100,10 +99,10 @@ options:
10099
-i, --installed show installed/removed only
101100
-I, --installed-only show installed only
102101
-n, --installed-net show net installed only
103-
-N INSTALLED_NET_DAYS, --installed-net-days INSTALLED_NET_DAYS
102+
-N, --installed-net-days INSTALLED_NET_DAYS
104103
days previously removed before being re-considered as
105104
new net installed, default=2. Set to 0 to disable.
106-
-d DAYS, --days DAYS show all packages only from given number of days ago,
105+
-d, --days DAYS show all packages only from given number of days ago,
107106
or from given YYYY-MM-DD[?HH:MM[:SS]],
108107
default=30(days), 0=today, -1=all. If only time is
109108
specified, then today is assumed.
@@ -112,13 +111,13 @@ options:
112111
-j, --nojustify don't right justify version numbers
113112
-v, --verbose be verbose, describe upgrades/downgrades
114113
-c, --no-color do not color output lines
115-
-p {pacman,zypper,apt,dnf}, --parser {pacman,zypper,apt,dnf}
114+
-p, --parser {pacman,zypper,apt,dnf}
116115
log parser type, default=pacman
117-
-f PARSER_PLUGIN, --parser-plugin PARSER_PLUGIN
116+
-f, --parser-plugin PARSER_PLUGIN
118117
path to alternate custom parser plugin file
119-
-t TIMEGAP, --timegap TIMEGAP
118+
-t, --timegap TIMEGAP
120119
max minutes gap between grouped changes, default=2
121-
-P PATH, --path PATH alternate log path[s] (separate multiple using ":",
120+
-P, --path PATH alternate log path[s] (separate multiple using ":",
122121
must be time sequenced)
123122
-g, --glob given package name[s] is glob pattern to match
124123
-r, --regex given package name[s] is regular expression to match

pkglog/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from sys import exit
2+
23
from . import pkglog
4+
35
if __name__ == '__main__':
46
exit(pkglog.main())

pkglog/parsers/apt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/python3
2-
'Parse Debian/Ubuntu APT log messages'
2+
"Parse Debian/Ubuntu APT log messages"
3+
34
import re
45
from datetime import datetime
56

@@ -13,10 +14,12 @@
1314
'Reinstall': 'reinstalled',
1415
}
1516

17+
1618
class g:
1719
action = None
1820
line = None
1921

22+
2023
def get_time(line):
2124
vals = line.split(':', maxsplit=1)
2225
if len(vals) != 2:
@@ -40,6 +43,7 @@ def get_time(line):
4043
g.line = rest[1:]
4144
return None
4245

46+
4347
def get_packages():
4448
if g.action:
4549
for pline in g.line.strip().split('),'):

pkglog/parsers/dnf.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/python3
2-
'Parse RedHat/Fedora DNF log messages'
2+
"Parse RedHat/Fedora DNF log messages"
3+
34
import re
45
from datetime import datetime
56

@@ -14,9 +15,11 @@
1415
'Reinstalled': ('reinstalled', 0),
1516
}
1617

18+
1719
class g:
18-
vers = {}
19-
pkgs = None
20+
vers = {} # type: ignore
21+
pkgs = None # type: ignore
22+
2023

2124
def get_time(line):
2225
fields = line.split(maxsplit=3)
@@ -49,7 +52,7 @@ def get_time(line):
4952
if index < 0:
5053
dts = dts.replace('Z', '+00:00')
5154
else:
52-
dts = dts[:index + 3] + ':' + dts[index + 3:]
55+
dts = dts[: index + 3] + ':' + dts[index + 3 :]
5356

5457
# Return the logged time in localtime
5558
try:
@@ -59,5 +62,6 @@ def get_time(line):
5962

6063
return dt
6164

65+
6266
def get_packages():
6367
yield g.pkgs

pkglog/parsers/pacman.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#!/usr/bin/python3
2-
'Parse Arch Linux pacman log messages'
2+
"Parse Arch Linux pacman log messages"
3+
34
import sys
45
from datetime import datetime
56

67
logfile = '/var/log/pacman.log'
78

89
LINETYPES = {'[ALPM]', '[PACMAN]'}
910

11+
1012
class g:
1113
line = None
1214

15+
1316
def get_time(line):
1417
# Handle old format pacman logs
1518
if len(line) > 11 and line[11] == ' ':
@@ -43,6 +46,7 @@ def get_time(line):
4346
# We also convert the logged time to localtime
4447
return dt.astimezone().replace(tzinfo=None)
4548

49+
4650
def get_packages():
4751
try:
4852
res = g.line.strip().split(maxsplit=2)

pkglog/parsers/zypper.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
#!/usr/bin/python3
2-
'Parse OpenSUSE zypper log format'
2+
"Parse OpenSUSE zypper log format"
3+
34
import sys
45
from datetime import datetime
56

67
# User may want to chmod 755 the "/var/log/zypp" directory so they can
78
# run this tool as normal user.
89
logfile = '/var/log/zypp/history'
910

10-
_pkgs = {}
11+
_pkgs = {} # type: ignore
12+
1113

1214
class g:
1315
pkg = None
1416
vers = None
1517
oldvers = None
1618
removed = None
1719

20+
1821
def get_time(line):
1922
vals = line.split('|', maxsplit=4)
2023
if len(vals) < 4:
@@ -43,12 +46,14 @@ def get_time(line):
4346

4447
return dt
4548

49+
4650
def get_packages():
4751
try:
48-
from looseversion import LooseVersion as Version
52+
from looseversion import LooseVersion as Version # type: ignore
4953
except Exception:
50-
sys.exit('Error: Need to install Python looseversion package to use '
51-
'zypper parsing.')
54+
sys.exit(
55+
'Error: Need to install Python looseversion package to use zypper parsing.'
56+
)
5257

5358
if g.removed:
5459
action = 'removed'

0 commit comments

Comments
 (0)