site_graphlogo
  -   Terms of Use and Privacy
Source Code
cutup   rss
site_graphlogo
  -   Terms of Use and Privacy
Source Code
cutup   rss

Source Code | DOTish FILTer

Triple pub uses a munged up version of DOT with emoji locally. This filter will convert the proprietary local format into RDF. Additionally, predicates of 🗝️ are treated as key-value pairs and sent off to syslog. Note that the map, the RDF takes the last known key-value pair for the comment. Think of it as a road map, where "sells burritos" is listed on the gas station. In a year, perhaps they don't sell burritos, but if you get an updated map, you'll have what they do sell. You don't really look at the map to buy burritos anyway, but it doesn't hurt to have the latest KVP snapshot as part of the map.

#!/usr/bin/python3
# coding=utf-8
#DOTishFILTer
# The person who associated a work with this deed has dedicated
# the work to the public domain by waiving all of his or her rights
# to the work worldwide under copyright law, including all related
# and neighboring rights, to the extent allowed by law.
# You can copy, modify, distribute and perform the work, even for
# commercial purposes, all without asking permission.
# In no way are the patent or trademark rights of any person affected by
# CC0, nor are the rights that other persons may have in the work or in
# how the work is used, such as publicity or privacy rights.
# Unless expressly stated otherwise, the person who associated a work with
# this deed makes no warranties about the work, and disclaims liability
# for all uses of the work, to the fullest extent permitted by applicable law.
# When using or citing the work, you should not imply endorsement by the 
# author or the affirmer.
# https://creativecommons.org/publicdomain/zero/1.0/

import sys
import re
graph='https://example.com/'
bits=re.compile('^(.+) (.+) (.+)$')
bitse=re.compile('^(.+) = (.+)$')
for l in sys.stdin:
   try:
      if l.find('=')!=-1:
         m = bitse.match(l)
         print('<'+graph+m.group(1)+'/> <http://www.w3.org/2000/01/rdf-schema#label> "'+m.group(2)+'" .') 
      else:
         m = bits.match(l)
         s=m.group(1)
         p=m.group(2)
         o=m.group(3)
         if p=='🏷️':
            print('<'+graph+s+'/> <http://www.w3.org/2000/01/rdf-schema#label> "'+o+'" .') 
         else:
            print('<'+graph+s+'/> <http://www.w3.org/2000/01/rdf-schema#label> "'+s+'" .') 
            print('<'+graph+o+'/> <http://www.w3.org/2000/01/rdf-schema#label> "'+o+'" .') 
            print('<'+graph+s+'/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/dfd#Process> .')
            print('<'+graph+s+'DataFlow'+o+'/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/dfd#DataFlow> .') 
            mo=re.search('\d',o)
            if o.find('D')!=-1 and mo:
               print('<'+graph+o+'/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/dfd#DataStore> .')
            elif mo:
               print('<'+graph+o+'/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/dfd#Process> .')
            if not(o.find('D')!=-1 and mo) and not mo:
               print('<'+graph+o+'/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/dfd#Interface> .')
            if p=='➡️':
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#from>  <'+graph+s+'/> .') 
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#to>  <'+graph+o+'/> .') 
            elif p=='⬅️':
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#to>  <'+graph+s+'/> .') 
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#from>  <'+graph+o+'/> .') 
            elif p=='↔️':
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#from>  <'+graph+s+'/> .') 
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#to>  <'+graph+o+'/> .') 
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#to>  <'+graph+s+'/> .') 
               print('<'+graph+s+'DataFlow'+o+'/> <https://w3id.org/dfd#from>  <'+graph+o+'/> .') 
   except:
      print('invalid format')