Skip to content

Instantly share code, notes, and snippets.

@abs51295
Created October 29, 2018 12:25
Show Gist options
  • Select an option

  • Save abs51295/48e3c44473455c25875720fa53d502b6 to your computer and use it in GitHub Desktop.

Select an option

Save abs51295/48e3c44473455c25875720fa53d502b6 to your computer and use it in GitHub Desktop.

Revisions

  1. abs51295 created this gist Oct 29, 2018.
    7 changes: 7 additions & 0 deletions canonicalize_name.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import re

    _canonicalize_regex = re.compile(r"[-_.]+")

    def canonicalize_name(name):
    # This is taken from PEP 503.
    return _canonicalize_regex.sub("-", name).lower()