From da11f49cfbb4d0976a078729ca627a8f82c1a882 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Tue, 13 Jul 2021 19:38:54 +0200 Subject: [PATCH] wip --- libs/hashable.py | 6 ++++-- libs/systemd.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/hashable.py b/libs/hashable.py index 5cb4562..9ed68b1 100644 --- a/libs/hashable.py +++ b/libs/hashable.py @@ -1,7 +1,9 @@ +import json + class hdict(dict): def __hash__(self): - return hash(tuple(sorted(self.items()))) + return hash(json.dumps(self, sorted=True)) class hlist(list): def __hash__(self): - return hash(tuple(sorted(self))) + return hash(json.dumps(self, sorted=True)) diff --git a/libs/systemd.py b/libs/systemd.py index 421dbb0..60a742b 100644 --- a/libs/systemd.py +++ b/libs/systemd.py @@ -7,7 +7,7 @@ template = ''' # ${segment.split('#', 2)[1]} % endif [${segment.split('#')[0]}] -% for option, value in options.items(): +% for option, value in sorted(options.items()): % if isinstance(value, dict): % for k, v in value.items(): ${option}=${k}=${v}