From b271a0b0b1860919d88b1df89e41031f4b5059b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Wed, 2 Mar 2016 17:06:46 +0100 Subject: [PATCH] Add generator wrapper to fetch RedFams by status and ending Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=26 FS#26] --- lib/redfam.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/redfam.py b/lib/redfam.py index e513a0b..d4086ea 100644 --- a/lib/redfam.py +++ b/lib/redfam.py @@ -467,6 +467,19 @@ class RedFamWorker( RedFam ): print(fam) raise + @classmethod + def gen_by_status_and_ending( cls, status, ending ): + """ + Yield red_fams stored in db by given status which have an ending after + given one + """ + mysql = MysqlRedFam() + for fam in mysql.get_by_status_and_ending( status, ending ): + try: + yield cls( fam ) + except RedFamHashError: + print(fam) + raise class RedFamError( Exception ): """