Example #1
0
def getScreenRGB2(env):
    return List([
        List([
            int('#{:02x}{:02x}{:02x}'.format(j[0], j[1], j[2])[1:], 16)
            for j in i
        ]) for i in env.render(mode='rgb_array')
    ])
Example #2
0
def handler(message):

    print(List.to_string(list(message)[0]))
    Lol = list(map(lambda x: List.to_string(x), list(message)))
    print(Lol)
    updateGrid(gridArray, Lol)

    drawGridAux()
    pygame.display.flip()
Example #3
0
 def test_hash_list(self):
     input = Map({List([1, 2, 3]): [4, 5, 6]})
     self.assertEquals(
         input[List([1, 2, 3])],
         List([4, 5, 6])
     )
     self.assertEquals(
         (input, b""),
         decode(encode(input))
     )
Example #4
0
def getScreenRGB3(env):
    rgb_array = env.render(mode='rgb_array')
    return List([
        List([List([j[0] for j in i]) for i in rgb_array]),
        List([List([j[1] for j in i]) for i in rgb_array]),
        List([List([j[2] for j in i]) for i in rgb_array])
    ])
Example #5
0
    def decode_string(self, string: ErlangList):
        """Decodes for Python a string sent from Erlang (seen as a list, yet
        known to actually be a string).

        Erlang and ErlPort treat lists and strings the same way. However, the
        Python 'List' class, into which ErlPort turns Erlang lists, provides a
        'to_string' method. Thus, one can make use of this method whenever one
        knows that a list received from Erlang corresponds actually to a string.
        """

        return string.to_string()
Example #6
0
    def test_encode_map(self):
        self.assertEqual(
            b"\x83t\x00\x00\x00\x01t\x00\x00\x00\x00t\x00\x00\x00\x00",
            encode(Map({Map(): Map()})))

        self.assertEqual(
            b'\x83t\x00\x00\x00\x01k\x00\x06hello1k\x00\x06world1',
            encode(Map({b"hello1": b"world1"})))

        self.assertEqual(
            b"\x83t\x00\x00\x00\x01k\x00\x06hello1k\x00\x03\x01\x02\x03",
            encode(Map({b"hello1": List([1, 2, 3])})))
Example #7
0
 def test_encode_list(self):
     self.assertEqual("\x83l\0\0\0\1jj", encode([[]]))
     self.assertEqual("\x83l\0\0\0\5jjjjjj", encode([[], [], [], [], []]))
     self.assertEqual(
         "\x83l\0\0\0\5jjjjjj",
         encode(List([List([]),
                      List([]),
                      List([]),
                      List([]),
                      List([])])))
Example #8
0
    def test_encode_map(self):
        self.assertEqual(
            "\x83t\x00\x00\x00\x01t\x00\x00\x00\x00t\x00\x00\x00\x00",
            encode(Map({Map(): Map()}))
        )

        self.assertEqual(
            "\x83t\x00\x00\x00\x01m\x00\x00\x00\x06"
            "hello1m\x00\x00\x00\x06world1",
            encode(Map(hello1="world1"))
        )

        self.assertEqual(
            "\x83t\x00\x00\x00\x01m\x00\x00\x00\x06"
            "hello1k\x00\x03\x01\x02\x03",
            encode(Map(hello1=List([1, 2, 3])))
        )
Example #9
0
    def test_decode_map(self):
        self.assertEqual(
            (Map({"hello": "world"}), b""),
            decode(
                b"\x83t\x00\x00\x00\x01m\x00\x00\x00\x05hellom\x00\x00\x00\x05world"
            ))

        self.assertEqual(
            (Map({"hello": "world"}), b"rest"),
            decode(
                b"\x83t\x00\x00\x00\x01m\x00\x00\x00\x05hellom\x00\x00\x00\x05worldrest"
            ))

        self.assertEqual(
            (Map({"hello": List()}), b""),
            decode(b"\x83t\x00\x00\x00\x01m\x00\x00\x00\x05helloj"))

        self.assertRaises(IncompleteData, decode, b"\x83t\x00\x00\x00")
Example #10
0
    def test_decode_map(self):
        self.assertEqual(
            (Map(hello="world"), ""),
            decode(
                "\x83t\x00\x00\x00\x01m\x00\x00\x00\x05"
                "hellom\x00\x00\x00\x05world")
        )

        self.assertEqual(
            (Map(hello="world"), "rest"),
            decode(
                "\x83t\x00\x00\x00\x01m\x00\x00\x00\x05"
                "hellom\x00\x00\x00\x05worldrest")
        )

        self.assertEqual(
            (Map(hello=List()), ""),
            decode("\x83t\x00\x00\x00\x01m\x00\x00\x00\x05helloj")
        )

        self.assertRaises(IncompleteData, decode, "\x83t\x00\x00\x00")
Example #11
0
 def test_to_string(self):
     lst = List([116, 101, 115, 116])
     self.assertEqual(u"test", lst.to_string())
     self.assertTrue(isinstance(lst.to_string(), unicode))
     self.assertRaises(TypeError, List("ab").to_string)
Example #12
0
 def test_list(self):
     lst = List([116, 101, 115, 116])
     self.assertTrue(isinstance(lst, list))
     self.assertEqual([116, 101, 115, 116], lst)
     self.assertEqual("List([116, 101, 115, 116])", repr(lst))
Example #13
0
 def test_nested_list(self):
     input = List([[[[[[]]]]]])
     self.assertEquals(
         (input, b""),
         decode(encode(input))
     )
Example #14
0
 def test_simple_list(self):
     input = List([1, 2, 3])
     self.assertEquals(
         (input, b""),
         decode(encode(input))
     )
Example #15
0
 def test_empty_list(self):
     input = List()
     self.assertEquals(
         (input, b""),
         decode(encode(input))
     )