Added findings of pylint, formatted with yapf

This commit is contained in:
Tobias Schmidl 2020-09-21 08:13:37 +02:00
parent 8f705ab8bc
commit 6b82d02649

View file

@ -1,6 +1,5 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Get apt updates for `argos <https://github.com/p-e-w/argos>`""" """ Get apt updates for `argos <https://github.com/p-e-w/argos>`"""
# <bitbar.title>apt</bitbar.title> # <bitbar.title>apt</bitbar.title>
# <bitbar.version>v1.0</bitbar.version> # <bitbar.version>v1.0</bitbar.version>
@ -11,37 +10,39 @@
# <bitbar.dependencies>python,aptdaemon,apt</bitbar.dependencies> # <bitbar.dependencies>python,aptdaemon,apt</bitbar.dependencies>
# <bitbar.abouturl>https://github.com/schtobia/argos-httping/blob/master/httping.py</bitbar.abouturl> # <bitbar.abouturl>https://github.com/schtobia/argos-httping/blob/master/httping.py</bitbar.abouturl>
from apt import Cache
import sys import sys
from apt import Cache
__author__ = "Tobias Schmidl" __author__ = "Tobias Schmidl"
__copyright__ = "Copyright 2018, Tobias Schmidl" __copyright__ = "Copyright 2018, Tobias Schmidl"
__license__ = "MIT" __license__ = "MIT"
__version__ = "0.0.1" __version__ = "0.0.1"
__maintainer__ = "Tobias Schmidl" __maintainer__ = "Tobias Schmidl"
class Themes: THEMES = {
# Themes are from http://colorbrewer2.org/ # Themes are from http://colorbrewer2.org/
purple_green = ["#762a83", "#9970ab","#c2a5cf","#a6dba0","#5aae61","#1b7837"] "purple_green": ["#762a83", "#9970ab", "#c2a5cf", "#a6dba0", "#5aae61", "#1b7837"],
red_green = ["#d73027", "#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"] "red_green": ["#d73027", "#fc8d59", "#fee08b", "#d9ef8b", "#91cf60", "#1a9850"],
original = ["#acacac","#ff0101","#cc673b","#ce8458","#6bbb15","#0ed812"] "original": ["#acacac", "#ff0101", "#cc673b", "#ce8458", "#6bbb15", "#0ed812"]
selected_colors = red_green }
CURRENT_THEME = THEMES["red_green"]
try: if __name__ == "__main__":
try:
from aptdaemon import client from aptdaemon import client
apt_client = client.AptClient() apt_client = client.AptClient()
apt_client.update_cache(wait=True) apt_client.update_cache(wait=True)
except ImportError as err: except ImportError as err:
print(str(err), file=sys.stderr) print(str(err), file=sys.stderr)
cache = Cache() cache = Cache()
cache.open() cache.open()
update_list = [pkg for pkg in cache if pkg.is_upgradable] update_list = [pkg for pkg in cache if pkg.is_upgradable]
if len(update_list) == 0: if len(update_list) == 0:
print('<span color="' + Themes.selected_colors[5] + '">apt: ✔</span>\n----\nclean | font = monospace') print('<span color="' + CURRENT_THEME[5] + '">apt: ✔</span>\n----\nclean | font = monospace')
sys.exit(0) sys.exit(0)
else: else:
print('<span color="' + Themes.selected_colors[2] + '">apt: ✦ pending</span>\n----') print('<span color="' + CURRENT_THEME[2] + '">apt: ✦ pending</span>\n----')
for pkg in update_list: for pkg in update_list:
print(pkg.name + ": " + pkg.installed.version + "" + pkg.candidate.version + " | font = monospace") print(pkg.name + ": " + pkg.installed.version + "" + pkg.candidate.version + " | font = monospace")