當前位置: 首頁>>代碼示例>>Python>>正文


Python normality.slugify方法代碼示例

本文整理匯總了Python中normality.slugify方法的典型用法代碼示例。如果您正苦於以下問題:Python normality.slugify方法的具體用法?Python normality.slugify怎麽用?Python normality.slugify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在normality的用法示例。


在下文中一共展示了normality.slugify方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_empty

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def test_empty(self):
        self.assertEqual(None, slugify(None))
        self.assertEqual(None, ascii_text(None))
        self.assertEqual(None, latinize_text(None))
        self.assertEqual(None, normalize(None))
        self.assertEqual(None, normalize(''))
        self.assertEqual(None, normalize(' ')) 
開發者ID:pudo,項目名稱:normality,代碼行數:9,代碼來源:test_normality.py

示例2: test_petro

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def test_petro(self):
        text = u'Порошенко Петро Олексійович'
        self.assertEqual('porosenko-petro-oleksijovic', slugify(text))
        self.assertEqual('Porosenko Petro Oleksijovic', ascii_text(text))
        self.assertEqual(u'Porošenko Petro Oleksíjovič', latinize_text(text))
        self.assertEqual(u'порошенко петро олексіиович', normalize(text)) 
開發者ID:pudo,項目名稱:normality,代碼行數:8,代碼來源:test_normality.py

示例3: test_slugify

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def test_slugify(self):
        text = u'BABY! camel-is good'
        self.assertEqual('baby-camel-is-good', slugify(text, sep='-')) 
開發者ID:pudo,項目名稱:normality,代碼行數:5,代碼來源:test_normality.py

示例4: column_alias

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def column_alias(cell, names):
    """ Generate a normalized version of the column name. """
    column = slugify(cell.column or '', sep='_')
    column = column.strip('_')
    column = 'column' if not len(column) else column
    name, i = column, 2
    # de-dupe: column, column_2, column_3, ...
    while name in names:
        name = '%s_%s' % (name, i)
        i += 1
    return name 
開發者ID:openspending,項目名稱:spendb,代碼行數:13,代碼來源:extract.py

示例5: slug

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def slug(name):
    return slugify(name, sep='_') 
開發者ID:openspending,項目名稱:spendb,代碼行數:4,代碼來源:model_migrate.py

示例6: get_queries

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def get_queries():
    for ds, map in get_mappings():
        ds_name = ds['name']
        table_pattern = ds_name + '__'
        entry_table = '"' + table_pattern + 'entry"'
        fields = [(entry_table + '.id', '_openspending_id')]
        joins = []
        for dim, desc in map.items():
            if desc.get('type') == 'compound':
                dim_table = '"%s%s"' % (table_pattern, dim)
                joins.append((dim_table, dim))
                for attr, attr_desc in desc.get('attributes').items():
                    alias = '%s_%s' % (dim, attr)
                    fields.append(('%s."%s"' % (dim_table, attr), alias))
            elif desc.get('type') == 'date':
                dim_table = '"%s%s"' % (table_pattern, dim)
                joins.append((dim_table, dim))
                for attr in ['name', 'year', 'month', 'day', 'week',
                             'yearmonth', 'quarter']:
                    alias = '%s_%s' % (dim, attr)
                    fields.append(('%s."%s"' % (dim_table, attr), alias))
                fields.append(('%s.name' % dim_table, dim))
            else:
                fields.append(('%s."%s"' % (entry_table, dim), dim))

        select_clause = []
        for src, alias in fields:
            select_clause.append('%s AS "%s"' % (src, slugify(alias, sep='_')))
        select_clause = ', '.join(select_clause)

        join_clause = []
        for table, dim in joins:
            qb = 'LEFT JOIN %s ON %s."%s_id" = %s.id'
            qb = qb % (table, entry_table, dim, table)
            join_clause.append(qb)
        join_clause = ' '.join(join_clause)

        yield ds, 'SELECT %s FROM %s %s' % (select_clause, entry_table,
                                            join_clause) 
開發者ID:openspending,項目名稱:spendb,代碼行數:41,代碼來源:export.py

示例7: slugify

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def slugify(mapping, bind, values):
    """ Transform all values into URL-capable slugs. """
    for value in values:
        if isinstance(value, six.string_types):
            value = transliterate(value)
            value = normality.slugify(value)
        yield value 
開發者ID:pudo-attic,項目名稱:jsonmapping,代碼行數:9,代碼來源:transforms.py

示例8: node_id

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def node_id(self, value):
        return 'name:%s' % slugify(value) 
開發者ID:alephdata,項目名稱:followthemoney,代碼行數:4,代碼來源:name.py

示例9: node_id

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def node_id(self, value: str) -> str:
        return 'addr:%s' % slugify(value) 
開發者ID:alephdata,項目名稱:followthemoney,代碼行數:4,代碼來源:address.py

示例10: convert_snakecase

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def convert_snakecase(name):
    if name.upper() != name:
        name = titlecase(name)
    return slugify(name, sep='_') 
開發者ID:alephdata,項目名稱:memorious,代碼行數:6,代碼來源:__init__.py

示例11: parse

# 需要導入模塊: import normality [as 別名]
# 或者: from normality import slugify [as 別名]
def parse(context, data):
    emitter = EntityEmitter(context)
    references = defaultdict(list)
    with context.http.rehash(data) as res:
        xls = xlrd.open_workbook(res.file_path)
        ws = xls.sheet_by_index(0)
        headers = [slugify(h, sep='_') for h in ws.row_values(0)]
        for r in range(1, ws.nrows):
            row = ws.row(r)
            row = dict(zip(headers, row))
            for header, cell in row.items():
                if cell.ctype == 2:
                    row[header] = str(int(cell.value))
                elif cell.ctype == 3:
                    date = xldate_as_datetime(cell.value, xls.datemode)
                    row[header] = date.isoformat()
                elif cell.ctype == 0:
                    row[header] = None
                row[header] = cell.value

            reference = clean_reference(row.get('reference'))
            references[reference].append(row)

    for ref, rows in references.items():
        parse_reference(emitter, ref, rows)
    emitter.finalize() 
開發者ID:alephdata,項目名稱:opensanctions,代碼行數:28,代碼來源:au_dfat_sanctions.py


注:本文中的normality.slugify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。