]> gitweb.pimeys.fr Git - today.git/blobdiff - today.py
Maintenant on supporte d'être pipé dans un grep
[today.git] / today.py
index c08f8e6e155742af049d4db8893135de209f13b7..8594fdb47ed00228982a3979207a3627f0fa6a69 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"]:
@@ -376,7 +369,7 @@ def initialize():
     for ifile in range(len(files)):
         namefile = files[ifile]
         if os.path.isfile(namefile):
-            print "%s exists, skipping." % (namefile,)
+            print (u"%s exists, skipping." % (namefile,)).encode("utf-8")
         else:
             f = open(namefile, "w")
             f.write(contents[ifile].encode("utf-8"))
@@ -396,7 +389,7 @@ def sync():
     out = proc.stdout.read()
     newdict = json.loads(out)
     update_last_seen(newdict)
-    print u"Nouvel état : %r" % newdict
+    print (u"Nouvel état : %r" % newdict).encode("utf-8")
     
     
 
@@ -446,4 +439,4 @@ if __name__ == "__main__":
         args = sys.argv[2:]
         output = ACTIONS[commande](*args)
     if output:
-        print output
+        print output.encode("utf-8")