Names and normalization#

This specification defines the format that names for packages and extras are required to follow. It also describes how to normalize them, which should be done before lookups and comparisons.

Name format#

A valid name consists only of ASCII letters and numbers, period, underscore and hyphen. It must start and end with a letter or number. This means that valid project names are limited to those which match the following regex (run with re.IGNORECASE):

^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$

Name normalization#

名前は、すべての文字を小文字にして、 .,_ の文字が連続で1個以上出現したらそれを単独の - の文字に置き換えるべきです。これは、 Python の re モジュールを使って実装することができます:

import re

def normalize(name):
    return re.sub(r"[-_.]+", "-", name).lower()

次に挙げる名前はすべて同等ということになります:

  • friendly-bard (normalized form)

  • Friendly-Bard

  • FRIENDLY-BARD

  • friendly.bard

  • friendly_bard

  • friendly--bard

  • FrIeNdLy-._.-bArD (a terrible way to write a name, but it is valid)

歴史#

  • September 2015: The specification of name normalized was approved through 503.

  • November 2015: The specification of valid names was approved through 508.