]> Cypherpunks repositories - keks.git/commitdiff
set encoding support
authorSergey Matveev <stargrave@stargrave.org>
Fri, 15 Nov 2024 13:05:23 +0000 (16:05 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 15 Nov 2024 13:05:23 +0000 (16:05 +0300)
pyac/pyac.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index da93f15..d0789a7
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 # pyac -- Python YAC implementation
 # Copyright (C) 2024 Sergey Matveev <stargrave@stargrave.org>
 #
@@ -201,6 +202,10 @@ def dumps(v):
         return b"".join(raws)
     if isinstance(v, (list, tuple)):
         return b"".join([_byte(TagList)] + [dumps(i) for i in v] + [_byte(TagEOC)])
+    if isinstance(v, set):
+        if not all(isinstance(i, str) for i in v):
+            raise ValueError("set can contain only strings")
+        return dumps({i: None for i in v})
     if isinstance(v, dict):
         raws = [_byte(TagMap)]
         for k in sorted(v.keys(), key=LenFirstSort):