<NME> packstream.py
<BEF> # Copyright (c) "Neo4j"
# Neo4j Sweden AB [https://neo4j.com]
#
# This file is part of Neo4j.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# TODO: 6.0 - remove this file


from ._codec.packstream.v1 import (
    INT64_MAX,
    INT64_MIN,
    PACKED_UINT_8,
    PACKED_UINT_16,
    Packer,
    Structure,
    UnpackableBuffer,
    UNPACKED_UINT_8,
    UNPACKED_UINT_16,
    Unpacker,
)
from ._meta import deprecation_warn


__all__ = [
INT64_MAX = 2 ** 63


EndOfStream = object()


class Structure:

    def __init__(self, tag, *fields):
    "Structure",
    "Packer",
    "Unpacker",
    "UnpackableBuffer",
]

deprecation_warn(
    "The module 'neo4j.packstream' was made internal and will "
    "no longer be available for import in future versions.",
    stack_level=2
)
        else:
            raise OverflowError("List header size out of range")

    def pack_list_stream_header(self):
        self._write(b"\xD7")

    def pack_map_header(self, size):
        write = self._write
        if size <= 0x0F:
        else:
            raise OverflowError("Map header size out of range")

    def pack_map_stream_header(self):
        self._write(b"\xDB")

    def pack_struct(self, signature, fields):
        if len(signature) != 1 or not isinstance(signature, bytes):
            raise ValueError("Structure signature must be a single byte value")
        for field in fields:
            self._pack(field)

    def pack_end_of_stream(self):
        self._write(b"\xDF")


class Unpacker:

                return decode(self.read(size), "utf-8")

            # List
            elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7:
                return list(self._unpack_list_items(marker))

            # Map
            elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB:
                return self._unpack_map(marker)

            # Structure
                    value[i] = self._unpack()
                return value

            elif marker == 0xDF:  # END_OF_STREAM:
                return EndOfStream

            else:
                raise ValueError("Unknown PackStream marker %02X" % marker)

            size, = struct_unpack(">I", self.read(4))
            for _ in range(size):
                yield self._unpack()
        elif marker == 0xD7:  # LIST_STREAM:
            item = None
            while item is not EndOfStream:
                item = self._unpack()
                if item is not EndOfStream:
                    yield item
        else:
            return

                key = self._unpack()
                value[key] = self._unpack()
            return value
        elif marker == 0xDB:  # MAP_STREAM:
            value = {}
            key = None
            while key is not EndOfStream:
                key = self._unpack()
                if key is not EndOfStream:
                    value[key] = self._unpack()
            return value
        else:
            return None


<MSG> Drop list stream and map stream from packstream implementation (#713)

Ever since, were they unused and undocumented.
<DFF> @@ -38,9 +38,6 @@ INT64_MIN = -(2 ** 63)
 INT64_MAX = 2 ** 63
 
 
-EndOfStream = object()
-
-
 class Structure:
 
     def __init__(self, tag, *fields):
@@ -196,9 +193,6 @@ class Packer:
         else:
             raise OverflowError("List header size out of range")
 
-    def pack_list_stream_header(self):
-        self._write(b"\xD7")
-
     def pack_map_header(self, size):
         write = self._write
         if size <= 0x0F:
@@ -215,9 +209,6 @@ class Packer:
         else:
             raise OverflowError("Map header size out of range")
 
-    def pack_map_stream_header(self):
-        self._write(b"\xDB")
-
     def pack_struct(self, signature, fields):
         if len(signature) != 1 or not isinstance(signature, bytes):
             raise ValueError("Structure signature must be a single byte value")
@@ -231,9 +222,6 @@ class Packer:
         for field in fields:
             self._pack(field)
 
-    def pack_end_of_stream(self):
-        self._write(b"\xDF")
-
 
 class Unpacker:
 
@@ -316,11 +304,11 @@ class Unpacker:
                 return decode(self.read(size), "utf-8")
 
             # List
-            elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7:
+            elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD6:
                 return list(self._unpack_list_items(marker))
 
             # Map
-            elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB:
+            elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDA:
                 return self._unpack_map(marker)
 
             # Structure
@@ -331,9 +319,6 @@ class Unpacker:
                     value[i] = self._unpack()
                 return value
 
-            elif marker == 0xDF:  # END_OF_STREAM:
-                return EndOfStream
-
             else:
                 raise ValueError("Unknown PackStream marker %02X" % marker)
 
@@ -360,12 +345,6 @@ class Unpacker:
             size, = struct_unpack(">I", self.read(4))
             for _ in range(size):
                 yield self._unpack()
-        elif marker == 0xD7:  # LIST_STREAM:
-            item = None
-            while item is not EndOfStream:
-                item = self._unpack()
-                if item is not EndOfStream:
-                    yield item
         else:
             return
 
@@ -403,14 +382,6 @@ class Unpacker:
                 key = self._unpack()
                 value[key] = self._unpack()
             return value
-        elif marker == 0xDB:  # MAP_STREAM:
-            value = {}
-            key = None
-            while key is not EndOfStream:
-                key = self._unpack()
-                if key is not EndOfStream:
-                    value[key] = self._unpack()
-            return value
         else:
             return None
 

{'addition_count': 2, 'commit_subject': 'Drop list stream and map stream from packstream implementation (#713)', 'deletion_count': 31, 'file_extension': '.py', 'lang': 'py', 'license': 'apache-2.0', 'repo_name': 'neo4j/neo4j-python-driver'}