diff options
author | Natanael Arndt <arndtn@gmail.com> | 2021-03-01 17:43:39 +0100 |
---|---|---|
committer | Natanael Arndt <arndtn@gmail.com> | 2021-03-01 17:43:39 +0100 |
commit | eefaa374a01dbfef45da3984699b83f75962a0cb (patch) | |
tree | 2098124c3711aca0e8157368c8696833f0abc854 | |
parent | 6580da099a518f05561f2c15d8b1cdb6fabfd7fb (diff) | |
download | rdflib-eefaa374a01dbfef45da3984699b83f75962a0cb.tar.gz |
Use set instead of string or list for set of chars
-rwxr-xr-x | rdflib/plugins/parsers/notation3.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py index 99f6cc16..4bb6b5df 100755 --- a/rdflib/plugins/parsers/notation3.py +++ b/rdflib/plugins/parsers/notation3.py @@ -303,15 +303,15 @@ option_noregen = 0 # If set, do not regenerate genids on output # characters. The XML spec switched to assuming unknown things were name # characaters. # _namechars = string.lowercase + string.uppercase + string.digits + '_-' -_notQNameChars = list("\t\r\n !\"#$&'()*,+/;<=>?@[\\]^`{|}~") # else valid qname :-/ -_notKeywordsChars = _notQNameChars + ["."] -_notNameChars = _notQNameChars + [":"] # Assume anything else valid name :-/ +_notQNameChars = set("\t\r\n !\"#$&'()*,+/;<=>?@[\\]^`{|}~") # else valid qname :-/ +_notKeywordsChars = _notQNameChars | {"."} +_notNameChars = _notQNameChars | {":"} # Assume anything else valid name :-/ _rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" -hexChars = list("ABCDEFabcdef0123456789") -escapeChars = list("(_~.-!$&'()*+,;=/?#@%)") # valid for \ escapes in localnames -numberChars = list("0123456789-") -numberCharsPlus = numberChars + ["+", "."] +hexChars = set("ABCDEFabcdef0123456789") +escapeChars = set("(_~.-!$&'()*+,;=/?#@%)") # valid for \ escapes in localnames +numberChars = set("0123456789-") +numberCharsPlus = numberChars | {"+", "."} def unicodeExpand(m): try: @@ -848,7 +848,7 @@ class SinkParser: if j < 0: return j # nope - while argstr[j] in ["!", "^"]: # no spaces, must follow exactly (?) + while argstr[j] in {"!", "^"}: # no spaces, must follow exactly (?) ch = argstr[j] subj = res.pop() obj = self.blankNode(uri=self.here(j)) @@ -1240,10 +1240,10 @@ class SinkParser: try: while True: ch = argstr[i] - if ch in [" ", "\t"]: + if ch in {" ", "\t"}: i += 1 continue - elif ch not in ["#", "\r", "\n"]: + elif ch not in {"#", "\r", "\n"}: return i break except IndexError: @@ -1585,11 +1585,11 @@ class SinkParser: if ch == delim1: j = i continue - elif ch in ['"', "'"] and ch != delim1: + elif ch in {'"', "'"} and ch != delim1: ustr += ch j = i + 1 continue - elif ch in ["\r", "\n"]: + elif ch in {"\r", "\n"}: if delim == delim1: raise BadSyntax( self._thisDoc, |