Example #1
0
 def setdefault (self, k, d=None):
     """W.setdefault (k,d=None) -> W.get (k, d), also set W[k] = d if k not in W
     """
     changed = not IterableUserDict.has_key (self, k)
     v = IterableUserDict.setdefault (self, k, d)
     if changed and self._valuechanged:
         self._valuechanged ()
     return v
Example #2
0
def get_subscriptions():
    """Return the list of subscription dictionaries."""
    from UserDict import IterableUserDict as UserDict
    # Read sections from config file
    # TODO Abstraction to allow reading subscriptions from different sources
    feed_section = re.compile('^feed:\s*(.*)', re.I)
    subs = []
    for section in config.sections():
        match = feed_section.match(section)
        if match:
            # UserDict allows adding attrs, whereas real dict does not
            subscription = UserDict(config.items(section))
            subscription['label'] = match.group(1).strip()
            subscription.setdefault('slug', slugify(subscription['label']))
            subscription.setdefault('errors', '')
            subscription.section = section
            if not subscription.has_key('url'):
                # TODO Log an error if feed section has no url
                continue
            subs.append(subscription)
    return subs
Example #3
0
 def setdefault(self, key, failobj=None):
     IterableUserDict.setdefault(self, key, failobj)
     if key not in self._keys: self._keys.append(key)
Example #4
0
 def setdefault(self, name, default):
     if hasattr(default, 'items'):
         default = DotDict(default)
     return IterableUserDict.setdefault(self, name, default)
Example #5
0
 def setdefault(self, key, failobj=None):
     IterableUserDict.setdefault(self, key, failobj)
     if key not in self._keys:
         self._keys.append(key)