예제 #1
0
    def transform(self, data):
        sets = etree.Element('set')

        set_spec = etree.SubElement(sets, 'setSpec')
        set_spec.text = slugfy(data)

        set_name = etree.SubElement(sets, 'setName')
        set_name.text = data

        return sets
예제 #2
0
    def transform(self, item):
        xml, data = item
        header = etree.SubElement(xml, 'header')
        if data.get('deleted'):
            header.attrib['status'] = 'deleted'

        identifier = etree.SubElement(header, 'identifier')
        identifier.text = data.get('identifier')

        datestamp = etree.SubElement(header, 'datestamp')
        datestamp.text = data.get('updated')

        set_spec = etree.SubElement(header, 'setSpec')
        set_spec.text = slugfy(data.get('publisher', ''))

        return (xml, data)
예제 #3
0
    def test_slugfy(self):
        result = slugfy(u'São Paulo Futebol Clube')

        self.assertEqual(u'sao-paulo-futebol-clube', result)
예제 #4
0
    def test_slugfy_realy_crazy_chars(self):
        result = slugfy(u'   without separators in the begining and end of a string   ')

        self.assertEqual(u'without-separators-in-the-begining-and-end-of-a-string', result)
예제 #5
0
    def test_slugfy_realy_crazy_chars(self):
        result = slugfy(u'must be empty of crazy chars @çÇ&$%^&*()-_+=¡£¢§¶•–‘“÷≥≤')

        self.assertEqual(u'must-be-empty-of-crazy-chars-cc', result)
예제 #6
0
    def test_slugfy_differente_separator(self):
        result = slugfy(u'São Paulo Futebol Clube', separator='#')

        self.assertEqual(u'sao#paulo#futebol#clube', result)
예제 #7
0
    def test_slugfy_multiple_white_spaces(self):
        result = slugfy(u'São  Paulo    Futebol Clube')

        self.assertEqual(u'sao-paulo-futebol-clube', result)