From 5c7a458ed49853c86647402d0796724bf682d424 Mon Sep 17 00:00:00 2001 From: Laurie Clark-Michalek Date: Mon, 6 Jun 2011 23:09:20 +0000 Subject: Implemented result alignment option --- archey3 | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/archey3 b/archey3 index 10bcd91..407c57d 100755 --- a/archey3 +++ b/archey3 @@ -57,7 +57,7 @@ LOGOS = {'Arch Linux': '''{c1} {c2} #########. .########` {results[13]} {c2} ######' '###### {results[14]} {c2} ;#### ####; {results[15]} -{c2} ##' '## {results[16]} +{c2} ##' '## {results[16]} {c2} #' `# {results[17]} \x1b[0m''' } @@ -565,6 +565,7 @@ class Archey(object): def render(self): results = self.prepare_results() + results = self.arrange_results(results) return LOGOS[self.distro_name].format(c1=self.color(1), c2=self.color(2), @@ -591,6 +592,23 @@ class Archey(object): outputs = [self.format_item(line) for line in outputs] return outputs + [""] * (18 - len(outputs)) + def arrange_results(self, results): + """ + Arranges the results as specified in the config file. + """ + arrangement = self.config.get("core", "align", fallback="top") + if arrangement == "top": + return results + elif arrangement == "bottom": + return results[::-1] + elif arrangement == "center": + actuall_res = [res for res in results if res] + offset = [""] * int((len(results) - len(actuall_res)) / 2) + return (offset + actuall_res + + [""] * (len(results) - len(actuall_res))) + else: + return results + def parse_display(self): """ Iterates over the display attribute of the Archey class, and tries to -- cgit v1.2.3