From ea4036b3d48c72977c3cd744f50da08a898256ab Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Fri, 18 Feb 2022 10:42:40 +0100 Subject: [PATCH] ArgparseEdgeType: Re-enable Inkscape format Got dropped in ecf14540f5d74d8100edcca7dce72b7e6fe26d42 while moving to Inkscape 1.0. Related: #369 --- boxes/__init__.py | 4 ++-- scripts/boxes2inkscape | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index b106622..b567feb 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -198,9 +198,9 @@ class ArgparseEdgeType: return """\n""" % (name, options) def inx(self, name, viewname, arg): - return (' \n' % + return (' \n' % (name, viewname, quoteattr(arg.help or "")) + - ''.join((' %s %s\n' % ( + ''.join((' \n' % ( e, e, self.names.get(e, "")) for e in self.edges)) + ' \n') diff --git a/scripts/boxes2inkscape b/scripts/boxes2inkscape index ae6e65d..438c97c 100755 --- a/scripts/boxes2inkscape +++ b/scripts/boxes2inkscape @@ -46,18 +46,14 @@ class Boxes2INX: if prefix and name.startswith(prefix + '_'): viewname = name[len(prefix)+1:] - #returns old enum type. disabled - #if (isinstance(a, argparse._StoreAction) and hasattr(a.type, "inx")): - #return a.type.inx(name, viewname, a) #see boxes.__init__.py - - #elif a.dest == "layout": # XXX - if a.dest == "layout": # XXX + if (isinstance(a, argparse._StoreAction) and hasattr(a.type, "inx")): + return a.type.inx(name, viewname, a) #see boxes.__init__.py + elif a.dest == "layout": return "" val = a.default.split("\n") input = """""" % \ (name, max((len(l) for l in val))+10, len(val)+1, a.default) - - elif (isinstance(a, argparse._StoreAction) and hasattr(a.type, "inx")) or a.choices: + elif a.choices: uniqueChoices = [] for e in a.choices: if e not in uniqueChoices: @@ -65,7 +61,6 @@ class Boxes2INX: return (''' \n''' % (name, viewname, quoteattr(a.help or viewname)) + "".join(' \n' % (e, e) for e in uniqueChoices) + ' \n') - else: default = a.default if isinstance(a.type, boxes.BoolArg):