From 0c709b2bab6e4d65d55542ef9d9986f72bb7fb95 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Thu, 26 Sep 2013 15:19:49 +0200 Subject: Lib: when generating static format, promote url (from 'web' attr) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- lib.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib.py b/lib.py index 18e57e4..adfdf9c 100644 --- a/lib.py +++ b/lib.py @@ -43,6 +43,8 @@ def bl_map_nodes_edges(nodes, edges, prev_nnames=None): class LibMeta(type): + promote_url = False + def __new__(cls, name, bases, attrs): ret = super(LibMeta, cls).__new__(cls, name, bases, attrs) if REGISTRY.setdefault(name, ret) is not ret: @@ -66,7 +68,11 @@ class LibMeta(type): for akey, avalue in getattr(cls, 'defaults', {}).iteritems(): kwargs.setdefault(akey, avalue) - kwargs['URL'] = "class://" + self.__class__.__name__ + if type(self).promote_url: + if hasattr(self, 'web'): + kwargs['URL'] = getattr(self, 'web', None) + else: + kwargs['URL'] = "class://" + self.__class__.__name__ old_init(self, *args, **kwargs) super(cls, self).__init__(*args, **kwargs) @@ -316,6 +322,7 @@ def main(graph, argv, *args, **kws): if x: xdot_graph(graph, **kws) else: + LibMeta.promote_url = True ext = argv[1] if len(argv) > 1 else 'pdf' fmt = {'dot': 'raw'}.get(ext, ext) output += extsep + ext -- cgit