Esempio n. 1
0
	def __init__(self, d=None, path=None):
		if not path:
			path = os.path.join(os.getcwd(), 'project.pbxproj')

		self.pbxproj_path =os.path.abspath(path)
		self.source_root = os.path.abspath(os.path.join(os.path.split(path)[0], '..'))

		IterableUserDict.__init__(self, d)

		self.data = PBXDict(self.data)
		self.objects = self.get('objects')
		self.modified = False

		root_id = self.get('rootObject')
		if root_id:
			self.root_object = self.objects[root_id]
			root_group_id = self.root_object.get('mainGroup')
			self.root_group = self.objects[root_group_id]
		else:
			print "error: project has no root object"
			self.root_object = None
			self.root_group = None

		for k,v in self.objects.iteritems():
			v.id = k
Esempio n. 2
0
    def __init__(self, probe, columns):
        logger.debug('=== BEGIN NEW SNMP TABLE===')

        # This is the SNMP probe that handle SNMP communication
        self.__probe = probe

        # Get indexes and oid values
        indexes = self.__probe.getnext({'indexes':
                                        columns.pop('indexes')})['indexes']

        # Append index to all OIDs
        values = dict.fromkeys(columns, list())
        for _, index in indexes:
            cols = {}
            for name, oid in columns.viewitems():
                o = '%s.%s' % (oid, index)
                cols[name] = o
            # Query values
            results = self.__probe.get(cols)
            for k, v in results.viewitems():
                values[k].append(v)
                print values

        IterableUserDict.__init__(self, values)

        logger.debug('=== BEGIN NEW SNMP TABLE===')
Esempio n. 3
0
class BaseApp(object):

    default_config = dict(client_version='pydevp2p {}'.format(__version__),
                          deactivated_services=[])

    def __init__(self, config=default_config):
        self.config = utils.update_config_with_defaults(config, self.default_config)
        self.services = IterableUserDict()

    def register_service(self, service):
        """
        registeres protocol with app, which will be accessible as
        app.services.<protocol.name> (e.g. app.services.p2p or app.services.eth)
        """
        assert isinstance(service, BaseService)
        assert service.name not in self.services
        log.info('registering service', service=service.name)
        self.services[service.name] = service
        setattr(self.services, service.name, service)

    def deregister_service(self, service):
        assert isinstance(service, BaseService)
        self.services.remove(service)
        delattr(self.services, service.name)

    def start(self):
        for service in self.services.values():
            service.start()

    def stop(self):
        for service in self.services.values():
            service.stop()
    def __init__(self, group_name=None, default_target=None, default_args=None, default_kwargs=None,
                 default_flags=None, default_kill_wait=0.5, max_processes=1000, process_plus_impl=None):

        self.group_name = group_name

        self._defaults = dict(
            target=default_target,
            args=default_args,
            kwargs=default_kwargs,
            flags=self._curate_flags(default_flags),
            kill_wait=default_kill_wait
        )

        self.max_processes = max_processes

        if process_plus_impl:
            assert issubclass(process_plus_impl, ProcessPlus)

        self.ProcessPlusImpl = ProcessPlus if not process_plus_impl else process_plus_impl

        self.__limbo_group = None  # Must access through property
        self.__dead_group = None  # Must access through property

        self._num_keep_dead = 100
        self._num_deleted_dead = 0

        self.logger = logging.getLogger(__name__)

        self._thread_action_loop = None
        self.stop_action = True
        self.action_loop_interval = 1  # seconds between each actions pass

        IterableUserDict.__init__(self)
Esempio n. 5
0
    def __init__(self, d=None, path=None):
        if not path:
            path = os.path.join(os.getcwd(), 'project.pbxproj')

        self.pbxproj_path =os.path.abspath(path)
        self.source_root = os.path.abspath(os.path.join(os.path.split(path)[0], '..'))

        IterableUserDict.__init__(self, d)

        self.data = PBXDict(self.data)
        self.objects = self.get('objects')
        self.modified = False

        root_id = self.get('rootObject')
        if root_id:
            self.root_object = self.objects[root_id]
            root_group_id = self.root_object.get('mainGroup')
            self.root_group = self.objects[root_group_id]
        else:
            print "error: project has no root object"
            self.root_object = None
            self.root_group = None

        for k,v in self.objects.iteritems():
            v.id = k
Esempio n. 6
0
File: app.py Progetto: jnnk/pydevp2p
class BaseApp(object):
    def __init__(self, config):
        self.config = config
        self.services = IterableUserDict()

    def register_service(self, service):
        """
        registeres protocol with peer, which will be accessible as
        peer.<protocol.name> (e.g. peer.p2p or peer.eth)
        """
        assert isinstance(service, BaseService)
        assert service.name not in self.services
        log.info('registering service', service=service.name)
        self.services[service.name] = service
        setattr(self.services, service.name, service)

    def deregister_service(self, service):
        assert isinstance(service, BaseService)
        self.services.remove(service)
        delattr(self.services, service.name)

    def start(self):
        for service in self.services.values():
            service.start()

    def stop(self):
        for service in self.services.values():
            service.stop()
Esempio n. 7
0
    def __init__(self, probe, columns):
        logger.debug('=== BEGIN NEW SNMP TABLE===')

        # This is the SNMP probe that handle SNMP communication
        self.__probe = probe

        # Get indexes and oid values
        indexes = self.__probe.getnext(
            {'indexes': columns.pop('indexes')})['indexes']

        # Append index to all OIDs
        values = dict.fromkeys(columns, list())
        for _, index in indexes:
            cols = {}
            for name, oid in columns.viewitems():
                o = '%s.%s' % (oid, index)
                cols[name] = o
            # Query values
            results = self.__probe.get(cols)
            for k, v in results.viewitems():
                values[k].append(v)
                print values

        IterableUserDict.__init__(self, values)

        logger.debug('=== BEGIN NEW SNMP TABLE===')
Esempio n. 8
0
    def __init__(self, initialdata=None, tag=None, **kwargs):
        """Constructor

        Parameters
        -----------
        initialdata : dict or dataId
            A dict of initial data for the DataId
        tag : any type, or a container of any type
            A value or container of values used to restrict the DataId to one or more repositories that
            share that tag value. It will be stored in a set for comparison with the set of tags assigned to
            repositories.
        kwargs : any values
            key-value pairs to be used as part of the DataId's data.
        """
        UserDict.__init__(self, initialdata)
        try:
            self.tag = copy.deepcopy(initialdata.tag)
        except AttributeError:
            self.tag = set()

        if tag is not None:
            if isinstance(tag, basestring):
                self.tag.update([tag])
            else:
                try:
                    self.tag.update(tag)
                except TypeError:
                    self.tag.update([tag])

        self.data.update(kwargs)
Esempio n. 9
0
 def insert(self, Key, Newkey, Newvalue, Order):
     Index = self._key_list.index(Key)
     if Order == 'BEFORE':
         self._key_list.insert(Index, Newkey)
         IterableUserDict.__setitem__(self, Newkey, Newvalue)
     elif Order == 'AFTER':
         self._key_list.insert(Index + 1, Newkey)
         IterableUserDict.__setitem__(self, Newkey, Newvalue)
Esempio n. 10
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
Esempio n. 11
0
 def __setitem__ (self, i, y):
     """W.__setitem__ (i, y) <==> w[i] = y
     """
     IterableUserDict.__setitem__ (self, i, y)
     if isinstance (y, WidgetStyle):
         y.set_value_changed (self._valuechanged)
     if self._valuechanged:
         self._valuechanged ()
Esempio n. 12
0
 def insert(self, Key, Newkey, Newvalue, Order):
     Index = self._key_list.index(Key)
     if Order == 'BEFORE':
         self._key_list.insert(Index, Newkey)
         IterableUserDict.__setitem__(self, Newkey, Newvalue)
     elif Order == 'AFTER':
         self._key_list.insert(Index + 1, Newkey)
         IterableUserDict.__setitem__(self, Newkey, Newvalue)
Esempio n. 13
0
 def insert(self, key, newkey, newvalue, order):
     index = self._key_list.index(key)
     if order == 'BEFORE':
         self._key_list.insert(index, newkey)
         IterableUserDict.__setitem__(self, newkey, newvalue)
     elif order == 'AFTER':
         self._key_list.insert(index + 1, newkey)
         IterableUserDict.__setitem__(self, newkey, newvalue)
Esempio n. 14
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing', self.conf_file)
            exit(1)
        else:
            self.load()
Esempio n. 15
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing', self.conf_file)
            exit(1)
        else:
            self.load()
Esempio n. 16
0
 def __init__(self, useEnv=True, verboseConfig=False):
     IterableUserDict.__init__(self)
     self.verboseConfig = verboseConfig
     self.sourceAndVerboseStatus = {}
     thisDir = os.path.dirname(__file__)
     configFile = os.path.join(thisDir, "MAT_settings.config")
     if os.path.exists(configFile):
         self._readConfigFile(configFile)
     else:
         raise ConfigError, "config file doesn't exist"
     self.useEnv = useEnv
Esempio n. 17
0
    def clear (self, y):
        """W.clear () -> None

        Remove all items from the WidgetStyle dictionary.
        """
        changed = self._valuechanged
        self.set_value_changed (None)
        IterableUserDict.clear (self)
        self.set_value_changed (changed)
        if changed:
            changed ()
Esempio n. 18
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing. Using defaults.', self.conf_file)
            self.use_defaults()
            self.save()
        else:
            self.load()
Esempio n. 19
0
 def __init__(self, cutoffs, data=None):
     """Create a HistogramBucketDict with cutoff points for buckets."""
     IterableUserDict.__init__(self)
     cutoffs = cutoffs[:]
     cutoffs.reverse()
     self.cutoffs = cutoffs
     self.firstcutoff = cutoffs[0]
     self.lastcutoff = cutoffs[-1]
     for cutoff in cutoffs:
         self[cutoff] = 0
     if data:
         self.add_all(data)
Esempio n. 20
0
    def update (self, E, **F):
        """W.update (E, **F) -> None

        Update W from E and F.

        for k in E: W[k] = E[k] (if E has keys else: for (k, v) in E:
        W[k] = v) then: for k in F: W[k] = F[k]
        """
        amount = len (self)
        IterableUserDict.update (self, E, **F)
        if self._valuechanged and (len (self) != amount):
            self._valuechanged ()
Esempio n. 21
0
 def __init__(self, cutoffs, data=None):
     """Create a HistogramBucketDict with cutoff points for buckets."""
     IterableUserDict.__init__(self)
     cutoffs = cutoffs[:]
     cutoffs.reverse()
     self.cutoffs = cutoffs
     self.firstcutoff = cutoffs[0]
     self.lastcutoff = cutoffs[-1]
     for cutoff in cutoffs:
         self[cutoff] = 0
     if data:
         self.add_all(data)
Esempio n. 22
0
    def pop (self, k, d=None):
        """W.pop (k, d=None) -> object

        Remove specified key and return the corresponding value.

        If key is not found, d is returned if given, otherwise KeyError
        is raised.
        """
        changed = IterableUserDict.has_key (self, k)
        v = IterableUserDict.pop (self, k, d)
        if changed and self._valuechanged:
            self._valuechanged ()
        return v
Esempio n. 23
0
File: sa.py Progetto: mrowl/filmdata
 def __init__(self, schemas, meta, name=None, seed_cols=None):
     """
     Create a new DynamicModels instance.
     Arguments:
         schemas - a list of all the schemas for the underlying tables
         meta - the meta object for this sqla session
         name - the name for this instance (will be the prefix to the
             table names)
         seed_cols - a lambda function which will generate columns present
             in each of the underlying tables
     """
     IterableUserDict.__init__(self)
     self._build(schemas, meta, name, seed_cols)
Esempio n. 24
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            try:
                with open(self.conf_file, 'w') as file:
                    pass
            except:
                logging.error('Config-file %s missing and failed to create',
                              self.conf_file)
                exit(1)
        self.load()
        self.save()
Esempio n. 25
0
File: sners.py Progetto: bodik/sner2
	def __init__(self, **kwargs):
        	IterableUserDict.__init__(self)
	        self.data = kwargs
		if "_id" in self:
			if self["_id"] == "":
				#*/add because add is using edit template
				del self["_id"]
			elif "$oid" in self["_id"]:
				self["_id"] = ObjectId(self["_id"]["$oid"])
			else:
				#*/edit
				self["_id"] = ObjectId(self["_id"])

		self.client = MongoClient()
		self.db = self.client[self.dbname]
		self.coll = self.db[self.collname]
Esempio n. 26
0
    def __init__(self, *args, **kwargs):
        rv = IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            logging.debug('Config-file %s missing. Trying to download', self.conf_file)
            
            rsaPub = open(self.home+'/.ssh/id_rsa.pub','r')
            publicId = rsaPub.readline(512)
            rsaPub.close()
            values = {'publicId' : publicId}
            data = urllib.urlencode(values)
            req = urllib2.Request(GETCONFIG_URL, data)
            response = urllib2.urlopen(req)
            html = response.read()
            pos = html.find('\r\n\r\n')
            config = html[pos+4:]
            
            confFile = open(self.conf_file,'w')
            confFile.write(config)
            confFile.close()
            
            self.load()
        else:
            self.load()
        return rv
Esempio n. 27
0
 def __init__(self, asc=True, default=0.0, *args, **kwargs):
     """
     Initialize the sparse SparseDictionary
     :param asc: whether the dictionary will be queried in ascending or descending order. Ascending corresponds
     to sender payoffs where we accumulate upwards, and descending corresponds to receiver payoffs where we are
     accumulating downwards
     :param default: The default value to return if the key does not have a value associated with it
     """
     IterableUserDict.__init__(self, *args, **kwargs)
     self.default = default
     if asc:
         self.cmp = operator.lt
     else:
         self.cmp = operator.gt
     self.history = []
     self.last_key, self.last_value = None, None
Esempio n. 28
0
class BaseApp(object):
    client_name = 'pyethcrawler'
    client_version = '0.1/%s/%s' % (sys.platform,
                                   'py%d.%d.%d' % sys.version_info[:3])
    client_version_string = '%s/v%s' % (client_name, client_version)
    start_console = False
    default_config = {}
    default_config['client_version_string'] = client_version_string
    default_config['result_dir'] = ''
    default_config['prev_routing_table'] = '/results/routing-table_170109-084715.csv'
    default_config['prev_peers'] = ''
#    default_config['p2p'] = dict(bootstrap_nodes=[],listen_port=30304,listen_host='0.0.0.0')
    privkey_hex = 'b3b9736ba5e4b9d0f85231291316c7fd82bde4ae80bb7ca98175cf6d11c0c4eb'
    pubkey = crypto.privtopub(privkey_hex.decode('hex'))
    default_config['node'] = dict(privkey_hex=privkey_hex, id=crypto.sha3(pubkey))

    def __init__(self, config=default_config):
        self.config = utils.update_config_with_defaults(config, self.default_config)
        self.services = IterableUserDict()

    def register_service(self, service):
        """
        registeres protocol with app, which will be accessible as
        app.services.<protocol.name> (e.g. app.services.p2p or app.services.eth)
        """
        assert isinstance(service, BaseService)
        assert service.name not in self.services
        log.info('registering service', service=service.name)
        self.services[service.name] = service
        setattr(self.services, service.name, service)

    def deregister_service(self, service):
        assert isinstance(service, BaseService)
        self.services.remove(service)
        delattr(self.services, service.name)

    def start(self):
        for service in self.services.values():
            service.start()

    def stop(self):
        for service in self.services.values():
            service.stop()

    def join(self):
        for service in self.services.values():
            service.join()
Esempio n. 29
0
 def pop(self, key, *default):
     ret = IterableUserDict.pop(self, key, *default)
     try:
         self._keys.remove(key)
     except ValueError:
         # This exception can happen when a default value is passed, so we
         # can safely ignore it
         pass
     return ret
Esempio n. 30
0
 def __init__(self):
     IterableUserDict.__init__(self)
     self.data['#FFFF00'] = translationBundle.get(673)
     self.data['#0000FF'] = translationBundle.get(674)
     self.data['#FFFFFF'] = translationBundle.get(675)
     self.data['#996633'] = translationBundle.get(676)
     self.data['#8B4513'] = translationBundle.get(677)
     self.data['#99FFFF'] = translationBundle.get(678)
     self.data['#00FFFF'] = translationBundle.get(679)
     self.data['#CCCCCC'] = translationBundle.get(680)
     self.data['#999999'] = translationBundle.get(681)
     self.data['#800080'] = translationBundle.get(682)
     self.data['#FF9900'] = translationBundle.get(683)
     self.data['#000000'] = translationBundle.get(684)
     self.data['#FF0000'] = translationBundle.get(685)
     self.data['#FF00FF'] = translationBundle.get(686)
     self.data['#009900'] = translationBundle.get(687)
     self.data['#006600'] = translationBundle.get(688)
Esempio n. 31
0
    def __init__(self, *args, **kwargs):
        IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()
        self.auth_backends_list = [NoAuth(), BasicAuth(self)]
        if os.path.isdir('/opt/wott'):
            self.auth_backends_list.append(WoTTAuth(self))
        self.auth_backends = {}
        for backend in self.auth_backends_list:
            DEFAULTS.update(backend.config)
            self.auth_backends[backend.name] = backend

        if not path.isfile(self.conf_file):
            logging.error('Config-file %s missing. Using defaults.', self.conf_file)
            self.use_defaults()
            self.save()
        else:
            self.load()
Esempio n. 32
0
    def test_user_collections(self):
        # Note: Not "UserDict" because UserDict doesn't implement
        # __iter__ and hence isn't a collections_abc.Mapping, and doesn't
        # implement enough API to implement the NSDictionary interface.
        v = IterableUserDict()
        self.assertIsSubclass(classOfProxy(v), NSMutableDictionary)

        v = UserList()
        self.assertIsSubclass(classOfProxy(v), NSMutableArray)
Esempio n. 33
0
    def popitem (self):
        """W.popitem () -> (k, v)

        Remove and return some (key, value) pair as a 2-tuple

        Raises a KeyError if D is empty.
        """
        v = IterableUserDict.popitem (self)
        if self._valuechanged:
            self._valuechanged ()
        return v
Esempio n. 34
0
 def __getitem__(self, item):
     try:
         out = IterableUserDict.__getitem__(self, item)
         self.last_key = item
         self.last_value = out
         return out
     except KeyError as e:
         if self.last_key is None or self.cmp(item, self.last_key):
             return self.default
         else:
             return self.last_value
Esempio n. 35
0
    def __init__(self, *args, **kwargs):
        rv = IterableUserDict.__init__(self, *args, **kwargs)
        self.conf_file = path.join(CONFIG_DIR, 'screenly.conf')

        if not path.isfile(self.conf_file):
            print 'Config-file missing.'
            logging.error('Config-file missing.')
            exit(1)
        else:
            self.load()
        return rv
Esempio n. 36
0
    def __init__(self, *args, **kwargs):
        rv = IterableUserDict.__init__(self, *args, **kwargs)
        self.home = getenv('HOME')
        self.conf_file = self.get_configfile()

        if not path.isfile(self.conf_file):
            print 'Config-file %s missing' % (self.conf_file)
            exit(1)
        else:
            self.load()
        return rv
    def testValidate(self):
        field = self._Field_Factory(title=u'test field', description=u'',
                                    readonly=False, required=False)
        field.validate(None)
        field.validate('')
        field.validate('abc')
        field.validate([1, 2, 3])
        field.validate({'a': 1, 'b': 2})
        field.validate(IterableUserDict())

        self.assertRaises(NotAContainer, field.validate, 1)
        self.assertRaises(NotAContainer, field.validate, True)
        self.assertRaises(NotAnIterator, field.validate, UserDict)
Esempio n. 38
0
    def __init__(self):
        IterableUserDict.__init__(self)
        # Set up couchdb.
        self._db_name = "simple-player"
        self._key = None

        self._record_type = (
            "http://wiki.ubuntu.com/Quickly/RecordTypes/SimplePlayer/"
            "Preferences")
        
        # set up signals in a separate class
        # because IterableUserDict uses self.data (documented)
        # and gtk.Invisible appears to use self.data.
        class Publisher(gtk.Invisible):
            __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST,
                 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
                 'loaded' : (gobject.SIGNAL_RUN_LAST,
                 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))}
        
        publisher = Publisher()
        self.emit  = publisher.emit
        self.connect  = publisher.connect
Esempio n. 39
0
    def __init__(self,
                 group_name=None,
                 default_target=None,
                 default_args=None,
                 default_kwargs=None,
                 default_flags=None,
                 default_kill_wait=0.5,
                 max_processes=1000,
                 process_plus_impl=None):

        self.group_name = group_name

        self._defaults = dict(target=default_target,
                              args=default_args,
                              kwargs=default_kwargs,
                              flags=self._curate_flags(default_flags),
                              kill_wait=default_kill_wait)

        self.max_processes = max_processes

        if process_plus_impl:
            assert issubclass(process_plus_impl, ProcessPlus)

        self.ProcessPlusImpl = ProcessPlus if not process_plus_impl else process_plus_impl

        self.__limbo_group = None  # Must access through property
        self.__dead_group = None  # Must access through property

        self._num_keep_dead = 100
        self._num_deleted_dead = 0

        self.logger = logging.getLogger(__name__)

        self._thread_action_loop = None
        self.stop_action = True
        self.action_loop_interval = 1  # seconds between each actions pass

        IterableUserDict.__init__(self)
Esempio n. 40
0
    def __setitem__(self, pkg_id, session_data):
        """Set an `zope.session.interfaces.ISessionData`

            >>> sdc = PersistentSessionDataContainer()
            >>> sad = SessionData()

        ``__setitem__`` sets the ``ISessionData``'s ``lastAccessTime``

            >>> sad.getLastAccessTime()
            0
            >>> sdc['1'] = sad
            >>> 0 < sad.getLastAccessTime() <= time.time()
            True

        We can retrieve the same object we put in

            >>> sdc['1'] is sad
            True

        """
        session_data.setLastAccessTime(int(time.time()))
        return UserDict.__setitem__(self, pkg_id, session_data)
Esempio n. 41
0
    def __setitem__(self, pkg_id, session_data):
        """Set an ISessionPkgData

            >>> sdc = PersistentSessionDataContainer()
            >>> sad = SessionData()

        __setitem__ sets the ISessionData's lastAccessTime

            >>> sad.lastAccessTime
            0
            >>> sdc['1'] = sad
            >>> 0 < sad.lastAccessTime <= time.time()
            True

        We can retrieve the same object we put in

            >>> sdc['1'] is sad
            True

        """
        session_data.lastAccessTime = int(time.time())
        return IterableUserDict.__setitem__(self, pkg_id, session_data)
Esempio n. 42
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
Esempio n. 43
0
 def __getitem__(self, key):
     useEnv = self.useEnv
     if key == "MAT_PKG_HOME":
         useEnv = False
     if useEnv and os.environ.has_key(key):
         v = os.environ[key]
         if (not self.sourceAndVerboseStatus.has_key(key)) or \
            (self.sourceAndVerboseStatus[key][0] != "<shell environment>"):
             self.sourceAndVerboseStatus[key] = [
                 "<shell environment>", False
             ]
     else:
         v = IterableUserDict.__getitem__(self, key)
     # If we've gotten this far, getitem hasn't thrown KeyError, which means
     # that the key HAS to have an entry in sourceAndVerboseStatus.
     # But let's check.
     if not self.sourceAndVerboseStatus.has_key(key):
         self.sourceAndVerboseStatus[key] = ["<unknown source>", False]
     if self.verboseConfig and (not self.sourceAndVerboseStatus[key][1]):
         self.sourceAndVerboseStatus[key][1] = True
         print >> sys.stderr, "[Read value of config var %s from %s]" % (
             key, self.sourceAndVerboseStatus[key][0])
     return v
Esempio n. 44
0
 def clear(self):
     self._key_list = []
     IterableUserDict.clear(self)
Esempio n. 45
0
 def append(self, Sdict2):
     for Key in Sdict2:
         if Key not in self._key_list:
             self._key_list.append(Key)
         IterableUserDict.__setitem__(self, Key, Sdict2[Key])
Esempio n. 46
0
 def __delitem__(self, Key):
     self._key_list.remove(Key)
     IterableUserDict.__delitem__(self, Key)
Esempio n. 47
0
 def __setitem__(self, Key, Value):
     if Key not in self._key_list:
         self._key_list.append(Key)
     IterableUserDict.__setitem__(self, Key, Value)
Esempio n. 48
0
 def items(self):
     """Returns a list of pairs.  Each pair consists of a bucket
     range and the number of items in that range."""
     descs = self.bucket_descriptions()
     return [(descs[k], v) for k, v in IterableUserDict.items(self)]
Esempio n. 49
0
 def copy(self):
     dict = IterableUserDict.copy(self)
     dict._keys = self._keys[:]
     return dict
Esempio n. 50
0
 def clear(self):
     IterableUserDict.clear(self)
     self._keys = []