Skip to content
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
4 changes: 2 additions & 2 deletions src/wikitextprocessor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ def expand_args(coded: str, argmap: TemplateArgs) -> str:
expand_args(args[0], argmap), parent, True
).strip()
self.expand_stack.pop()
if k.isdigit() and int(k) > 0:
if k.isdecimal() and int(k) > 0:
k = int(k)
else:
k = re.sub(r"\s+", " ", k).strip()
Expand Down Expand Up @@ -1550,7 +1550,7 @@ def expander(arg: str) -> str:
# https://en.wikipedia.org/wiki/Help:Template
# (but not around unnamed parameters)
k, arg = m2.groups()
if k.isdigit() and int(k) > 0:
if k.isdecimal() and int(k) > 0:
k = int(k)
else:
self.expand_stack.append("ARGNAME")
Expand Down
4 changes: 2 additions & 2 deletions src/wikitextprocessor/luaexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def recurse(x: Union[list, tuple, dict]) -> Any:
# Convert numeric keys to integers and see if we can make it a
# table with sequential integer keys.
for k, v in list(x.items()):
if k.isdigit() and int(k) > 0:
if k.isdecimal() and int(k) > 0:
del x[k]
x[int(k)] = recurse(v)
else:
Expand Down Expand Up @@ -440,7 +440,7 @@ def make_frame(
if m is not None:
# named parameter
k, arg = m.groups()
if k.isdigit() and int(k) > 0:
if k.isdecimal() and int(k) > 0:
# Greek wiktionary uses '0', '00' and '000' as
# parameter names...
k = int(k)
Expand Down
4 changes: 2 additions & 2 deletions src/wikitextprocessor/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ def template_parameters(self) -> TemplateParameters:
equal_sign_index + 1 :
].lstrip()
if (
parameter_name.isdigit()
parameter_name.isdecimal()
and int(parameter_name) > 0
): # value contains "="
parameter_name = int(parameter_name)
Expand Down Expand Up @@ -1997,7 +1997,7 @@ def tag_fn(ctx: "Wtp", token: str) -> None:
# Give a warning on unsupported HTML tags. WikiText limits the set of
# tags that are allowed.
if name not in ctx.allowed_html_tags:
if not name.isdigit() and not SILENT_HTML_LIKE:
if not name.isdecimal() and not SILENT_HTML_LIKE:
ctx.debug(
"html tag <{}{}> not allowed in WikiText".format(
name, "/" if also_end else ""
Expand Down
18 changes: 9 additions & 9 deletions src/wikitextprocessor/parserfns.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def ns_fn(
return ""
lc_arg = arg.lower()
for key, ns in wtp.NAMESPACE_DATA.items():
if arg.isdigit() and ns["id"] == int(arg):
if arg.isdecimal() and ns["id"] == int(arg):
return ns["name"]
if ns["name"].lower() == lc_arg or lc_arg == key.lower():
return ns["name"]
Expand Down Expand Up @@ -1122,8 +1122,8 @@ def padleft_fn(
v = expander(args[0]) if args else ""
cntstr = expander(args[1]).strip() if len(args) >= 2 else "0"
pad = expander(args[2]) if len(args) >= 3 else "0"
if not cntstr.isdigit():
if cntstr.startswith("-") and cntstr[1:].isdigit():
if not cntstr.isdecimal():
if cntstr.startswith("-") and cntstr[1:].isdecimal():
pass
else:
ctx.warning(
Expand All @@ -1147,9 +1147,9 @@ def padright_fn(
v = expander(args[0]) if args else ""
cntstr = expander(args[1]).strip() if len(args) >= 2 else "0"
pad = expander(args[2]) if len(args) >= 3 else "0"
if not cntstr.isdigit():
if not cntstr.isdecimal():
cnt = 0
if cntstr.startswith("-") and cntstr[1:].isdigit():
if cntstr.startswith("-") and cntstr[1:].isdecimal():
pass
else:
ctx.warning(
Expand Down Expand Up @@ -1385,7 +1385,7 @@ def pos_fn(
arg0 = expander(args[0]).strip() if args else ""
arg1 = expander(args[1]) or " " if len(args) >= 2 else " "
offsetstr = expander(args[2]).strip() if len(args) >= 3 else ""
if not offsetstr or not offsetstr.isdigit():
if not offsetstr or not offsetstr.isdecimal():
offset = 0
else:
offset = int(offsetstr)
Expand All @@ -1402,7 +1402,7 @@ def rpos_fn(
arg0 = expander(args[0]).strip() if args else ""
arg1 = expander(args[1]) or " " if len(args) >= 2 else " "
offsetstr = expander(args[2]).strip() if len(args) >= 3 else ""
if not offsetstr or not offsetstr.isdigit():
if not offsetstr or not offsetstr.isdecimal():
offset = 0
else:
offset = int(offsetstr)
Expand Down Expand Up @@ -1445,7 +1445,7 @@ def pad_fn(
cntstr = expander(args[1]).strip() if len(args) >= 2 else ""
pad = expander(args[2]) if len(args) >= 3 and args[2] else "0"
direction = expander(args[3]) if len(args) >= 4 else ""
if not cntstr.isdigit():
if not cntstr.isdecimal():
ctx.warning(
"pad length is not integer: {!r}".format(cntstr),
sortid="parserfns/1133",
Expand Down Expand Up @@ -1973,7 +1973,7 @@ def call_parser_function(
ofs = arg.find("=")
if ofs >= 0:
k = arg[:ofs]
if k.isdigit():
if k.isdecimal():
k = int(k)
arg = arg[ofs + 1 :]
else:
Expand Down