| |
- builtins.list(builtins.object)
-
- MatchList
- builtins.object
-
- Csv
- Format
- Format
- Http
- HttpRequest
- HttpResponse
- Json
- Network
- Path
- PegParser
- StandardMatch
- StandardRules
- Types
- Url
class Format(builtins.object) |
|
Format(name: str, match: Callable, decode: Callable, probable_true_positive: Callable = <function Format.<lambda> at 0x0000020BC3832F80>, probable_false_positive: Callable = <function Format.<lambda> at 0x0000020BC3833010>) -> None
Format is a dataclass used in formats dict to list, check,
decode and verify probable validity for all formats.
Formats was defined to check untrusted/identified strings,
there are probably lot of False positive because multiples formats
were very flexible. The `probable_true_positive` is used to identify
a probable real value for the format (by default return False),
and `probable_false_positive` is used to identify a probable false
value for the format (by default return True.) |
|
Methods defined here:
- __eq__(self, other)
- Return self==value.
- __init__(self, name: str, match: Callable, decode: Callable, probable_true_positive: Callable = <function Format.<lambda> at 0x0000020BC3832F80>, probable_false_positive: Callable = <function Format.<lambda> at 0x0000020BC3833010>) -> None
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
- probable_false_positive lambda x
- probable_true_positive lambda x
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __annotations__ = {'decode': typing.Callable, 'match': typing.Callable, 'name': <class 'str'>, 'probable_false_positive': typing.Callable, 'probable_true_positive': typing.Callable}
- __dataclass_fields__ = {'decode': Field(name='decode',type=typing.Callable,default...appingproxy({}),kw_only=False,_field_type=_FIELD), 'match': Field(name='match',type=typing.Callable,default=...appingproxy({}),kw_only=False,_field_type=_FIELD), 'name': Field(name='name',type=<class 'str'>,default=<da...appingproxy({}),kw_only=False,_field_type=_FIELD), 'probable_false_positive': Field(name='probable_false_positive',type=typing...appingproxy({}),kw_only=False,_field_type=_FIELD), 'probable_true_positive': Field(name='probable_true_positive',type=typing....appingproxy({}),kw_only=False,_field_type=_FIELD)}
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
- __hash__ = None
- __match_args__ = ('name', 'match', 'decode', 'probable_true_positive', 'probable_false_positive')
|
class HttpRequest(builtins.object) |
|
HttpRequest(verb: str, uri: str, magic: bytes, version: float, headers: List[Tuple[str, str]], body: bytes, content_length: int = 0, content_type: str = None, host: str = None) -> None
HttpRequest(verb: str, uri: str, magic: bytes, version: float, headers: List[Tuple[str, str]], body: bytes, content_length: int = 0, content_type: str = None, host: str = None) |
|
Methods defined here:
- __bytes__(self) -> bytes
- This magic method returns bytes for the full request
in the HTTP format.
>>> bytes(HttpRequest('GET', '/', b'HTTP', 1.0, [], b'body content'))
b"GET / HTTP/1.0\r\nContent-Length: 12\r\nUser-Agent: Maurice Lambert's HTTP client\r\n\r\nbody content"
>>> bytes(HttpRequest('POST', '/upload', b'HTTP', 1.1, [('Content-Length', '12'), ('Content-Type', 'application/json'), ('User-Agent', 'TestClient')], b'', 10, 'plain/text'))
b'POST /upload HTTP/1.1\r\nContent-Length: 12\r\nContent-Type: application/json\r\nUser-Agent: TestClient\r\n\r\n'
>>> bytes(HttpRequest('HEAD', '/wp-admin?user=admin', b'HTTP', 1.0, [], b'body content', 10, 'plain/text'))
b"HEAD /wp-admin?user=admin HTTP/1.0\r\nContent-Type: plain/text\r\nContent-Length: 10\r\nUser-Agent: Maurice Lambert's HTTP client\r\n\r\nbody content"
>>>
- __eq__(self, other)
- Return self==value.
- __init__(self, verb: str, uri: str, magic: bytes, version: float, headers: List[Tuple[str, str]], body: bytes, content_length: int = 0, content_type: str = None, host: str = None) -> None
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __annotations__ = {'body': <class 'bytes'>, 'content_length': <class 'int'>, 'content_type': <class 'str'>, 'headers': typing.List[typing.Tuple[str, str]], 'host': <class 'str'>, 'magic': <class 'bytes'>, 'uri': <class 'str'>, 'verb': <class 'str'>, 'version': <class 'float'>}
- __dataclass_fields__ = {'body': Field(name='body',type=<class 'bytes'>,default=<...appingproxy({}),kw_only=False,_field_type=_FIELD), 'content_length': Field(name='content_length',type=<class 'int'>,d...appingproxy({}),kw_only=False,_field_type=_FIELD), 'content_type': Field(name='content_type',type=<class 'str'>,def...appingproxy({}),kw_only=False,_field_type=_FIELD), 'headers': Field(name='headers',type=typing.List[typing.Tup...appingproxy({}),kw_only=False,_field_type=_FIELD), 'host': Field(name='host',type=<class 'str'>,default=Non...appingproxy({}),kw_only=False,_field_type=_FIELD), 'magic': Field(name='magic',type=<class 'bytes'>,default=...appingproxy({}),kw_only=False,_field_type=_FIELD), 'uri': Field(name='uri',type=<class 'str'>,default=<dat...appingproxy({}),kw_only=False,_field_type=_FIELD), 'verb': Field(name='verb',type=<class 'str'>,default=<da...appingproxy({}),kw_only=False,_field_type=_FIELD), 'version': Field(name='version',type=<class 'float'>,defaul...appingproxy({}),kw_only=False,_field_type=_FIELD)}
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
- __hash__ = None
- __match_args__ = ('verb', 'uri', 'magic', 'version', 'headers', 'body', 'content_length', 'content_type', 'host')
- content_length = 0
- content_type = None
- host = None
|
class HttpResponse(builtins.object) |
|
HttpResponse(magic: bytes, version: float, code: int, reason: str, headers: List[Tuple[str, str]], body: bytes, content_length: int = 0, content_type: str = None) -> None
HttpResponse(magic: bytes, version: float, code: int, reason: str, headers: List[Tuple[str, str]], body: bytes, content_length: int = 0, content_type: str = None) |
|
Methods defined here:
- __bytes__(self) -> bytes
- This magic method returns bytes for the full response
in the HTTP format.
>>> bytes(HttpResponse(b'HTTP', 1.0, 200, 'OK', [], b'body content'))
b"HTTP/1.0 200 OK\r\nContent-Length: 12\r\nServer: Maurice Lambert's HTTP server\r\n\r\nbody content"
>>> bytes(HttpResponse(b'HTTP', 1.1, 201, 'Created', [('Content-Length', '12'), ('Content-Type', 'application/json'), ('Server', 'TestServer')], b'', 10, 'plain/text'))
b'HTTP/1.1 201 Created\r\nContent-Length: 12\r\nContent-Type: application/json\r\nServer: TestServer\r\n\r\n'
>>> bytes(HttpResponse(b'HTTP', 1.0, 202, 'Accepted', [], b'body content', 10, 'plain/text'))
b"HTTP/1.0 202 Accepted\r\nContent-Type: plain/text\r\nContent-Length: 10\r\nServer: Maurice Lambert's HTTP server\r\n\r\nbody content"
>>>
- __eq__(self, other)
- Return self==value.
- __init__(self, magic: bytes, version: float, code: int, reason: str, headers: List[Tuple[str, str]], body: bytes, content_length: int = 0, content_type: str = None) -> None
- Initialize self. See help(type(self)) for accurate signature.
- __repr__(self)
- Return repr(self).
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __annotations__ = {'body': <class 'bytes'>, 'code': <class 'int'>, 'content_length': <class 'int'>, 'content_type': <class 'str'>, 'headers': typing.List[typing.Tuple[str, str]], 'magic': <class 'bytes'>, 'reason': <class 'str'>, 'version': <class 'float'>}
- __dataclass_fields__ = {'body': Field(name='body',type=<class 'bytes'>,default=<...appingproxy({}),kw_only=False,_field_type=_FIELD), 'code': Field(name='code',type=<class 'int'>,default=<da...appingproxy({}),kw_only=False,_field_type=_FIELD), 'content_length': Field(name='content_length',type=<class 'int'>,d...appingproxy({}),kw_only=False,_field_type=_FIELD), 'content_type': Field(name='content_type',type=<class 'str'>,def...appingproxy({}),kw_only=False,_field_type=_FIELD), 'headers': Field(name='headers',type=typing.List[typing.Tup...appingproxy({}),kw_only=False,_field_type=_FIELD), 'magic': Field(name='magic',type=<class 'bytes'>,default=...appingproxy({}),kw_only=False,_field_type=_FIELD), 'reason': Field(name='reason',type=<class 'str'>,default=<...appingproxy({}),kw_only=False,_field_type=_FIELD), 'version': Field(name='version',type=<class 'float'>,defaul...appingproxy({}),kw_only=False,_field_type=_FIELD)}
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)
- __hash__ = None
- __match_args__ = ('magic', 'version', 'code', 'reason', 'headers', 'body', 'content_length', 'content_type')
- content_length = 0
- content_type = None
|
class MatchList(builtins.list) |
|
MatchList(*args, **kwargs)
Simple list with hidden argument to identify match. |
|
- Method resolution order:
- MatchList
- builtins.list
- builtins.object
Methods defined here:
- __init__(self, *args, **kwargs)
- Initialize self. See help(type(self)) for accurate signature.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from builtins.list:
- __add__(self, value, /)
- Return self+value.
- __contains__(self, key, /)
- Return key in self.
- __delitem__(self, key, /)
- Delete self[key].
- __eq__(self, value, /)
- Return self==value.
- __ge__(self, value, /)
- Return self>=value.
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __gt__(self, value, /)
- Return self>value.
- __iadd__(self, value, /)
- Implement self+=value.
- __imul__(self, value, /)
- Implement self*=value.
- __iter__(self, /)
- Implement iter(self).
- __le__(self, value, /)
- Return self<=value.
- __len__(self, /)
- Return len(self).
- __lt__(self, value, /)
- Return self<value.
- __mul__(self, value, /)
- Return self*value.
- __ne__(self, value, /)
- Return self!=value.
- __repr__(self, /)
- Return repr(self).
- __reversed__(self, /)
- Return a reverse iterator over the list.
- __rmul__(self, value, /)
- Return value*self.
- __setitem__(self, key, value, /)
- Set self[key] to value.
- __sizeof__(self, /)
- Return the size of the list in memory, in bytes.
- append(self, object, /)
- Append object to the end of the list.
- clear(self, /)
- Remove all items from list.
- copy(self, /)
- Return a shallow copy of the list.
- count(self, value, /)
- Return number of occurrences of value.
- extend(self, iterable, /)
- Extend list by appending elements from the iterable.
- index(self, value, start=0, stop=9223372036854775807, /)
- Return first index of value.
Raises ValueError if the value is not present.
- insert(self, index, object, /)
- Insert object before index.
- pop(self, index=-1, /)
- Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(self, value, /)
- Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse(self, /)
- Reverse *IN PLACE*.
- sort(self, /, *, key=None, reverse=False)
- Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them,
ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
Class methods inherited from builtins.list:
- __class_getitem__(...) from builtins.type
- See PEP 585
Static methods inherited from builtins.list:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Data and other attributes inherited from builtins.list:
- __hash__ = None
|
class PegParser(builtins.object) |
|
This class implements methods for a PEG parser. |
|
Methods defined here:
- and_predicate(first: Callable, data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method implements the PEG `and predicate`
("match without consume data" | position is always the same).
- not_predicate(first: Callable, data: bytes, position: int) -> Tuple[int, Optional[bool]]
- This method implements the PEG `not predicate`
("don't match without consume data" | position is always the same).
- one_or_more(first: Callable, data: bytes, position: int) -> Tuple[int, Optional[List[bytes]]]
- This method implements the PEG `one or more`
(like "+" in regex).
- ordered_choice(rules: Iterable[Callable], data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method implements the PEG `ordered choice`
("OR" operator, like "|" in regex).
- sequence(rules: Iterable[Callable], data: bytes, position: int) -> Tuple[int, Optional[List[bytes]]]
- This method implements the PEG `sequence`
("match 2 elements").
- zero_or_more(first: Callable, data: bytes, position: int) -> Tuple[int, List[bytes]]
- This method implements the PEG `zero or more` or `optional`
(like "*" in regex).
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class StandardMatch(builtins.object) |
|
This class implements methods to match standard characters groups. |
|
Methods defined here:
- check_char(char: int) -> Callable
- Generic method to generate a check for a specific character.
- is_blank(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII special character.
>>> StandardMatch.is_blank(b" 1Bc", 0)
(1, b' ')
>>> StandardMatch.is_blank(b" 1Bc", 1)
(1, None)
>>> len([x for x in range(256) if StandardMatch.is_blank(bytes((x,)), 0)[1] is not None])
6
>>>
- is_digit(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII digit character.
>>> StandardMatch.is_digit(b"a1Bc", 0)
(0, None)
>>> StandardMatch.is_digit(b"a1Bc", 1)
(2, b'1')
>>> StandardMatch.is_digit(b"a1Bc", 2)
(2, None)
>>> len([x for x in range(256) if StandardMatch.is_digit(bytes((x,)), 0)[1] is not None])
10
>>>
- is_hex(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII hexadecimal character.
>>> StandardMatch.is_hex(b"a1Bc", 0)
(1, b'a')
>>> StandardMatch.is_hex(b"a1Bc", 1)
(2, b'1')
>>> StandardMatch.is_hex(b"a1Bc", 2)
(3, b'B')
>>> StandardMatch.is_hex(b"a1Bg", 3)
(3, None)
>>> len([x for x in range(256) if StandardMatch.is_hex(bytes((x,)), 0)[1] is not None])
22
>>>
- is_letter(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII letter
(upper or lower case).
>>> StandardMatch.is_letter(b"a1Bc", 0)
(1, b'a')
>>> StandardMatch.is_letter(b"a1Bc", 1)
(1, None)
>>> StandardMatch.is_letter(b"a1Bc", 2)
(3, b'B')
>>> len([x for x in range(256) if StandardMatch.is_letter(bytes((x,)), 0)[1] is not None])
52
>>>
- is_lower(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII lower case letter.
>>> StandardMatch.is_lower(b"a1Bc", 0)
(1, b'a')
>>> StandardMatch.is_lower(b"a1Bc", 1)
(1, None)
>>> StandardMatch.is_lower(b"a1Bc", 2)
(2, None)
>>> len([x for x in range(256) if StandardMatch.is_lower(bytes((x,)), 0)[1] is not None])
26
>>>
- is_octal(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII octal character.
>>> StandardMatch.is_octal(b"01234567", 0)
(1, b'0')
>>> StandardMatch.is_octal(b"789", 0)
(1, b'7')
>>> StandardMatch.is_octal(b"a123", 0)
(0, None)
>>> StandardMatch.is_octal(b";+123", 0)
(0, None)
>>> len([x for x in range(256) if StandardMatch.is_octal(bytes((x,)), 0)[1] is not None])
8
>>>
- is_printable(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII printable character.
>>> StandardMatch.is_printable(b"a1Bc", 0)
(1, b'a')
>>> StandardMatch.is_printable(b"a1Bc", 1)
(2, b'1')
>>> StandardMatch.is_printable(b"a1Bc", 2)
(3, b'B')
>>> StandardMatch.is_printable(b"a1B\0", 3)
(3, None)
>>> from string import printable
>>> len([x for x in range(256) if StandardMatch.is_printable(bytes((x,)), 0)[1] is not None]) == len(printable)
True
>>>
- is_special(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII special character.
>>> StandardMatch.is_special(b";1Bc", 0)
(1, b';')
>>> StandardMatch.is_special(b" 1Bc", 1)
(1, None)
>>> from string import printable
>>> len([x for x in range(256) if StandardMatch.is_special(bytes((x,)), 0)[1] is not None]) == len(printable) - 26 * 2 - 10 - 6
True
>>>
- is_upper(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an ASCII upper case letter.
>>> StandardMatch.is_upper(b"a1Bc", 0)
(0, None)
>>> StandardMatch.is_upper(b"a1Bc", 1)
(1, None)
>>> StandardMatch.is_upper(b"a1Bc", 2)
(3, b'B')
>>> len([x for x in range(256) if StandardMatch.is_upper(bytes((x,)), 0)[1] is not None])
26
>>>
- or_check_chars(*chars: int) -> Callable
- Generic method to generate wrapper for `check_char`
with `ordered_choice`.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class StandardRules(builtins.object) |
|
This class implements standard rules. |
|
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- Csv = <class 'PegParser.StandardRules.Csv'>
- This class implements a complete parser for CSV and multi-CSV.
- Format = <class 'PegParser.StandardRules.Format'>
- This class implements standard data formats parsing rules.
- Http = <class 'PegParser.StandardRules.Http'>
- This class implements a complete parser for http.
- Json = <class 'PegParser.StandardRules.Json'>
- This class implements strict and permissive JSON parser.
- Network = <class 'PegParser.StandardRules.Network'>
- This class implements methods to parse Network formats and data.
- Path = <class 'PegParser.StandardRules.Path'>
- This class implements Windows and NT path.
- Types = <class 'PegParser.StandardRules.Types'>
- This class implements standard types parsing rules.
- Url = <class 'PegParser.StandardRules.Url'>
- This class implements methods to parse an URL.
|
StandardRules_Csv = class Csv(builtins.object) |
|
This class implements a complete parser for CSV and multi-CSV. |
|
Methods defined here:
- full(data: bytes, position: int = 0) -> Tuple[int, List[List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]]]]]]]]]]]
- This function parses the full CSV file.
>>> StandardRules.Csv.full(b'"1","test""test","other"\n')
(24, [[[b'"', [b'1'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't', [b'"', b'"'], b't', b'e', b's', b't'], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]]], []])
>>> StandardRules.Csv.full(b'"1","test"test","other"\r\n')
(10, [[[b'"', [b'1'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't'], b'"']]]], []])
>>> StandardRules.Csv.full(b'"1","test\n')
(3, [[[b'"', [b'1'], b'"'], []], []])
>>> StandardRules.Csv.full(b'"1","test,"other"\n"2"')
(11, [[[b'"', [b'1'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't', b','], b'"']]]], []])
>>> StandardRules.Csv.full(b'"1","","other"\n"2"\n"3","test"')
(29, [[[b'"', [b'1'], b'"'], [[b',', [b'"', [], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]]], [[b'\n', [[b'"', [b'2'], b'"'], []]], [b'\n', [[b'"', [b'3'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't'], b'"']]]]]]])
>>> StandardRules.Csv.full(b'"1"')
(3, [[[b'"', [b'1'], b'"'], []], []])
>>> StandardRules.Csv.full(b'')
(0, None)
>>>
- line(data: bytes, position: int = 0) -> Tuple[int, List[List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]]]]]
- This function parses a CSV line.
>>> StandardRules.Csv.line(b'"1","test""test","other"')
(24, [[b'"', [b'1'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't', [b'"', b'"'], b't', b'e', b's', b't'], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]]])
>>> StandardRules.Csv.line(b'"1","test"test","other"')
(10, [[b'"', [b'1'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't'], b'"']]]])
>>> StandardRules.Csv.line(b'"1","test')
(3, [[b'"', [b'1'], b'"'], []])
>>> StandardRules.Csv.line(b'"1","test,"other"')
(11, [[b'"', [b'1'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't', b','], b'"']]]])
>>> StandardRules.Csv.line(b'"1","","other"')
(14, [[b'"', [b'1'], b'"'], [[b',', [b'"', [], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]]])
>>> StandardRules.Csv.line(b'"1"')
(3, [[b'"', [b'1'], b'"'], []])
>>> StandardRules.Csv.line(b'')
(0, None)
>>>
- line_delimiter(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function parses the line delimiter ('\n' or '\r\n').
>>> StandardRules.Csv.line_delimiter(b'\n')
(1, b'\n')
>>> StandardRules.Csv.line_delimiter(b'\r\n')
(2, [b'\r', b'\n'])
>>> StandardRules.Csv.line_delimiter(b'"')
(0, None)
>>> StandardRules.Csv.line_delimiter(b'test')
(0, None)
>>>
- multi(data: bytes, position: int = 0) -> Tuple[int, List[List[Union[bytes, List[List[List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]]]]]]]]]]]]]]]
- This function parses a multi-csv.
>>> StandardRules.Csv.multi(b'"1","","other"\n"2"\n"3","test"\n\r\n"1","","other"\r\n"2"\r\n"3","test"')
(63, [[[[b'"', [b'1'], b'"'], [[b',', [b'"', [], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]]], [[b'\n', [[b'"', [b'2'], b'"'], []]], [b'\n', [[b'"', [b'3'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't'], b'"']]]]]]], [[b'\n', [b'\r', b'\n'], [[[b'"', [b'1'], b'"'], [[b',', [b'"', [], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]]], [[[b'\r', b'\n'], [[b'"', [b'2'], b'"'], []]], [[b'\r', b'\n'], [[b'"', [b'3'], b'"'], [[b',', [b'"', [b't', b'e', b's', b't'], b'"']]]]]]]]]])
>>>
- quoted_value(data: bytes, position: int = 0) -> Tuple[int, Optional[List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]
- This function parses a CSV quoted value.
>>> StandardRules.Csv.quoted_value(b'"test""test"')
(12, [b'"', [b't', b'e', b's', b't', [b'"', b'"'], b't', b'e', b's', b't'], b'"'])
>>> StandardRules.Csv.quoted_value(b'"test"test"')
(6, [b'"', [b't', b'e', b's', b't'], b'"'])
>>> StandardRules.Csv.quoted_value(b'"test')
(0, None)
>>> StandardRules.Csv.quoted_value(b'""')
(2, [b'"', [], b'"'])
>>>
- value(data: bytes, position: int = 0) -> Tuple[int, Optional[List[Union[bytes, List[bytes]]]]]
- This function parses a CSV value.
>>> StandardRules.Csv.value(b'test""test')
(10, [b't', b'e', b's', b't', [b'"', b'"'], b't', b'e', b's', b't'])
>>> StandardRules.Csv.value(b'test"test')
(4, [b't', b'e', b's', b't'])
>>>
- values(data: bytes, position: int = 0) -> Tuple[int, List[List[Union[bytes, List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]]]
- This function parses second to last value in the line.
>>> StandardRules.Csv.values(b',"test""test","other"')
(21, [[b',', [b'"', [b't', b'e', b's', b't', [b'"', b'"'], b't', b'e', b's', b't'], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]])
>>> StandardRules.Csv.values(b',"test"test","other"')
(7, [[b',', [b'"', [b't', b'e', b's', b't'], b'"']]])
>>> StandardRules.Csv.values(b',"test')
(0, [])
>>> StandardRules.Csv.values(b',"test,"other"')
(8, [[b',', [b'"', [b't', b'e', b's', b't', b','], b'"']]])
>>> StandardRules.Csv.values(b',"","other"')
(11, [[b',', [b'"', [], b'"']], [b',', [b'"', [b'o', b't', b'h', b'e', b'r'], b'"']]])
>>> StandardRules.Csv.values(b'')
(0, [])
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Format = class Format(builtins.object) |
|
This class implements standard data formats parsing rules. |
|
Methods defined here:
- base32(data: bytes, position: int = 0, lower: bool = False, insensitive: bool = False) -> Tuple[int, Iterable[Union[bool, Iterable[Union[bytes, Iterable[bytes]]]]]]
- This method checks for base32 format.
>>> StandardRules.Format.base32(b"AB======")
(8, [[], [b'A', b'B', b'=', b'=', b'=', b'=', b'=', b'=']])
>>> StandardRules.Format.base32(b"ABC2====")
(8, [[], [b'A', b'B', b'C', b'2', b'=', b'=', b'=', b'=']])
>>> StandardRules.Format.base32(b"ABC23===")
(8, [[], [b'A', b'B', b'C', b'2', b'3', b'=', b'=', b'=']])
>>> StandardRules.Format.base32(b"ABC23ZT=")
(8, [[], [b'A', b'B', b'C', b'2', b'3', b'Z', b'T', b'=']])
>>> StandardRules.Format.base32(b"ABC23ZT7")
(8, [[[b'A', b'B', b'C', b'2', b'3', b'Z', b'T', b'7']], True])
>>> StandardRules.Format.base32(b"AB")
(0, [[], True])
>>> StandardRules.Format.base32(b"A1======")
(0, [[], True])
>>> StandardRules.Format.base32(b"A ======")
(0, [[], True])
>>> StandardRules.Format.base32(b"ABC23ZT7KF======")
(16, [[[b'A', b'B', b'C', b'2', b'3', b'Z', b'T', b'7']], [b'K', b'F', b'=', b'=', b'=', b'=', b'=', b'=']])
>>>
- base32_insensitive(data: bytes, position: int = 0) -> Tuple[int, Iterable[Union[bool, Iterable[Union[bytes, Iterable[bytes]]]]]]
- This method checks for insensitive base32 format.
>>> StandardRules.Format.base32_insensitive(b"aB======")
(8, [[], [b'a', b'B', b'=', b'=', b'=', b'=', b'=', b'=']])
>>> StandardRules.Format.base32_insensitive(b"aBc2====")
(8, [[], [b'a', b'B', b'c', b'2', b'=', b'=', b'=', b'=']])
>>> StandardRules.Format.base32_insensitive(b"aBc23===")
(8, [[], [b'a', b'B', b'c', b'2', b'3', b'=', b'=', b'=']])
>>> StandardRules.Format.base32_insensitive(b"aBc23zt=")
(8, [[], [b'a', b'B', b'c', b'2', b'3', b'z', b't', b'=']])
>>> StandardRules.Format.base32_insensitive(b"aBc23zt7")
(8, [[[b'a', b'B', b'c', b'2', b'3', b'z', b't', b'7']], True])
>>> StandardRules.Format.base32_insensitive(b"ab")
(0, [[], True])
>>> StandardRules.Format.base32_insensitive(b"a1======")
(0, [[], True])
>>> StandardRules.Format.base32_insensitive(b"a ======")
(0, [[], True])
>>> StandardRules.Format.base32_insensitive(b"aBc23zt7kf======")
(16, [[[b'a', b'B', b'c', b'2', b'3', b'z', b't', b'7']], [b'k', b'f', b'=', b'=', b'=', b'=', b'=', b'=']])
>>>
- base32_lower(data: bytes, position: int = 0) -> Tuple[int, Iterable[Union[bool, Iterable[Union[bytes, Iterable[bytes]]]]]]
- This method checks for lower base32 format.
>>> StandardRules.Format.base32_lower(b"ab======")
(8, [[], [b'a', b'b', b'=', b'=', b'=', b'=', b'=', b'=']])
>>> StandardRules.Format.base32_lower(b"abc2====")
(8, [[], [b'a', b'b', b'c', b'2', b'=', b'=', b'=', b'=']])
>>> StandardRules.Format.base32_lower(b"abc23===")
(8, [[], [b'a', b'b', b'c', b'2', b'3', b'=', b'=', b'=']])
>>> StandardRules.Format.base32_lower(b"abc23zt=")
(8, [[], [b'a', b'b', b'c', b'2', b'3', b'z', b't', b'=']])
>>> StandardRules.Format.base32_lower(b"abc23zt7")
(8, [[[b'a', b'b', b'c', b'2', b'3', b'z', b't', b'7']], True])
>>> StandardRules.Format.base32_lower(b"ab")
(0, [[], True])
>>> StandardRules.Format.base32_lower(b"a1======")
(0, [[], True])
>>> StandardRules.Format.base32_lower(b"a ======")
(0, [[], True])
>>> StandardRules.Format.base32_lower(b"abc23zt7kf======")
(16, [[[b'a', b'b', b'c', b'2', b'3', b'z', b't', b'7']], [b'k', b'f', b'=', b'=', b'=', b'=', b'=', b'=']])
>>>
- base64(data: bytes, position: int = 0, urlsafe: bool = False) -> Tuple[int, Iterable[Union[bool, Iterable[Union[bytes, Iterable[bytes]]]]]]
- This method checks for base64 format.
>>> StandardRules.Format.base64(b'Y5==')
(4, [[], [b'Y', b'5', b'=', b'=']])
>>> StandardRules.Format.base64(b'Y5+=')
(4, [[], [b'Y', b'5', b'+', b'=']])
>>> StandardRules.Format.base64(b"Y5+/")
(4, [[[b'Y', b'5', b'+', b'/']], True])
>>> StandardRules.Format.base64(b"09AZaz+/")
(8, [[[b'0', b'9', b'A', b'Z'], [b'a', b'z', b'+', b'/']], True])
>>> StandardRules.Format.base64(b"++==")
(4, [[], [b'+', b'+', b'=', b'=']])
>>> StandardRules.Format.base64(b"///=")
(4, [[], [b'/', b'/', b'/', b'=']])
>>> StandardRules.Format.base64(b"a=")
(0, [[], True])
>>> StandardRules.Format.base64(b"a ==")
(0, [[], True])
>>>
- base64_urlsafe(data: bytes, position: int = 0) -> Tuple[int, Iterable[Union[bool, Iterable[Union[bytes, Iterable[bytes]]]]]]
- This method checks for base64 urlsafe format.
>>> StandardRules.Format.base64_urlsafe(b'Y5==')
(4, [[], [b'Y', b'5', b'=', b'=']])
>>> StandardRules.Format.base64_urlsafe(b'Y5-=')
(4, [[], [b'Y', b'5', b'-', b'=']])
>>> StandardRules.Format.base64_urlsafe(b"Y5-_")
(4, [[[b'Y', b'5', b'-', b'_']], True])
>>> StandardRules.Format.base64_urlsafe(b"09AZaz-_")
(8, [[[b'0', b'9', b'A', b'Z'], [b'a', b'z', b'-', b'_']], True])
>>> StandardRules.Format.base64_urlsafe(b"--==")
(4, [[], [b'-', b'-', b'=', b'=']])
>>> StandardRules.Format.base64_urlsafe(b"___=")
(4, [[], [b'_', b'_', b'_', b'=']])
>>> StandardRules.Format.base64_urlsafe(b"a=")
(0, [[], True])
>>> StandardRules.Format.base64_urlsafe(b"a+==")
(0, [[], True])
>>> StandardRules.Format.base64_urlsafe(b"a/==")
(0, [[], True])
>>>
- base85(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[bytes]]]]
- This method checks for base85 format.
>>> StandardRules.Format.base85(b'VPRomVE')
(5, [[b'V', b'P', b'R', b'o', b'm']])
>>> StandardRules.Format.base85(b'VPRomVPO')
(5, [[b'V', b'P', b'R', b'o', b'm']])
>>> StandardRules.Format.base85(b"VPRomVPRn")
(5, [[b'V', b'P', b'R', b'o', b'm']])
>>> StandardRules.Format.base85(b"VPRomVPRom")
(10, [[b'V', b'P', b'R', b'o', b'm'], [b'V', b'P', b'R', b'o', b'm']])
>>> StandardRules.Format.base85(b"VPRomVPRom``+|}{;<=>")
(20, [[b'V', b'P', b'R', b'o', b'm'], [b'V', b'P', b'R', b'o', b'm'], [b'`', b'`', b'+', b'|', b'}'], [b'{', b';', b'<', b'=', b'>']])
>>> StandardRules.Format.base85(b"VPRo mVPRom``+|}{;<=>")
(0, None)
>>>
- blanks(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks for multiples blank characters.
>>> StandardRules.Format.blanks(b"\n \n\r\n ")
(7, [b'\n', b' ', b'\n', b'\r', b'\n', b' ', b' '])
>>> StandardRules.Format.blanks(b"\r\t+")
(2, [b'\r', b'\t'])
>>> StandardRules.Format.blanks(b" ;")
(1, [b' '])
>>> StandardRules.Format.blanks(b"a ")
(0, None)
>>>
- hex(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks for hexadecimal characters.
>>> StandardRules.Format.hex(b"abcdef")
(6, [b'a', b'b', b'c', b'd', b'e', b'f'])
>>> StandardRules.Format.hex(b"abc0123")
(7, [b'a', b'b', b'c', b'0', b'1', b'2', b'3'])
>>> StandardRules.Format.hex(b"0123abc")
(7, [b'0', b'1', b'2', b'3', b'a', b'b', b'c'])
>>> StandardRules.Format.hex(b"+123")
(0, None)
>>> StandardRules.Format.hex(b"0B2;")
(3, [b'0', b'B', b'2'])
>>> StandardRules.Format.hex(b"a ")
(1, [b'a'])
>>>
- hexadecimal(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[bytes]]]]
- This method checks for multiples pairs of hexadecimal characters.
>>> StandardRules.Format.hexadecimal(b"abcdef")
(6, [[b'a', b'b'], [b'c', b'd'], [b'e', b'f']])
>>> StandardRules.Format.hexadecimal(b"abc0123")
(6, [[b'a', b'b'], [b'c', b'0'], [b'1', b'2']])
>>> StandardRules.Format.hexadecimal(b"0123abc")
(6, [[b'0', b'1'], [b'2', b'3'], [b'a', b'b']])
>>> StandardRules.Format.hexadecimal(b"+123")
(0, None)
>>> StandardRules.Format.hexadecimal(b"0B2;")
(2, [[b'0', b'B']])
>>> StandardRules.Format.hexadecimal(b"a ")
(0, None)
>>>
- integer(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bool, bytes, Iterable[bytes]]]]]
- This method checks signed integer.
>>> StandardRules.Format.integer(b"+1")
(2, [b'+', [b'1']])
>>> StandardRules.Format.integer(b"-123")
(4, [b'-', [b'1', b'2', b'3']])
>>> StandardRules.Format.integer(b"123")
(3, [True, [b'1', b'2', b'3']])
>>> StandardRules.Format.integer(b"1a3")
(1, [True, [b'1']])
>>> StandardRules.Format.integer(b"+a")
(0, None)
>>> StandardRules.Format.integer(b"-abc")
(0, None)
>>>
- octal(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks for a word.
>>> StandardRules.Format.octal(b"01234567")
(8, [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7'])
>>> StandardRules.Format.octal(b"789")
(1, [b'7'])
>>> StandardRules.Format.octal(b"abc123")
(0, None)
>>> StandardRules.Format.octal(b"+123")
(0, None)
>>> StandardRules.Format.octal(b"0;B2;")
(1, [b'0'])
>>> StandardRules.Format.octal(b"a ")
(0, None)
>>>
- optional_blanks(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks for optional multiples blank characters.
>>> StandardRules.Format.optional_blanks(b"\n \n\r\n ")
(7, [b'\n', b' ', b'\n', b'\r', b'\n', b' ', b' '])
>>> StandardRules.Format.optional_blanks(b"\r\t+")
(2, [b'\r', b'\t'])
>>> StandardRules.Format.optional_blanks(b" ;")
(1, [b' '])
>>> StandardRules.Format.optional_blanks(b"a ")
(0, [])
>>>
- string_null_terminated_length(minimum_length: int = 3) -> Callable
- This function matchs null terminated string
(like in C char* = "...") with `length` characters.
>>> StandardRules.Format.string_null_terminated_length()(b"abcdef\0")
(7, [b'a', b'b', b'c', [b'd', b'e', b'f'], b'\x00'])
>>> StandardRules.Format.string_null_terminated_length(3)(b"abc\0")
(4, [b'a', b'b', b'c', [], b'\x00'])
>>> StandardRules.Format.string_null_terminated_length(5)(b"abc\0")
(0, None)
>>> StandardRules.Format.string_null_terminated_length(5)(b"a\1bcdef\0")
(0, None)
>>>
- unicode_null_terminated_length(minimum_length: int = 3) -> Callable
- This function matchs null terminated string
(like in C char* = "...") with `length` characters.
>>> StandardRules.Format.unicode_null_terminated_length()(b"a\0b\0c\0d\0e\0f\0\0\0")
(14, [[b'a', b'\x00'], [b'b', b'\x00'], [b'c', b'\x00'], [[b'd', b'\x00'], [b'e', b'\x00'], [b'f', b'\x00']], b'\x00', b'\x00'])
>>> StandardRules.Format.unicode_null_terminated_length(3)(b"a\0b\0c\0\0\0")
(8, [[b'a', b'\x00'], [b'b', b'\x00'], [b'c', b'\x00'], [], b'\x00', b'\x00'])
>>> StandardRules.Format.unicode_null_terminated_length(5)(b"a\0b\0c\0\0\0")
(0, None)
>>> StandardRules.Format.unicode_null_terminated_length(5)(b"a\1b\0c\0d\0e\0f\0\0\0")
(0, None)
>>>
- word(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks for a word.
>>> StandardRules.Format.word(b"abc")
(3, [b'a', b'b', b'c'])
>>> StandardRules.Format.word(b"abc;")
(3, [b'a', b'b', b'c'])
>>> StandardRules.Format.word(b"+123")
(0, None)
>>> StandardRules.Format.word(b"1abc")
(0, None)
>>> StandardRules.Format.word(b"a ")
(1, [b'a'])
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Http = class Http(builtins.object) |
|
This class implements a complete parser for http. |
|
Methods defined here:
- field_name(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method returns `field_name` bytes for HTTP.
>>> StandardRules.Http.field_name(b'Content-Type')
(12, [b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'])
>>> StandardRules.Http.field_name(b'Content-Length')
(14, [b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'])
>>>
- field_value(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method returns `field_value` bytes for HTTP.
>>> StandardRules.Http.field_value(b'application/json; charset="utf8"')
(32, [b'a', b'p', b'p', b'l', b'i', b'c', b'a', b't', b'i', b'o', b'n', b'/', b'j', b's', b'o', b'n', b';', b' ', b'c', b'h', b'a', b'r', b's', b'e', b't', b'=', b'"', b'u', b't', b'f', b'8', b'"'])
>>> StandardRules.Http.field_value(b'Fri, 02 May 2025 14:02:56 GMT')
(29, [b'F', b'r', b'i', b',', b' ', b'0', b'2', b' ', b'M', b'a', b'y', b' ', b'2', b'0', b'2', b'5', b' ', b'1', b'4', b':', b'0', b'2', b':', b'5', b'6', b' ', b'G', b'M', b'T'])
>>>
- header(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method parses a HTTP header.
>>> StandardRules.Http.header(b'Content-Type: application/json\r\n')
(32, [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'], b':', b' ', [b'a', b'p', b'p', b'l', b'i', b'c', b'a', b't', b'i', b'o', b'n', b'/', b'j', b's', b'o', b'n'], b'\r', b'\n'])
>>> StandardRules.Http.header(b'Content-Length: 12\r\n')
(20, [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'], b':', b' ', [b'1', b'2'], b'\r', b'\n'])
>>>
- headers(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method parses HTTP headers.
>>> StandardRules.Http.headers(b'Content-Type: application/json\r\nContent-Length: 12\r\n\r\n')
(54, [[[[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'], b':', b' ', [b'a', b'p', b'p', b'l', b'i', b'c', b'a', b't', b'i', b'o', b'n', b'/', b'j', b's', b'o', b'n'], b'\r', b'\n'], [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'], b':', b' ', [b'1', b'2'], b'\r', b'\n']], b'\r', b'\n'])
>>>
- is_text_char(data: bytes, position: int) -> Tuple[int, Optional[bytes]]
- This method checks a position for an HTTP TEXT character.
>>> StandardRules.Http.is_text_char(b"a1Bc", 0)
(1, b'a')
>>> StandardRules.Http.is_text_char(b"a1Bc", 1)
(2, b'1')
>>> StandardRules.Http.is_text_char(b"a1Bc", 2)
(3, b'B')
>>> StandardRules.Http.is_text_char(b"a1B\0", 3)
(3, None)
>>> len([x for x in range(256) if StandardRules.Http.is_text_char(bytes((x,)), 0)[1] is not None])
96
>>>
- magic(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method returns `magic` bytes for the protocol.
>>> StandardRules.Http.magic(b'http')
(4, [b'h', b't', b't', b'p'])
>>> StandardRules.Http.magic(b'HTTP')
(4, [b'H', b'T', b'T', b'P'])
>>>
- protocol_version(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]
- This method returns `version` bytes for the protocol.
>>> StandardRules.Http.protocol_version(b'HTTP/1.0')
(8, [[b'H', b'T', b'T', b'P'], b'/', [[b'1'], b'.', [b'0']]])
>>> StandardRules.Http.protocol_version(b'http/1.1')
(8, [[b'h', b't', b't', b'p'], b'/', [[b'1'], b'.', [b'1']]])
>>>
- reason(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method returns `reason` bytes for the response status.
>>> StandardRules.Http.reason(b'OK')
(2, [b'O', b'K'])
>>> StandardRules.Http.reason(b'Internal Server Error')
(21, [b'I', b'n', b't', b'e', b'r', b'n', b'a', b'l', b' ', b'S', b'e', b'r', b'v', b'e', b'r', b' ', b'E', b'r', b'r', b'o', b'r'])
>>>
- request(data: bytes, position: int = 0)
- This method parses HTTP request.
>>> StandardRules.Http.request(b'POST http://test.test/test;test=test?test=test HTTP/1.0\r\nHost: myhost\r\nContent-Type: application/json; charset="utf-8"\r\nContent-Length: 12\r\n\r\nabcdefabcdef')
(142, [[b'P', b'O', b'S', b'T'], b' ', [[b'h', [b't', b't', b'p']], b':', [b'/', b'/', [[b't', [b'e', b's', b't']], [[b'.', [b't', [b'e', b's', b't']]]]], [[b'/', [[b't', b'e', b's', b't']]]]], [b';', [[[b't', b'e', b's', b't'], b'=', [b't', b'e', b's', b't']], []]], [b'?', [[b't', b'e', b's', b't'], b'=', [b't', b'e', b's', b't']]], True], b' ', [[b'H', b'T', b'T', b'P'], b'/', [[b'1'], b'.', [b'0']]], b'\r', b'\n', [[[[b'H', b'o', b's', b't'], b':', b' ', [b'm', b'y', b'h', b'o', b's', b't'], b'\r', b'\n'], [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'], b':', b' ', [b'a', b'p', b'p', b'l', b'i', b'c', b'a', b't', b'i', b'o', b'n', b'/', b'j', b's', b'o', b'n', b';', b' ', b'c', b'h', b'a', b'r', b's', b'e', b't', b'=', b'"', b'u', b't', b'f', b'-', b'8', b'"'], b'\r', b'\n'], [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'], b':', b' ', [b'1', b'2'], b'\r', b'\n']], b'\r', b'\n']])
>>> StandardRules.Http.request(b'POST /test;test=test?test=test HTTP/1.0\r\nHost: myhost\r\nContent-Type: application/json; charset="utf-8"\r\nContent-Length: 12\r\n\r\nabcdefabcdef')
(126, [[b'P', b'O', b'S', b'T'], b' ', [[[b'/', [[b't', b'e', b's', b't']]]], [b';', [[[b't', b'e', b's', b't'], b'=', [b't', b'e', b's', b't']], []]], [b'?', [[b't', b'e', b's', b't'], b'=', [b't', b'e', b's', b't']]]], b' ', [[b'H', b'T', b'T', b'P'], b'/', [[b'1'], b'.', [b'0']]], b'\r', b'\n', [[[[b'H', b'o', b's', b't'], b':', b' ', [b'm', b'y', b'h', b'o', b's', b't'], b'\r', b'\n'], [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'], b':', b' ', [b'a', b'p', b'p', b'l', b'i', b'c', b'a', b't', b'i', b'o', b'n', b'/', b'j', b's', b'o', b'n', b';', b' ', b'c', b'h', b'a', b'r', b's', b'e', b't', b'=', b'"', b'u', b't', b'f', b'-', b'8', b'"'], b'\r', b'\n'], [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'], b':', b' ', [b'1', b'2'], b'\r', b'\n']], b'\r', b'\n']])
>>>
- response(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]
- This method parses HTTP response.
>>> StandardRules.Http.response(b'HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: 12\r\n\r\n')
(71, [[[[b'H', b'T', b'T', b'P'], b'/', [[b'1'], b'.', [b'1']]], b' ', [b'2', b'0', b'0'], b' ', [b'O', b'K'], b'\r', b'\n'], [[[[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'], b':', b' ', [b'a', b'p', b'p', b'l', b'i', b'c', b'a', b't', b'i', b'o', b'n', b'/', b'j', b's', b'o', b'n'], b'\r', b'\n'], [[b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'], b':', b' ', [b'1', b'2'], b'\r', b'\n']], b'\r', b'\n']])
>>>
- response_start(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]
- This method parses the first line for HTTP response.
>>> StandardRules.Http.response_start(b'HTTP/1.1 200 OK\r\n')
(17, [[[b'H', b'T', b'T', b'P'], b'/', [[b'1'], b'.', [b'1']]], b' ', [b'2', b'0', b'0'], b' ', [b'O', b'K'], b'\r', b'\n'])
>>> StandardRules.Http.response_start(b'HTTP/1.0 500 Internal Server Error\r\n')
(36, [[[b'H', b'T', b'T', b'P'], b'/', [[b'1'], b'.', [b'0']]], b' ', [b'5', b'0', b'0'], b' ', [b'I', b'n', b't', b'e', b'r', b'n', b'a', b'l', b' ', b'S', b'e', b'r', b'v', b'e', b'r', b' ', b'E', b'r', b'r', b'o', b'r'], b'\r', b'\n'])
>>>
- status_code(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method returns `status code` bytes for the response.
>>> StandardRules.Http.status_code(b'200')
(3, [b'2', b'0', b'0'])
>>> StandardRules.Http.status_code(b'404')
(3, [b'4', b'0', b'4'])
>>>
- text(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method parses HTTP TEXT format.
>>> StandardRules.Http.text(b'HTTp Text 200 !')
(15, [b'H', b'T', b'T', b'p', b' ', b'T', b'e', b'x', b't', b' ', b'2', b'0', b'0', b' ', b'!'])
>>> StandardRules.Http.text(b'Another text to test 5.5, other things ?":@#')
(44, [b'A', b'n', b'o', b't', b'h', b'e', b'r', b' ', b't', b'e', b'x', b't', b' ', b't', b'o', b' ', b't', b'e', b's', b't', b' ', b'5', b'.', b'5', b',', b' ', b'o', b't', b'h', b'e', b'r', b' ', b't', b'h', b'i', b'n', b'g', b's', b' ', b'?', b'"', b':', b'@', b'#'])
>>>
- token(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method parses the first line for HTTP response.
>>> StandardRules.Http.token(b'Content-Type')
(12, [b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'T', b'y', b'p', b'e'])
>>> StandardRules.Http.token(b'Content-Length')
(14, [b'C', b'o', b'n', b't', b'e', b'n', b't', b'-', b'L', b'e', b'n', b'g', b't', b'h'])
>>>
- verb(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method returns `verb` bytes for the protocol.
>>> StandardRules.Http.verb(b'GET')
(3, [b'G', b'E', b'T'])
>>> StandardRules.Http.verb(b'POST')
(4, [b'P', b'O', b'S', b'T'])
>>> StandardRules.Http.verb(b'put')
(3, [b'p', b'u', b't'])
>>> StandardRules.Http.verb(b'delete')
(6, [b'd', b'e', b'l', b'e', b't', b'e'])
>>> StandardRules.Http.verb(b'Options')
(7, [b'O', b'p', b't', b'i', b'o', b'n', b's'])
>>> StandardRules.Http.verb(b'hEAD')
(4, [b'h', b'E', b'A', b'D'])
>>> StandardRules.Http.verb(b'PaTcH')
(5, [b'P', b'a', b'T', b'c', b'H'])
>>> StandardRules.Http.verb(b'tRaCe')
(5, [b't', b'R', b'a', b'C', b'e'])
>>>
- version(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method returns `version` bytes for the protocol.
>>> StandardRules.Http.version(b'1.0')
(3, [[b'1'], b'.', [b'0']])
>>> StandardRules.Http.version(b'1.1')
(3, [[b'1'], b'.', [b'1']])
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Json = class Json(builtins.object) |
|
This class implements strict and permissive JSON parser. |
|
Methods defined here:
- dict(data: bytes, position: int = 0) -> Tuple[int, Optional[List]]
- This function checks for strict JSON dict.
>>> StandardRules.Json.dict(b'{"1": null}')
(11, [[b'{'], [], [], [], [[b'"', [b'1'], b'"'], [], b':', [b' '], [b'n', b'u', b'l', b'l'], []], [], [b'}']])
>>> StandardRules.Json.dict(b'{"1": null, "2": true}')
(22, [[b'{'], [], [[[[b'"', [b'1'], b'"'], [], b':', [b' '], [b'n', b'u', b'l', b'l'], []], b',', [b' ']]], [], [[b'"', [b'2'], b'"'], [], b':', [b' '], [b't', b'r', b'u', b'e'], []], [], [b'}']])
>>> StandardRules.Json.dict(b'{"1": null, "2" : 1.5 , "3": {"test": true, "1": 2}, "4": [1, 2, false]}')
(72, [[b'{'], [], [[[[b'"', [b'1'], b'"'], [], b':', [b' '], [b'n', b'u', b'l', b'l'], []], b',', [b' ']], [[[b'"', [b'2'], b'"'], [b' '], b':', [b' '], [[b'1'], b'.', [b'5']], [b' ']], b',', [b' ']], [[[b'"', [b'3'], b'"'], [], b':', [b' '], [[b'{'], [], [[[[b'"', [b't', b'e', b's', b't'], b'"'], [], b':', [b' '], [b't', b'r', b'u', b'e'], []], b',', [b' ']]], [], [[b'"', [b'1'], b'"'], [], b':', [b' '], [b'2'], []], [], [b'}']], []], b',', [b' ']]], [], [[b'"', [b'4'], b'"'], [], b':', [b' '], [[b'['], [], [[[b'1'], [], b',', [b' ']], [[b'2'], [], b',', [b' ']]], [], [b'f', b'a', b'l', b's', b'e'], [], [b']']], []], [], [b'}']])
>>> StandardRules.Json.dict(b'{"1": null')
(0, None)
>>> StandardRules.Json.dict(b'{"1" null}')
(0, None)
>>> StandardRules.Json.dict(b'{"1", null}')
(0, None)
>>> StandardRules.Json.dict(b'{"1": null,}')
(0, None)
>>>
- false(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function checks for strict false value.
>>> StandardRules.Json.false(b'false')
(5, [b'f', b'a', b'l', b's', b'e'])
>>> StandardRules.Json.false(b'False')
(0, None)
>>> StandardRules.Json.false(b'FALSE')
(0, None)
>>>
- full(data: bytes, position: int = 0) -> Tuple[int, Optional[List]]
- This function matchs all JSON type (dict, list, string, float,
integer, boolean, null).
>>> StandardRules.Json.full(b'{}')
(2, [[b'{'], [], [b'}']])
>>> StandardRules.Json.full(b'{"key": "value", "test": "test"}')
(32, [[b'{'], [], [[[[b'"', [b'k', b'e', b'y'], b'"'], [], b':', [b' '], [b'"', [b'v', b'a', b'l', b'u', b'e'], b'"'], []], b',', [b' ']]], [], [[b'"', [b't', b'e', b's', b't'], b'"'], [], b':', [b' '], [b'"', [b't', b'e', b's', b't'], b'"'], []], [], [b'}']])
>>> StandardRules.Json.full(b'[]')
(2, [[b'['], [], [b']']])
>>> StandardRules.Json.full(b'[1, 2.5, nul]')
(0, None)
>>> StandardRules.Json.full(b'"string"')
(8, [b'"', [b's', b't', b'r', b'i', b'n', b'g'], b'"'])
>>> StandardRules.Json.full(b'1.5')
(3, [[b'1'], b'.', [b'5']])
>>> StandardRules.Json.full(b'1')
(1, [b'1'])
>>> StandardRules.Json.full(b'true')
(4, [b't', b'r', b'u', b'e'])
>>> StandardRules.Json.full(b'null')
(4, [b'n', b'u', b'l', b'l'])
>>>
- list(data: bytes, position: int = 0) -> Tuple[int, Optional[List]]
- This function checks for strict JSON list.
>>> StandardRules.Json.list(b'[]')
(2, [[b'['], [], [b']']])
>>> StandardRules.Json.list(b'[ ]')
(3, [[b'['], [b' '], [b']']])
>>> StandardRules.Json.list(b'[null]')
(6, [[b'['], [], [], [], [b'n', b'u', b'l', b'l'], [], [b']']])
>>> StandardRules.Json.list(b'[1, 1.5, 2 , "test", true, [false, null], {"test": 1, "1": null}]')
(65, [[b'['], [], [[[b'1'], [], b',', [b' ']], [[[b'1'], b'.', [b'5']], [], b',', [b' ']], [[b'2'], [b' '], b',', [b' ']], [[b'"', [b't', b'e', b's', b't'], b'"'], [], b',', [b' ']], [[b't', b'r', b'u', b'e'], [], b',', [b' ']], [[[b'['], [], [[[b'f', b'a', b'l', b's', b'e'], [], b',', [b' ']]], [], [b'n', b'u', b'l', b'l'], [], [b']']], [], b',', [b' ']]], [], [[b'{'], [], [[[[b'"', [b't', b'e', b's', b't'], b'"'], [], b':', [b' '], [b'1'], []], b',', [b' ']]], [], [[b'"', [b'1'], b'"'], [], b':', [b' '], [b'n', b'u', b'l', b'l'], []], [], [b'}']], [], [b']']])
>>> StandardRules.Json.list(b'[')
(0, None)
>>> StandardRules.Json.list(b'[1,]')
(0, None)
>>> StandardRules.Json.list(b'[1 null]')
(0, None)
>>>
- null(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function checks for strict null value.
>>> StandardRules.Json.null(b'null')
(4, [b'n', b'u', b'l', b'l'])
>>> StandardRules.Json.null(b'NulL')
(0, None)
>>> StandardRules.Json.null(b'None')
(0, None)
>>> StandardRules.Json.null(b'nonE')
(0, None)
>>> StandardRules.Json.null(b'nil')
(0, None)
>>> StandardRules.Json.null(b'nIl')
(0, None)
>>> StandardRules.Json.null(b'undefined')
(0, None)
>>> StandardRules.Json.null(b'undeFined')
(0, None)
>>>
- permissive_dict(data: bytes, position: int = 0) -> Tuple[int, Optional[List]]
- This function checks for a permissive JSON dict
(trailing comma, forgot comma, ...).
>>> StandardRules.Json.permissive_dict(b'{}')
(2, [[b'{'], [], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{"1": nuLl}')
(11, [[b'{'], [], [], [], [[b'"', [b'1'], b'"'], [b':', [b' ']], [b'n', b'u', b'L', b'l']], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{1: null "2": true}')
(19, [[b'{'], [], [[[[b'1'], [b':', [b' ']], [b'n', b'u', b'l', b'l']], [[b' ']]]], [], [[b'"', [b'2'], b'"'], [b':', [b' ']], [b't', b'r', b'u', b'e']], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{"1" null, "2" : 1.5 , "3": {"test" true "1" 2},"4" :[1 2, false]}')
(66, [[b'{'], [], [[[[b'"', [b'1'], b'"'], [[b' ']], [b'n', b'u', b'l', b'l']], [b',', [b' ']]], [[[b'"', [b'2'], b'"'], [[b' '], b':', [b' ']], [[b'1'], b'.', [b'5']]], [[b' '], b',', [b' ']]], [[[b'"', [b'3'], b'"'], [b':', [b' ']], [[b'{'], [], [[[[b'"', [b't', b'e', b's', b't'], b'"'], [[b' ']], [b't', b'r', b'u', b'e']], [[b' ']]]], [], [[b'"', [b'1'], b'"'], [[b' ']], [b'2']], [], [b'}']]], [b',']]], [], [[b'"', [b'4'], b'"'], [[b' '], b':'], [[b'['], [], [[[b'1'], [[b' ']]], [[b'2'], [b',', [b' ']]]], [], [b'f', b'a', b'l', b's', b'e'], [], [b']']]], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{"1": null')
(0, None)
>>> StandardRules.Json.permissive_dict(b'{true null}')
(11, [[b'{'], [], [], [], [[b't', b'r', b'u', b'e'], [[b' ']], [b'n', b'u', b'l', b'l']], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{"1" null,unDefinEd "2"}')
(24, [[b'{'], [], [[[[b'"', [b'1'], b'"'], [[b' ']], [b'n', b'u', b'l', b'l']], [b',']]], [], [[b'u', b'n', b'D', b'e', b'f', b'i', b'n', b'E', b'd'], [[b' ']], [b'"', [b'2'], b'"']], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{"1" niL unDefinEd "2"}')
(23, [[b'{'], [], [[[[b'"', [b'1'], b'"'], [[b' ']], [b'n', b'i', b'L']], [[b' ']]]], [], [[b'u', b'n', b'D', b'e', b'f', b'i', b'n', b'E', b'd'], [[b' ']], [b'"', [b'2'], b'"']], [], [b'}']])
>>> StandardRules.Json.permissive_dict(b'{"1", null}')
(0, None)
>>> StandardRules.Json.permissive_dict(b'{1.5:null,}')
(11, [[b'{'], [], [[[[[b'1'], b'.', [b'5']], [b':'], [b'n', b'u', b'l', b'l']], [b',']]], [b'}']])
>>>
- permissive_false(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function checks for permissive false value.
>>> StandardRules.Json.permissive_false(b'false')
(5, [b'f', b'a', b'l', b's', b'e'])
>>> StandardRules.Json.permissive_false(b'False')
(5, [b'F', b'a', b'l', b's', b'e'])
>>> StandardRules.Json.permissive_false(b'FALSE')
(5, [b'F', b'A', b'L', b'S', b'E'])
>>>
- permissive_full(data: bytes, position: int = 0) -> Tuple[int, Optional[List]]
- This function matchs all JSON permissive type
(dict, list, string, float, integer, boolean, null).
>>> StandardRules.Json.permissive_full(b'{}')
(2, [[b'{'], [], [], [b'}']])
>>> StandardRules.Json.permissive_full(b'{NONE: FAlse 1.5 "test", ,}')
(27, [[b'{'], [], [[[[b'N', b'O', b'N', b'E'], [b':', [b' ']], [b'F', b'A', b'l', b's', b'e']], [[b' ']]], [[[[b'1'], b'.', [b'5']], [[b' ']], [b'"', [b't', b'e', b's', b't'], b'"']], [b',', [b' '], b',']]], [b'}']])
>>> StandardRules.Json.permissive_full(b'[]')
(2, [[b'['], [], [], [b']']])
>>> StandardRules.Json.permissive_full(b'[1, 2.5, unDefiNed nIl ,,,, ]')
(29, [[b'['], [], [[[b'1'], [b',', [b' ']]], [[[b'2'], b'.', [b'5']], [b',', [b' ']]], [[b'u', b'n', b'D', b'e', b'f', b'i', b'N', b'e', b'd'], [[b' ']]], [[b'n', b'I', b'l'], [[b' '], b',', b',', b',', b',', [b' ']]]], [b']']])
>>> StandardRules.Json.permissive_full(b'"string"')
(8, [b'"', [b's', b't', b'r', b'i', b'n', b'g'], b'"'])
>>> StandardRules.Json.permissive_full(b'1.5')
(3, [[b'1'], b'.', [b'5']])
>>> StandardRules.Json.permissive_full(b'1')
(1, [b'1'])
>>> StandardRules.Json.permissive_full(b'trUe')
(4, [b't', b'r', b'U', b'e'])
>>> StandardRules.Json.permissive_full(b'nUll')
(4, [b'n', b'U', b'l', b'l'])
>>>
- permissive_list(data: bytes, position: int = 0) -> Tuple[int, Optional[List]]
- This function checks for a permissive JSON list
(trailing comma, forgot comma, ...).
>>> StandardRules.Json.permissive_list(b'[]')
(2, [[b'['], [], [], [b']']])
>>> StandardRules.Json.permissive_list(b'[ ]')
(3, [[b'['], [b' '], [], [b']']])
>>> StandardRules.Json.permissive_list(b'[uNdefIned]')
(11, [[b'['], [], [], [], [b'u', b'N', b'd', b'e', b'f', b'I', b'n', b'e', b'd'], [], [b']']])
>>> StandardRules.Json.permissive_list(b'[1 1.5,2 , "test" trUE,, , , FalSe, nil,, {"test" fAlSe trUE nuLl} ,,,, ]')
(75, [[b'['], [], [[[b'1'], [[b' ']]], [[[b'1'], b'.', [b'5']], [b',']], [[b'2'], [[b' '], b',', [b' ']]], [[b'"', [b't', b'e', b's', b't'], b'"'], [[b' ']]], [[b't', b'r', b'U', b'E'], [b',', b',', [b' '], b',', [b' '], b',', [b' ']]], [[b'F', b'a', b'l', b'S', b'e'], [b',', [b' ', b' ', b' ']]], [[b'n', b'i', b'l'], [b',', b',', [b' ']]], [[[b'{'], [], [[[[b'"', [b't', b'e', b's', b't'], b'"'], [[b' ']], [b'f', b'A', b'l', b'S', b'e']], [[b' ']]]], [], [[b't', b'r', b'U', b'E'], [[b' ']], [b'n', b'u', b'L', b'l']], [], [b'}']], [[b' '], b',', b',', b',', b',', [b' ']]]], [b']']])
>>> StandardRules.Json.permissive_list(b'[')
(0, None)
>>> StandardRules.Json.permissive_list(b'[1,]')
(4, [[b'['], [], [[[b'1'], [b',']]], [b']']])
>>> StandardRules.Json.permissive_list(b'[1 noNe]')
(8, [[b'['], [], [[[b'1'], [[b' ']]]], [], [b'n', b'o', b'N', b'e'], [], [b']']])
>>>
- permissive_null(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function checks for permissive null value.
>>> StandardRules.Json.permissive_null(b'null')
(4, [b'n', b'u', b'l', b'l'])
>>> StandardRules.Json.permissive_null(b'NulL')
(4, [b'N', b'u', b'l', b'L'])
>>> StandardRules.Json.permissive_null(b'None')
(4, [b'N', b'o', b'n', b'e'])
>>> StandardRules.Json.permissive_null(b'nonE')
(4, [b'n', b'o', b'n', b'E'])
>>> StandardRules.Json.permissive_null(b'nil')
(3, [b'n', b'i', b'l'])
>>> StandardRules.Json.permissive_null(b'nIl')
(3, [b'n', b'I', b'l'])
>>> StandardRules.Json.permissive_null(b'undefined')
(9, [b'u', b'n', b'd', b'e', b'f', b'i', b'n', b'e', b'd'])
>>> StandardRules.Json.permissive_null(b'undeFined')
(9, [b'u', b'n', b'd', b'e', b'F', b'i', b'n', b'e', b'd'])
>>>
- permissive_simple_value(data: bytes, position: int = 0) -> Tuple[int, Optional[List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]
- This function checks for permissive `simple` value
(null, boolean, integer, float, string).
>>> StandardRules.Json.permissive_simple_value(b'nUll')
(4, [b'n', b'U', b'l', b'l'])
>>> StandardRules.Json.permissive_simple_value(b'tRue')
(4, [b't', b'R', b'u', b'e'])
>>> StandardRules.Json.permissive_simple_value(b'faLSe')
(5, [b'f', b'a', b'L', b'S', b'e'])
>>> StandardRules.Json.permissive_simple_value(b'1234567890')
(10, [b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'0'])
>>> StandardRules.Json.permissive_simple_value(b'0x0123456789aBcDeF')
(18, [b'0', b'x', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'B', b'c', b'D', b'e', b'F']])
>>> StandardRules.Json.permissive_simple_value(b'0o01234567')
(10, [b'0', b'o', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7']])
>>> StandardRules.Json.permissive_simple_value(b'1.23')
(4, [[b'1'], b'.', [b'2', b'3']])
>>> StandardRules.Json.permissive_simple_value(b'"test\\"abc"')
(11, [b'"', [b't', b'e', b's', b't', [b'\\', b'"'], b'a', b'b', b'c'], b'"'])
>>>
- permissive_true(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function checks for permissive true value.
>>> StandardRules.Json.permissive_true(b'true')
(4, [b't', b'r', b'u', b'e'])
>>> StandardRules.Json.permissive_true(b'True')
(4, [b'T', b'r', b'u', b'e'])
>>> StandardRules.Json.permissive_true(b'TRUE')
(4, [b'T', b'R', b'U', b'E'])
>>>
- simple_value(data: bytes, position: int = 0) -> Tuple[int, Optional[List[Union[bytes, List[Union[bytes, List[bytes]]]]]]]
- This function checks for strict `simple` value (null,
boolean, integer, float, string).
>>> StandardRules.Json.simple_value(b'null')
(4, [b'n', b'u', b'l', b'l'])
>>> StandardRules.Json.simple_value(b'true')
(4, [b't', b'r', b'u', b'e'])
>>> StandardRules.Json.simple_value(b'false')
(5, [b'f', b'a', b'l', b's', b'e'])
>>> StandardRules.Json.simple_value(b'1234567890')
(10, [b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'0'])
>>> StandardRules.Json.simple_value(b'0x0123456789aBcDeF')
(18, [b'0', b'x', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'B', b'c', b'D', b'e', b'F']])
>>> StandardRules.Json.simple_value(b'0o01234567')
(10, [b'0', b'o', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7']])
>>> StandardRules.Json.simple_value(b'1.23')
(4, [[b'1'], b'.', [b'2', b'3']])
>>> StandardRules.Json.simple_value(b'"test\\"abc"')
(11, [b'"', [b't', b'e', b's', b't', [b'\\', b'"'], b'a', b'b', b'c'], b'"'])
>>>
- true(data: bytes, position: int = 0) -> Tuple[int, Optional[List[bytes]]]
- This function checks for strict true value.
>>> StandardRules.Json.true(b'true')
(4, [b't', b'r', b'u', b'e'])
>>> StandardRules.Json.true(b'True')
(0, None)
>>> StandardRules.Json.true(b'TRUE')
(0, None)
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Network = class Network(builtins.object) |
|
This class implements methods to parse Network formats and data. |
|
Methods defined here:
- fqdn(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]]]]]
- This method parses the FQDN format.
>>> StandardRules.Network.fqdn(b"test012.abc.com")
(15, [[b't', [b'e', b's', b't', b'0', b'1', b'2']], [[b'.', [b'a', [b'b', b'c']]], [b'.', [b'c', [b'o', b'm']]]]])
>>> StandardRules.Network.fqdn(b"test012.abc-def.com")
(19, [[b't', [b'e', b's', b't', b'0', b'1', b'2']], [[b'.', [b'a', [b'b', b'c', [[b'-'], b'd'], b'e', b'f']]], [b'.', [b'c', [b'o', b'm']]]]])
>>> StandardRules.Network.fqdn(b".test012.abc-def.com")
(0, None)
>>> StandardRules.Network.fqdn(b"test012.abc-def.com.")
(19, [[b't', [b'e', b's', b't', b'0', b'1', b'2']], [[b'.', [b'a', [b'b', b'c', [[b'-'], b'd'], b'e', b'f']]], [b'.', [b'c', [b'o', b'm']]]]])
>>> StandardRules.Network.fqdn(b"-test012.abc-def.com")
(0, None)
>>> StandardRules.Network.fqdn(b"test012.abc-def.com-")
(19, [[b't', [b'e', b's', b't', b'0', b'1', b'2']], [[b'.', [b'a', [b'b', b'c', [[b'-'], b'd'], b'e', b'f']]], [b'.', [b'c', [b'o', b'm']]]]])
>>> StandardRules.Network.fqdn(b"012test.abc-def.com-")
(19, [[b'0', [b'1', b'2', b't', b'e', b's', b't']], [[b'.', [b'a', [b'b', b'c', [[b'-'], b'd'], b'e', b'f']]], [b'.', [b'c', [b'o', b'm']]]]])
>>>
- host(data: bytes, position: int = 0) -> Tuple[int, Iterable[Union[bytes, Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]
- This method parses the network host value.
>>> StandardRules.Network.host(b"test-hostname")
(13, [b't', [b'e', b's', b't', [[b'-'], b'h'], b'o', b's', b't', b'n', b'a', b'm', b'e']])
>>> StandardRules.Network.host(b"test.fqdn")
(9, [[b't', [b'e', b's', b't']], [[b'.', [b'f', [b'q', b'd', b'n']]]]])
>>> StandardRules.Network.host(b"127.0.0.1")
(9, [[b'1', [b'2', b'7']], [[b'.', [b'0', []]], [b'.', [b'0', []]], [b'.', [b'1', []]]]])
>>> StandardRules.Network.host(b"[::1]")
(5, [b'[', [b':', b':', b'1'], b']'])
>>> StandardRules.Network.host(b"[::dead:beef%eth1]")
(18, [b'[', [[b':', b':', [[b'd', b'e', b'a', b'd'], b':'], [b'b', b'e', b'e', b'f']], b'%', [[b'e', b't', b'h', b'1']]], b']'])
>>> StandardRules.Network.host(b"[v0123456789abcdef.%25]")
(23, [b'[', [b'v', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f'], b'.', [[[b'%', b'2', b'5']]]], b']'])
>>> StandardRules.Network.host(b"dead::beef")
(4, [b'd', [b'e', b'a', b'd']])
>>> StandardRules.Network.host(b"dead::beef%25test|")
(4, [b'd', [b'e', b'a', b'd']])
>>> StandardRules.Network.host(b"v0123456789abcdef.%25")
(17, [b'v', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f']])
>>>
- host_port(data: bytes, position: int = 0) -> Tuple[int, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]]
- This method parses the network host value with a port.
>>> StandardRules.Network.host_port(b"test-hostname:4545")
(18, [[b't', [b'e', b's', b't', [[b'-'], b'h'], b'o', b's', b't', b'n', b'a', b'm', b'e']], b':', [b'4', b'5', b'4', b'5']])
>>> StandardRules.Network.host_port(b"test.fqdn:8080")
(14, [[[b't', [b'e', b's', b't']], [[b'.', [b'f', [b'q', b'd', b'n']]]]], b':', [b'8', b'0', b'8', b'0']])
>>> StandardRules.Network.host_port(b"127.0.0.1:65535")
(15, [[[b'1', [b'2', b'7']], [[b'.', [b'0', []]], [b'.', [b'0', []]], [b'.', [b'1', []]]]], b':', [b'6', b'5', b'5', b'3', b'5']])
>>> StandardRules.Network.host_port(b"[::1]:1234")
(10, [[b'[', [b':', b':', b'1'], b']'], b':', [b'1', b'2', b'3', b'4']])
>>> StandardRules.Network.host_port(b"[::dead:beef%eth1]:7845")
(23, [[b'[', [[b':', b':', [[b'd', b'e', b'a', b'd'], b':'], [b'b', b'e', b'e', b'f']], b'%', [[b'e', b't', b'h', b'1']]], b']'], b':', [b'7', b'8', b'4', b'5']])
>>> StandardRules.Network.host_port(b"[v0123456789abcdef.%25]:8989")
(28, [[b'[', [b'v', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f'], b'.', [[[b'%', b'2', b'5']]]], b']'], b':', [b'8', b'9', b'8', b'9']])
>>> StandardRules.Network.host_port(b"[dead::beef]:abc")
(0, None)
>>> StandardRules.Network.host_port(b"[dead::beef%25t]:+4578")
(0, None)
>>> StandardRules.Network.host_port(b"[v0123456789abcdef.%25]4542")
(0, None)
>>>
- hostname(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]
- This method parses hostnames value.
>>> StandardRules.Network.hostname(b"test")
(4, [b't', [b'e', b's', b't']])
>>> StandardRules.Network.hostname(b"test-abc")
(8, [b't', [b'e', b's', b't', [[b'-'], b'a'], b'b', b'c']])
>>> StandardRules.Network.hostname(b"a")
(1, [b'a', []])
>>> StandardRules.Network.hostname(b"test-ABC456")
(11, [b't', [b'e', b's', b't', [[b'-'], b'A'], b'B', b'C', b'4', b'5', b'6']])
>>> StandardRules.Network.hostname(b"6test")
(5, [b'6', [b't', b'e', b's', b't']])
>>> StandardRules.Network.hostname(b"6test-")
(5, [b'6', [b't', b'e', b's', b't']])
>>> StandardRules.Network.hostname(b"-6test")
(0, None)
>>>
- ipv4(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method parses IPv4 format.
>>> StandardRules.Network.ipv4(b"256.256.256.256")
(0, None)
>>> StandardRules.Network.ipv4(b"310.200.200.200")
(0, None)
>>> StandardRules.Network.ipv4(b"255.255.255.255")
(15, [[b'2', b'5', b'5'], b'.', [b'2', b'5', b'5'], b'.', [b'2', b'5', b'5'], b'.', [b'2', b'5', b'5']])
>>> StandardRules.Network.ipv4(b"249.230.225.212")
(15, [[b'2', b'4', b'9'], b'.', [b'2', b'3', b'0'], b'.', [b'2', b'2', b'5'], b'.', [b'2', b'1', b'2']])
>>> StandardRules.Network.ipv4(b"199.130.125.112")
(15, [[b'1', b'9', b'9'], b'.', [b'1', b'3', b'0'], b'.', [b'1', b'2', b'5'], b'.', [b'1', b'1', b'2']])
>>> StandardRules.Network.ipv4(b"1.1.1.1")
(7, [b'1', b'.', b'1', b'.', b'1', b'.', b'1'])
>>> StandardRules.Network.ipv4(b"0.0.0.0")
(7, [b'0', b'.', b'0', b'.', b'0', b'.', b'0'])
>>> StandardRules.Network.ipv4(b"10.20.80.90")
(11, [[b'1', b'0'], b'.', [b'2', b'0'], b'.', [b'8', b'0'], b'.', [b'9', b'0']])
>>> StandardRules.Network.ipv4(b".20.80.90")
(0, None)
>>> StandardRules.Network.ipv4(b"10.20.80.")
(0, None)
>>> StandardRules.Network.ipv4(b"10.20..80.90")
(0, None)
>>> StandardRules.Network.ipv4(b"10.20.80.1110")
(12, [[b'1', b'0'], b'.', [b'2', b'0'], b'.', [b'8', b'0'], b'.', [b'1', b'1', b'1']])
>>>
- ipv6(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]
- This method parses IPv6 formats.
>>> StandardRules.Network.ipv6(b":1:")
(0, None)
>>> StandardRules.Network.ipv6(b"2:1:3")
(0, None)
>>> StandardRules.Network.ipv6(b"5:4:2:1:3")
(0, None)
>>> StandardRules.Network.ipv6(b"::")
(2, [b':', b':'])
>>> StandardRules.Network.ipv6(b"::1")
(3, [b':', b':', b'1'])
>>> StandardRules.Network.ipv6(b"::1:2")
(5, [b':', b':', [b'1', b':'], b'2'])
>>> StandardRules.Network.ipv6(b"::1:2:3")
(7, [b':', b':', [b'1', b':'], [b'2', b':'], b'3'])
>>> StandardRules.Network.ipv6(b"1::2:3:4:5")
(10, [b'1', b':', b':', [b'2', b':'], [b'3', b':'], [b'4', b':'], b'5'])
>>> StandardRules.Network.ipv6(b"1:2::3:4:5")
(10, [[b'1', b':'], b'2', b':', b':', [b'3', b':'], [b'4', b':'], b'5'])
>>> StandardRules.Network.ipv6(b"1:2:3::4:5")
(10, [[b'1', b':'], [b'2', b':'], b'3', b':', b':', [b'4', b':'], b'5'])
>>> StandardRules.Network.ipv6(b"1:2:3:4::5")
(10, [[b'1', b':'], [b'2', b':'], [b'3', b':'], b'4', b':', b':', b'5'])
>>> StandardRules.Network.ipv6(b"1:2:3:4:5::")
(11, [[b'1', b':'], [b'2', b':'], [b'3', b':'], [b'4', b':'], b'5', b':', b':'])
>>> StandardRules.Network.ipv6(b"f09f:9af9:a09a::0af0:0b2c")
(25, [[[b'f', b'0', b'9', b'f'], b':'], [[b'9', b'a', b'f', b'9'], b':'], [b'a', b'0', b'9', b'a'], b':', b':', [[b'0', b'a', b'f', b'0'], b':'], [b'0', b'b', b'2', b'c']])
>>> StandardRules.Network.ipv6(b"0090:9009:0090::0000:0000")
(25, [[[b'0', b'0', b'9', b'0'], b':'], [[b'9', b'0', b'0', b'9'], b':'], [b'0', b'0', b'9', b'0'], b':', b':', [[b'0', b'0', b'0', b'0'], b':'], [b'0', b'0', b'0', b'0']])
>>> StandardRules.Network.ipv6(b"0:9:0::0:0")
(10, [[b'0', b':'], [b'9', b':'], b'0', b':', b':', [b'0', b':'], b'0'])
>>> StandardRules.Network.ipv6(b"2001:0db8:0000:0000:0000:ff00:0042:8329")
(39, [[[b'2', b'0', b'0', b'1'], b':'], [[b'0', b'd', b'b', b'8'], b':'], [[b'0', b'0', b'0', b'0'], b':'], [[b'0', b'0', b'0', b'0'], b':'], [[b'0', b'0', b'0', b'0'], b':'], [[b'f', b'f', b'0', b'0'], b':'], [[b'0', b'0', b'4', b'2'], b':'], [b'8', b'3', b'2', b'9']])
>>>
- ipv6_zoneid(data: bytes, position: int = 0) -> Tuple[int, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]
- This method parses IPv6 with Zone ID.
>>> StandardRules.Network.ipv6_zoneid(b"::1%eth0")
(8, [[b':', b':', b'1'], b'%', [[b'e', b't', b'h', b'0']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%0")
(5, [[b':', b':', b'1'], b'%', [[b'0']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%9")
(5, [[b':', b':', b'1'], b'%', [[b'9']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%259")
(7, [[b':', b':', b'1'], [b'%', b'2', b'5'], [[b'9']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%250")
(7, [[b':', b':', b'1'], [b'%', b'2', b'5'], [[b'0']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%25eth0")
(10, [[b':', b':', b'1'], [b'%', b'2', b'5'], [[b'e', b't', b'h', b'0']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%eth0-_~.test")
(16, [[b':', b':', b'1'], b'%', [[b'e', b't', b'h', b'0', b'-', b'_', b'~', b'.', b't', b'e', b's', b't']]])
>>> StandardRules.Network.ipv6_zoneid(b"::1%eth0-_~.#test")
(12, [[b':', b':', b'1'], b'%', [[b'e', b't', b'h', b'0', b'-', b'_', b'~', b'.']]])
>>>
- ipvfuture(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method parses the IPvFuture.
>>> StandardRules.Network.ipvfuture(b"v0123456789abcdef.any_characters-including&$(exploit)'&&exploit")
(63, [b'v', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f'], b'.', [[b'a', b'n', b'y', b'_', b'c', b'h', b'a', b'r', b'a', b'c', b't', b'e', b'r', b's', b'-', b'i', b'n', b'c', b'l', b'u', b'd', b'i', b'n', b'g'], b'&', b'$', b'(', [b'e', b'x', b'p', b'l', b'o', b'i', b't'], b')', b"'", b'&', b'&', [b'e', b'x', b'p', b'l', b'o', b'i', b't']]])
>>> StandardRules.Network.ipvfuture(b"0123456789abcdef.any_characters-including&$(exploit)'&&exploit")
(0, None)
>>> StandardRules.Network.ipvfuture(b"v.any_characters-including&$(exploit)'&&exploit")
(0, None)
>>> StandardRules.Network.ipvfuture(b"v0123456789abcdefany_characters-including&$(exploit)'&&exploit")
(0, None)
>>> StandardRules.Network.ipvfuture(b"v0123456789abcdef.?any_characters-including&$(exploit)'&&exploit")
(0, None)
>>> StandardRules.Network.ipvfuture(b"v0123456789abcdef.%25")
(21, [b'v', [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'a', b'b', b'c', b'd', b'e', b'f'], b'.', [[[b'%', b'2', b'5']]]])
>>> StandardRules.Network.ipvfuture(b"v0123456789abcdef.%2")
(0, None)
>>>
- user_info(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method parses the network host value with a port.
>>> StandardRules.Network.user_info(b"toto:123")
(8, [[b't', b'o', b't', b'o'], b':', [b'1', b'2', b'3']])
>>> StandardRules.Network.user_info(b"test:p@ssword")
(6, [[b't', b'e', b's', b't'], b':', [b'p']])
>>> StandardRules.Network.user_info(b"test123:p+~._-ssword%25")
(23, [[b't', b'e', b's', b't', b'1', b'2', b'3'], b':', [b'p', b'+', b'~', b'.', b'_', b'-', b's', b's', b'w', b'o', b'r', b'd', [b'%', b'2', b'5']]])
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Path = class Path(builtins.object) |
|
This class implements Windows and NT path. |
|
Methods defined here:
- base_filename(data: bytes, position: int = 0, in_extension: bool = False) -> Tuple[int, Optional[Iterable[bytes]]]
- This function matchs base filename.
>>> StandardRules.Path.base_filename(b'test')
(4, [b't', b'e', b's', b't'])
>>> StandardRules.Path.base_filename(b't test*test')
(6, [b't', b' ', b't', b'e', b's', b't'])
>>> StandardRules.Path.base_filename(b'$MFT')
(4, [b'$', b'M', b'F', b'T'])
>>> StandardRules.Path.base_filename(b'\\test')
(0, None)
>>>
- drive_path(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]]
- This function matchs Windows path starting by drive letter.
>>> StandardRules.Path.drive_path(b'D:\\test')
(7, [b'D', b':', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.drive_path(b'D:\\test\\')
(8, [b'D', b':', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.drive_path(b'D:\\test\\1\\2\\test.txt')
(20, [b'D', b':', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>>
- extensions(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Union[bytes, Iterable[bytes]]]]]]
- This function matchs extensions.
>>> StandardRules.Path.extensions(b'.exe')
(4, [[b'.', [b'e', b'x', b'e']]])
>>> StandardRules.Path.extensions(b'.dll')
(4, [[b'.', [b'd', b'l', b'l']]])
>>> StandardRules.Path.extensions(b'.py')
(3, [[b'.', [b'p', b'y']]])
>>> StandardRules.Path.extensions(b'.c.txt.zip.tar.gz')
(17, [[b'.', [b'c']], [b'.', [b't', b'x', b't']], [b'.', [b'z', b'i', b'p']], [b'.', [b't', b'a', b'r']], [b'.', [b'g', b'z']]])
>>>
- filename(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Iterable[Union[bytes, Iterable[bytes]]]]]]]
- This function matchs filename.
>>> StandardRules.Path.filename(b'test')
(4, [b't', b'e', b's', b't'])
>>> StandardRules.Path.filename(b'test*test.test')
(4, [b't', b'e', b's', b't'])
>>> StandardRules.Path.filename(b'$MFT.txt.tar.gz')
(15, [[b'$', b'M', b'F', b'T'], [[b'.', [b't', b'x', b't']], [b'.', [b't', b'a', b'r']], [b'.', [b'g', b'z']]]])
>>> StandardRules.Path.filename(b'\\test.py')
(0, None)
>>>
- filename_extension(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Iterable[Union[bytes, Iterable[bytes]]]]]]]
- This function matchs filename with extension.
>>> StandardRules.Path.filename_extension(b'test.exe')
(8, [[b't', b'e', b's', b't'], [[b'.', [b'e', b'x', b'e']]]])
>>> StandardRules.Path.filename_extension(b'test*test.test')
(0, None)
>>> StandardRules.Path.filename_extension(b'$MFT.txt.tar.gz')
(15, [[b'$', b'M', b'F', b'T'], [[b'.', [b't', b'x', b't']], [b'.', [b't', b'a', b'r']], [b'.', [b'g', b'z']]]])
>>> StandardRules.Path.filename_extension(b'\\test.py')
(0, None)
>>>
- linux_path(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable]]
- This function matchs Linux path.
>>> StandardRules.Path.linux_path(b'./test')
(6, [b'.', [[[b'/'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.linux_path(b'/root/test')
(10, [[[b'/'], [b'r', b'o', b'o', b't']], [[b'/'], [b't', b'e', b's', b't']]])
>>> StandardRules.Path.linux_path(b'/root/test.txt')
(14, [[[b'/'], [b'r', b'o', b'o', b't']], [[b'/'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]])
>>> StandardRules.Path.linux_path(b'/1/2/3/.././../4/test.tar.gz')
(28, [[[b'/'], [b'1']], [[b'/'], [b'2']], [[b'/'], [b'3']], [[b'/'], [b'.', b'.']], [[b'/'], [b'.']], [[b'/'], [b'.', b'.']], [[b'/'], [b'4']], [[b'/'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'a', b'r']], [b'.', [b'g', b'z']]]]]])
>>>
- nt_path(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable]]
- This function matchs NT path.
>>> StandardRules.Path.nt_path(b'\\\\?\\test')
(8, [b'\\', b'\\', b'?', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.nt_path(b'\\\\.\\test\\')
(9, [b'\\', b'\\', b'.', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.nt_path(b'\\\\.\\test\\1\\2\\test.txt')
(21, [b'\\', b'\\', b'.', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>>
- path(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable]]
- This function matchs system path.
>>> StandardRules.Path.path(b'./test')
(6, [b'.', [[[b'/'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.path(b'/root/test')
(10, [[[b'/'], [b'r', b'o', b'o', b't']], [[b'/'], [b't', b'e', b's', b't']]])
>>> StandardRules.Path.path(b'/root/test.txt')
(14, [[[b'/'], [b'r', b'o', b'o', b't']], [[b'/'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]])
>>> StandardRules.Path.path(b'/1/2/3/.././../4/test.tar.gz')
(28, [[[b'/'], [b'1']], [[b'/'], [b'2']], [[b'/'], [b'3']], [[b'/'], [b'.', b'.']], [[b'/'], [b'.']], [[b'/'], [b'.', b'.']], [[b'/'], [b'4']], [[b'/'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'a', b'r']], [b'.', [b'g', b'z']]]]]])
>>> StandardRules.Path.path(b'.\\test')
(6, [b'.', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.path(b'.\\test\\')
(7, [b'.', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.path(b'.\\test\\1\\2\\test.txt')
(19, [b'.', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>> StandardRules.Path.path(b'\\\\?\\test')
(8, [b'\\', b'\\', b'?', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.path(b'\\\\.\\test\\')
(9, [b'\\', b'\\', b'.', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.path(b'\\\\.\\test\\1\\2\\test.txt')
(21, [b'\\', b'\\', b'.', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>> StandardRules.Path.path(b'D:\\test')
(7, [b'D', b':', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.path(b'D:\\test\\')
(8, [b'D', b':', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.path(b'D:\\test\\1\\2\\test.txt')
(20, [b'D', b':', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>>
- relative_path(data: bytes, position: int = 0, unix: bool = False) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]]]]
- This function matchs relative path.
>>> StandardRules.Path.relative_path(b'.\\test')
(6, [b'.', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.relative_path(b'.\\test\\')
(7, [b'.', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.relative_path(b'.\\test\\1\\2\\test.txt')
(19, [b'.', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>>
- windows_path(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable]]
- This function matchs Windows path.
>>> StandardRules.Path.windows_path(b'.\\test')
(6, [b'.', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.windows_path(b'.\\test\\')
(7, [b'.', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.windows_path(b'.\\test\\1\\2\\test.txt')
(19, [b'.', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>> StandardRules.Path.windows_path(b'\\\\?\\test')
(8, [b'\\', b'\\', b'?', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.windows_path(b'\\\\.\\test\\')
(9, [b'\\', b'\\', b'.', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.windows_path(b'\\\\.\\test\\1\\2\\test.txt')
(21, [b'\\', b'\\', b'.', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>> StandardRules.Path.windows_path(b'D:\\test')
(7, [b'D', b':', [[[b'\\'], [b't', b'e', b's', b't']]]])
>>> StandardRules.Path.windows_path(b'D:\\test\\')
(8, [b'D', b':', [[[[b'\\'], [b't', b'e', b's', b't']]], b'\\']])
>>> StandardRules.Path.windows_path(b'D:\\test\\1\\2\\test.txt')
(20, [b'D', b':', [[[b'\\'], [b't', b'e', b's', b't']], [[b'\\'], [b'1']], [[b'\\'], [b'2']], [[b'\\'], [[b't', b'e', b's', b't'], [[b'.', [b't', b'x', b't']]]]]]])
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Types = class Types(builtins.object) |
|
This class implements standard types parsing rules. |
|
Methods defined here:
- bool(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks multiples digits.
>>> StandardRules.Types.bool(b"true")
(4, [b't', b'r', b'u', b'e'])
>>> StandardRules.Types.bool(b"false")
(5, [b'f', b'a', b'l', b's', b'e'])
>>> StandardRules.Types.bool(b"True")
(0, None)
>>> StandardRules.Types.bool(b"False")
(0, None)
>>> StandardRules.Types.bool(b"test")
(0, None)
>>> StandardRules.Types.bool(b"tru")
(0, None)
>>>
- digits(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks multiples digits.
>>> StandardRules.Types.digits(b"0123456789")
(10, [b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9'])
>>> StandardRules.Types.digits(b"abc0123")
(0, None)
>>> StandardRules.Types.digits(b"0123abc")
(4, [b'0', b'1', b'2', b'3'])
>>> StandardRules.Types.digits(b"+123")
(0, None)
>>> StandardRules.Types.digits(b"0B2;")
(1, [b'0'])
>>> StandardRules.Types.digits(b"a ")
(0, None)
>>>
- float(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks multiples digits.
>>> StandardRules.Types.float(b"1.525")
(5, [[b'1'], b'.', [b'5', b'2', b'5']])
>>> StandardRules.Types.float(b"4521.5")
(6, [[b'4', b'5', b'2', b'1'], b'.', [b'5']])
>>> StandardRules.Types.float(b"0.2356")
(6, [[b'0'], b'.', [b'2', b'3', b'5', b'6']])
>>> StandardRules.Types.float(b"5624.0")
(6, [[b'5', b'6', b'2', b'4'], b'.', [b'0']])
>>> StandardRules.Types.float(b".0256")
(0, None)
>>> StandardRules.Types.float(b"0256.")
(0, None)
>>>
- hex_integer(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks hexadecimal integer.
>>> StandardRules.Types.hex_integer(b"0x123")
(5, [b'0', b'x', [b'1', b'2', b'3']])
>>> StandardRules.Types.hex_integer(b"0Xa1c")
(5, [b'0', b'X', [b'a', b'1', b'c']])
>>> StandardRules.Types.hex_integer(b"0xg23")
(0, None)
>>> StandardRules.Types.hex_integer(b"0x1;")
(3, [b'0', b'x', [b'1']])
>>> StandardRules.Types.hex_integer(b"0x 1")
(0, None)
>>>
- octal_integer(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[bytes]]]
- This method checks hexadecimal integer.
>>> StandardRules.Types.octal_integer(b"0o123")
(5, [b'0', b'o', [b'1', b'2', b'3']])
>>> StandardRules.Types.octal_integer(b"0O123")
(5, [b'0', b'O', [b'1', b'2', b'3']])
>>> StandardRules.Types.octal_integer(b"0o891")
(0, None)
>>> StandardRules.Types.octal_integer(b"0O891")
(0, None)
>>> StandardRules.Types.octal_integer(b"0Oabc")
(0, None)
>>> StandardRules.Types.octal_integer(b"0Oabc")
(0, None)
>>> StandardRules.Types.octal_integer(b"123")
(0, None)
>>> StandardRules.Types.octal_integer(b"+0o123")
(0, None)
>>>
- string(data: bytes, position: int = 0)
- This method checks for string.
>>> StandardRules.Types.string(b'"test"')
(6, [b'"', [b't', b'e', b's', b't'], b'"'])
>>> StandardRules.Types.string(b"'test2.,'")
(9, [b"'", [b't', b'e', b's', b't', b'2', b'.', b','], b"'"])
>>> StandardRules.Types.string(b"'\\x56\\t\\r\\7\\45\\111'")
(0, None)
>>> StandardRules.Types.string(b"test")
(0, None)
>>> StandardRules.Types.string(b"'\\98'")
(0, None)
>>> StandardRules.Types.string(b"'\\xgf'")
(0, None)
>>> StandardRules.Types.string(b"'\\N{NAME -TEST1}'")
(17, [b"'", [[b'\\', b'N', b'{', [b'N', b'A', b'M', b'E', b' ', b'-', b'T', b'E', b'S', b'T', b'1'], b'}']], b"'"])
>>> StandardRules.Types.string(b"'\\u0020'")
(0, None)
>>> StandardRules.Types.string(b"'\\U00000020'")
(0, None)
>>> StandardRules.Types.string(b'"test')
(0, None)
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
StandardRules_Url = class Url(builtins.object) |
|
This class implements methods to parse an URL. |
|
Methods defined here:
- form_data(data: bytes, position: int = 0) -> Tuple[int, Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]
- This method checks the form data format used in POST
body and GET query.
>>> StandardRules.Url.form_data(b"abc=def&def=abc")
(15, [[[b'a', b'b', b'c'], b'=', [b'd', b'e', b'f']], [[b'&', [[b'd', b'e', b'f'], b'=', [b'a', b'b', b'c']]]]])
>>> StandardRules.Url.form_data(b"abc")
(3, [[b'a', b'b', b'c'], []])
>>> StandardRules.Url.form_data(b"abc&def")
(7, [[b'a', b'b', b'c'], [[b'&', [b'd', b'e', b'f']]]])
>>> StandardRules.Url.form_data(b"&def=abc")
(8, [[], [[b'&', [[b'd', b'e', b'f'], b'=', [b'a', b'b', b'c']]]]])
>>> StandardRules.Url.form_data(b"&def?=abc")
(4, [[], [[b'&', [b'd', b'e', b'f']]]])
>>> StandardRules.Url.form_data(b"&def;")
(4, [[], [[b'&', [b'd', b'e', b'f']]]])
>>> StandardRules.Url.form_data(b"/abc%/def")
(0, [[], []])
>>> StandardRules.Url.form_data(b"+")
(1, [[b'+'], []])
>>>
- fragment(data: bytes, position: int = 0) -> Tuple[int, Union[bool, Iterable[Union[bytes, Iterable[Iterable[bytes]]]]]]
- This method checks URL fragment.
>>> StandardRules.Url.fragment(b"#AZaz09-_.~+")
(12, [b'#', [[b'A', b'Z', b'a', b'z', b'0', b'9', b'-', b'_', b'.', b'~', b'+']]])
>>> StandardRules.Url.fragment(b"AZaz09-_.~")
(0, True)
>>> StandardRules.Url.fragment(b"!$&'()*,;=:@/?")
(0, True)
>>> StandardRules.Url.fragment(b"#")
(1, [b'#', []])
>>>
- full(data: bytes, position: int = 0)
- This method parses the full URL.
>>> StandardRules.Url.full(b"https://my.full.url/with/path;and=parameters?query=too#fragment")
(63, [[b'h', [b't', b't', b'p', b's']], b':', [b'/', b'/', [[b'm', [b'y']], [[b'.', [b'f', [b'u', b'l', b'l']]], [b'.', [b'u', [b'r', b'l']]]]], [[b'/', [[b'w', b'i', b't', b'h']]], [b'/', [[b'p', b'a', b't', b'h']]]]], [b';', [[[b'a', b'n', b'd'], b'=', [b'p', b'a', b'r', b'a', b'm', b'e', b't', b'e', b'r', b's']], []]], [b'?', [[b'q', b'u', b'e', b'r', b'y'], b'=', [b't', b'o', b'o']]], [b'#', [[b'f', b'r', b'a', b'g', b'm', b'e', b'n', b't']]]])
>>> StandardRules.Url.full(b"http://www.ics.uci.edu/pub/ietf/uri/#Related")
(44, [[b'h', [b't', b't', b'p']], b':', [b'/', b'/', [[b'w', [b'w', b'w']], [[b'.', [b'i', [b'c', b's']]], [b'.', [b'u', [b'c', b'i']]], [b'.', [b'e', [b'd', b'u']]]]], [[b'/', [[b'p', b'u', b'b']]], [b'/', [[b'i', b'e', b't', b'f']]], [b'/', [[b'u', b'r', b'i']]], [b'/', []]]], True, True, [b'#', [[b'R', b'e', b'l', b'a', b't', b'e', b'd']]]])
>>> StandardRules.Url.full(b"ftp://ftp.is.co.za/rfc/rfc1808.txt")
(34, [[b'f', [b't', b'p']], b':', [b'/', b'/', [[b'f', [b't', b'p']], [[b'.', [b'i', [b's']]], [b'.', [b'c', [b'o']]], [b'.', [b'z', [b'a']]]]], [[b'/', [[b'r', b'f', b'c']]], [b'/', [[b'r', b'f', b'c', b'1', b'8', b'0', b'8', b'.', b't', b'x', b't']]]]], True, True, True])
>>> StandardRules.Url.full(b"http://www.ietf.org/rfc/rfc2396.txt")
(35, [[b'h', [b't', b't', b'p']], b':', [b'/', b'/', [[b'w', [b'w', b'w']], [[b'.', [b'i', [b'e', b't', b'f']]], [b'.', [b'o', [b'r', b'g']]]]], [[b'/', [[b'r', b'f', b'c']]], [b'/', [[b'r', b'f', b'c', b'2', b'3', b'9', b'6', b'.', b't', b'x', b't']]]]], True, True, True])
>>> StandardRules.Url.full(b"ldap://[2001:db8::7]/c=GB?objectClass?one")
(41, [[b'l', [b'd', b'a', b'p']], b':', [b'/', b'/', [b'[', [[[b'2', b'0', b'0', b'1'], b':'], [b'd', b'b', b'8'], b':', b':', b'7'], b']'], [[b'/', [[b'c'], b'=', [b'G', b'B']]]]], True, [b'?', [[b'o', b'b', b'j', b'e', b'c', b't', b'C', b'l', b'a', b's', b's'], b'?', [b'o', b'n', b'e']]], True])
>>> StandardRules.Url.full(b"mailto:John.Doe@example.com")
(27, [[b'm', [b'a', b'i', b'l', b't', b'o']], b':', [[[b'J', b'o', b'h', b'n', b'.', b'D', b'o', b'e'], b'@', [b'e', b'x', b'a', b'm', b'p', b'l', b'e', b'.', b'c', b'o', b'm']], []], True, True, True])
>>> StandardRules.Url.full(b"news:comp.infosystems.www.servers.unix")
(38, [[b'n', [b'e', b'w', b's']], b':', [[[b'c', b'o', b'm', b'p', b'.', b'i', b'n', b'f', b'o', b's', b'y', b's', b't', b'e', b'm', b's', b'.', b'w', b'w', b'w', b'.', b's', b'e', b'r', b'v', b'e', b'r', b's', b'.', b'u', b'n', b'i', b'x']], []], True, True, True])
>>> StandardRules.Url.full(b"tel:+1-816-555-1212")
(19, [[b't', [b'e', b'l']], b':', [[b'+', [b'1', b'-', b'8', b'1', b'6', b'-', b'5', b'5', b'5', b'-', b'1', b'2', b'1', b'2']], []], True, True, True])
>>> StandardRules.Url.full(b"telnet://192.0.2.16:80/")
(23, [[b't', [b'e', b'l', b'n', b'e', b't']], b':', [b'/', b'/', [[[b'1', [b'9', b'2']], [[b'.', [b'0', []]], [b'.', [b'2', []]], [b'.', [b'1', [b'6']]]]], b':', [b'8', b'0']], [[b'/', []]]], True, True, True])
>>> StandardRules.Url.full(b"urn:oasis:names:specification:docbook:dtd:xml:4.1.2")
(51, [[b'u', [b'r', b'n']], b':', [[[b'o', b'a', b's', b'i', b's'], b':', [b'n', b'a', b'm', b'e', b's'], b':', [b's', b'p', b'e', b'c', b'i', b'f', b'i', b'c', b'a', b't', b'i', b'o', b'n'], b':', [b'd', b'o', b'c', b'b', b'o', b'o', b'k'], b':', [b'd', b't', b'd'], b':', [b'x', b'm', b'l'], b':', [b'4', b'.', b'1', b'.', b'2']], []], True, True, True])
>>>
- parameters(data: bytes, position: int = 0) -> Tuple[int, Union[bool, Iterable[Union[bytes, Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]]]
- This method checks URL parameters.
>>> StandardRules.Url.parameters(b";abc=def&def=abc")
(16, [b';', [[[b'a', b'b', b'c'], b'=', [b'd', b'e', b'f']], [[b'&', [[b'd', b'e', b'f'], b'=', [b'a', b'b', b'c']]]]]])
>>> StandardRules.Url.parameters(b";abc")
(4, [b';', [[b'a', b'b', b'c'], []]])
>>> StandardRules.Url.parameters(b";abc&def")
(8, [b';', [[b'a', b'b', b'c'], [[b'&', [b'd', b'e', b'f']]]]])
>>> StandardRules.Url.parameters(b";")
(1, [b';', [[], []]])
>>> StandardRules.Url.parameters(b";&def=abc")
(9, [b';', [[], [[b'&', [[b'd', b'e', b'f'], b'=', [b'a', b'b', b'c']]]]]])
>>> StandardRules.Url.parameters(b";&def;=abc")
(5, [b';', [[], [[b'&', [b'd', b'e', b'f']]]]])
>>> StandardRules.Url.parameters(b"&def;")
(0, True)
>>> StandardRules.Url.parameters(b"/abc%/def")
(0, True)
>>> StandardRules.Url.parameters(b"+")
(0, True)
>>>
- path(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]]
- This method checks URL path.
>>> StandardRules.Url.path(b"/abc/def.")
(9, [[b'/', [[b'a', b'b', b'c']]], [b'/', [[b'd', b'e', b'f', b'.']]]])
>>> StandardRules.Url.path(b"/abc?/def")
(4, [[b'/', [[b'a', b'b', b'c']]]])
>>> StandardRules.Url.path(b"/a-bc#/def")
(5, [[b'/', [[b'a', b'-', b'b', b'c']]]])
>>> StandardRules.Url.path(b"/a_bc%25/def")
(12, [[b'/', [[b'a', b'_', b'b', b'c', [b'%', b'2', b'5']]]], [b'/', [[b'd', b'e', b'f']]]])
>>> StandardRules.Url.path(b"/a~bc%2F/def")
(12, [[b'/', [[b'a', b'~', b'b', b'c', [b'%', b'2', b'F']]]], [b'/', [[b'd', b'e', b'f']]]])
>>> StandardRules.Url.path(b"//def")
(5, [[b'/', []], [b'/', [[b'd', b'e', b'f']]]])
>>> StandardRules.Url.path(b"/abc%2/def")
(4, [[b'/', [[b'a', b'b', b'c']]]])
>>> StandardRules.Url.path(b"/abc%/def")
(4, [[b'/', [[b'a', b'b', b'c']]]])
>>> StandardRules.Url.path(b"/")
(1, [[b'/', []]])
>>> StandardRules.Url.path(b"/c=test")
(7, [[b'/', [[b'c'], b'=', [b't', b'e', b's', b't']]]])
>>> StandardRules.Url.path(b"")
(0, None)
>>>
- path_rootless(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Iterable[Iterable[Union[bytes, Iterable[Iterable[bytes]]]]]]]]
- This method checks path root-less.
>>> StandardRules.Url.path_rootless(b"abc/def.")
(8, [[[b'a', b'b', b'c']], [[b'/', [[b'd', b'e', b'f', b'.']]]]])
>>> StandardRules.Url.path_rootless(b"abc?/def")
(3, [[[b'a', b'b', b'c']], []])
>>> StandardRules.Url.path_rootless(b"a-bc#/def")
(4, [[[b'a', b'-', b'b', b'c']], []])
>>> StandardRules.Url.path_rootless(b"a_bc%25/def")
(11, [[[b'a', b'_', b'b', b'c', [b'%', b'2', b'5']]], [[b'/', [[b'd', b'e', b'f']]]]])
>>>
- query(data: bytes, position: int = 0) -> Tuple[int, Union[bool, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[Union[bytes, Iterable[bytes]]]]]]]]]
- This method checks URL query.
>>> StandardRules.Url.query(b"?abc=def&def=abc")
(16, [b'?', [[b'a', b'b', b'c'], b'=', [b'd', b'e', b'f'], b'&', [b'd', b'e', b'f'], b'=', [b'a', b'b', b'c']]])
>>> StandardRules.Url.query(b"?abc%25")
(7, [b'?', [[b'a', b'b', b'c', [b'%', b'2', b'5']]]])
>>> StandardRules.Url.query(b"?abc&def")
(8, [b'?', [[b'a', b'b', b'c'], b'&', [b'd', b'e', b'f']]])
>>> StandardRules.Url.query(b"?")
(1, [b'?', []])
>>> StandardRules.Url.query(b"?&def=abc")
(9, [b'?', [b'&', [b'd', b'e', b'f'], b'=', [b'a', b'b', b'c']]])
>>> StandardRules.Url.query(b"?&def?=abc")
(10, [b'?', [b'&', [b'd', b'e', b'f'], b'?', b'=', [b'a', b'b', b'c']]])
>>> StandardRules.Url.query(b"&def;")
(0, True)
>>> StandardRules.Url.query(b"/abc%/def")
(0, True)
>>> StandardRules.Url.query(b"+")
(0, True)
>>>
- scheme(data: bytes, position: int = 0) -> Tuple[int, Optional[Iterable[Union[bytes, Iterable[bytes]]]]]
- This method checks URL scheme.
>>> StandardRules.Url.scheme(b"http")
(4, [b'h', [b't', b't', b'p']])
>>> StandardRules.Url.scheme(b"git+ssh")
(7, [b'g', [b'i', b't', b'+', b's', b's', b'h']])
>>> StandardRules.Url.scheme(b"gopher")
(6, [b'g', [b'o', b'p', b'h', b'e', b'r']])
>>> StandardRules.Url.scheme(b"itms-services")
(13, [b'i', [b't', b'm', b's', b'-', b's', b'e', b'r', b'v', b'i', b'c', b'e', b's']])
>>> StandardRules.Url.scheme(b"TEST.0tEst9")
(11, [b'T', [b'E', b'S', b'T', b'.', b'0', b't', b'E', b's', b't', b'9']])
>>> StandardRules.Url.scheme(b"TEST,0tEst9")
(4, [b'T', [b'E', b'S', b'T']])
>>>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |