Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
normalize project name before publish
closes #3632 https://pulp.plan.io/issues/3632
- Loading branch information
Showing
4 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pycodestyle: | ||
max-line-length: 100 # Default is 79 in PEP8 | ||
ignore: # Errors and warnings to ignore | ||
- E401 # multiple imports on one line | ||
exclude: | ||
- "./docs/*" | ||
- "*/build/*" | ||
- "*/migrations/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import re | ||
|
||
|
||
def sanitize_name(name): | ||
""" | ||
Strips out all non-alphanumeric characters, including underscores, and replaces them with | ||
hyphens. Runs of multiple non-alphanumeric characters are replaced by only one hyphen. | ||
This is to take a given python package name and create an iteration of it that can be | ||
used as part of a url, e.g. for the simple api. | ||
Args: | ||
name (str): A project name to sanitize | ||
""" | ||
return re.sub('[^A-Za-z0-9]+', '-', name).lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters