aif-ng/aif/pacman/_common.py

23 lines
604 B
Python
Raw Normal View History

import configparser
import logging
from collections import OrderedDict
2020-01-03 03:38:35 -05:00
# TODO: Add pacman.conf parsing?
_logger = logging.getLogger('pacman:_common')
class MultiOrderedDict(OrderedDict):
# Thanks, dude: https://stackoverflow.com/a/38286559/733214
def __setitem__(self, key, value):
if key in self:
if isinstance(value, list):
self[key].extend(value)
return(None)
elif isinstance(value, str):
if len(self[key]) > 1:
return(None)
super(MultiOrderedDict, self).__setitem__(key, value)