OILS / _devbuild / gen / find_asdl.py View on Github | oilshell.org

1250 lines, 907 significant
1from asdl import pybase
2from mycpp import mops
3from typing import Optional, List, Tuple, Dict, Any, cast, TYPE_CHECKING
4
5
6from asdl import runtime # For runtime.NO_SPID
7from asdl.runtime import NewRecord, NewLeaf, TraversalState
8from _devbuild.gen.hnode_asdl import color_e, hnode, hnode_e, hnode_t, Field
9
10class expr_e(object):
11 Concatenation = 1
12 Disjunction = 2
13 Conjunction = 3
14 Negation = 4
15 True_ = 5
16 False_ = 6
17 PathTest = 7
18 StatTest = 8
19 DeleteAction = 9
20 PruneAction = 10
21 QuitAction = 11
22 PrintAction = 12
23 LsAction = 13
24 ExecAction = 14
25
26_expr_str = {
27 1: 'Concatenation',
28 2: 'Disjunction',
29 3: 'Conjunction',
30 4: 'Negation',
31 5: 'True_',
32 6: 'False_',
33 7: 'PathTest',
34 8: 'StatTest',
35 9: 'DeleteAction',
36 10: 'PruneAction',
37 11: 'QuitAction',
38 12: 'PrintAction',
39 13: 'LsAction',
40 14: 'ExecAction',
41}
42
43def expr_str(tag, dot=True):
44 # type: (int, bool) -> str
45 v = _expr_str[tag]
46 if dot:
47 return "expr.%s" % v
48 else:
49 return v
50
51class expr_t(pybase.CompoundObj):
52 def tag(self):
53 # type: () -> int
54 return self._type_tag
55 pass
56
57class expr__True_(expr_t):
58 _type_tag = 5
59 __slots__ = ()
60
61 def __init__(self, ):
62 # type: () -> None
63 pass
64
65 def PrettyTree(self, trav=None):
66 # type: (Optional[TraversalState]) -> hnode_t
67 trav = trav or TraversalState()
68 heap_id = id(self)
69 if heap_id in trav.seen:
70 return hnode.AlreadySeen(heap_id)
71 trav.seen[heap_id] = True
72 out_node = NewRecord('expr__True_')
73 L = out_node.fields
74
75 return out_node
76
77 def _AbbreviatedTree(self, trav=None):
78 # type: (Optional[TraversalState]) -> hnode_t
79 trav = trav or TraversalState()
80 heap_id = id(self)
81 if heap_id in trav.seen:
82 return hnode.AlreadySeen(heap_id)
83 trav.seen[heap_id] = True
84 out_node = NewRecord('expr__True_')
85 L = out_node.fields
86 return out_node
87
88 def AbbreviatedTree(self, trav=None):
89 # type: (Optional[TraversalState]) -> hnode_t
90 return self._AbbreviatedTree(trav=trav)
91
92class expr__False_(expr_t):
93 _type_tag = 6
94 __slots__ = ()
95
96 def __init__(self, ):
97 # type: () -> None
98 pass
99
100 def PrettyTree(self, trav=None):
101 # type: (Optional[TraversalState]) -> hnode_t
102 trav = trav or TraversalState()
103 heap_id = id(self)
104 if heap_id in trav.seen:
105 return hnode.AlreadySeen(heap_id)
106 trav.seen[heap_id] = True
107 out_node = NewRecord('expr__False_')
108 L = out_node.fields
109
110 return out_node
111
112 def _AbbreviatedTree(self, trav=None):
113 # type: (Optional[TraversalState]) -> hnode_t
114 trav = trav or TraversalState()
115 heap_id = id(self)
116 if heap_id in trav.seen:
117 return hnode.AlreadySeen(heap_id)
118 trav.seen[heap_id] = True
119 out_node = NewRecord('expr__False_')
120 L = out_node.fields
121 return out_node
122
123 def AbbreviatedTree(self, trav=None):
124 # type: (Optional[TraversalState]) -> hnode_t
125 return self._AbbreviatedTree(trav=trav)
126
127class expr__DeleteAction(expr_t):
128 _type_tag = 9
129 __slots__ = ()
130
131 def __init__(self, ):
132 # type: () -> None
133 pass
134
135 def PrettyTree(self, trav=None):
136 # type: (Optional[TraversalState]) -> hnode_t
137 trav = trav or TraversalState()
138 heap_id = id(self)
139 if heap_id in trav.seen:
140 return hnode.AlreadySeen(heap_id)
141 trav.seen[heap_id] = True
142 out_node = NewRecord('expr__DeleteAction')
143 L = out_node.fields
144
145 return out_node
146
147 def _AbbreviatedTree(self, trav=None):
148 # type: (Optional[TraversalState]) -> hnode_t
149 trav = trav or TraversalState()
150 heap_id = id(self)
151 if heap_id in trav.seen:
152 return hnode.AlreadySeen(heap_id)
153 trav.seen[heap_id] = True
154 out_node = NewRecord('expr__DeleteAction')
155 L = out_node.fields
156 return out_node
157
158 def AbbreviatedTree(self, trav=None):
159 # type: (Optional[TraversalState]) -> hnode_t
160 return self._AbbreviatedTree(trav=trav)
161
162class expr__PruneAction(expr_t):
163 _type_tag = 10
164 __slots__ = ()
165
166 def __init__(self, ):
167 # type: () -> None
168 pass
169
170 def PrettyTree(self, trav=None):
171 # type: (Optional[TraversalState]) -> hnode_t
172 trav = trav or TraversalState()
173 heap_id = id(self)
174 if heap_id in trav.seen:
175 return hnode.AlreadySeen(heap_id)
176 trav.seen[heap_id] = True
177 out_node = NewRecord('expr__PruneAction')
178 L = out_node.fields
179
180 return out_node
181
182 def _AbbreviatedTree(self, trav=None):
183 # type: (Optional[TraversalState]) -> hnode_t
184 trav = trav or TraversalState()
185 heap_id = id(self)
186 if heap_id in trav.seen:
187 return hnode.AlreadySeen(heap_id)
188 trav.seen[heap_id] = True
189 out_node = NewRecord('expr__PruneAction')
190 L = out_node.fields
191 return out_node
192
193 def AbbreviatedTree(self, trav=None):
194 # type: (Optional[TraversalState]) -> hnode_t
195 return self._AbbreviatedTree(trav=trav)
196
197class expr__QuitAction(expr_t):
198 _type_tag = 11
199 __slots__ = ()
200
201 def __init__(self, ):
202 # type: () -> None
203 pass
204
205 def PrettyTree(self, trav=None):
206 # type: (Optional[TraversalState]) -> hnode_t
207 trav = trav or TraversalState()
208 heap_id = id(self)
209 if heap_id in trav.seen:
210 return hnode.AlreadySeen(heap_id)
211 trav.seen[heap_id] = True
212 out_node = NewRecord('expr__QuitAction')
213 L = out_node.fields
214
215 return out_node
216
217 def _AbbreviatedTree(self, trav=None):
218 # type: (Optional[TraversalState]) -> hnode_t
219 trav = trav or TraversalState()
220 heap_id = id(self)
221 if heap_id in trav.seen:
222 return hnode.AlreadySeen(heap_id)
223 trav.seen[heap_id] = True
224 out_node = NewRecord('expr__QuitAction')
225 L = out_node.fields
226 return out_node
227
228 def AbbreviatedTree(self, trav=None):
229 # type: (Optional[TraversalState]) -> hnode_t
230 return self._AbbreviatedTree(trav=trav)
231
232class expr(object):
233 class Concatenation(expr_t):
234 _type_tag = 1
235 __slots__ = ('exprs',)
236
237 def __init__(self, exprs):
238 # type: (List[expr_t]) -> None
239 self.exprs = exprs
240
241 @staticmethod
242 def CreateNull(alloc_lists=False):
243 # type: () -> expr.Concatenation
244 return expr.Concatenation([] if alloc_lists else cast('List[expr_t]', None))
245
246 def PrettyTree(self, trav=None):
247 # type: (Optional[TraversalState]) -> hnode_t
248 trav = trav or TraversalState()
249 heap_id = id(self)
250 if heap_id in trav.seen:
251 return hnode.AlreadySeen(heap_id)
252 trav.seen[heap_id] = True
253 out_node = NewRecord('expr.Concatenation')
254 L = out_node.fields
255
256 if self.exprs is not None: # List
257 x0 = hnode.Array([])
258 for i0 in self.exprs:
259 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
260 i0.PrettyTree(trav=trav))
261 x0.children.append(h)
262 L.append(Field('exprs', x0))
263
264 return out_node
265
266 def _AbbreviatedTree(self, trav=None):
267 # type: (Optional[TraversalState]) -> hnode_t
268 trav = trav or TraversalState()
269 heap_id = id(self)
270 if heap_id in trav.seen:
271 return hnode.AlreadySeen(heap_id)
272 trav.seen[heap_id] = True
273 out_node = NewRecord('expr.Concatenation')
274 L = out_node.fields
275 if self.exprs is not None: # List
276 x0 = hnode.Array([])
277 for i0 in self.exprs:
278 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
279 i0.AbbreviatedTree(trav=trav))
280 x0.children.append(h)
281 L.append(Field('exprs', x0))
282
283 return out_node
284
285 def AbbreviatedTree(self, trav=None):
286 # type: (Optional[TraversalState]) -> hnode_t
287 return self._AbbreviatedTree(trav=trav)
288
289 class Disjunction(expr_t):
290 _type_tag = 2
291 __slots__ = ('exprs',)
292
293 def __init__(self, exprs):
294 # type: (List[expr_t]) -> None
295 self.exprs = exprs
296
297 @staticmethod
298 def CreateNull(alloc_lists=False):
299 # type: () -> expr.Disjunction
300 return expr.Disjunction([] if alloc_lists else cast('List[expr_t]', None))
301
302 def PrettyTree(self, trav=None):
303 # type: (Optional[TraversalState]) -> hnode_t
304 trav = trav or TraversalState()
305 heap_id = id(self)
306 if heap_id in trav.seen:
307 return hnode.AlreadySeen(heap_id)
308 trav.seen[heap_id] = True
309 out_node = NewRecord('expr.Disjunction')
310 L = out_node.fields
311
312 if self.exprs is not None: # List
313 x0 = hnode.Array([])
314 for i0 in self.exprs:
315 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
316 i0.PrettyTree(trav=trav))
317 x0.children.append(h)
318 L.append(Field('exprs', x0))
319
320 return out_node
321
322 def _AbbreviatedTree(self, trav=None):
323 # type: (Optional[TraversalState]) -> hnode_t
324 trav = trav or TraversalState()
325 heap_id = id(self)
326 if heap_id in trav.seen:
327 return hnode.AlreadySeen(heap_id)
328 trav.seen[heap_id] = True
329 out_node = NewRecord('expr.Disjunction')
330 L = out_node.fields
331 if self.exprs is not None: # List
332 x0 = hnode.Array([])
333 for i0 in self.exprs:
334 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
335 i0.AbbreviatedTree(trav=trav))
336 x0.children.append(h)
337 L.append(Field('exprs', x0))
338
339 return out_node
340
341 def AbbreviatedTree(self, trav=None):
342 # type: (Optional[TraversalState]) -> hnode_t
343 return self._AbbreviatedTree(trav=trav)
344
345 class Conjunction(expr_t):
346 _type_tag = 3
347 __slots__ = ('exprs',)
348
349 def __init__(self, exprs):
350 # type: (List[expr_t]) -> None
351 self.exprs = exprs
352
353 @staticmethod
354 def CreateNull(alloc_lists=False):
355 # type: () -> expr.Conjunction
356 return expr.Conjunction([] if alloc_lists else cast('List[expr_t]', None))
357
358 def PrettyTree(self, trav=None):
359 # type: (Optional[TraversalState]) -> hnode_t
360 trav = trav or TraversalState()
361 heap_id = id(self)
362 if heap_id in trav.seen:
363 return hnode.AlreadySeen(heap_id)
364 trav.seen[heap_id] = True
365 out_node = NewRecord('expr.Conjunction')
366 L = out_node.fields
367
368 if self.exprs is not None: # List
369 x0 = hnode.Array([])
370 for i0 in self.exprs:
371 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
372 i0.PrettyTree(trav=trav))
373 x0.children.append(h)
374 L.append(Field('exprs', x0))
375
376 return out_node
377
378 def _AbbreviatedTree(self, trav=None):
379 # type: (Optional[TraversalState]) -> hnode_t
380 trav = trav or TraversalState()
381 heap_id = id(self)
382 if heap_id in trav.seen:
383 return hnode.AlreadySeen(heap_id)
384 trav.seen[heap_id] = True
385 out_node = NewRecord('expr.Conjunction')
386 L = out_node.fields
387 if self.exprs is not None: # List
388 x0 = hnode.Array([])
389 for i0 in self.exprs:
390 h = (hnode.Leaf("_", color_e.OtherConst) if i0 is None else
391 i0.AbbreviatedTree(trav=trav))
392 x0.children.append(h)
393 L.append(Field('exprs', x0))
394
395 return out_node
396
397 def AbbreviatedTree(self, trav=None):
398 # type: (Optional[TraversalState]) -> hnode_t
399 return self._AbbreviatedTree(trav=trav)
400
401 class Negation(expr_t):
402 _type_tag = 4
403 __slots__ = ('expr',)
404
405 def __init__(self, expr):
406 # type: (expr_t) -> None
407 self.expr = expr
408
409 @staticmethod
410 def CreateNull(alloc_lists=False):
411 # type: () -> expr.Negation
412 return expr.Negation(cast(expr_t, None))
413
414 def PrettyTree(self, trav=None):
415 # type: (Optional[TraversalState]) -> hnode_t
416 trav = trav or TraversalState()
417 heap_id = id(self)
418 if heap_id in trav.seen:
419 return hnode.AlreadySeen(heap_id)
420 trav.seen[heap_id] = True
421 out_node = NewRecord('expr.Negation')
422 L = out_node.fields
423
424 assert self.expr is not None
425 x0 = self.expr.PrettyTree(trav=trav)
426 L.append(Field('expr', x0))
427
428 return out_node
429
430 def _AbbreviatedTree(self, trav=None):
431 # type: (Optional[TraversalState]) -> hnode_t
432 trav = trav or TraversalState()
433 heap_id = id(self)
434 if heap_id in trav.seen:
435 return hnode.AlreadySeen(heap_id)
436 trav.seen[heap_id] = True
437 out_node = NewRecord('expr.Negation')
438 L = out_node.fields
439 assert self.expr is not None
440 x0 = self.expr.AbbreviatedTree(trav=trav)
441 L.append(Field('expr', x0))
442
443 return out_node
444
445 def AbbreviatedTree(self, trav=None):
446 # type: (Optional[TraversalState]) -> hnode_t
447 return self._AbbreviatedTree(trav=trav)
448
449 True_ = expr__True_()
450
451 False_ = expr__False_()
452
453 class PathTest(expr_t):
454 _type_tag = 7
455 __slots__ = ('a', 'p')
456
457 def __init__(self, a, p):
458 # type: (pathAccessor_t, predicate_t) -> None
459 self.a = a
460 self.p = p
461
462 @staticmethod
463 def CreateNull(alloc_lists=False):
464 # type: () -> expr.PathTest
465 return expr.PathTest(pathAccessor_e.FullPath, cast(predicate_t, None))
466
467 def PrettyTree(self, trav=None):
468 # type: (Optional[TraversalState]) -> hnode_t
469 trav = trav or TraversalState()
470 heap_id = id(self)
471 if heap_id in trav.seen:
472 return hnode.AlreadySeen(heap_id)
473 trav.seen[heap_id] = True
474 out_node = NewRecord('expr.PathTest')
475 L = out_node.fields
476
477 x0 = hnode.Leaf(pathAccessor_str(self.a), color_e.TypeName)
478 L.append(Field('a', x0))
479
480 assert self.p is not None
481 x1 = self.p.PrettyTree(trav=trav)
482 L.append(Field('p', x1))
483
484 return out_node
485
486 def _AbbreviatedTree(self, trav=None):
487 # type: (Optional[TraversalState]) -> hnode_t
488 trav = trav or TraversalState()
489 heap_id = id(self)
490 if heap_id in trav.seen:
491 return hnode.AlreadySeen(heap_id)
492 trav.seen[heap_id] = True
493 out_node = NewRecord('expr.PathTest')
494 L = out_node.fields
495 x0 = hnode.Leaf(pathAccessor_str(self.a), color_e.TypeName)
496 L.append(Field('a', x0))
497
498 assert self.p is not None
499 x1 = self.p.AbbreviatedTree(trav=trav)
500 L.append(Field('p', x1))
501
502 return out_node
503
504 def AbbreviatedTree(self, trav=None):
505 # type: (Optional[TraversalState]) -> hnode_t
506 return self._AbbreviatedTree(trav=trav)
507
508 class StatTest(expr_t):
509 _type_tag = 8
510 __slots__ = ('a', 'p')
511
512 def __init__(self, a, p):
513 # type: (statAccessor_t, predicate_t) -> None
514 self.a = a
515 self.p = p
516
517 @staticmethod
518 def CreateNull(alloc_lists=False):
519 # type: () -> expr.StatTest
520 return expr.StatTest(statAccessor_e.AccessTime, cast(predicate_t, None))
521
522 def PrettyTree(self, trav=None):
523 # type: (Optional[TraversalState]) -> hnode_t
524 trav = trav or TraversalState()
525 heap_id = id(self)
526 if heap_id in trav.seen:
527 return hnode.AlreadySeen(heap_id)
528 trav.seen[heap_id] = True
529 out_node = NewRecord('expr.StatTest')
530 L = out_node.fields
531
532 x0 = hnode.Leaf(statAccessor_str(self.a), color_e.TypeName)
533 L.append(Field('a', x0))
534
535 assert self.p is not None
536 x1 = self.p.PrettyTree(trav=trav)
537 L.append(Field('p', x1))
538
539 return out_node
540
541 def _AbbreviatedTree(self, trav=None):
542 # type: (Optional[TraversalState]) -> hnode_t
543 trav = trav or TraversalState()
544 heap_id = id(self)
545 if heap_id in trav.seen:
546 return hnode.AlreadySeen(heap_id)
547 trav.seen[heap_id] = True
548 out_node = NewRecord('expr.StatTest')
549 L = out_node.fields
550 x0 = hnode.Leaf(statAccessor_str(self.a), color_e.TypeName)
551 L.append(Field('a', x0))
552
553 assert self.p is not None
554 x1 = self.p.AbbreviatedTree(trav=trav)
555 L.append(Field('p', x1))
556
557 return out_node
558
559 def AbbreviatedTree(self, trav=None):
560 # type: (Optional[TraversalState]) -> hnode_t
561 return self._AbbreviatedTree(trav=trav)
562
563 DeleteAction = expr__DeleteAction()
564
565 PruneAction = expr__PruneAction()
566
567 QuitAction = expr__QuitAction()
568
569 class PrintAction(expr_t):
570 _type_tag = 12
571 __slots__ = ('file', 'format')
572
573 def __init__(self, file, format):
574 # type: (Optional[str], Optional[str]) -> None
575 self.file = file
576 self.format = format
577
578 @staticmethod
579 def CreateNull(alloc_lists=False):
580 # type: () -> expr.PrintAction
581 return expr.PrintAction(cast('Optional[str]', None), cast('Optional[str]', None))
582
583 def PrettyTree(self, trav=None):
584 # type: (Optional[TraversalState]) -> hnode_t
585 trav = trav or TraversalState()
586 heap_id = id(self)
587 if heap_id in trav.seen:
588 return hnode.AlreadySeen(heap_id)
589 trav.seen[heap_id] = True
590 out_node = NewRecord('expr.PrintAction')
591 L = out_node.fields
592
593 if self.file is not None: # Optional
594 x0 = NewLeaf(self.file, color_e.StringConst)
595 L.append(Field('file', x0))
596
597 if self.format is not None: # Optional
598 x1 = NewLeaf(self.format, color_e.StringConst)
599 L.append(Field('format', x1))
600
601 return out_node
602
603 def _AbbreviatedTree(self, trav=None):
604 # type: (Optional[TraversalState]) -> hnode_t
605 trav = trav or TraversalState()
606 heap_id = id(self)
607 if heap_id in trav.seen:
608 return hnode.AlreadySeen(heap_id)
609 trav.seen[heap_id] = True
610 out_node = NewRecord('expr.PrintAction')
611 L = out_node.fields
612 if self.file is not None: # Optional
613 x0 = NewLeaf(self.file, color_e.StringConst)
614 L.append(Field('file', x0))
615
616 if self.format is not None: # Optional
617 x1 = NewLeaf(self.format, color_e.StringConst)
618 L.append(Field('format', x1))
619
620 return out_node
621
622 def AbbreviatedTree(self, trav=None):
623 # type: (Optional[TraversalState]) -> hnode_t
624 return self._AbbreviatedTree(trav=trav)
625
626 class LsAction(expr_t):
627 _type_tag = 13
628 __slots__ = ('file',)
629
630 def __init__(self, file):
631 # type: (Optional[str]) -> None
632 self.file = file
633
634 @staticmethod
635 def CreateNull(alloc_lists=False):
636 # type: () -> expr.LsAction
637 return expr.LsAction(cast('Optional[str]', None))
638
639 def PrettyTree(self, trav=None):
640 # type: (Optional[TraversalState]) -> hnode_t
641 trav = trav or TraversalState()
642 heap_id = id(self)
643 if heap_id in trav.seen:
644 return hnode.AlreadySeen(heap_id)
645 trav.seen[heap_id] = True
646 out_node = NewRecord('expr.LsAction')
647 L = out_node.fields
648
649 if self.file is not None: # Optional
650 x0 = NewLeaf(self.file, color_e.StringConst)
651 L.append(Field('file', x0))
652
653 return out_node
654
655 def _AbbreviatedTree(self, trav=None):
656 # type: (Optional[TraversalState]) -> hnode_t
657 trav = trav or TraversalState()
658 heap_id = id(self)
659 if heap_id in trav.seen:
660 return hnode.AlreadySeen(heap_id)
661 trav.seen[heap_id] = True
662 out_node = NewRecord('expr.LsAction')
663 L = out_node.fields
664 if self.file is not None: # Optional
665 x0 = NewLeaf(self.file, color_e.StringConst)
666 L.append(Field('file', x0))
667
668 return out_node
669
670 def AbbreviatedTree(self, trav=None):
671 # type: (Optional[TraversalState]) -> hnode_t
672 return self._AbbreviatedTree(trav=trav)
673
674 class ExecAction(expr_t):
675 _type_tag = 14
676 __slots__ = ('batch', 'dir', 'ok', 'argv')
677
678 def __init__(self, batch, dir, ok, argv):
679 # type: (bool, bool, bool, List[str]) -> None
680 self.batch = batch
681 self.dir = dir
682 self.ok = ok
683 self.argv = argv
684
685 @staticmethod
686 def CreateNull(alloc_lists=False):
687 # type: () -> expr.ExecAction
688 return expr.ExecAction(False, False, False, [] if alloc_lists else cast('List[str]', None))
689
690 def PrettyTree(self, trav=None):
691 # type: (Optional[TraversalState]) -> hnode_t
692 trav = trav or TraversalState()
693 heap_id = id(self)
694 if heap_id in trav.seen:
695 return hnode.AlreadySeen(heap_id)
696 trav.seen[heap_id] = True
697 out_node = NewRecord('expr.ExecAction')
698 L = out_node.fields
699
700 x0 = hnode.Leaf('T' if self.batch else 'F', color_e.OtherConst)
701 L.append(Field('batch', x0))
702
703 x1 = hnode.Leaf('T' if self.dir else 'F', color_e.OtherConst)
704 L.append(Field('dir', x1))
705
706 x2 = hnode.Leaf('T' if self.ok else 'F', color_e.OtherConst)
707 L.append(Field('ok', x2))
708
709 if self.argv is not None: # List
710 x3 = hnode.Array([])
711 for i3 in self.argv:
712 x3.children.append(NewLeaf(i3, color_e.StringConst))
713 L.append(Field('argv', x3))
714
715 return out_node
716
717 def _AbbreviatedTree(self, trav=None):
718 # type: (Optional[TraversalState]) -> hnode_t
719 trav = trav or TraversalState()
720 heap_id = id(self)
721 if heap_id in trav.seen:
722 return hnode.AlreadySeen(heap_id)
723 trav.seen[heap_id] = True
724 out_node = NewRecord('expr.ExecAction')
725 L = out_node.fields
726 x0 = hnode.Leaf('T' if self.batch else 'F', color_e.OtherConst)
727 L.append(Field('batch', x0))
728
729 x1 = hnode.Leaf('T' if self.dir else 'F', color_e.OtherConst)
730 L.append(Field('dir', x1))
731
732 x2 = hnode.Leaf('T' if self.ok else 'F', color_e.OtherConst)
733 L.append(Field('ok', x2))
734
735 if self.argv is not None: # List
736 x3 = hnode.Array([])
737 for i3 in self.argv:
738 x3.children.append(NewLeaf(i3, color_e.StringConst))
739 L.append(Field('argv', x3))
740
741 return out_node
742
743 def AbbreviatedTree(self, trav=None):
744 # type: (Optional[TraversalState]) -> hnode_t
745 return self._AbbreviatedTree(trav=trav)
746
747 pass
748
749class pathAccessor_t(pybase.SimpleObj):
750 pass
751
752class pathAccessor_e(object):
753 FullPath = pathAccessor_t(1)
754 Filename = pathAccessor_t(2)
755
756_pathAccessor_str = {
757 1: 'pathAccessor.FullPath',
758 2: 'pathAccessor.Filename',
759}
760
761def pathAccessor_str(val):
762 # type: (pathAccessor_t) -> str
763 return _pathAccessor_str[val]
764
765class statAccessor_t(pybase.SimpleObj):
766 pass
767
768class statAccessor_e(object):
769 AccessTime = statAccessor_t(1)
770 CreationTime = statAccessor_t(2)
771 ModificationTime = statAccessor_t(3)
772 Filesystem = statAccessor_t(4)
773 Inode = statAccessor_t(5)
774 LinkCount = statAccessor_t(6)
775 Mode = statAccessor_t(7)
776 Filetype = statAccessor_t(8)
777 Uid = statAccessor_t(9)
778 Gid = statAccessor_t(10)
779 Username = statAccessor_t(11)
780 Groupname = statAccessor_t(12)
781 Size = statAccessor_t(13)
782
783_statAccessor_str = {
784 1: 'statAccessor.AccessTime',
785 2: 'statAccessor.CreationTime',
786 3: 'statAccessor.ModificationTime',
787 4: 'statAccessor.Filesystem',
788 5: 'statAccessor.Inode',
789 6: 'statAccessor.LinkCount',
790 7: 'statAccessor.Mode',
791 8: 'statAccessor.Filetype',
792 9: 'statAccessor.Uid',
793 10: 'statAccessor.Gid',
794 11: 'statAccessor.Username',
795 12: 'statAccessor.Groupname',
796 13: 'statAccessor.Size',
797}
798
799def statAccessor_str(val):
800 # type: (statAccessor_t) -> str
801 return _statAccessor_str[val]
802
803class predicate_e(object):
804 EQ = 1
805 GE = 2
806 LE = 3
807 StringMatch = 4
808 GlobMatch = 5
809 RegexMatch = 6
810 Readable = 7
811 Writable = 8
812 Executable = 9
813
814_predicate_str = {
815 1: 'EQ',
816 2: 'GE',
817 3: 'LE',
818 4: 'StringMatch',
819 5: 'GlobMatch',
820 6: 'RegexMatch',
821 7: 'Readable',
822 8: 'Writable',
823 9: 'Executable',
824}
825
826def predicate_str(tag, dot=True):
827 # type: (int, bool) -> str
828 v = _predicate_str[tag]
829 if dot:
830 return "predicate.%s" % v
831 else:
832 return v
833
834class predicate_t(pybase.CompoundObj):
835 def tag(self):
836 # type: () -> int
837 return self._type_tag
838 pass
839
840class predicate__Readable(predicate_t):
841 _type_tag = 7
842 __slots__ = ()
843
844 def __init__(self, ):
845 # type: () -> None
846 pass
847
848 def PrettyTree(self, trav=None):
849 # type: (Optional[TraversalState]) -> hnode_t
850 trav = trav or TraversalState()
851 heap_id = id(self)
852 if heap_id in trav.seen:
853 return hnode.AlreadySeen(heap_id)
854 trav.seen[heap_id] = True
855 out_node = NewRecord('predicate__Readable')
856 L = out_node.fields
857
858 return out_node
859
860 def _AbbreviatedTree(self, trav=None):
861 # type: (Optional[TraversalState]) -> hnode_t
862 trav = trav or TraversalState()
863 heap_id = id(self)
864 if heap_id in trav.seen:
865 return hnode.AlreadySeen(heap_id)
866 trav.seen[heap_id] = True
867 out_node = NewRecord('predicate__Readable')
868 L = out_node.fields
869 return out_node
870
871 def AbbreviatedTree(self, trav=None):
872 # type: (Optional[TraversalState]) -> hnode_t
873 return self._AbbreviatedTree(trav=trav)
874
875class predicate__Writable(predicate_t):
876 _type_tag = 8
877 __slots__ = ()
878
879 def __init__(self, ):
880 # type: () -> None
881 pass
882
883 def PrettyTree(self, trav=None):
884 # type: (Optional[TraversalState]) -> hnode_t
885 trav = trav or TraversalState()
886 heap_id = id(self)
887 if heap_id in trav.seen:
888 return hnode.AlreadySeen(heap_id)
889 trav.seen[heap_id] = True
890 out_node = NewRecord('predicate__Writable')
891 L = out_node.fields
892
893 return out_node
894
895 def _AbbreviatedTree(self, trav=None):
896 # type: (Optional[TraversalState]) -> hnode_t
897 trav = trav or TraversalState()
898 heap_id = id(self)
899 if heap_id in trav.seen:
900 return hnode.AlreadySeen(heap_id)
901 trav.seen[heap_id] = True
902 out_node = NewRecord('predicate__Writable')
903 L = out_node.fields
904 return out_node
905
906 def AbbreviatedTree(self, trav=None):
907 # type: (Optional[TraversalState]) -> hnode_t
908 return self._AbbreviatedTree(trav=trav)
909
910class predicate__Executable(predicate_t):
911 _type_tag = 9
912 __slots__ = ()
913
914 def __init__(self, ):
915 # type: () -> None
916 pass
917
918 def PrettyTree(self, trav=None):
919 # type: (Optional[TraversalState]) -> hnode_t
920 trav = trav or TraversalState()
921 heap_id = id(self)
922 if heap_id in trav.seen:
923 return hnode.AlreadySeen(heap_id)
924 trav.seen[heap_id] = True
925 out_node = NewRecord('predicate__Executable')
926 L = out_node.fields
927
928 return out_node
929
930 def _AbbreviatedTree(self, trav=None):
931 # type: (Optional[TraversalState]) -> hnode_t
932 trav = trav or TraversalState()
933 heap_id = id(self)
934 if heap_id in trav.seen:
935 return hnode.AlreadySeen(heap_id)
936 trav.seen[heap_id] = True
937 out_node = NewRecord('predicate__Executable')
938 L = out_node.fields
939 return out_node
940
941 def AbbreviatedTree(self, trav=None):
942 # type: (Optional[TraversalState]) -> hnode_t
943 return self._AbbreviatedTree(trav=trav)
944
945class predicate(object):
946 class EQ(predicate_t):
947 _type_tag = 1
948 __slots__ = ('n',)
949
950 def __init__(self, n):
951 # type: (int) -> None
952 self.n = n
953
954 @staticmethod
955 def CreateNull(alloc_lists=False):
956 # type: () -> predicate.EQ
957 return predicate.EQ(-1)
958
959 def PrettyTree(self, trav=None):
960 # type: (Optional[TraversalState]) -> hnode_t
961 trav = trav or TraversalState()
962 heap_id = id(self)
963 if heap_id in trav.seen:
964 return hnode.AlreadySeen(heap_id)
965 trav.seen[heap_id] = True
966 out_node = NewRecord('predicate.EQ')
967 L = out_node.fields
968
969 x0 = hnode.Leaf(str(self.n), color_e.OtherConst)
970 L.append(Field('n', x0))
971
972 return out_node
973
974 def _AbbreviatedTree(self, trav=None):
975 # type: (Optional[TraversalState]) -> hnode_t
976 trav = trav or TraversalState()
977 heap_id = id(self)
978 if heap_id in trav.seen:
979 return hnode.AlreadySeen(heap_id)
980 trav.seen[heap_id] = True
981 out_node = NewRecord('predicate.EQ')
982 L = out_node.fields
983 x0 = hnode.Leaf(str(self.n), color_e.OtherConst)
984 L.append(Field('n', x0))
985
986 return out_node
987
988 def AbbreviatedTree(self, trav=None):
989 # type: (Optional[TraversalState]) -> hnode_t
990 return self._AbbreviatedTree(trav=trav)
991
992 class GE(predicate_t):
993 _type_tag = 2
994 __slots__ = ('n',)
995
996 def __init__(self, n):
997 # type: (int) -> None
998 self.n = n
999
1000 @staticmethod
1001 def CreateNull(alloc_lists=False):
1002 # type: () -> predicate.GE
1003 return predicate.GE(-1)
1004
1005 def PrettyTree(self, trav=None):
1006 # type: (Optional[TraversalState]) -> hnode_t
1007 trav = trav or TraversalState()
1008 heap_id = id(self)
1009 if heap_id in trav.seen:
1010 return hnode.AlreadySeen(heap_id)
1011 trav.seen[heap_id] = True
1012 out_node = NewRecord('predicate.GE')
1013 L = out_node.fields
1014
1015 x0 = hnode.Leaf(str(self.n), color_e.OtherConst)
1016 L.append(Field('n', x0))
1017
1018 return out_node
1019
1020 def _AbbreviatedTree(self, trav=None):
1021 # type: (Optional[TraversalState]) -> hnode_t
1022 trav = trav or TraversalState()
1023 heap_id = id(self)
1024 if heap_id in trav.seen:
1025 return hnode.AlreadySeen(heap_id)
1026 trav.seen[heap_id] = True
1027 out_node = NewRecord('predicate.GE')
1028 L = out_node.fields
1029 x0 = hnode.Leaf(str(self.n), color_e.OtherConst)
1030 L.append(Field('n', x0))
1031
1032 return out_node
1033
1034 def AbbreviatedTree(self, trav=None):
1035 # type: (Optional[TraversalState]) -> hnode_t
1036 return self._AbbreviatedTree(trav=trav)
1037
1038 class LE(predicate_t):
1039 _type_tag = 3
1040 __slots__ = ('n',)
1041
1042 def __init__(self, n):
1043 # type: (int) -> None
1044 self.n = n
1045
1046 @staticmethod
1047 def CreateNull(alloc_lists=False):
1048 # type: () -> predicate.LE
1049 return predicate.LE(-1)
1050
1051 def PrettyTree(self, trav=None):
1052 # type: (Optional[TraversalState]) -> hnode_t
1053 trav = trav or TraversalState()
1054 heap_id = id(self)
1055 if heap_id in trav.seen:
1056 return hnode.AlreadySeen(heap_id)
1057 trav.seen[heap_id] = True
1058 out_node = NewRecord('predicate.LE')
1059 L = out_node.fields
1060
1061 x0 = hnode.Leaf(str(self.n), color_e.OtherConst)
1062 L.append(Field('n', x0))
1063
1064 return out_node
1065
1066 def _AbbreviatedTree(self, trav=None):
1067 # type: (Optional[TraversalState]) -> hnode_t
1068 trav = trav or TraversalState()
1069 heap_id = id(self)
1070 if heap_id in trav.seen:
1071 return hnode.AlreadySeen(heap_id)
1072 trav.seen[heap_id] = True
1073 out_node = NewRecord('predicate.LE')
1074 L = out_node.fields
1075 x0 = hnode.Leaf(str(self.n), color_e.OtherConst)
1076 L.append(Field('n', x0))
1077
1078 return out_node
1079
1080 def AbbreviatedTree(self, trav=None):
1081 # type: (Optional[TraversalState]) -> hnode_t
1082 return self._AbbreviatedTree(trav=trav)
1083
1084 class StringMatch(predicate_t):
1085 _type_tag = 4
1086 __slots__ = ('str', 'ignoreCase')
1087
1088 def __init__(self, str, ignoreCase):
1089 # type: (str, bool) -> None
1090 self.str = str
1091 self.ignoreCase = ignoreCase
1092
1093 @staticmethod
1094 def CreateNull(alloc_lists=False):
1095 # type: () -> predicate.StringMatch
1096 return predicate.StringMatch('', False)
1097
1098 def PrettyTree(self, trav=None):
1099 # type: (Optional[TraversalState]) -> hnode_t
1100 trav = trav or TraversalState()
1101 heap_id = id(self)
1102 if heap_id in trav.seen:
1103 return hnode.AlreadySeen(heap_id)
1104 trav.seen[heap_id] = True
1105 out_node = NewRecord('predicate.StringMatch')
1106 L = out_node.fields
1107
1108 x0 = NewLeaf(self.str, color_e.StringConst)
1109 L.append(Field('str', x0))
1110
1111 x1 = hnode.Leaf('T' if self.ignoreCase else 'F', color_e.OtherConst)
1112 L.append(Field('ignoreCase', x1))
1113
1114 return out_node
1115
1116 def _AbbreviatedTree(self, trav=None):
1117 # type: (Optional[TraversalState]) -> hnode_t
1118 trav = trav or TraversalState()
1119 heap_id = id(self)
1120 if heap_id in trav.seen:
1121 return hnode.AlreadySeen(heap_id)
1122 trav.seen[heap_id] = True
1123 out_node = NewRecord('predicate.StringMatch')
1124 L = out_node.fields
1125 x0 = NewLeaf(self.str, color_e.StringConst)
1126 L.append(Field('str', x0))
1127
1128 x1 = hnode.Leaf('T' if self.ignoreCase else 'F', color_e.OtherConst)
1129 L.append(Field('ignoreCase', x1))
1130
1131 return out_node
1132
1133 def AbbreviatedTree(self, trav=None):
1134 # type: (Optional[TraversalState]) -> hnode_t
1135 return self._AbbreviatedTree(trav=trav)
1136
1137 class GlobMatch(predicate_t):
1138 _type_tag = 5
1139 __slots__ = ('glob', 'ignoreCase')
1140
1141 def __init__(self, glob, ignoreCase):
1142 # type: (str, bool) -> None
1143 self.glob = glob
1144 self.ignoreCase = ignoreCase
1145
1146 @staticmethod
1147 def CreateNull(alloc_lists=False):
1148 # type: () -> predicate.GlobMatch
1149 return predicate.GlobMatch('', False)
1150
1151 def PrettyTree(self, trav=None):
1152 # type: (Optional[TraversalState]) -> hnode_t
1153 trav = trav or TraversalState()
1154 heap_id = id(self)
1155 if heap_id in trav.seen:
1156 return hnode.AlreadySeen(heap_id)
1157 trav.seen[heap_id] = True
1158 out_node = NewRecord('predicate.GlobMatch')
1159 L = out_node.fields
1160
1161 x0 = NewLeaf(self.glob, color_e.StringConst)
1162 L.append(Field('glob', x0))
1163
1164 x1 = hnode.Leaf('T' if self.ignoreCase else 'F', color_e.OtherConst)
1165 L.append(Field('ignoreCase', x1))
1166
1167 return out_node
1168
1169 def _AbbreviatedTree(self, trav=None):
1170 # type: (Optional[TraversalState]) -> hnode_t
1171 trav = trav or TraversalState()
1172 heap_id = id(self)
1173 if heap_id in trav.seen:
1174 return hnode.AlreadySeen(heap_id)
1175 trav.seen[heap_id] = True
1176 out_node = NewRecord('predicate.GlobMatch')
1177 L = out_node.fields
1178 x0 = NewLeaf(self.glob, color_e.StringConst)
1179 L.append(Field('glob', x0))
1180
1181 x1 = hnode.Leaf('T' if self.ignoreCase else 'F', color_e.OtherConst)
1182 L.append(Field('ignoreCase', x1))
1183
1184 return out_node
1185
1186 def AbbreviatedTree(self, trav=None):
1187 # type: (Optional[TraversalState]) -> hnode_t
1188 return self._AbbreviatedTree(trav=trav)
1189
1190 class RegexMatch(predicate_t):
1191 _type_tag = 6
1192 __slots__ = ('re', 'ignoreCase')
1193
1194 def __init__(self, re, ignoreCase):
1195 # type: (str, bool) -> None
1196 self.re = re
1197 self.ignoreCase = ignoreCase
1198
1199 @staticmethod
1200 def CreateNull(alloc_lists=False):
1201 # type: () -> predicate.RegexMatch
1202 return predicate.RegexMatch('', False)
1203
1204 def PrettyTree(self, trav=None):
1205 # type: (Optional[TraversalState]) -> hnode_t
1206 trav = trav or TraversalState()
1207 heap_id = id(self)
1208 if heap_id in trav.seen:
1209 return hnode.AlreadySeen(heap_id)
1210 trav.seen[heap_id] = True
1211 out_node = NewRecord('predicate.RegexMatch')
1212 L = out_node.fields
1213
1214 x0 = NewLeaf(self.re, color_e.StringConst)
1215 L.append(Field('re', x0))
1216
1217 x1 = hnode.Leaf('T' if self.ignoreCase else 'F', color_e.OtherConst)
1218 L.append(Field('ignoreCase', x1))
1219
1220 return out_node
1221
1222 def _AbbreviatedTree(self, trav=None):
1223 # type: (Optional[TraversalState]) -> hnode_t
1224 trav = trav or TraversalState()
1225 heap_id = id(self)
1226 if heap_id in trav.seen:
1227 return hnode.AlreadySeen(heap_id)
1228 trav.seen[heap_id] = True
1229 out_node = NewRecord('predicate.RegexMatch')
1230 L = out_node.fields
1231 x0 = NewLeaf(self.re, color_e.StringConst)
1232 L.append(Field('re', x0))
1233
1234 x1 = hnode.Leaf('T' if self.ignoreCase else 'F', color_e.OtherConst)
1235 L.append(Field('ignoreCase', x1))
1236
1237 return out_node
1238
1239 def AbbreviatedTree(self, trav=None):
1240 # type: (Optional[TraversalState]) -> hnode_t
1241 return self._AbbreviatedTree(trav=trav)
1242
1243 Readable = predicate__Readable()
1244
1245 Writable = predicate__Writable()
1246
1247 Executable = predicate__Executable()
1248
1249 pass
1250