aridity 85__tar.gz → 86__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aridity-85 → aridity-86}/PKG-INFO +47 -58
- {aridity-85 → aridity-86}/README.md +46 -57
- aridity-86/aridity/directives.py +80 -0
- aridity-86/aridity/functions.py +288 -0
- {aridity-85 → aridity-86}/aridity/model.py +1 -3
- {aridity-85 → aridity-86}/aridity/repl.py +3 -6
- {aridity-85 → aridity-86}/aridity/scope.py +36 -41
- {aridity-85 → aridity-86}/aridity/util.py +1 -15
- {aridity-85 → aridity-86}/aridity.egg-info/PKG-INFO +47 -58
- {aridity-85 → aridity-86}/setup.py +1 -1
- aridity-85/aridity/directives.py +0 -97
- aridity-85/aridity/functions.py +0 -271
- {aridity-85 → aridity-86}/aridity/__init__.py +0 -0
- {aridity-85 → aridity-86}/aridity/arid_config.py +0 -0
- {aridity-85 → aridity-86}/aridity/config.py +0 -0
- {aridity-85 → aridity-86}/aridity/grammar.py +0 -0
- {aridity-85 → aridity-86}/aridity/keyring.py +0 -0
- {aridity-85 → aridity-86}/aridity/processtemplate.py +0 -0
- {aridity-85 → aridity-86}/aridity/resolve.py +0 -0
- {aridity-85 → aridity-86}/aridity/search.py +0 -0
- {aridity-85 → aridity-86}/aridity/stacks.py +0 -0
- {aridity-85 → aridity-86}/aridity.egg-info/SOURCES.txt +0 -0
- {aridity-85 → aridity-86}/aridity.egg-info/dependency_links.txt +0 -0
- {aridity-85 → aridity-86}/aridity.egg-info/entry_points.txt +0 -0
- {aridity-85 → aridity-86}/aridity.egg-info/requires.txt +0 -0
- {aridity-85 → aridity-86}/aridity.egg-info/top_level.txt +0 -0
- {aridity-85 → aridity-86}/parabject.py +0 -0
- {aridity-85 → aridity-86}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aridity
|
|
3
|
-
Version:
|
|
3
|
+
Version: 86
|
|
4
4
|
Summary: DRY config and template system, easily extensible with Python
|
|
5
5
|
Home-page: https://pypi.org/project/aridity/
|
|
6
6
|
Author: foyono
|
|
@@ -354,57 +354,56 @@ Yield values only. Iterate over `-self` for keys and values.
|
|
|
354
354
|
|
|
355
355
|
### aridity.directives
|
|
356
356
|
|
|
357
|
-
<a id="aridity.directives.
|
|
357
|
+
<a id="aridity.directives.colon"></a>
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
###### colon
|
|
360
360
|
|
|
361
361
|
```python
|
|
362
|
-
|
|
363
|
-
class Colon()
|
|
362
|
+
def colon(prefix, suffix, scope)
|
|
364
363
|
```
|
|
365
364
|
|
|
366
365
|
Ignore rest of logical line.
|
|
367
366
|
|
|
368
|
-
<a id="aridity.directives.
|
|
367
|
+
<a id="aridity.directives.source"></a>
|
|
369
368
|
|
|
370
|
-
|
|
369
|
+
###### source
|
|
371
370
|
|
|
372
371
|
```python
|
|
373
|
-
@
|
|
374
|
-
|
|
372
|
+
@prime
|
|
373
|
+
def source(prefix, suffix, scope)
|
|
375
374
|
```
|
|
376
375
|
|
|
377
376
|
Include path or resource at prefix.
|
|
378
377
|
|
|
379
|
-
<a id="aridity.directives.
|
|
378
|
+
<a id="aridity.directives.equals"></a>
|
|
380
379
|
|
|
381
|
-
|
|
380
|
+
###### equals
|
|
382
381
|
|
|
383
382
|
```python
|
|
384
|
-
@
|
|
385
|
-
|
|
383
|
+
@prime
|
|
384
|
+
def equals(prefix, suffix, scope)
|
|
386
385
|
```
|
|
387
386
|
|
|
388
387
|
Assign expression to path.
|
|
389
388
|
|
|
390
|
-
<a id="aridity.directives.
|
|
389
|
+
<a id="aridity.directives.colonequals"></a>
|
|
391
390
|
|
|
392
|
-
|
|
391
|
+
###### colonequals
|
|
393
392
|
|
|
394
393
|
```python
|
|
395
|
-
@
|
|
396
|
-
|
|
394
|
+
@prime
|
|
395
|
+
def colonequals(prefix, suffix, scope)
|
|
397
396
|
```
|
|
398
397
|
|
|
399
398
|
Evaluate expression and assign result to path.
|
|
400
399
|
|
|
401
|
-
<a id="aridity.directives.
|
|
400
|
+
<a id="aridity.directives.plusequals"></a>
|
|
402
401
|
|
|
403
|
-
|
|
402
|
+
###### plusequals
|
|
404
403
|
|
|
405
404
|
```python
|
|
406
|
-
@
|
|
407
|
-
|
|
405
|
+
@prime
|
|
406
|
+
def plusequals(prefix, suffix, scope)
|
|
408
407
|
```
|
|
409
408
|
|
|
410
409
|
Assign expression to prefix plus an opaque key, i.e. add to list.
|
|
@@ -413,15 +412,7 @@ Assign expression to prefix plus an opaque key, i.e. add to list.
|
|
|
413
412
|
|
|
414
413
|
### aridity.functions
|
|
415
414
|
|
|
416
|
-
<a id="aridity.functions.
|
|
417
|
-
|
|
418
|
-
#### Functions Objects
|
|
419
|
-
|
|
420
|
-
```python
|
|
421
|
-
class Functions()
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
<a id="aridity.functions.Functions.screenstr"></a>
|
|
415
|
+
<a id="aridity.functions.screenstr"></a>
|
|
425
416
|
|
|
426
417
|
###### screenstr
|
|
427
418
|
|
|
@@ -431,7 +422,7 @@ def screenstr(scope, resolvable)
|
|
|
431
422
|
|
|
432
423
|
GNU Screen string literal.
|
|
433
424
|
|
|
434
|
-
<a id="aridity.functions.
|
|
425
|
+
<a id="aridity.functions.scstr"></a>
|
|
435
426
|
|
|
436
427
|
###### scstr
|
|
437
428
|
|
|
@@ -441,7 +432,7 @@ def scstr(scope, resolvable)
|
|
|
441
432
|
|
|
442
433
|
SuperCollider string literal.
|
|
443
434
|
|
|
444
|
-
<a id="aridity.functions.
|
|
435
|
+
<a id="aridity.functions.hclstr"></a>
|
|
445
436
|
|
|
446
437
|
###### hclstr
|
|
447
438
|
|
|
@@ -451,7 +442,7 @@ def hclstr(scope, resolvable)
|
|
|
451
442
|
|
|
452
443
|
HashiCorp configuration language string literal.
|
|
453
444
|
|
|
454
|
-
<a id="aridity.functions.
|
|
445
|
+
<a id="aridity.functions.groovystr"></a>
|
|
455
446
|
|
|
456
447
|
###### groovystr
|
|
457
448
|
|
|
@@ -461,7 +452,7 @@ def groovystr(scope, resolvable)
|
|
|
461
452
|
|
|
462
453
|
Groovy string literal.
|
|
463
454
|
|
|
464
|
-
<a id="aridity.functions.
|
|
455
|
+
<a id="aridity.functions.pystr"></a>
|
|
465
456
|
|
|
466
457
|
###### pystr
|
|
467
458
|
|
|
@@ -471,7 +462,7 @@ def pystr(scope, resolvable)
|
|
|
471
462
|
|
|
472
463
|
Python literal.
|
|
473
464
|
|
|
474
|
-
<a id="aridity.functions.
|
|
465
|
+
<a id="aridity.functions.shstr"></a>
|
|
475
466
|
|
|
476
467
|
###### shstr
|
|
477
468
|
|
|
@@ -481,7 +472,7 @@ def shstr(scope, resolvable)
|
|
|
481
472
|
|
|
482
473
|
Shell string literal.
|
|
483
474
|
|
|
484
|
-
<a id="aridity.functions.
|
|
475
|
+
<a id="aridity.functions.jsonquote"></a>
|
|
485
476
|
|
|
486
477
|
###### jsonquote
|
|
487
478
|
|
|
@@ -491,7 +482,7 @@ def jsonquote(scope, resolvable)
|
|
|
491
482
|
|
|
492
483
|
JSON literal, also suitable for YAML.
|
|
493
484
|
|
|
494
|
-
<a id="aridity.functions.
|
|
485
|
+
<a id="aridity.functions.xmlattr"></a>
|
|
495
486
|
|
|
496
487
|
###### xmlattr
|
|
497
488
|
|
|
@@ -501,7 +492,7 @@ def xmlattr(scope, resolvable)
|
|
|
501
492
|
|
|
502
493
|
XML attribute literal (including quotes).
|
|
503
494
|
|
|
504
|
-
<a id="aridity.functions.
|
|
495
|
+
<a id="aridity.functions.xmltext"></a>
|
|
505
496
|
|
|
506
497
|
###### xmltext
|
|
507
498
|
|
|
@@ -511,7 +502,7 @@ def xmltext(scope, resolvable)
|
|
|
511
502
|
|
|
512
503
|
XML content, suggest assigning this to & with xmlattr assigned to " as is convention.
|
|
513
504
|
|
|
514
|
-
<a id="aridity.functions.
|
|
505
|
+
<a id="aridity.functions.tomlquote"></a>
|
|
515
506
|
|
|
516
507
|
###### tomlquote
|
|
517
508
|
|
|
@@ -521,7 +512,7 @@ def tomlquote(scope, resolvable)
|
|
|
521
512
|
|
|
522
513
|
TOML string literal.
|
|
523
514
|
|
|
524
|
-
<a id="aridity.functions.
|
|
515
|
+
<a id="aridity.functions.urlquote"></a>
|
|
525
516
|
|
|
526
517
|
###### urlquote
|
|
527
518
|
|
|
@@ -531,19 +522,19 @@ def urlquote(scope, resolvable)
|
|
|
531
522
|
|
|
532
523
|
Percent-encode all reserved characters.
|
|
533
524
|
|
|
534
|
-
<a id="aridity.functions.
|
|
525
|
+
<a id="aridity.functions.map_"></a>
|
|
535
526
|
|
|
536
|
-
###### map
|
|
527
|
+
###### map\_
|
|
537
528
|
|
|
538
529
|
```python
|
|
539
|
-
def
|
|
530
|
+
def map_(scope, objsresolvable, *args)
|
|
540
531
|
```
|
|
541
532
|
|
|
542
533
|
If given 1 arg, evaluate it against every scope in `objsresolvable` and return that list.
|
|
543
534
|
If given 2 args, the first is a variable name to which each scope is temporarily assigned.
|
|
544
535
|
If given 3 args, the first two are variable names for scope key and scope respectively.
|
|
545
536
|
|
|
546
|
-
<a id="aridity.functions.
|
|
537
|
+
<a id="aridity.functions.join"></a>
|
|
547
538
|
|
|
548
539
|
###### join
|
|
549
540
|
|
|
@@ -553,49 +544,47 @@ def join(scope, partsresolvable, sepresolvable=None)
|
|
|
553
544
|
|
|
554
545
|
Concatenate the given list, using optional separator. Frequently used with `map`.
|
|
555
546
|
|
|
556
|
-
<a id="aridity.functions.
|
|
547
|
+
<a id="aridity.functions.str_"></a>
|
|
557
548
|
|
|
558
|
-
###### str
|
|
549
|
+
###### str\_
|
|
559
550
|
|
|
560
551
|
```python
|
|
561
|
-
def
|
|
552
|
+
def str_(scope, resolvable)
|
|
562
553
|
```
|
|
563
554
|
|
|
564
555
|
Coerce to string.
|
|
565
556
|
|
|
566
|
-
<a id="aridity.functions.
|
|
557
|
+
<a id="aridity.functions.list_"></a>
|
|
567
558
|
|
|
568
|
-
###### list
|
|
559
|
+
###### list\_
|
|
569
560
|
|
|
570
561
|
```python
|
|
571
|
-
def
|
|
562
|
+
def list_(scope, *resolvables)
|
|
572
563
|
```
|
|
573
564
|
|
|
574
565
|
Create a list.
|
|
575
566
|
|
|
576
|
-
<a id="aridity.functions.
|
|
567
|
+
<a id="aridity.functions.try_"></a>
|
|
577
568
|
|
|
578
569
|
###### try\_
|
|
579
570
|
|
|
580
571
|
```python
|
|
581
|
-
@realname('try')
|
|
582
572
|
def try_(scope, *resolvables)
|
|
583
573
|
```
|
|
584
574
|
|
|
585
575
|
Attempt to evaluate each resolvable, returning the first that succeeds.
|
|
586
576
|
|
|
587
|
-
<a id="aridity.functions.
|
|
577
|
+
<a id="aridity.functions.hereslash"></a>
|
|
588
578
|
|
|
589
579
|
###### hereslash
|
|
590
580
|
|
|
591
581
|
```python
|
|
592
|
-
@realname('./')
|
|
593
582
|
def hereslash(scope, *resolvables)
|
|
594
583
|
```
|
|
595
584
|
|
|
596
585
|
Join the given path components with the directory of the current resource.
|
|
597
586
|
|
|
598
|
-
<a id="aridity.functions.
|
|
587
|
+
<a id="aridity.functions.readfile"></a>
|
|
599
588
|
|
|
600
589
|
###### readfile
|
|
601
590
|
|
|
@@ -605,7 +594,7 @@ def readfile(scope, resolvable)
|
|
|
605
594
|
|
|
606
595
|
Include the content of the given path.
|
|
607
596
|
|
|
608
|
-
<a id="aridity.functions.
|
|
597
|
+
<a id="aridity.functions.processtemplate"></a>
|
|
609
598
|
|
|
610
599
|
###### processtemplate
|
|
611
600
|
|
|
@@ -615,7 +604,7 @@ def processtemplate(scope, resolvable)
|
|
|
615
604
|
|
|
616
605
|
Evaluate the content of the given path as an expression.
|
|
617
606
|
|
|
618
|
-
<a id="aridity.functions.
|
|
607
|
+
<a id="aridity.functions.pyref"></a>
|
|
619
608
|
|
|
620
609
|
###### pyref
|
|
621
610
|
|
|
@@ -625,7 +614,7 @@ def pyref(scope, moduleresolvable, qualnameresolvable)
|
|
|
625
614
|
|
|
626
615
|
Python object in given module with given qualified name. Module may be relative to current resource, in which case assignment with `:=` is normally necessary. Typically used to import functions.
|
|
627
616
|
|
|
628
|
-
<a id="aridity.functions.
|
|
617
|
+
<a id="aridity.functions.pyres"></a>
|
|
629
618
|
|
|
630
619
|
###### pyres
|
|
631
620
|
|
|
@@ -344,57 +344,56 @@ Yield values only. Iterate over `-self` for keys and values.
|
|
|
344
344
|
|
|
345
345
|
### aridity.directives
|
|
346
346
|
|
|
347
|
-
<a id="aridity.directives.
|
|
347
|
+
<a id="aridity.directives.colon"></a>
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
###### colon
|
|
350
350
|
|
|
351
351
|
```python
|
|
352
|
-
|
|
353
|
-
class Colon()
|
|
352
|
+
def colon(prefix, suffix, scope)
|
|
354
353
|
```
|
|
355
354
|
|
|
356
355
|
Ignore rest of logical line.
|
|
357
356
|
|
|
358
|
-
<a id="aridity.directives.
|
|
357
|
+
<a id="aridity.directives.source"></a>
|
|
359
358
|
|
|
360
|
-
|
|
359
|
+
###### source
|
|
361
360
|
|
|
362
361
|
```python
|
|
363
|
-
@
|
|
364
|
-
|
|
362
|
+
@prime
|
|
363
|
+
def source(prefix, suffix, scope)
|
|
365
364
|
```
|
|
366
365
|
|
|
367
366
|
Include path or resource at prefix.
|
|
368
367
|
|
|
369
|
-
<a id="aridity.directives.
|
|
368
|
+
<a id="aridity.directives.equals"></a>
|
|
370
369
|
|
|
371
|
-
|
|
370
|
+
###### equals
|
|
372
371
|
|
|
373
372
|
```python
|
|
374
|
-
@
|
|
375
|
-
|
|
373
|
+
@prime
|
|
374
|
+
def equals(prefix, suffix, scope)
|
|
376
375
|
```
|
|
377
376
|
|
|
378
377
|
Assign expression to path.
|
|
379
378
|
|
|
380
|
-
<a id="aridity.directives.
|
|
379
|
+
<a id="aridity.directives.colonequals"></a>
|
|
381
380
|
|
|
382
|
-
|
|
381
|
+
###### colonequals
|
|
383
382
|
|
|
384
383
|
```python
|
|
385
|
-
@
|
|
386
|
-
|
|
384
|
+
@prime
|
|
385
|
+
def colonequals(prefix, suffix, scope)
|
|
387
386
|
```
|
|
388
387
|
|
|
389
388
|
Evaluate expression and assign result to path.
|
|
390
389
|
|
|
391
|
-
<a id="aridity.directives.
|
|
390
|
+
<a id="aridity.directives.plusequals"></a>
|
|
392
391
|
|
|
393
|
-
|
|
392
|
+
###### plusequals
|
|
394
393
|
|
|
395
394
|
```python
|
|
396
|
-
@
|
|
397
|
-
|
|
395
|
+
@prime
|
|
396
|
+
def plusequals(prefix, suffix, scope)
|
|
398
397
|
```
|
|
399
398
|
|
|
400
399
|
Assign expression to prefix plus an opaque key, i.e. add to list.
|
|
@@ -403,15 +402,7 @@ Assign expression to prefix plus an opaque key, i.e. add to list.
|
|
|
403
402
|
|
|
404
403
|
### aridity.functions
|
|
405
404
|
|
|
406
|
-
<a id="aridity.functions.
|
|
407
|
-
|
|
408
|
-
#### Functions Objects
|
|
409
|
-
|
|
410
|
-
```python
|
|
411
|
-
class Functions()
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
<a id="aridity.functions.Functions.screenstr"></a>
|
|
405
|
+
<a id="aridity.functions.screenstr"></a>
|
|
415
406
|
|
|
416
407
|
###### screenstr
|
|
417
408
|
|
|
@@ -421,7 +412,7 @@ def screenstr(scope, resolvable)
|
|
|
421
412
|
|
|
422
413
|
GNU Screen string literal.
|
|
423
414
|
|
|
424
|
-
<a id="aridity.functions.
|
|
415
|
+
<a id="aridity.functions.scstr"></a>
|
|
425
416
|
|
|
426
417
|
###### scstr
|
|
427
418
|
|
|
@@ -431,7 +422,7 @@ def scstr(scope, resolvable)
|
|
|
431
422
|
|
|
432
423
|
SuperCollider string literal.
|
|
433
424
|
|
|
434
|
-
<a id="aridity.functions.
|
|
425
|
+
<a id="aridity.functions.hclstr"></a>
|
|
435
426
|
|
|
436
427
|
###### hclstr
|
|
437
428
|
|
|
@@ -441,7 +432,7 @@ def hclstr(scope, resolvable)
|
|
|
441
432
|
|
|
442
433
|
HashiCorp configuration language string literal.
|
|
443
434
|
|
|
444
|
-
<a id="aridity.functions.
|
|
435
|
+
<a id="aridity.functions.groovystr"></a>
|
|
445
436
|
|
|
446
437
|
###### groovystr
|
|
447
438
|
|
|
@@ -451,7 +442,7 @@ def groovystr(scope, resolvable)
|
|
|
451
442
|
|
|
452
443
|
Groovy string literal.
|
|
453
444
|
|
|
454
|
-
<a id="aridity.functions.
|
|
445
|
+
<a id="aridity.functions.pystr"></a>
|
|
455
446
|
|
|
456
447
|
###### pystr
|
|
457
448
|
|
|
@@ -461,7 +452,7 @@ def pystr(scope, resolvable)
|
|
|
461
452
|
|
|
462
453
|
Python literal.
|
|
463
454
|
|
|
464
|
-
<a id="aridity.functions.
|
|
455
|
+
<a id="aridity.functions.shstr"></a>
|
|
465
456
|
|
|
466
457
|
###### shstr
|
|
467
458
|
|
|
@@ -471,7 +462,7 @@ def shstr(scope, resolvable)
|
|
|
471
462
|
|
|
472
463
|
Shell string literal.
|
|
473
464
|
|
|
474
|
-
<a id="aridity.functions.
|
|
465
|
+
<a id="aridity.functions.jsonquote"></a>
|
|
475
466
|
|
|
476
467
|
###### jsonquote
|
|
477
468
|
|
|
@@ -481,7 +472,7 @@ def jsonquote(scope, resolvable)
|
|
|
481
472
|
|
|
482
473
|
JSON literal, also suitable for YAML.
|
|
483
474
|
|
|
484
|
-
<a id="aridity.functions.
|
|
475
|
+
<a id="aridity.functions.xmlattr"></a>
|
|
485
476
|
|
|
486
477
|
###### xmlattr
|
|
487
478
|
|
|
@@ -491,7 +482,7 @@ def xmlattr(scope, resolvable)
|
|
|
491
482
|
|
|
492
483
|
XML attribute literal (including quotes).
|
|
493
484
|
|
|
494
|
-
<a id="aridity.functions.
|
|
485
|
+
<a id="aridity.functions.xmltext"></a>
|
|
495
486
|
|
|
496
487
|
###### xmltext
|
|
497
488
|
|
|
@@ -501,7 +492,7 @@ def xmltext(scope, resolvable)
|
|
|
501
492
|
|
|
502
493
|
XML content, suggest assigning this to & with xmlattr assigned to " as is convention.
|
|
503
494
|
|
|
504
|
-
<a id="aridity.functions.
|
|
495
|
+
<a id="aridity.functions.tomlquote"></a>
|
|
505
496
|
|
|
506
497
|
###### tomlquote
|
|
507
498
|
|
|
@@ -511,7 +502,7 @@ def tomlquote(scope, resolvable)
|
|
|
511
502
|
|
|
512
503
|
TOML string literal.
|
|
513
504
|
|
|
514
|
-
<a id="aridity.functions.
|
|
505
|
+
<a id="aridity.functions.urlquote"></a>
|
|
515
506
|
|
|
516
507
|
###### urlquote
|
|
517
508
|
|
|
@@ -521,19 +512,19 @@ def urlquote(scope, resolvable)
|
|
|
521
512
|
|
|
522
513
|
Percent-encode all reserved characters.
|
|
523
514
|
|
|
524
|
-
<a id="aridity.functions.
|
|
515
|
+
<a id="aridity.functions.map_"></a>
|
|
525
516
|
|
|
526
|
-
###### map
|
|
517
|
+
###### map\_
|
|
527
518
|
|
|
528
519
|
```python
|
|
529
|
-
def
|
|
520
|
+
def map_(scope, objsresolvable, *args)
|
|
530
521
|
```
|
|
531
522
|
|
|
532
523
|
If given 1 arg, evaluate it against every scope in `objsresolvable` and return that list.
|
|
533
524
|
If given 2 args, the first is a variable name to which each scope is temporarily assigned.
|
|
534
525
|
If given 3 args, the first two are variable names for scope key and scope respectively.
|
|
535
526
|
|
|
536
|
-
<a id="aridity.functions.
|
|
527
|
+
<a id="aridity.functions.join"></a>
|
|
537
528
|
|
|
538
529
|
###### join
|
|
539
530
|
|
|
@@ -543,49 +534,47 @@ def join(scope, partsresolvable, sepresolvable=None)
|
|
|
543
534
|
|
|
544
535
|
Concatenate the given list, using optional separator. Frequently used with `map`.
|
|
545
536
|
|
|
546
|
-
<a id="aridity.functions.
|
|
537
|
+
<a id="aridity.functions.str_"></a>
|
|
547
538
|
|
|
548
|
-
###### str
|
|
539
|
+
###### str\_
|
|
549
540
|
|
|
550
541
|
```python
|
|
551
|
-
def
|
|
542
|
+
def str_(scope, resolvable)
|
|
552
543
|
```
|
|
553
544
|
|
|
554
545
|
Coerce to string.
|
|
555
546
|
|
|
556
|
-
<a id="aridity.functions.
|
|
547
|
+
<a id="aridity.functions.list_"></a>
|
|
557
548
|
|
|
558
|
-
###### list
|
|
549
|
+
###### list\_
|
|
559
550
|
|
|
560
551
|
```python
|
|
561
|
-
def
|
|
552
|
+
def list_(scope, *resolvables)
|
|
562
553
|
```
|
|
563
554
|
|
|
564
555
|
Create a list.
|
|
565
556
|
|
|
566
|
-
<a id="aridity.functions.
|
|
557
|
+
<a id="aridity.functions.try_"></a>
|
|
567
558
|
|
|
568
559
|
###### try\_
|
|
569
560
|
|
|
570
561
|
```python
|
|
571
|
-
@realname('try')
|
|
572
562
|
def try_(scope, *resolvables)
|
|
573
563
|
```
|
|
574
564
|
|
|
575
565
|
Attempt to evaluate each resolvable, returning the first that succeeds.
|
|
576
566
|
|
|
577
|
-
<a id="aridity.functions.
|
|
567
|
+
<a id="aridity.functions.hereslash"></a>
|
|
578
568
|
|
|
579
569
|
###### hereslash
|
|
580
570
|
|
|
581
571
|
```python
|
|
582
|
-
@realname('./')
|
|
583
572
|
def hereslash(scope, *resolvables)
|
|
584
573
|
```
|
|
585
574
|
|
|
586
575
|
Join the given path components with the directory of the current resource.
|
|
587
576
|
|
|
588
|
-
<a id="aridity.functions.
|
|
577
|
+
<a id="aridity.functions.readfile"></a>
|
|
589
578
|
|
|
590
579
|
###### readfile
|
|
591
580
|
|
|
@@ -595,7 +584,7 @@ def readfile(scope, resolvable)
|
|
|
595
584
|
|
|
596
585
|
Include the content of the given path.
|
|
597
586
|
|
|
598
|
-
<a id="aridity.functions.
|
|
587
|
+
<a id="aridity.functions.processtemplate"></a>
|
|
599
588
|
|
|
600
589
|
###### processtemplate
|
|
601
590
|
|
|
@@ -605,7 +594,7 @@ def processtemplate(scope, resolvable)
|
|
|
605
594
|
|
|
606
595
|
Evaluate the content of the given path as an expression.
|
|
607
596
|
|
|
608
|
-
<a id="aridity.functions.
|
|
597
|
+
<a id="aridity.functions.pyref"></a>
|
|
609
598
|
|
|
610
599
|
###### pyref
|
|
611
600
|
|
|
@@ -615,7 +604,7 @@ def pyref(scope, moduleresolvable, qualnameresolvable)
|
|
|
615
604
|
|
|
616
605
|
Python object in given module with given qualified name. Module may be relative to current resource, in which case assignment with `:=` is normally necessary. Typically used to import functions.
|
|
617
606
|
|
|
618
|
-
<a id="aridity.functions.
|
|
607
|
+
<a id="aridity.functions.pyres"></a>
|
|
619
608
|
|
|
620
609
|
###### pyres
|
|
621
610
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from .model import Stream
|
|
2
|
+
from .search import resolvedscopeornone
|
|
3
|
+
import os, sys, unicodedata
|
|
4
|
+
|
|
5
|
+
def acceptdirectivename(word):
|
|
6
|
+
return word and unicodedata.category(word[0])[0] in 'PS'
|
|
7
|
+
|
|
8
|
+
def prime(d):
|
|
9
|
+
def pd(prefix, suffix, scope):
|
|
10
|
+
if not prefix.directives:
|
|
11
|
+
return d(prefix, suffix, scope)
|
|
12
|
+
return pd
|
|
13
|
+
|
|
14
|
+
def colon(prefix, suffix, scope):
|
|
15
|
+
'Ignore rest of logical line.'
|
|
16
|
+
return prefix
|
|
17
|
+
|
|
18
|
+
@prime
|
|
19
|
+
def _redirect(prefix, suffix, scope):
|
|
20
|
+
scope['stdout',] = Stream(suffix.tophrase().resolve(scope).openable(scope).open(True))
|
|
21
|
+
|
|
22
|
+
@prime
|
|
23
|
+
def _write(prefix, suffix, scope):
|
|
24
|
+
scope.resolved('stdout').flush(suffix.tophrase().resolve(scope).textvalue)
|
|
25
|
+
|
|
26
|
+
@prime
|
|
27
|
+
def source(prefix, suffix, scope):
|
|
28
|
+
'Include path or resource at prefix.'
|
|
29
|
+
# XXX: Use full algo to get phrasescope?
|
|
30
|
+
phrasescope = scope
|
|
31
|
+
for word in prefix.topath(scope):
|
|
32
|
+
s = resolvedscopeornone(phrasescope, [word])
|
|
33
|
+
if s is None:
|
|
34
|
+
break
|
|
35
|
+
phrasescope = s
|
|
36
|
+
suffix.tophrase().resolve(phrasescope).openable(phrasescope).source(scope, prefix)
|
|
37
|
+
|
|
38
|
+
@prime
|
|
39
|
+
def _cd(prefix, suffix, scope):
|
|
40
|
+
scope['cwd',] = suffix.tophrase().resolve(scope).openable(scope)
|
|
41
|
+
|
|
42
|
+
@prime
|
|
43
|
+
def _test(prefix, suffix, scope):
|
|
44
|
+
sys.stderr.write(str(suffix.tophrase().resolve(scope)))
|
|
45
|
+
sys.stderr.write(os.linesep)
|
|
46
|
+
|
|
47
|
+
@prime
|
|
48
|
+
def equals(prefix, suffix, scope):
|
|
49
|
+
'Assign expression to path.'
|
|
50
|
+
scope[prefix.topath(scope)] = suffix.tophrase()
|
|
51
|
+
|
|
52
|
+
@prime
|
|
53
|
+
def colonequals(prefix, suffix, scope):
|
|
54
|
+
'Evaluate expression and assign result to path.'
|
|
55
|
+
path = prefix.topath(scope)
|
|
56
|
+
scope[path] = suffix.tophrase().resolve(scope.getorcreatesubscope(path[:-1]))
|
|
57
|
+
|
|
58
|
+
@prime
|
|
59
|
+
def plusequals(prefix, suffix, scope):
|
|
60
|
+
'Assign expression to prefix plus an opaque key, i.e. add to list.'
|
|
61
|
+
from .functions import OpaqueKey
|
|
62
|
+
phrase = suffix.tophrase()
|
|
63
|
+
scope[prefix.topath(scope) + (OpaqueKey(),)] = phrase
|
|
64
|
+
|
|
65
|
+
@prime
|
|
66
|
+
def _cat(prefix, suffix, scope):
|
|
67
|
+
scope = scope.getorcreatesubscope(prefix.topath(scope))
|
|
68
|
+
scope.resolved('stdout').flush(suffix.tophrase().resolve(scope).openable(scope).processtemplate(scope).textvalue)
|
|
69
|
+
|
|
70
|
+
def coredirectives():
|
|
71
|
+
yield ':', colon
|
|
72
|
+
yield '!redirect', _redirect
|
|
73
|
+
yield '!write', _write
|
|
74
|
+
yield '.', source
|
|
75
|
+
yield '!cd', _cd
|
|
76
|
+
yield '!test', _test
|
|
77
|
+
yield '=', equals
|
|
78
|
+
yield ':=', colonequals
|
|
79
|
+
yield '+=', plusequals
|
|
80
|
+
yield '<', _cat
|