Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the regular expression escapes for more recent python versions. #343

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scabha/basetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def parse(value: str, expand_user=True):

If expand_user is True, ~ in (file-protocol) paths will be expanded.
"""
match = re.fullmatch("((\w+)://)(.*)", value)
match = re.fullmatch(r'((\w+)://)(.*)', value)
if not match:
protocol, path, remote = "file", value, False
else:
Expand Down
2 changes: 1 addition & 1 deletion scabha/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def rich_help(self, tree, max_category=ParameterCategory.Optional):
attrs.append(f"choices: {', '.join(schema.choices)}")
info = []
schema.info and info.append(rich.markup.escape(schema.info))
attrs and info.append(f"[dim]\[{rich.markup.escape(', '.join(attrs))}][/dim]")
attrs and info.append(f"[dim]\\[{rich.markup.escape(', '.join(attrs))}][/dim]")
table.add_row(f"[bold]{name}[/bold]",
f"[dim]{rich.markup.escape(str(schema.dtype))}[/dim]",
" ".join(info))
Expand Down
2 changes: 1 addition & 1 deletion scabha/configuratt/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def load_include_files(keyword):
if not incl:
raise ConfigurattError(f"{errloc}: empty {keyword} specifier")
# check for [flags] at end of specifier
match = re.match("^(.*)\[(.*)\]$", incl)
match = re.match(r'^(.*)\[(.*)\]$', incl)
if match:
incl = match.group(1)
flags = set([x.strip().lower() for x in match.group(2).split(",")])
Expand Down
2 changes: 1 addition & 1 deletion stimela/backends/kube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class DebugOptions(object):
# if >0, events will be collected and reported
log_events: bool = False
# format string for reporting kubernetes events, this can include rich markup
event_format: str = "=NOSUBST('\[k8s event type: {event.type}, reason: {event.reason}] {event.message}')"
event_format: str = "=NOSUBST('\\[k8s event type: {event.type}, reason: {event.reason}] {event.message}')"
event_colors: Dict[str, str] = DictDefault(
warning="blue", error="yellow", default="grey50")

Expand Down
4 changes: 2 additions & 2 deletions stimela/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def resolve_recipe_file(filename: str):

# check for (location)filename.yml or (location)/filename.yml style
match1 = re.fullmatch("^\\((.+)\\)/?(.+)$", filename)
match2 = re.fullmatch("^([\w.]+)::(.+)$", filename)
match2 = re.fullmatch(r"^([\w.]+)::(.+)$", filename)
if match1 or match2:
modulename, fname = (match1 or match2).groups()
try:
Expand Down Expand Up @@ -84,7 +84,7 @@ def load_recipe_files(filenames: List[str]):
for filename in filenames:
# check for (location)filename.yaml or (location)/filename.yaml style
match1 = re.fullmatch("^\\((.+)\\)/?(.+)$", filename)
match2 = re.fullmatch("^([\w.]+)::(.+)$", filename)
match2 = re.fullmatch(r"^([\w.]+)::(.+)$", filename)
if match1 or match2:
modulename, filename = (match1 or match2).groups()
try:
Expand Down
2 changes: 1 addition & 1 deletion stimela/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _load(conf, config_file):
ncpu=psutil.cpu_count(logical=True),
node=platform.node().split('.', 1)[0],
hostname=platform.node(),
env={key: value.replace('${', '\${') for key, value in os.environ.items()})
env={key: value.replace('${', r'\${') for key, value in os.environ.items()})
runtime['ncpu-logical'] = psutil.cpu_count(logical=True)
runtime['ncpu-physical'] = psutil.cpu_count(logical=False)

Expand Down
2 changes: 1 addition & 1 deletion stimela/kitchen/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def _add_alias(self, alias_name: str, alias_target: Union[str, Tuple],
alias_target = alias_target.replace("$", alias_name.rsplit('.', 1)[-1])
step_spec, step_param_name = alias_target.split('.', 1)
# treat label as a "(cabtype)" specifier?
if re.match('^\(.+\)$', step_spec):
if re.match(r'^\(.+\)$', step_spec):
steps = [(label, step) for label, step in self.steps.items()
if (isinstance(step.cargo, Cab) and step.cab == step_spec[1:-1]) or
(isinstance(step.cargo, Recipe) and step.recipe == step_spec[1:-1])]
Expand Down
2 changes: 1 addition & 1 deletion stimela/kitchen/wranglers.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def __init__(self, regex: re.Pattern, spec: str, name: Optional[str], group: str
self.name = name or group
if group in regex.groupindex:
self.gid = group
elif re.fullmatch('\d+', group):
elif re.fullmatch(r'\d+', group):
gid = int(group)
if gid > regex.groups:
raise CabValidationError(f"wrangler action '{spec}' for '{regex.pattern}': {gid} is not a valid ()-group")
Expand Down
Loading