| ... | ... |
@@ -1446,9 +1446,9 @@ class DotWidget(gtk.DrawingArea): |
| 1446 | 1446 |
def set_filter(self, filter): |
| 1447 | 1447 |
self.filter = filter |
| 1448 | 1448 |
|
| 1449 |
- def set_dotcode(self, dotcode, filename='<stdin>'): |
|
| 1450 |
- if isinstance(dotcode, unicode): |
|
| 1451 |
- dotcode = dotcode.encode('utf8')
|
|
| 1449 |
+ def run_filter(self, dotcode): |
|
| 1450 |
+ if not self.filter: |
|
| 1451 |
+ return dotcode |
|
| 1452 | 1452 |
p = subprocess.Popen( |
| 1453 | 1453 |
[self.filter, '-Txdot'], |
| 1454 | 1454 |
stdin=subprocess.PIPE, |
| ... | ... |
@@ -1466,6 +1466,14 @@ class DotWidget(gtk.DrawingArea): |
| 1466 | 1466 |
dialog.set_title('Dot Viewer')
|
| 1467 | 1467 |
dialog.run() |
| 1468 | 1468 |
dialog.destroy() |
| 1469 |
+ return None |
|
| 1470 |
+ return xdotcode |
|
| 1471 |
+ |
|
| 1472 |
+ def set_dotcode(self, dotcode, filename='<stdin>'): |
|
| 1473 |
+ if isinstance(dotcode, unicode): |
|
| 1474 |
+ dotcode = dotcode.encode('utf8')
|
|
| 1475 |
+ xdotcode = self.run_filter(dotcode) |
|
| 1476 |
+ if xdotcode is None: |
|
| 1469 | 1477 |
return False |
| 1470 | 1478 |
try: |
| 1471 | 1479 |
self.set_xdotcode(xdotcode) |
| ... | ... |
@@ -1872,6 +1880,10 @@ def main(): |
| 1872 | 1880 |
type='choice', choices=('dot', 'neato', 'twopi', 'circo', 'fdp'),
|
| 1873 | 1881 |
dest='filter', default='dot', |
| 1874 | 1882 |
help='graphviz filter: dot, neato, twopi, circo, or fdp [default: %default]') |
| 1883 |
+ parser.add_option( |
|
| 1884 |
+ '-n', '--no-filter', |
|
| 1885 |
+ action='store_const', const=None, dest='filter', |
|
| 1886 |
+ help='assume input is already filtered into xdot format (use e.g. dot -Txdot)') |
|
| 1875 | 1887 |
|
| 1876 | 1888 |
(options, args) = parser.parse_args(sys.argv[1:]) |
| 1877 | 1889 |
if len(args) > 1: |