From 367f86987deffbd191b1b2dab7fb6ef0ac543386 Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 18 Mar 2017 22:24:38 -1000 Subject: [PATCH] readabilite: spread score to all ancestors Instead of just parents and grandparents --- morss/readabilite.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/morss/readabilite.py b/morss/readabilite.py index c424513..d667515 100644 --- a/morss/readabilite.py +++ b/morss/readabilite.py @@ -88,13 +88,13 @@ def score_all(root): grades[item] = score - parent = item.getparent() - if parent is not None: - grades[parent] += score / 2. - - gdparent = parent.getparent() - if gdparent is not None: - grades[gdparent] += score / 4. + factor = 2 + for ancestor in item.iterancestors(): + if score / factor > 1: + grades[ancestor] += score / factor + factor *= 2 + else: + break return grades