Commit a300fb77 authored by Yannick Chudy's avatar Yannick Chudy

0.6.1 log formating, visualisation url parameters

parent 6402cf81
...@@ -99,7 +99,7 @@ def namedtuple_with_defaults(typename, field_names, default_values=()): ...@@ -99,7 +99,7 @@ def namedtuple_with_defaults(typename, field_names, default_values=()):
T.__new__.__defaults__ = tuple(prototype) T.__new__.__defaults__ = tuple(prototype)
return T return T
# "" , text , @ , # , + , % , = , ! , (float) ,[default] # label , text , @ , # , + , % , = , ! , (float) ,[default]
Prop = namedtuple_with_defaults('Prop', ['name', 'type' ,'isref', 'isindex', 'ismulti', 'isproj','iscliq', 'isignored', 'direction', 'weight','value' ], default_values=() ) Prop = namedtuple_with_defaults('Prop', ['name', 'type' ,'isref', 'isindex', 'ismulti', 'isproj','iscliq', 'isignored', 'direction', 'weight','value' ], default_values=() )
...@@ -208,15 +208,17 @@ class Botapad(object): ...@@ -208,15 +208,17 @@ class Botapad(object):
try : try :
url = convert_url(path) url = convert_url(path)
self.log( " * Converting url %s to %s" % ( path, url ) ) self.log( " * Converting url %s to %s" % ( path, url ) )
self.log( " * Downloading %s %s\n" % (url, separator)) self.log( " * Downloading %s %s" % (url, separator))
r = requests.get(url) r = requests.get(url)
print r
content = r.text content = r.text
self.log( " %s, %s\n" % (r, len(content)))
# bug BOM ggdoc # bug BOM ggdoc
if content[0:1] == u'\ufeff': if content[0:1] == u'\ufeff':
content = content[1:] content = content[1:]
lines = content.split('\n') lines = content.split('\n')
except : except :
raise
raise BotapadURLError("Can't download %s" % url, url) raise BotapadURLError("Can't download %s" % url, url)
else: else:
...@@ -381,7 +383,11 @@ class Botapad(object): ...@@ -381,7 +383,11 @@ class Botapad(object):
start = 0 start = 0
end = None end = None
props = props[start: end] props = props[start: end]
print "props", props self.log( "\n * @%s : Props " % label )
self.log( " (%s)" % ",".join(Prop()._fields) )
for e in props:
self.log( " %s" % str([v for v in e]) )
names = [ k.name for k in props ] names = [ k.name for k in props ]
projs = [ k.name for k in props if k.isproj ] projs = [ k.name for k in props if k.isproj ]
...@@ -412,7 +418,7 @@ class Botapad(object): ...@@ -412,7 +418,7 @@ class Botapad(object):
self.current = (VERTEX, label, props) self.current = (VERTEX, label, props)
if not label in self.nodetypes: if not label in self.nodetypes:
self.log( "* posting @ %s [%s]" % (label, ", ".join(names)) , indexes, projs) self.log( "\n >> posting @ %s [%s] [%s] [%s]" % (label, ", ".join(names) , ", ".join(indexes), ", ".join(projs)))
self.nodetypes[label] = self.bot.post_nodetype(self.gid, label, label, typeprops(props)) self.nodetypes[label] = self.bot.post_nodetype(self.gid, label, label, typeprops(props))
self.node_headers[label] = props self.node_headers[label] = props
...@@ -424,7 +430,7 @@ class Botapad(object): ...@@ -424,7 +430,7 @@ class Botapad(object):
if "label" not in names : props = [Prop( name="label", type=Text(), value="" )] + props if "label" not in names : props = [Prop( name="label", type=Text(), value="" )] + props
if "weight" not in names : props = [Prop( name="weight", type=Numeric(), value=1. )] + props if "weight" not in names : props = [Prop( name="weight", type=Numeric(), value=1. )] + props
names = [ k.name for k in props ] names = [ k.name for k in props ]
self.log( "* posting _ %s [%s]" % (label, ", ".join(names)) ) self.log( " >> posting _ %s [%s]" % (label, ", ".join(names)) )
self.edgetypes[label] = self.bot.post_edgetype(self.gid, label, "", typeprops(props)) self.edgetypes[label] = self.bot.post_edgetype(self.gid, label, "", typeprops(props))
self.edge_headers[label] = props self.edge_headers[label] = props
...@@ -521,7 +527,7 @@ class Botapad(object): ...@@ -521,7 +527,7 @@ class Botapad(object):
# post nodes # post nodes
node = None node = None
self.log( " [POST] @ %s %s" % (len(payload), label) , names ,index_props) self.log( " [POST] @ %s %s [%s] (%s)" % (len(payload), label , ", ".join(names) , ", ".join(["%s" % e for e in index_props]) ))
for node, uuid in self.bot.post_nodes(self.gid, iter(payload)): for node, uuid in self.bot.post_nodes(self.gid, iter(payload)):
key = "%s" % ("".join([ node['properties'][names[i]] for i in index_props ])) key = "%s" % ("".join([ node['properties'][names[i]] for i in index_props ]))
...@@ -685,7 +691,6 @@ class Botapad(object): ...@@ -685,7 +691,6 @@ class Botapad(object):
self.log( " * [Projector] posting _ %% %s %s %s " % (len(edges), direction, etname ) ) self.log( " * [Projector] posting _ %% %s %s %s " % (len(edges), direction, etname ) )
for e in self.bot.post_edges(self.gid, iter(edges), extra=lambda x : etname) : for e in self.bot.post_edges(self.gid, iter(edges), extra=lambda x : etname) :
self.debug(e) self.debug(e)
print(e)
def main(): def main():
......
...@@ -423,7 +423,10 @@ def botimport(repo, padurl, gid, content_type): ...@@ -423,7 +423,10 @@ def botimport(repo, padurl, gid, content_type):
reader = args.get("format", "csv") reader = args.get("format", "csv")
args = dict(request.args) args = dict(zip(
request.args.keys(),
request.args.values()
))
args['s'] = padurl args['s'] = padurl
if padurl: if padurl:
...@@ -442,17 +445,21 @@ def botimport(repo, padurl, gid, content_type): ...@@ -442,17 +445,21 @@ def botimport(repo, padurl, gid, content_type):
# gviz # gviz
'el': "#viz", 'el': "#viz",
'background_color' : color, 'background_color' : color,
'initial_size' : 16,
'user_font_size' : 1, # todo check where used
'user_vtx_size' : 2, 'initial_size' : 6,
'vtx_size' : args.get("vertex_size", 2 ), 'vtx_size' : args.get("vertex_size", 2 ),
'user_font_size': int(args.get("user_font_size", 1) ),
'user_vtx_size' : int(args.get("user_vtx_size" , 2) ),
'show_text' : 0 if args.get("no_text" , None ) else 1, # removes vertex text 'show_text' : 0 if args.get("no_text" , None ) else 1, # removes vertex text
'show_nodes' : 0 if args.get("no_nodes" , None ) else 1, # removes vertex only 'show_nodes' : 0 if args.get("no_nodes" , None ) else 1, # removes vertex only
'show_edges' : 0 if args.get("no_edges" , None ) else 1, # removes edges 'show_edges' : 0 if args.get("no_edges" , None ) else 1, # removes edges
'show_images': 0 if args.get("no_images", None ) else 1, # removes vertex images 'show_images': 0 if args.get("no_images", None ) else 1, # removes vertex images
'auto_rotate': 0, 'auto_rotate': int(args.get("auto_rotate", 0 )),
'adaptive_zoom': 1, 'adaptive_zoom': int(args.get("adaptive_zoom", 1 )),
} }
...@@ -503,7 +510,6 @@ def botimport(repo, padurl, gid, content_type): ...@@ -503,7 +510,6 @@ def botimport(repo, padurl, gid, content_type):
print pzeros , graph.summary() print pzeros , graph.summary()
graph = subgraph(graph, length=length, cut=cut, pzeros=pzeros, add_loops=addloops, mode=mode) graph = subgraph(graph, length=length, cut=cut, pzeros=pzeros, add_loops=addloops, mode=mode)
print LENMIN , graph.summary()
data = export_graph(graph, id_attribute='uuid') data = export_graph(graph, id_attribute='uuid')
......
...@@ -4,6 +4,8 @@ from setuptools import setup, find_packages ...@@ -4,6 +4,8 @@ from setuptools import setup, find_packages
""" """
0.6.1 log formating
visualisation url parameters
0.6 added edge direction with reification > or < where % === %< 0.6 added edge direction with reification > or < where % === %<
""" """
...@@ -19,7 +21,7 @@ required = [] ...@@ -19,7 +21,7 @@ required = []
setup( setup(
name='botapad', name='botapad',
version='0.6', version='0.6.1',
description='padagraph pad parser', description='padagraph pad parser',
author='ynnk, a-tsioh', author='ynnk, a-tsioh',
author_email='contact@padagraph.io', author_email='contact@padagraph.io',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment