-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move isValidItemName func to Utilities module
- Loading branch information
Showing
2 changed files
with
22 additions
and
17 deletions.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,20 @@ | ||
| """A collection of utilities to be used throughout the webqueue2 API. | ||
| """ | ||
|
|
||
| import re | ||
|
|
||
| def isValidItemName(name: str) -> bool: | ||
| """Returns true if file name is a valid item name | ||
| Example: | ||
| isValidItemName("21") -> true | ||
| isValidItemName("twentyone") -> false | ||
| Args: | ||
| name (str): The name to test. | ||
| Returns: | ||
| bool: Name is valid item name. | ||
| """ | ||
| itemPattern = re.compile("^[0123456789]{1,3}$") | ||
| return True if itemPattern.match(name) else False |