Commit Graph

50 Commits

Author SHA1 Message Date
jesopo 14d38192cf truncate on \r and \n too 2022-01-28 17:36:45 +00:00
jesopo d8fa394a30 unnecessary truthiness check
closes #4
2022-01-02 23:50:18 +00:00
jesopo 6a679c7650 superfluous old line 2020-10-01 22:00:21 +00:00
jesopo e2f7c1eb84 merge tokenise() and tokenise_b() - using Union[str,bytes] 2020-09-30 20:00:36 +00:00
jesopo b9a2b6c1de raise ValueError when trying to tokenise without a command 2020-07-24 10:38:37 +00:00
jesopo c84509618f split tokenise.py to line.py and hostmask.py, rename hostmask parse
Line.hostmake now throws ValueError if source was None
2020-07-03 23:07:04 +01:00
jesopo 3cbc9f1bfb `line` -> `line_b` 2020-05-15 16:43:18 +01:00
jesopo cbeb39628d truncate tokenisations at null byte 2020-05-15 16:41:12 +01:00
jesopo 4dbb84e5c0 __init__.py shouldn't need to import format() 2020-04-21 17:36:47 +01:00
jesopo f1f6bb0d61 a better solution to cyclical imports 2020-04-21 17:23:37 +01:00
jesopo 0ce64137af always decode tags as utf8, use fallbacks for rest of line 2020-04-19 14:08:33 +01:00
jesopo 554d9a25f5 add some object copy methods to Line 2020-04-13 11:35:14 +01:00
jesopo 5a15869653 "iso-8859" should be "iso-8859-1" but use "latin-1" because it's clearer 2020-04-11 14:01:49 +01:00
jesopo cddcc00610 split Line and Hostmask out to objects.py 2020-03-24 14:49:53 +00:00
jesopo 05aedf08ac hanging \ at the end of a tag value is now handled by the while loop 2020-03-23 18:24:04 +00:00
jesopo 85e21c5421 empty last params should be colon-prepended 2020-03-23 16:59:32 +00:00
jesopo 5b998e816f don't force formatted commands to uppercase 2020-03-23 16:59:27 +00:00
jesopo 2e1809e3d8 make tag unescaping progressive-lexer style 2020-03-23 16:47:33 +00:00
jesopo 2c666a41e5 make missing tag values "", not None; it's simpler in code 2020-03-23 16:47:13 +00:00
jesopo a76df71774 we should still catch :trailing if there's nothing after : 2020-03-23 16:26:21 +00:00
jesopo 572c1e9b98 change Hostmask __init__, move tokenisation to Hostmask.from_source( 2020-03-15 19:46:33 +00:00
jesopo 37bd2abdc5 add py.typed to indicate irctokens supports typehints 2020-03-12 15:29:44 +00:00
jesopo 89a2a6c131 replace irctokens.format() with irctokens.build().format() 2020-03-12 13:53:10 +00:00
jesopo 27058522b8 non-last params can't start with colon, support last param starting with colon 2020-03-12 08:28:44 +00:00
jesopo 3ae207aa05 lone backslashes at the end of escaped tag values should be removed 2020-03-11 23:56:53 +00:00
jesopo 38b98a15e3 don't gracefully handle spaces in non-last param, throw ValueError 2020-03-11 23:38:36 +00:00
jesopo e523f03d4f prevent tag replacements overlapping each other 2020-03-11 23:32:52 +00:00
jesopo a82105e09f gracefully handle spaces in non-last params (split them) 2020-03-11 23:05:11 +00:00
jesopo e41a58842b don't try to parse Line.source from Line.hostmask when it is None 2020-03-11 22:57:49 +00:00
jesopo 564dec73b6 use fstring repr (!r) for Hostmask and Line __repr__s 2020-03-11 22:10:51 +00:00
jesopo 91648986c8 use "from typing import x" 2020-03-11 21:45:26 +00:00
jesopo 8e49ab9a14 fstrings, not modulo formatting 2020-03-11 21:32:26 +00:00
jesopo 410ce64ae9 don't use [] (mutable) for func arg default values 2020-03-11 21:32:07 +00:00
jesopo 9e5afb9f16 add __repr__ to Line 2020-03-11 20:25:18 +00:00
jesopo f1a1079873 add __repr__ to Hostmask 2020-03-11 20:22:44 +00:00
jesopo 9cd39ddcdc add Line.hostmask property to lazy-parse .source in to a Hostmask 2020-03-11 20:17:56 +00:00
jesopo 2bc35c57f7 add hostmask parsing (irctokens.Hostmask("n!u@h")) 2020-03-11 18:04:50 +00:00
jesopo 86fad88f92 allow suppling encoding to StatefulEncoder and StatefulDecoder (and tests!) 2020-03-11 17:38:30 +00:00
jesopo 8630c63f46 StatefulEncoder._buffer is a bytes object 2020-03-11 17:12:49 +00:00
jesopo 53d056c3e0 add .clear() to StatefulDecoder too (and tests for .clear() on both statefuls) 2020-03-11 17:09:54 +00:00
jesopo 4b9ff45921 remove superfluous spaces 2020-03-11 17:04:58 +00:00
Austin Ewens e5001ccb9c
Adds the ability to easily reset the encoder
The initialize function is also refactored to use the clear function to reduce code duplication as they would be doing the same thing.
2020-03-11 11:54:46 -05:00
jesopo 22be792bc0 remove StatefulEncoder.push() return type 2020-03-11 16:31:26 +00:00
jesopo 8773240c0c return Line objects successfully sent with StatefulEncoder.pop() 2020-03-11 16:30:44 +00:00
jesopo 49d2e78475 add a stateful encoder (irctokens.StatefulEncoder()) 2020-03-11 15:17:17 +00:00
jesopo 3cdc163b87 StatefulDecoder.push() should return None when given b"" (disconnect) 2020-03-11 15:16:49 +00:00
jesopo 949b10945e implement a stateful decoder (irctokens.StatefulDecoder()) 2020-03-11 14:50:31 +00:00
jesopo c98bb87993 fix _escape_tag typehint issue 2020-03-11 13:44:44 +00:00
jesopo 07836f98d4 add code to serialise/format Line objects 2020-03-11 13:42:23 +00:00
jesopo dad9b4a268 make irctokens a __init__.py package 2020-03-11 12:20:26 +00:00