From f577bd2bf9eeb972e7a37e9aceb64af758e9354b Mon Sep 17 00:00:00 2001 From: schroeji Date: Mon, 21 Sep 2015 13:08:05 +0200 Subject: [PATCH] Added aur_only mode for yaourt backend --- i3pystatus/updates/yaourt.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/i3pystatus/updates/yaourt.py b/i3pystatus/updates/yaourt.py index 9d68455..50a4770 100644 --- a/i3pystatus/updates/yaourt.py +++ b/i3pystatus/updates/yaourt.py @@ -1,18 +1,25 @@ """ This module counts the available updates using yaourt. -You should not use it together with the pacman backend otherwise -some packeges might be counted twice. +By default it will only count aur packages. +If you want to count both pacman and aur packages set the variable +count_only_aur = False """ - +import re from i3pystatus.core.command import run_through_shell from i3pystatus.updates import Backend class Yaourt(Backend): - + def __init__(self, aur_only = True): + self.aur_only = aur_only + @property + def updates(self): command = ["yaourt", "-Qua"] checkupdates = run_through_shell(command) - return checkupdates.out.count('\n') + if(self.aur_only): + return len( re.findall("^aur/", checkupdates.out, flags=re.M) ) + return checkupdates.out.count("\n") + Backend = Yaourt