summaryrefslogtreecommitdiff
path: root/pyparsing
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2022-06-16 07:39:35 -0500
committerptmcg <ptmcg@austin.rr.com>2022-06-16 07:39:35 -0500
commit6dcf9aad746d0f3ca873fa1c023f36819bf0b6df (patch)
treebfede886d757be277118fb8bcfa6fc887b93e87b /pyparsing
parent9c39a15cb42486bbbee828268d80cef3fe362df3 (diff)
downloadpyparsing-git-6dcf9aad746d0f3ca873fa1c023f36819bf0b6df.tar.gz
Clean up docstrings to use new PEP8 names instead of old camelCase names
Diffstat (limited to 'pyparsing')
-rw-r--r--pyparsing/common.py14
-rw-r--r--pyparsing/core.py16
-rw-r--r--pyparsing/helpers.py6
3 files changed, 18 insertions, 18 deletions
diff --git a/pyparsing/common.py b/pyparsing/common.py
index 9b52ed0..bb8472a 100644
--- a/pyparsing/common.py
+++ b/pyparsing/common.py
@@ -260,8 +260,8 @@ class pyparsing_common:
Example::
date_expr = pyparsing_common.iso8601_date.copy()
- date_expr.setParseAction(pyparsing_common.convertToDate())
- print(date_expr.parseString("1999-12-31"))
+ date_expr.set_parse_action(pyparsing_common.convert_to_date())
+ print(date_expr.parse_string("1999-12-31"))
prints::
@@ -287,8 +287,8 @@ class pyparsing_common:
Example::
dt_expr = pyparsing_common.iso8601_datetime.copy()
- dt_expr.setParseAction(pyparsing_common.convertToDatetime())
- print(dt_expr.parseString("1999-12-31T23:59:59.999"))
+ dt_expr.set_parse_action(pyparsing_common.convert_to_datetime())
+ print(dt_expr.parse_string("1999-12-31T23:59:59.999"))
prints::
@@ -326,9 +326,9 @@ class pyparsing_common:
# strip HTML links from normal text
text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
- td, td_end = makeHTMLTags("TD")
- table_text = td + SkipTo(td_end).setParseAction(pyparsing_common.stripHTMLTags)("body") + td_end
- print(table_text.parseString(text).body)
+ td, td_end = make_html_tags("TD")
+ table_text = td + SkipTo(td_end).set_parse_action(pyparsing_common.strip_html_tags)("body") + td_end
+ print(table_text.parse_string(text).body)
Prints::
diff --git a/pyparsing/core.py b/pyparsing/core.py
index 861548b..d35923f 100644
--- a/pyparsing/core.py
+++ b/pyparsing/core.py
@@ -485,7 +485,7 @@ class ParserElement(ABC):
base.suppress_warning(Diagnostics.warn_on_parse_using_empty_Forward)
# statement would normally raise a warning, but is now suppressed
- print(base.parseString("x"))
+ print(base.parse_string("x"))
"""
self.suppress_warnings_.append(warning_type)
@@ -2368,7 +2368,7 @@ class Keyword(Token):
Accepts two optional constructor arguments in addition to the
keyword string:
- - ``identChars`` is a string of characters that would be valid
+ - ``ident_chars`` is a string of characters that would be valid
identifier characters, defaulting to all alphanumerics + "_" and
"$"
- ``caseless`` allows case-insensitive matching, default is ``False``.
@@ -3028,10 +3028,10 @@ class Regex(Token):
# prints "<h1>main title</h1>"
"""
if self.asGroupList:
- raise TypeError("cannot use sub() with Regex(asGroupList=True)")
+ raise TypeError("cannot use sub() with Regex(as_group_list=True)")
if self.asMatch and callable(repl):
- raise TypeError("cannot use sub() with a callable with Regex(asMatch=True)")
+ raise TypeError("cannot use sub() with a callable with Regex(as_match=True)")
if self.asMatch:
@@ -3124,7 +3124,7 @@ class QuotedString(Token):
else:
endQuoteChar = endQuoteChar.strip()
if not endQuoteChar:
- raise ValueError("endQuoteChar cannot be the empty string")
+ raise ValueError("end_quote_char cannot be the empty string")
self.quoteChar = quote_char
self.quoteCharLen = len(quote_char)
@@ -3441,7 +3441,7 @@ class LineStart(PositionToken):
B AAA and definitely not this one
'''
- for t in (LineStart() + 'AAA' + restOfLine).search_string(test):
+ for t in (LineStart() + 'AAA' + rest_of_line).search_string(test):
print(t)
prints::
@@ -4531,7 +4531,7 @@ class AtLineStart(ParseElementEnhance):
B AAA and definitely not this one
'''
- for t in (AtLineStart('AAA') + restOfLine).search_string(test):
+ for t in (AtLineStart('AAA') + rest_of_line).search_string(test):
print(t)
prints::
@@ -5787,7 +5787,7 @@ sgl_quoted_string = Combine(
quoted_string = Combine(
Regex(r'"(?:[^"\n\r\\]|(?:"")|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*') + '"'
| Regex(r"'(?:[^'\n\r\\]|(?:'')|(?:\\(?:[^x]|x[0-9a-fA-F]+)))*") + "'"
-).set_name("quotedString using single or double quotes")
+).set_name("quoted string using single or double quotes")
unicode_string = Combine("u" + quoted_string.copy()).set_name("unicode string literal")
diff --git a/pyparsing/helpers.py b/pyparsing/helpers.py
index 4663177..1b48cfc 100644
--- a/pyparsing/helpers.py
+++ b/pyparsing/helpers.py
@@ -226,7 +226,7 @@ def one_of(
- ``caseless`` - treat all literals as caseless - (default= ``False``)
- ``use_regex`` - as an optimization, will
generate a :class:`Regex` object; otherwise, will generate
- a :class:`MatchFirst` object (if ``caseless=True`` or ``asKeyword=True``, or if
+ a :class:`MatchFirst` object (if ``caseless=True`` or ``as_keyword=True``, or if
creating a :class:`Regex` raises an exception) - (default= ``True``)
- ``as_keyword`` - enforce :class:`Keyword`-style matching on the
generated expressions - (default= ``False``)
@@ -445,12 +445,12 @@ def locatedExpr(expr: ParserElement) -> ParserElement:
- ``value`` - the actual parsed results
Be careful if the input text contains ``<TAB>`` characters, you
- may want to call :class:`ParserElement.parseWithTabs`
+ may want to call :class:`ParserElement.parse_with_tabs`
Example::
wd = Word(alphas)
- for match in locatedExpr(wd).searchString("ljsdf123lksdjjf123lkkjj1222"):
+ for match in locatedExpr(wd).search_string("ljsdf123lksdjjf123lkkjj1222"):
print(match)
prints::