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}