mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 16:36:20 +00:00
More type annotations.
This commit is contained in:
parent
595ce94f2b
commit
c26d94b9b3
@ -14,14 +14,19 @@ if PY2:
|
||||
|
||||
from past.builtins import long
|
||||
|
||||
try:
|
||||
from typing import Optional, Tuple, List
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def netstring(s):
|
||||
|
||||
def netstring(s): # type: (bytes) -> bytes
|
||||
assert isinstance(s, bytes), s # no unicode here
|
||||
return b"%d:%s," % (len(s), s,)
|
||||
|
||||
def split_netstring(data, numstrings,
|
||||
position=0,
|
||||
required_trailer=None):
|
||||
required_trailer=None): # type (bytes, init, int, Optional[bytes]) -> Tuple[List[bytes], int]
|
||||
"""like string.split(), but extracts netstrings. Ignore all bytes of data
|
||||
before the 'position' byte. Return a tuple of (list of elements (numstrings
|
||||
in length), new position index). The new position index points to the first
|
||||
|
Loading…
x
Reference in New Issue
Block a user