How to use the svgis.style.sanitize function in svgis

To help you get started, we’ve selected a few svgis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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_')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / tests / test_style.py View on Github external
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')
github fitnr / svgis / svgis / svgis.py View on Github external
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''
github fitnr / svgis / svgis / svgis.py View on Github external
# 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())
        }