mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Resolve homebrew and homebrew_cask package name validation issues (#1038)
Add basic regression tests Add changelog Rename _create_regex_group to better suit function Fix '-' use in Homebrew validation
This commit is contained in:
parent
4842f67da1
commit
4c379bd3b2
5 changed files with 62 additions and 14 deletions
|
@ -152,7 +152,7 @@ class HomebrewCaskException(Exception):
|
|||
|
||||
|
||||
# utils ------------------------------------------------------------------- {{{
|
||||
def _create_regex_group(s):
|
||||
def _create_regex_group_complement(s):
|
||||
lines = (line.strip() for line in s.split('\n') if line.strip())
|
||||
chars = filter(None, (line.split('#')[0].strip() for line in lines))
|
||||
group = r'[^' + r''.join(chars) + r']'
|
||||
|
@ -170,7 +170,7 @@ class HomebrewCask(object):
|
|||
: # colons
|
||||
{sep} # the OS-specific path separator
|
||||
. # dots
|
||||
- # dashes
|
||||
\- # dashes
|
||||
'''.format(sep=os.path.sep)
|
||||
|
||||
VALID_BREW_PATH_CHARS = r'''
|
||||
|
@ -178,20 +178,20 @@ class HomebrewCask(object):
|
|||
\s # spaces
|
||||
{sep} # the OS-specific path separator
|
||||
. # dots
|
||||
- # dashes
|
||||
\- # dashes
|
||||
'''.format(sep=os.path.sep)
|
||||
|
||||
VALID_CASK_CHARS = r'''
|
||||
\w # alphanumeric characters (i.e., [a-zA-Z0-9_])
|
||||
. # dots
|
||||
/ # slash (for taps)
|
||||
- # dashes
|
||||
\- # dashes
|
||||
@ # at symbol
|
||||
'''
|
||||
|
||||
INVALID_PATH_REGEX = _create_regex_group(VALID_PATH_CHARS)
|
||||
INVALID_BREW_PATH_REGEX = _create_regex_group(VALID_BREW_PATH_CHARS)
|
||||
INVALID_CASK_REGEX = _create_regex_group(VALID_CASK_CHARS)
|
||||
INVALID_PATH_REGEX = _create_regex_group_complement(VALID_PATH_CHARS)
|
||||
INVALID_BREW_PATH_REGEX = _create_regex_group_complement(VALID_BREW_PATH_CHARS)
|
||||
INVALID_CASK_REGEX = _create_regex_group_complement(VALID_CASK_CHARS)
|
||||
# /class regexes ----------------------------------------------- }}}
|
||||
|
||||
# class validations -------------------------------------------- {{{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue