def init(self, *args, **kwargs): super(Processor, self).init(*args, **kwargs) # command -> plugin self.command = cidict() # plugin name -> commands self.commands = cidict() # plugin name -> plugin self.plugins = cidict()
def init(self, init_args=None, init_kwargs=None): self.init_args = init_args or tuple() self.init_kwargs = init_kwargs or dict() self.logger = getLogger(__name__) self.plugins = cidict()
def test_case_insensitive_membership(self): d = cidict.cidict(foo=1, bar=2) self.assertEqual(2, len(d)) assert 'foo' in d assert 'FOO' in d assert 'bar' in d assert 'BAR' in d
def test_case_insensitive_access(self): d = cidict.cidict(foo=1, bar=2) self.assertEqual(2, len(d)) self.assertEqual(1, d['foo']) self.assertEqual(1, d['FOO']) self.assertEqual(2, d['bar']) self.assertEqual(2, d['BAR'])
def _build_initial_headers(self): # We do not set multiple headers ourselves and therefore # can use a dictionary for headers headers = cidict.cidict() if self.config.user_agent is not None: headers['user-agent'] = self.config.user_agent return headers
def init(self, data, config): self.data = data self.config = config self.terminate = False self.host = self.config["host"] self.port = self.config["port"] self.auth = { "host": gethostname(), "server": self.host, "nick": self.config["nick"], "ident": kdb.__name__, "name": self.config.get("settings", {}).get("name", kdb.__description__), } if "password" in self.config: self.auth["password"] = self.config["password"] # command -> plugin self.command = cidict() # plugin name -> commands self.commands = cidict() # plugin name -> plugin self.plugins = cidict() self.data.init( { "state": { "host": self.auth["host"], "server": self.auth["server"], "nick": self.auth["nick"], "ident": self.auth["ident"], "name": self.auth["name"], } } ) self.transport = TCPClient(channel=self.channel).register(self) self.protocol = IRC(channel=self.channel).register(self)
def test_missing_keys(self): d = cidict.cidict(foo=1) assert 'foo' in d assert 'bar' not in d self.assertEqual(1, d['foo']) try: d['bar'] except KeyError: pass else: self.fail('Expected KeyError to be raised')
def headers(self): '''Returns response headers as a case-insensitive dictionary. If multiple headers with the same name are present in the response, the last header overwrites preceding ones. Use raw_headers to retrieve headers as a list with duplicate headers preserved. ''' raw_headers = self.raw_headers map = cidict.cidict() for key, value in raw_headers: map[key] = value return map
def init(self, *args, **kwargs): super(Greeting, self).init(*args, **kwargs) seed(time()) self.data.init( { "greeting": { "history": cidict(), "greetings": DEFAULTS, } } ) Commands().register(self)
def init(self, init_args=None, init_kwargs=None): self.init_args = init_args or tuple() self.init_kwargs = init_kwargs or dict() self.plugins = cidict()
def test_init_kwargs_conflict(self): d = cidict.cidict(foo=1, bar=2, BAR=3) self.assertEqual(2, len(d)) self.assertEqual(1, d['foo']) assert d.has_key('bar') assert d['bar'] in [2, 3]
def test_empty(self): d = cidict.cidict() self.assertEqual(0, len(d))
def test_init_kwargs_ci_override(self): d = cidict.cidict(dict(foo=1, BAR=2), FOO=4, bar=5) self.assertEqual(2, len(d)) self.assertEqual(4, d['foo']) self.assertEqual(5, d['bar'])
def test_init_maping_no_conflict(self): d = cidict.cidict(dict(foo=1, bar=2)) self.assertEqual(2, len(d)) self.assertEqual(1, d['foo']) self.assertEqual(2, d['bar'])
def _guess_media_info(self, results): return [( result, cidict(guess_media_info(result['title'])), ) for result in results]