Here are the examples of the python api scrapy.utils.python.stringify_dict taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
3
Example 1
Project: scrapy Source File: test_utils_python.py
@unittest.skipUnless(six.PY2, "deprecated function")
def test_stringify_dict(self):
d = {'a': 123, u'b': b'c', u'd': u'e', object(): u'e'}
d2 = stringify_dict(d, keys_only=False)
self.assertEqual(d, d2)
self.failIf(d is d2) # shouldn't modify in place
self.failIf(any(isinstance(x, six.text_type) for x in d2.keys()))
self.failIf(any(isinstance(x, six.text_type) for x in d2.values()))
3
Example 2
Project: scrapy Source File: test_utils_python.py
@unittest.skipUnless(six.PY2, "deprecated function")
def test_stringify_dict_tuples(self):
tuples = [('a', 123), (u'b', 'c'), (u'd', u'e'), (object(), u'e')]
d = dict(tuples)
d2 = stringify_dict(tuples, keys_only=False)
self.assertEqual(d, d2)
self.failIf(d is d2) # shouldn't modify in place
self.failIf(any(isinstance(x, six.text_type) for x in d2.keys()), d2.keys())
self.failIf(any(isinstance(x, six.text_type) for x in d2.values()))
3
Example 3
Project: scrapy Source File: test_utils_python.py
@unittest.skipUnless(six.PY2, "deprecated function")
def test_stringify_dict_keys_only(self):
d = {'a': 123, u'b': 'c', u'd': u'e', object(): u'e'}
d2 = stringify_dict(d)
self.assertEqual(d, d2)
self.failIf(d is d2) # shouldn't modify in place
self.failIf(any(isinstance(x, six.text_type) for x in d2.keys()))
3
Example 4
Project: scrapyd Source File: launcher.py
def _spawn_process(self, message, slot):
msg = stringify_dict(message, keys_only=False)
project = msg['_project']
args = [sys.executable, '-m', self.runner, 'crawl']
args += get_crawl_args(msg)
e = self.app.getComponent(IEnvironment)
env = e.get_environment(msg, slot)
env = stringify_dict(env, keys_only=False)
pp = ScrapyProcessProtocol(slot, project, msg['_spider'], \
msg['_job'], env)
pp.deferred.addBoth(self._process_finished, slot)
reactor.spawnProcess(pp, sys.executable, args=args, env=env)
self.processes[slot] = pp