* update

* Update regex.py
This commit is contained in:
ZelinWang 2024-03-22 17:17:10 +08:00 коммит произвёл GitHub
Родитель 47a316a037
Коммит 4705b15c85
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -88,16 +88,17 @@ def search_argument_context(row_num, lines):
cmds = []
while row_num > 0:
row_num -= 1
# Match `with self.argument_context('') as c:`
sub_pattern0 = r'with self.argument_context\(\'(.*?)\'[\),]'
# Match `with self.argument_context(['"]['"]) as c:`
sub_pattern0 = r'with self.argument_context\([\'\"](.*?)[\'\"][\),]'
# Match `with self.argument_context(scope) as c:`
sub_pattern1 = r'with self.argument_context\(scope[\),]'
# Match `with self.argument_context(\'{} stop\'.format(scope)) as c:',
sub_pattern2 = r'with self.argument_context\(\'(.*)\'.format\(scope\)\)'
# Match `with self.argument_context(['"]{} stop['"].format(scope)) as c:',
sub_pattern2 = r'with self.argument_context\([\'\"](.*)[\'\"].format\(scope\)\)'
# There are many matching patterns, but their proportion is very small. Ignore these commands.
ref0 = re.findall(sub_pattern0, lines[row_num])
ref1 = re.findall(sub_pattern1, lines[row_num])
ref2 = re.findall(sub_pattern2, lines[row_num])
# Match `with self.argument_context('') as c:`
# Match `with self.argument_context(['"]['"]) as c:`
if ref0:
cmds = ref0
break
@ -107,7 +108,7 @@ def search_argument_context(row_num, lines):
cmds = json.loads(
re.findall(sub_pattern, lines[row_num - 1])[0].replace('\'', '"'))
break
# Match `with self.argument_context(\'{} stop\'.format(scope)) as c:',
# Match `with self.argument_context(['"]{} stop['"].format(scope)) as c:',
if ref2:
sub_pattern = r'for scope in (.*):'
format_strings = json.loads(

Просмотреть файл

@ -192,16 +192,15 @@ def _run_pep8(modules):
def _config_file_path(style_type="pylint"):
cli_repo_path = get_azdev_config().get("cli", "repo_path")
ext_repo_path = filter(
lambda x: "azure-cli-extension" in x,
get_azdev_config().get("ext", "repo_paths").split(),
)
from configparser import NoSectionError
try:
ext_repo_path = next(ext_repo_path)
except StopIteration:
ext_repo_path = []
cli_repo_path = get_azdev_config().get("cli", "repo_path")
except NoSectionError:
cli_repo_path = None
try:
ext_repo_path = get_azdev_config().get("ext", "repo_paths").split(',')[0]
except NoSectionError:
ext_repo_path = None
if style_type not in ["pylint", "flake8"]:
raise ValueError("style_tyle value allows only: pylint, flake8.")