Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
def testSanitize(self):
assert style.sanitize(None) == u'None'
assert style.sanitize(u'') == u''
self.assertEqual(style.sanitize(u'ü'), u'_ü')
self.assertEqual(style.sanitize(u'!foo'), u'_!foo')
assert style.sanitize(u'müller') == u'müller'
self.assertEqual(style.sanitize(1), u'_1')
self.assertEqual(style.sanitize('foo.bar'), u'foobar')
self.assertEqual(style.sanitize(u'fooba.r'), u'foobar')
self.assertEqual(style.sanitize('.foo'), u'foo')
self.assertEqual(style.sanitize(u'foo#bar'), u'foobar')
self.assertEqual(style.sanitize(u'foobar#'), u'foobar')
self.assertEqual(style.sanitize(u'x \t'), 'x_')
self.assertEqual(style.sanitize(u'"huh"'), u'huh')
kwargs.get('id', feature.get('id', '?')), name, e)
return ''
# Set up the element's properties.
drawargs = _style.construct_datas(datas, feature['properties'])
classes = _style.construct_classes(classes, feature['properties'])
# Add the layer name to the class list.
if name != '?':
classes.insert(0, _style.sanitize(name))
drawargs['class'] = ' '.join(classes)
if 'id_field' in kwargs and kwargs['id_field'] in feature['properties']:
drawargs['id'] = _style.sanitize(feature['properties'].get(kwargs['id_field']))
try:
# Draw the geometry.
return draw.geometry(geom, precision=precision, **drawargs)
except errors.SvgisError as e:
self.log.warning('unable to draw feature %s of %s: %s',
kwargs.get('id', feature.get('id', '?')), name, e)
return u''
# When we have no passed bounds:
else:
# Set the output CRS, if not yet set, using this layer's bounds.
self.set_out_crs(layer.bounds)
# Extend projection_bounds
self.update_projected_bounds(layer.crs, self.out_crs, layer.bounds, padding)
bounds = layer.bounds
kwargs = self._prepare_layer(layer, path, bounds, **kwargs)
group = tuple(self.feature(f, **kwargs) for _, f in layer.items(bbox=bounds))
return {
'members': group,
'id': kwargs['name'],
'class': u' '.join(_style.sanitize(c) for c in layer.schema['properties'].keys())
}