]> gitweb.pimeys.fr Git - today.git/blobdiff - today.py
def exists ? U know, any is implemented in python -_-
[today.git] / today.py
index 80d05fb3caef6e0c5e675307c023c65e1b9d37e0..4522d0770e02e0f7e0fc561afbb72d487bc97650 100755 (executable)
--- a/today.py
+++ b/today.py
@@ -110,13 +110,6 @@ def get_timers():
     timers = add_title(u"Timers", timers)
     return timers
 
-def exists(l):
-    """Renvoie True si au moins un élément de l est vrai"""
-    for i in l:
-        if i:
-            return True
-    return False
-
 def get_birthdays(*search):
     """Obtenir la liste des anniversaires à venir,
        ou la liste des anniversaires correspondants à une recherche"""
@@ -143,7 +136,7 @@ def get_birthdays(*search):
         search = [i.lower() for i in search]
         tous = ("--all" in search)
         for date, nom in liste:
-            if tous or exists([term.lower() in nom.lower() for term in search]):
+            if tous or any([term.lower() in nom.lower() for term in search]):
                 thisyeardate = datetime.datetime(now.year, date.month, date.day)
                 delta = thisyeardate - now + datetime.timedelta(1)
                 age = now.year - date.year
@@ -194,7 +187,7 @@ def get_saints():
     for day in ["today", "tomorrow"]:
         ssaints = saints[day]
         for (sexe, saint) in ssaints:
-            if exists([firstname.lower() in saint.lower().split() for firstname in firstnames]):
+            if any([firstname.lower() in saint.lower().split() for firstname in firstnames]):
                 towish[day].append(sexe + saint)
     ttowish = []
     if towish["today"]:
@@ -235,7 +228,7 @@ def get_dtc(*args):
         cmd = "~/bin/dtc %s %s --json" % (args[0], args[1])
     else:
         return None
-    proc = subprocess.Popen(["ssh", config.distant_server, cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    proc = subprocess.Popen(["ssh", "-4", config.distant_server, cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     out, err = proc.communicate()
     out += err
     quotes = json.loads(out)
@@ -292,7 +285,7 @@ THINGS = {
 def check_all():
     """Vérifie si il y a des derniers trucs non lus/vus."""
     cmd = "%s whatsup" % (config.path_today_server,)
-    proc = subprocess.Popen(["ssh", config.distant_server, cmd], stdout=subprocess.PIPE)
+    proc = subprocess.Popen(["ssh", "-4", config.distant_server, cmd], stdout=subprocess.PIPE)
     out, err = proc.communicate()
     news = json.loads(out)
     seen = get_last_seen()
@@ -387,7 +380,7 @@ def sync():
        le maximum de chaque truc vu est gardé des deux côtés."""
     lasts = get_last_seen()
     cmd = "%s sync" % (config.path_today_server,)
-    proc = subprocess.Popen(["ssh", config.distant_server, cmd],
+    proc = subprocess.Popen(["ssh", "-4", config.distant_server, cmd],
                             stdin = subprocess.PIPE, stdout=subprocess.PIPE,
                             close_fds = True)
     lasts_raw = json.dumps(lasts)