Mercurial > hg
annotate mercurial/dagparser.py @ 41630:3d094bfaf885
subrepo: adjust subrepo prefix before calling subrepo.diff() (API)
Differential Revision: https://phab.mercurial-scm.org/D5886
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 07 Feb 2019 09:52:36 -0800 |
parents | e7aa113b14f7 |
children | 2372284d9457 |
rev | line source |
---|---|
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
1 # dagparser.py - parser and generator for concise description of DAGs |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
2 # |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2010 Peter Arrenbrecht <peter@arrenbrecht.ch> |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
4 # |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
7 |
25941
a75cda2dfc19
dagparser: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25170
diff
changeset
|
8 from __future__ import absolute_import |
a75cda2dfc19
dagparser: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25170
diff
changeset
|
9 |
a75cda2dfc19
dagparser: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25170
diff
changeset
|
10 import re |
a75cda2dfc19
dagparser: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25170
diff
changeset
|
11 import string |
a75cda2dfc19
dagparser: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25170
diff
changeset
|
12 |
a75cda2dfc19
dagparser: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25170
diff
changeset
|
13 from .i18n import _ |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
14 from . import ( |
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
15 error, |
34211
a48ad118c558
py3: wrap string constants in dagparser.py with bytestr()
Yuya Nishihara <yuya@tcha.org>
parents:
34210
diff
changeset
|
16 pycompat, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34212
diff
changeset
|
17 ) |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34212
diff
changeset
|
18 from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34212
diff
changeset
|
19 stringutil, |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
20 ) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
21 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
22 def parsedag(desc): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
23 '''parses a DAG from a concise textual description; generates events |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
24 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
25 "+n" is a linear run of n nodes based on the current default parent |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
26 "." is a single node based on the current default parent |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
27 "$" resets the default parent to -1 (implied at the start); |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
28 otherwise the default parent is always the last node created |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
29 "<p" sets the default parent to the backref p |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
30 "*p" is a fork at parent p, where p is a backref |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
31 "*p1/p2/.../pn" is a merge of parents p1..pn, where the pi are backrefs |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
32 "/p2/.../pn" is a merge of the preceding node and p2..pn |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
33 ":name" defines a label for the preceding node; labels can be redefined |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
34 "@text" emits an annotation event for text |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
35 "!command" emits an action event for the current node |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
36 "!!my command\n" is like "!", but to the end of the line |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
37 "#...\n" is a comment up to the end of the line |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
38 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
39 Whitespace between the above elements is ignored. |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
40 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
41 A backref is either |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
42 * a number n, which references the node curr-n, where curr is the current |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
43 node, or |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
44 * the name of a label you placed earlier using ":name", or |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
45 * empty to denote the default parent. |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
46 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
47 All string valued-elements are either strictly alphanumeric, or must |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
48 be enclosed in double quotes ("..."), with "\" as escape character. |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
49 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
50 Generates sequence of |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
51 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
52 ('n', (id, [parentids])) for node creation |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
53 ('l', (id, labelname)) for labels on nodes |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
54 ('a', text) for annotations |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
55 ('c', command) for actions (!) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
56 ('C', command) for line actions (!!) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
57 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
58 Examples |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
59 -------- |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
60 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
61 Example of a complex graph (output not shown for brevity): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
62 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
63 >>> len(list(parsedag(b""" |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
64 ... |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
65 ... +3 # 3 nodes in linear run |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
66 ... :forkhere # a label for the last of the 3 nodes from above |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
67 ... +5 # 5 more nodes on one branch |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
68 ... :mergethis # label again |
17500 | 69 ... <forkhere # set default parent to labeled fork node |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
70 ... +10 # 10 more nodes on a parallel branch |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
71 ... @stable # following nodes will be annotated as "stable" |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
72 ... +5 # 5 nodes in stable |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
73 ... !addfile # custom command; could trigger new file in next node |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
74 ... +2 # two more nodes |
17500 | 75 ... /mergethis # merge last node with labeled node |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
76 ... +4 # 4 more nodes descending from merge node |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
77 ... |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
78 ... """))) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
79 34 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
80 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
81 Empty list: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
82 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
83 >>> list(parsedag(b"")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
84 [] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
85 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
86 A simple linear run: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
87 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
88 >>> list(parsedag(b"+3")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
89 [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
90 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
91 Some non-standard ways to define such runs: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
92 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
93 >>> list(parsedag(b"+1+2")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
94 [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
95 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
96 >>> list(parsedag(b"+1*1*")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
97 [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
98 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
99 >>> list(parsedag(b"*")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
100 [('n', (0, [-1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
101 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
102 >>> list(parsedag(b"...")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
103 [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
104 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
105 A fork and a join, using numeric back references: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
106 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
107 >>> list(parsedag(b"+2*2*/2")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
108 [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ('n', (3, [2, 1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
109 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
110 >>> list(parsedag(b"+2<2+1/2")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
111 [('n', (0, [-1])), ('n', (1, [0])), ('n', (2, [0])), ('n', (3, [2, 1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
112 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
113 Placing a label: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
114 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
115 >>> list(parsedag(b"+1 :mylabel +1")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
116 [('n', (0, [-1])), ('l', (0, 'mylabel')), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
117 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
118 An empty label (silly, really): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
119 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
120 >>> list(parsedag(b"+1:+1")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
121 [('n', (0, [-1])), ('l', (0, '')), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
122 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
123 Fork and join, but with labels instead of numeric back references: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
124 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
125 >>> list(parsedag(b"+1:f +1:p2 *f */p2")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
126 [('n', (0, [-1])), ('l', (0, 'f')), ('n', (1, [0])), ('l', (1, 'p2')), |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
127 ('n', (2, [0])), ('n', (3, [2, 1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
128 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
129 >>> list(parsedag(b"+1:f +1:p2 <f +1 /p2")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
130 [('n', (0, [-1])), ('l', (0, 'f')), ('n', (1, [0])), ('l', (1, 'p2')), |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
131 ('n', (2, [0])), ('n', (3, [2, 1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
132 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
133 Restarting from the root: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
134 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
135 >>> list(parsedag(b"+1 $ +1")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
136 [('n', (0, [-1])), ('n', (1, [-1]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
137 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
138 Annotations, which are meant to introduce sticky state for subsequent nodes: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
139 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
140 >>> list(parsedag(b"+1 @ann +1")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
141 [('n', (0, [-1])), ('a', 'ann'), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
142 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
143 >>> list(parsedag(b'+1 @"my annotation" +1')) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
144 [('n', (0, [-1])), ('a', 'my annotation'), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
145 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
146 Commands, which are meant to operate on the most recently created node: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
147 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
148 >>> list(parsedag(b"+1 !cmd +1")) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
149 [('n', (0, [-1])), ('c', 'cmd'), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
150 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
151 >>> list(parsedag(b'+1 !"my command" +1')) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
152 [('n', (0, [-1])), ('c', 'my command'), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
153 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
154 >>> list(parsedag(b'+1 !!my command line\\n +1')) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
155 [('n', (0, [-1])), ('C', 'my command line'), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
156 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
157 Comments, which extend to the end of the line: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
158 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
159 >>> list(parsedag(b'+1 # comment\\n+1')) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
160 [('n', (0, [-1])), ('n', (1, [0]))] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
161 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
162 Error: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
163 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
164 >>> try: list(parsedag(b'+1 bad')) |
34138
0f9936d80e01
doctest: upgrade old-style "except" clause
Yuya Nishihara <yuya@tcha.org>
parents:
34137
diff
changeset
|
165 ... except Exception as e: print(pycompat.sysstr(bytes(e))) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
166 invalid character in dag description: bad... |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
167 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
168 ''' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
169 if not desc: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
170 return |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
171 |
34211
a48ad118c558
py3: wrap string constants in dagparser.py with bytestr()
Yuya Nishihara <yuya@tcha.org>
parents:
34210
diff
changeset
|
172 wordchars = pycompat.bytestr(string.ascii_letters + string.digits) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
173 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
174 labels = {} |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
175 p1 = -1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
176 r = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
177 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
178 def resolve(ref): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
179 if not ref: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
180 return p1 |
34211
a48ad118c558
py3: wrap string constants in dagparser.py with bytestr()
Yuya Nishihara <yuya@tcha.org>
parents:
34210
diff
changeset
|
181 elif ref[0] in pycompat.bytestr(string.digits): |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
182 return r - int(ref) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
183 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
184 return labels[ref] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
185 |
34212
dfd009e5f9f2
py3: iterate bytes as a byte string in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34211
diff
changeset
|
186 chiter = pycompat.iterbytestr(desc) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
187 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
188 def nextch(): |
25170
c69f4f7fe01a
dagparser: use 'next' instead of try/except for default value
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
17500
diff
changeset
|
189 return next(chiter, '\0') |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
190 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
191 def nextrun(c, allow): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
192 s = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
193 while c in allow: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
194 s += c |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
195 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
196 return c, s |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
197 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
198 def nextdelimited(c, limit, escape): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
199 s = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
200 while c != limit: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
201 if c == escape: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
202 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
203 s += c |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
204 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
205 return nextch(), s |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
206 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
207 def nextstring(c): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
208 if c == '"': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
209 return nextdelimited(nextch(), '"', '\\') |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
210 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
211 return nextrun(c, wordchars) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
212 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
213 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
214 while c != '\0': |
34211
a48ad118c558
py3: wrap string constants in dagparser.py with bytestr()
Yuya Nishihara <yuya@tcha.org>
parents:
34210
diff
changeset
|
215 while c in pycompat.bytestr(string.whitespace): |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
216 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
217 if c == '.': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
218 yield 'n', (r, [p1]) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
219 p1 = r |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
220 r += 1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
221 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
222 elif c == '+': |
34211
a48ad118c558
py3: wrap string constants in dagparser.py with bytestr()
Yuya Nishihara <yuya@tcha.org>
parents:
34210
diff
changeset
|
223 c, digs = nextrun(nextch(), pycompat.bytestr(string.digits)) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
224 n = int(digs) |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37084
diff
changeset
|
225 for i in pycompat.xrange(0, n): |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
226 yield 'n', (r, [p1]) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
227 p1 = r |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
228 r += 1 |
12387
4f8067c94729
cleanup: use x in (a, b) instead of x == a or x == b
Brodie Rao <brodie@bitheap.org>
parents:
12134
diff
changeset
|
229 elif c in '*/': |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
230 if c == '*': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
231 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
232 c, pref = nextstring(c) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
233 prefs = [pref] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
234 while c == '/': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
235 c, pref = nextstring(nextch()) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
236 prefs.append(pref) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
237 ps = [resolve(ref) for ref in prefs] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
238 yield 'n', (r, ps) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
239 p1 = r |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
240 r += 1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
241 elif c == '<': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
242 c, ref = nextstring(nextch()) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
243 p1 = resolve(ref) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
244 elif c == ':': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
245 c, name = nextstring(nextch()) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
246 labels[name] = p1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
247 yield 'l', (p1, name) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
248 elif c == '@': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
249 c, text = nextstring(nextch()) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
250 yield 'a', text |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
251 elif c == '!': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
252 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
253 if c == '!': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
254 cmd = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
255 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
256 while c not in '\n\r\0': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
257 cmd += c |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
258 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
259 yield 'C', cmd |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
260 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
261 c, cmd = nextstring(c) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
262 yield 'c', cmd |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
263 elif c == '#': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
264 while c not in '\n\r\0': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
265 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
266 elif c == '$': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
267 p1 = -1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
268 c = nextch() |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
269 elif c == '\0': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
270 return # in case it was preceded by whitespace |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
271 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
272 s = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
273 i = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
274 while c != '\0' and i < 10: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
275 s += c |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
276 i += 1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
277 c = nextch() |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25941
diff
changeset
|
278 raise error.Abort(_('invalid character in dag description: ' |
16683 | 279 '%s...') % s) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
280 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
281 def dagtextlines(events, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
282 addspaces=True, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
283 wraplabels=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
284 wrapannotations=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
285 wrapcommands=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
286 wrapnonlinear=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
287 usedots=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
288 maxlinewidth=70): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
289 '''generates single lines for dagtext()''' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
290 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
291 def wrapstring(text): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
292 if re.match("^[0-9a-z]*$", text): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
293 return text |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
294 return '"' + text.replace('\\', '\\\\').replace('"', '\"') + '"' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
295 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
296 def gen(): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
297 labels = {} |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
298 run = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
299 wantr = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
300 needroot = False |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
301 for kind, data in events: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
302 if kind == 'n': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
303 r, ps = data |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
304 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
305 # sanity check |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
306 if r != wantr: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25941
diff
changeset
|
307 raise error.Abort(_("expected id %i, got %i") % (wantr, r)) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
308 if not ps: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
309 ps = [-1] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
310 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
311 for p in ps: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
312 if p >= r: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25941
diff
changeset
|
313 raise error.Abort(_("parent id %i is larger than " |
12134
26d86a6cf2af
dagparser: translate and lowercase error messages
Martin Geisler <mg@aragost.com>
parents:
11879
diff
changeset
|
314 "current id %i") % (p, r)) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
315 wantr += 1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
316 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
317 # new root? |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
318 p1 = r - 1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
319 if len(ps) == 1 and ps[0] == -1: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
320 if needroot: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
321 if run: |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
322 yield '+%d' % run |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
323 run = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
324 if wrapnonlinear: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
325 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
326 yield '$' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
327 p1 = -1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
328 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
329 needroot = True |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
330 if len(ps) == 1 and ps[0] == p1: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
331 if usedots: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
332 yield "." |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
333 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
334 run += 1 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
335 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
336 if run: |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
337 yield '+%d' % run |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
338 run = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
339 if wrapnonlinear: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
340 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
341 prefs = [] |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
342 for p in ps: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
343 if p == p1: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
344 prefs.append('') |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
345 elif p in labels: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
346 prefs.append(labels[p]) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
347 else: |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
348 prefs.append('%d' % (r - p)) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
349 yield '*' + '/'.join(prefs) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
350 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
351 if run: |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
352 yield '+%d' % run |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
353 run = 0 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
354 if kind == 'l': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
355 rid, name = data |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
356 labels[rid] = name |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
357 yield ':' + name |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
358 if wraplabels: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
359 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
360 elif kind == 'c': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
361 yield '!' + wrapstring(data) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
362 if wrapcommands: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
363 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
364 elif kind == 'C': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
365 yield '!!' + data |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
366 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
367 elif kind == 'a': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
368 if wrapannotations: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
369 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
370 yield '@' + wrapstring(data) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
371 elif kind == '#': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
372 yield '#' + data |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
373 yield '\n' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
374 else: |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
375 raise error.Abort(_("invalid event type in dag: " |
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
376 "('%s', '%s')") |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34212
diff
changeset
|
377 % (stringutil.escapestr(kind), |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34212
diff
changeset
|
378 stringutil.escapestr(data))) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
379 if run: |
34210
8927534cacbc
py3: drop use of str() in dagparser.py
Yuya Nishihara <yuya@tcha.org>
parents:
34209
diff
changeset
|
380 yield '+%d' % run |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
381 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
382 line = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
383 for part in gen(): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
384 if part == '\n': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
385 if line: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
386 yield line |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
387 line = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
388 else: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
389 if len(line) + len(part) >= maxlinewidth: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
390 yield line |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
391 line = '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
392 elif addspaces and line and part != '.': |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
393 line += ' ' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
394 line += part |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
395 if line: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
396 yield line |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
397 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
398 def dagtext(dag, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
399 addspaces=True, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
400 wraplabels=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
401 wrapannotations=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
402 wrapcommands=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
403 wrapnonlinear=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
404 usedots=False, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
405 maxlinewidth=70): |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
406 '''generates lines of a textual representation for a dag event stream |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
407 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
408 events should generate what parsedag() does, so: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
409 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
410 ('n', (id, [parentids])) for node creation |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
411 ('l', (id, labelname)) for labels on nodes |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
412 ('a', text) for annotations |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
413 ('c', text) for commands |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
414 ('C', text) for line commands ('!!') |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
415 ('#', text) for comment lines |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
416 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
417 Parent nodes must come before child nodes. |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
418 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
419 Examples |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
420 -------- |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
421 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
422 Linear run: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
423 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
424 >>> dagtext([(b'n', (0, [-1])), (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
425 '+2' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
426 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
427 Two roots: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
428 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
429 >>> dagtext([(b'n', (0, [-1])), (b'n', (1, [-1]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
430 '+1 $ +1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
431 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
432 Fork and join: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
433 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
434 >>> dagtext([(b'n', (0, [-1])), (b'n', (1, [0])), (b'n', (2, [0])), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
435 ... (b'n', (3, [2, 1]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
436 '+2 *2 */2' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
437 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
438 Fork and join with labels: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
439 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
440 >>> dagtext([(b'n', (0, [-1])), (b'l', (0, b'f')), (b'n', (1, [0])), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
441 ... (b'l', (1, b'p2')), (b'n', (2, [0])), (b'n', (3, [2, 1]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
442 '+1 :f +1 :p2 *f */p2' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
443 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
444 Annotations: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
445 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
446 >>> dagtext([(b'n', (0, [-1])), (b'a', b'ann'), (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
447 '+1 @ann +1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
448 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
449 >>> dagtext([(b'n', (0, [-1])), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
450 ... (b'a', b'my annotation'), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
451 ... (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
452 '+1 @"my annotation" +1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
453 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
454 Commands: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
455 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
456 >>> dagtext([(b'n', (0, [-1])), (b'c', b'cmd'), (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
457 '+1 !cmd +1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
458 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
459 >>> dagtext([(b'n', (0, [-1])), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
460 ... (b'c', b'my command'), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
461 ... (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
462 '+1 !"my command" +1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
463 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
464 >>> dagtext([(b'n', (0, [-1])), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
465 ... (b'C', b'my command line'), |
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
466 ... (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
467 '+1 !!my command line\\n+1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
468 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
469 Comments: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
470 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
471 >>> dagtext([(b'n', (0, [-1])), (b'#', b' comment'), (b'n', (1, [0]))]) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
472 '+1 # comment\\n+1' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
473 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
474 >>> dagtext([]) |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
475 '' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
476 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
477 Combining parsedag and dagtext: |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
478 |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
33716
diff
changeset
|
479 >>> dagtext(parsedag(b'+1 :f +1 :p2 *f */p2')) |
11335
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
480 '+1 :f +1 :p2 *f */p2' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
481 |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
482 ''' |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
483 return "\n".join(dagtextlines(dag, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
484 addspaces, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
485 wraplabels, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
486 wrapannotations, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
487 wrapcommands, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
488 wrapnonlinear, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
489 usedots, |
3201ff1459dd
dagparser: parses and formats DAGs as concise text
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
diff
changeset
|
490 maxlinewidth)) |