Skip to content

Commit 4705b15

Browse files
authored
Fix two issues (#439)
* update * Update regex.py
1 parent 47a316a commit 4705b15

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

azdev/operations/regex.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ def search_argument_context(row_num, lines):
8888
cmds = []
8989
while row_num > 0:
9090
row_num -= 1
91-
# Match `with self.argument_context('') as c:`
92-
sub_pattern0 = r'with self.argument_context\(\'(.*?)\'[\),]'
91+
# Match `with self.argument_context(['"]['"]) as c:`
92+
sub_pattern0 = r'with self.argument_context\([\'\"](.*?)[\'\"][\),]'
9393
# Match `with self.argument_context(scope) as c:`
9494
sub_pattern1 = r'with self.argument_context\(scope[\),]'
95-
# Match `with self.argument_context(\'{} stop\'.format(scope)) as c:',
96-
sub_pattern2 = r'with self.argument_context\(\'(.*)\'.format\(scope\)\)'
95+
# Match `with self.argument_context(['"]{} stop['"].format(scope)) as c:',
96+
sub_pattern2 = r'with self.argument_context\([\'\"](.*)[\'\"].format\(scope\)\)'
97+
# There are many matching patterns, but their proportion is very small. Ignore these commands.
9798
ref0 = re.findall(sub_pattern0, lines[row_num])
9899
ref1 = re.findall(sub_pattern1, lines[row_num])
99100
ref2 = re.findall(sub_pattern2, lines[row_num])
100-
# Match `with self.argument_context('') as c:`
101+
# Match `with self.argument_context(['"]['"]) as c:`
101102
if ref0:
102103
cmds = ref0
103104
break
@@ -107,7 +108,7 @@ def search_argument_context(row_num, lines):
107108
cmds = json.loads(
108109
re.findall(sub_pattern, lines[row_num - 1])[0].replace('\'', '"'))
109110
break
110-
# Match `with self.argument_context(\'{} stop\'.format(scope)) as c:',
111+
# Match `with self.argument_context(['"]{} stop['"].format(scope)) as c:',
111112
if ref2:
112113
sub_pattern = r'for scope in (.*):'
113114
format_strings = json.loads(

azdev/operations/style.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,15 @@ def run(paths, rcfile, desc):
192192

193193

194194
def _config_file_path(style_type="pylint"):
195-
cli_repo_path = get_azdev_config().get("cli", "repo_path")
196-
197-
ext_repo_path = filter(
198-
lambda x: "azure-cli-extension" in x,
199-
get_azdev_config().get("ext", "repo_paths").split(),
200-
)
195+
from configparser import NoSectionError
196+
try:
197+
cli_repo_path = get_azdev_config().get("cli", "repo_path")
198+
except NoSectionError:
199+
cli_repo_path = None
201200
try:
202-
ext_repo_path = next(ext_repo_path)
203-
except StopIteration:
204-
ext_repo_path = []
201+
ext_repo_path = get_azdev_config().get("ext", "repo_paths").split(',')[0]
202+
except NoSectionError:
203+
ext_repo_path = None
205204

206205
if style_type not in ["pylint", "flake8"]:
207206
raise ValueError("style_tyle value allows only: pylint, flake8.")

0 commit comments

Comments
 (0)