diff --git a/src/wikitextprocessor/core.py b/src/wikitextprocessor/core.py index 5c3e4cd..741abe5 100644 --- a/src/wikitextprocessor/core.py +++ b/src/wikitextprocessor/core.py @@ -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() @@ -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") diff --git a/src/wikitextprocessor/luaexec.py b/src/wikitextprocessor/luaexec.py index 9ab9366..736abe9 100644 --- a/src/wikitextprocessor/luaexec.py +++ b/src/wikitextprocessor/luaexec.py @@ -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: @@ -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) diff --git a/src/wikitextprocessor/parser.py b/src/wikitextprocessor/parser.py index a8fac10..b7a169b 100644 --- a/src/wikitextprocessor/parser.py +++ b/src/wikitextprocessor/parser.py @@ -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) @@ -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 "" diff --git a/src/wikitextprocessor/parserfns.py b/src/wikitextprocessor/parserfns.py index 99b0a62..3ca62fa 100644 --- a/src/wikitextprocessor/parserfns.py +++ b/src/wikitextprocessor/parserfns.py @@ -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"] @@ -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( @@ -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( @@ -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) @@ -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) @@ -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", @@ -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: