File: utils.py

package info (click to toggle)
python-werkzeug 1.0.1%2Bdfsg1-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,888 kB
  • sloc: python: 21,897; javascript: 173; makefile: 36; xml: 16
file content (21 lines) | stat: -rw-r--r-- 378 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding: utf-8 -*-
"""
    cupoftee.utils
    ~~~~~~~~~~~~~~

    Various utilities.

    :copyright: 2007 Pallets
    :license: BSD-3-Clause
"""
import re


_sort_re = re.compile(r"\w+", re.UNICODE)


def unicodecmp(a, b):
    x, y = map(_sort_re.search, [a, b])
    x = (x.group() if x else a).lower()
    y = (y.group() if y else b).lower()
    return (x > y) - (x < y)