- Terms of Use and Privacy
Source Code
- Terms of Use and Privacy
Source Code

Source Code | Triple SEND

This code will send compressed triples. See Triple Pub.

# coding=utf-8
import zstandard as zstd
import base64
import paho.mqtt.publish as publish
import sys
from datetime import datetime
from datetime import date
dd = zstd.ZstdCompressionDict(data)
cctx = zstd.ZstdCompressor(dict_data=dd,level=22,write_checksum=False,write_dict_id=False,threads=2)
for l in sys.stdin:
   # The standard form for one piece of information is a triple on one line using this spec:
   # The form here is to facilitate real-time collaboration by adding timestamps and the ability to remove a triple.
   # The resultant graph does not need either of these.    20210218T132421.516Z add|sub
   # It is assumed that this is a single graph.  Different channels could be used to work on different graphs.
   # The collaborative portion is meant to be minimal as far as the interface and grammar, but is extensible to full RDF and beyond.  
   ts=datetime.utcnow().isoformat(sep='T', timespec='milliseconds').replace(':','').replace('-','').replace(' ','')+'Z'
   m=base64.b64encode(cctx.compress(bytearray(ts+' '+l.strip(),"utf8")))[5:].decode()