-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_console.html
2106 lines (1759 loc) · 156 KB
/
admin_console.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package admin_console</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>admin_console</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/lib/python3.10/site-packages/admin_console/__init__.py">/usr/lib/python3.10/site-packages/admin_console/__init__.py</a></font></td></tr></table>
<p><tt>Embeddable asynchronous console command prompt with extension support<br>
Example:<br>
<br>
import asyncio<br>
from admin_console import <a href="#AdminCommandExecutor">AdminCommandExecutor</a>, basic_command_set<br>
<br>
async def <a href="#-main">main</a>():<br>
ace = <a href="#AdminCommandExecutor">AdminCommandExecutor</a>()<br>
<a href="#-basic_command_set">basic_command_set</a>(ace)<br>
await ace.load_extensions()<br>
print("Terminal. Type help to see the list of commands")<br>
await ace.prompt_loop()<br>
print("Exit from command prompt")<br>
<br>
<br>
if __name__ == "__main__":<br>
asyncio.run(<a href="#-main">main</a>())</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="admin_console.ainput.html">ainput</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#Exception">builtins.Exception</a>(<a href="builtins.html#BaseException">builtins.BaseException</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#NotEnoughArguments">NotEnoughArguments</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#ValueError">builtins.ValueError</a>(<a href="builtins.html#Exception">builtins.Exception</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#InvalidArgument">InvalidArgument</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#float">builtins.float</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#BaseContinuousScale">BaseContinuousScale</a>(<a href="builtins.html#float">builtins.float</a>, <a href="admin_console.html#CustomType">CustomType</a>)
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#int">builtins.int</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#BaseDiscreteScale">BaseDiscreteScale</a>(<a href="builtins.html#int">builtins.int</a>, <a href="admin_console.html#CustomType">CustomType</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#FixedEnumType">FixedEnumType</a>
</font></dt></dl>
</dd>
</dl>
</dd>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#AdminCommand">AdminCommand</a>
</font></dt><dt><font face="helvetica, arial"><a href="admin_console.html#AdminCommandExecutor">AdminCommandExecutor</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#AdminCommandEWrapper">AdminCommandEWrapper</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="admin_console.html#AdminCommandExtension">AdminCommandExtension</a>
</font></dt><dt><font face="helvetica, arial"><a href="admin_console.html#CustomType">CustomType</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#BaseContinuousScale">BaseContinuousScale</a>(<a href="builtins.html#float">builtins.float</a>, <a href="admin_console.html#CustomType">CustomType</a>)
</font></dt><dt><font face="helvetica, arial"><a href="admin_console.html#BaseDiscreteScale">BaseDiscreteScale</a>(<a href="builtins.html#int">builtins.int</a>, <a href="admin_console.html#CustomType">CustomType</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="admin_console.html#FixedEnumType">FixedEnumType</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="admin_console.html#DateTimeType">DateTimeType</a>
</font></dt><dt><font face="helvetica, arial"><a href="admin_console.html#DateType">DateType</a>
</font></dt><dt><font face="helvetica, arial"><a href="admin_console.html#DurationType">DurationType</a>
</font></dt><dt><font face="helvetica, arial"><a href="admin_console.html#TimeType">TimeType</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="admin_console.html#FakeAsyncRawInput">FakeAsyncRawInput</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AdminCommand">class <strong>AdminCommand</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#AdminCommand">AdminCommand</a>(afunc, name: str, args: Sequence[Tuple[Union[str, <a href="builtins.html#int">int</a>, <a href="builtins.html#float">float</a>, bool, NoneType, admin_console.<a href="#CustomType">CustomType</a>], str]], optargs: Sequence[Tuple[Union[str, <a href="builtins.html#int">int</a>, <a href="builtins.html#float">float</a>, bool, NoneType, admin_console.<a href="#CustomType">CustomType</a>], str]], description: str = '', atabcomplete: Optional[Callable[[str], Coroutine[Any, Any, Any]]] = None)<br>
<br>
Represents a console command.<br>
To add a command of an extension, use <a href="#AdminCommandExtension">AdminCommandExtension</a>.add_command(<br>
afunc, name, args, optargs, description) instead<br>
Emits <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.cmdexec_event, <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.cmdtab_event<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AdminCommand-__init__"><strong>__init__</strong></a>(self, afunc, name: str, args: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]], optargs: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]], description: str = '', atabcomplete: Optional[Callable[[str], Coroutine[Any, Any, Any]]] = None)</dt><dd><tt>Parameters<br>
----------<br>
afunc : coroutine function<br>
await afunc(<a href="#AdminCommandExecutor">AdminCommandExecutor</a>, *args)<br>
Coroutine function that represents the command functor and receives parsed arguments<br>
name : str<br>
Name of the command<br>
args : list<br>
[(type : type, name : str), ...]<br>
List of the mandatory arguments of the command<br>
<br>
Possible types are: str, <a href="builtins.html#int">int</a>, <a href="builtins.html#float">float</a>, bool, None<br>
-------------------<br>
str: a word or a "string"<br>
<a href="builtins.html#int">int</a>: valid number, 123<br>
<a href="builtins.html#float">float</a>: a number with floating point, 123.456<br>
bool: switch argument, can be yes / no, true / false, y / n<br>
None: raw string, such an argument could be only the last argument of the command<br>
Cannot be used with at least 1 argument from optargs<br>
-------------------<br>
optargs : list<br>
[(type : class, name : str), ...]<br>
List of the optional arguments of the command<br>
Types are described in args<br>
description : str<br>
Description of what this command does. Shows in help<br>
atabcomplete : coroutine function<br>
await atabcomplete(<a href="#AdminCommandExecutor">AdminCommandExecutor</a>, *args)<br>
Coroutine function that is called when a tab with the last incomplete or empty argument is specified<br>
Must return None or a collection of suggested arguments</tt></dd></dl>
<dl><dt>async <a name="AdminCommand-execute"><strong>execute</strong></a>(self, executor, args: Sequence[object])</dt><dd><tt>Shouldn't be overriden, use afunc to assign a functor to the command</tt></dd></dl>
<dl><dt>async <a name="AdminCommand-tab_complete"><strong>tab_complete</strong></a>(self, executor, args: Sequence[object], argl: str = '') -> Optional[MutableSequence[str]]</dt><dd><tt>Shouldn't be overriden, use atabcomplete to assign a tab complete handler</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AdminCommandEWrapper">class <strong>AdminCommandEWrapper</strong></a>(<a href="admin_console.html#AdminCommandExecutor">AdminCommandExecutor</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#AdminCommandEWrapper">AdminCommandEWrapper</a>(*args, ace: admin_console.<a href="#AdminCommandExecutor">AdminCommandExecutor</a>, **kwargs)<br>
<br>
<a href="#AdminCommandExecutor">AdminCommandExecutor</a> wrapper. It overlays all the functions from the <a href="#AdminCommandExecutor">AdminCommandExecutor</a>, but anything could be replaced to change command behavior, like redirecting its output or providing a different way of IO.<br>
It operates with an existing <a href="#AdminCommandExecutor">AdminCommandExecutor</a>, if a special keyword argument is specified.<br>
Usually it is passed into the command callback instead of the <a href="#AdminCommandExecutor">AdminCommandExecutor</a>, like when a command output needs to be handled differently.<br>
Useful for a remote console server, or GUI, where command output is sent to a remote client or is shown in a GUI.<br>
A proper way to use it is to change its members, for example assigning a different AsyncRawInput or logger implementation.<br>
WARNING: this is NOT a sandbox solution for the extensions! This class is used to execute commands in a different way<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="admin_console.html#AdminCommandEWrapper">AdminCommandEWrapper</a></dd>
<dd><a href="admin_console.html#AdminCommandExecutor">AdminCommandExecutor</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="AdminCommandEWrapper-__getattribute__"><strong>__getattribute__</strong></a>(self, name: str, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-__init__"><strong>__init__</strong></a>(self, *args, ace: admin_console.AdminCommandExecutor, **kwargs)</dt><dd><tt>Parameters<br>
----------<br>
stuff : dict<br>
Arbitrary data storage<br>
use_config : bool<br>
Whether or not a config.json file should be created or loaded in a working directory. Defaults to True<br>
logger : logging.Logger<br>
logging.Logger instance to handle all the log messages<br>
extension_path : str<br>
Relative or absolute path to the extensions directory. Defaults to "extensions/"</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-__setattr__"><strong>__setattr__</strong></a>(self, name: str, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-override"><strong>override</strong></a>(self, name: str, value)</dt><dd><tt>Change the member of the class, but apply it only for the wrapper, not the real command executor<br>
For example, replace ainput with something else if the command needs to query input and show messages<br>
in a different way, rather than doing this in the main console</tt></dd></dl>
<hr>
Methods inherited from <a href="admin_console.html#AdminCommandExecutor">AdminCommandExecutor</a>:<br>
<dl><dt><a name="AdminCommandEWrapper-add_command"><strong>add_command</strong></a>(self, afunc: Callable[[Any], Coroutine[Any, Any, Any]], name: str, args: Sequence[Tuple[Type, str]] = (), optargs: Sequence[Tuple[Type, str]] = (), description: str = '', atabcomplete: Optional[Callable[[Any], Coroutine[Any, Any, Any]]] = None) -> bool</dt><dd><tt>Constructs an <a href="#AdminCommand">AdminCommand</a> instance with all the arguments passed.<br>
Adds the command to the first layer of the chainmap<br>
Emits cmdadd_event asynchronously.<br>
<br>
Note<br>
----<br>
This function will be transformed into an async function in the future versions<br>
<br>
Parameters<br>
----------<br>
see <a href="#AdminCommand">AdminCommand</a><br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-cmd_interruptor"><strong>cmd_interruptor</strong></a>(self)</dt><dd><tt>Listens for Ctrl + C event during command execution.<br>
Cancels the command execution task if Ctrl + C pressed.</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-dispatch"><strong>dispatch</strong></a>(self, cmdline: str) -> bool</dt><dd><tt>Executes a command. Shouldn't be used explicitly with input(). Use <a href="#AdminCommandEWrapper-prompt_loop">prompt_loop</a>() instead.<br>
<br>
Parameters<br>
----------<br>
cmdline : str<br>
A whole line representing a command<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-error"><strong>error</strong></a>(self, msg: str, log=True)</dt><dd><tt>Shows a red error message in the console and logs.<br>
ERROR: msg<br>
<br>
Parameters<br>
----------<br>
msg : str<br>
Message</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-full_cleanup"><strong>full_cleanup</strong></a>(self)</dt><dd><tt>Perform cleanup steps in <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.full_cleanup_steps</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-info"><strong>info</strong></a>(self, msg: str)</dt><dd><tt>Shows a regular info message in the console and logs.<br>
<br>
Parameters<br>
----------<br>
msg : str<br>
Message</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-interrupt_command"><strong>interrupt_command</strong></a>(self)</dt><dd><tt>Cancels the command execution task.<br>
Ctrl + C is replaced during any command being executed.</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-load_config"><strong>load_config</strong></a>(self, path: str = 'config.json') -> bool</dt><dd><tt>Loads a configuration from a JSON file<br>
<br>
Parameters<br>
----------<br>
path : str<br>
Absolute or relative path to the config file. Defaults to "config.json"<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-load_extension"><strong>load_extension</strong></a>(self, name: str) -> bool</dt><dd><tt>Loads a Python script as an extension from its extension path and call await extension_init(<a href="#AdminCommandExtension">AdminCommandExtension</a>)<br>
Emits extload_event.<br>
<br>
Parameters<br>
----------<br>
name : str<br>
The extensionless name of a file containing a Python script<br>
<br>
Returns<br>
-------<br>
bool<br>
Success<br>
<br>
Note<br>
----<br>
Due to the Python's importlib limitation, extensions cannot "import" other extensions properly<br>
and that way can't be implemented in any non-destructible way. Temporary modifying sys.modules<br>
may cause interference between multiple ACE instances (possible name collisions in<br>
sys.modules) and race conditions in multithreaded application.<br>
The only way one extension can make use of another is through <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.extensions['name'].*<br>
Extension objects must not be stored anywhere except by the <a href="#AdminCommandExecutor">AdminCommandExecutor</a> owning it.<br>
Otherwise the garbage collection won't work and the extension wouldn't unload properly.<br>
Also, the Python module cannot be unloaded from the memory, in that particular case, the modules<br>
are cached, and if the same extension loads again, its module is taken from the known_modules and<br>
reloaded.</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-load_extensions"><strong>load_extensions</strong></a>(self)</dt><dd><tt>Loads extensions from an extension directory specified in <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.extpath</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-log"><strong>log</strong></a>(self, msg: str, level=10)</dt><dd><tt>Shows a log message in the console and logs<br>
<br>
Parameters<br>
----------<br>
msg : str<br>
Message<br>
level : <a href="builtins.html#int">int</a><br>
Level of the log message between 0 and 50</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-parse_args"><strong>parse_args</strong></a>(self, argl: str, argtypes: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]] = None, opt_argtypes: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]] = None, *, raise_exc=True, saved_matches: Optional[MutableSequence[re.Match]] = None, until: Optional[int] = None) -> (<class 'list'>, <class 'str'>)</dt><dd><tt>Smart split the argument line and convert all the arguments to its types<br>
Raises <a href="#InvalidArgument">InvalidArgument</a>(argname) if one of the arguments couldn't be converted<br>
Raises <a href="#NotEnoughArguments">NotEnoughArguments</a>(len(args)) if there isn't enough arguments provided<br>
<br>
Parameters<br>
----------<br>
argl : str<br>
Argument line with raw space-separated arguments<br>
argtypes : list<br>
Any collection containing a tuples (type, name) representing an argument name and type<br>
The arguments that are listed in there are mandatory.<br>
opt_argtypes : list<br>
Same as argtypes, but those arguments are parsed after mandatory and are optional.<br>
Doesn't cause <a href="#NotEnoughArguments">NotEnoughArguments</a> to be raise if there is not enough optional arguments<br>
<br>
Keyword-only parameters:<br>
raise_exc : bool<br>
Whether or not exceptions are raised. If False, data is returned as it is<br>
saved_matches : list<br>
If specified, the parser will append the re.Match objects for each argument<br>
to this list except the last NoneType argument (if present in args),<br>
which does not have any boundaries<br>
until : <a href="builtins.html#int">int</a><br>
If specified, will stop parsing arguments when passed more than n symbols.<br>
Useful when passing sliced string isn't good due to storing argument boundaries<br>
in saved_matches.<br>
<br>
Returns<br>
-------<br>
list, str<br>
A list of converted arguments and the remnant<br>
If remnant isn't an empty string, then there is probably too many arguments provided</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-print"><strong>print</strong></a>(self, *value, sep=' ', end='\n')</dt><dd><tt>Prints a message in the console, preserving the prompt and user input, if any<br>
Partially copies the Python <a href="#AdminCommandEWrapper-print">print</a>() command</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-prompt_loop"><strong>prompt_loop</strong></a>(self)</dt><dd><tt>Asynchronously prompt for commands and dispatch them<br>
Blocks asynchronously until the prompt is closed.<br>
Prefer launching in asyncio.Task wrapper.</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-remove_command"><strong>remove_command</strong></a>(self, name: str)</dt><dd><tt>Permanently removes the command from the chainmap.<br>
Emits cmdrm_event asynchronously.<br>
<br>
Note<br>
----<br>
This function will be transformed into an async function in the future versions<br>
<br>
Parameters<br>
----------<br>
name : str<br>
name of the command<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-save_config"><strong>save_config</strong></a>(self, path: str = 'config.json') -> bool</dt><dd><tt>Saves a configuration into a JSON file<br>
<br>
Parameters<br>
----------<br>
path : str<br>
Absolute or relative path to the config file. Defaults to "config.json"<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-spawn_interruptor"><strong>spawn_interruptor</strong></a>(self)</dt><dd><tt>Spawn a listener for command cancellation keystroke.<br>
Useful when a command executes for an indefinite time and<br>
lets the user to bring back the prompt in emergency cases<br>
<br>
New in version 1.4.2</tt></dd></dl>
<dl><dt>async <a name="AdminCommandEWrapper-unload_extension"><strong>unload_extension</strong></a>(self, name: str, keep_dict=False) -> bool</dt><dd><tt>Unload an extension and call await extension_cleanup(<a href="#AdminCommandExtension">AdminCommandExtension</a>)<br>
Emits extunload_event.<br>
<br>
Parameters<br>
----------<br>
name : str<br>
The name of an extension<br>
keep_dict : bool<br>
DEPRECATED: ignored in version 1.1.0<br>
Whether or not this extension should be kept in the list. Defaults to False<br>
<br>
Returns<br>
-------<br>
bool<br>
Success<br>
<br>
Note<br>
----<br>
Due to a Python limitation, it is impossible to unload a module from memory, but<br>
its possible to reload them with importlib.reload()</tt></dd></dl>
<dl><dt><a name="AdminCommandEWrapper-usage"><strong>usage</strong></a>(self, cmdname: str, lang=True) -> str</dt><dd><tt>Get a formatted usage string for the command<br>
Raises KeyError if the command doesn't exist.<br>
<br>
Parameters<br>
----------<br>
cmdname : str<br>
Name of the command<br>
lang : bool<br>
Whether or not returned string should be formatted through lang['usage']<br>
<br>
Returns<br>
-------<br>
str<br>
Formatted string representing a usage of the command</tt></dd></dl>
<hr>
Data descriptors inherited from <a href="admin_console.html#AdminCommandExecutor">AdminCommandExecutor</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AdminCommandExecutor">class <strong>AdminCommandExecutor</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#AdminCommandExecutor">AdminCommandExecutor</a>(stuff: Optional[Mapping] = None, use_config=True, logger: logging.Logger = None, extension_path='extensions/', backend: Optional[admin_console.ainput.AsyncRawInput] = None)<br>
<br>
This is the main class of the library. It handles command execution and extension load/unload<br>
Firstly, an extensions should be loaded before prompting for commands.<br>
<br>
ace = <a href="#AdminCommandExecutor">AdminCommandExecutor</a>()<br>
await ace.<a href="#AdminCommandExecutor-load_extensions">load_extensions</a>()<br>
<br>
Launching a prompt. Waits until exit command is invoked.<br>
await ace.<a href="#AdminCommandExecutor-prompt_loop">prompt_loop</a>()<br>
<br>
Perform a cleanup<br>
await ace.<a href="#AdminCommandExecutor-full_cleanup">full_cleanup</a>()<br>
<br>
Members<br>
-------<br>
<a href="#AdminCommandExecutor">AdminCommandExecutor</a>.stuff : dict<br>
Arbitrary data storage. Can be used to share data between extensions<br>
<a href="#AdminCommandExecutor">AdminCommandExecutor</a>.commands : collections.ChainMap<br>
dictionary of a commands and its overrides (extension commands)<br>
{"name": <a href="#AdminCommand">AdminCommand</a>}, {"extensioncmd": <a href="#AdminCommand">AdminCommand</a>}, ....<br>
<a href="#AdminCommandExecutor">AdminCommandExecutor</a>.lang : dict<br>
dictionary of formattable strings<br>
{<br>
'nocmd': '{0}: unknown command',<br>
'usage': 'Usage: {0}',<br>
'invalidarg': '{0} is invalid, check your command arguments.',<br>
'toomanyargs': 'warning: this command receives {0} arguments, you provided {1} or more',<br>
'notenoughargs': 'not enough arguments: the command receives {0} arguments, you provided {1}.'<br>
}<br>
<a href="#AdminCommandExecutor">AdminCommandExecutor</a>.types : dict<br>
dictionary of typenames<br>
{<br>
str: 'word',<br>
<a href="builtins.html#int">int</a>: 'n',<br>
<a href="builtins.html#float">float</a>: 'n.n',<br>
bool: 'yes / no',<br>
None: 'text...'<br>
}<br>
<a href="#AdminCommandExecutor">AdminCommandExecutor</a>.extpath : str<br>
self.<strong>prompt_dispatching</strong> : bool = True<br>
Set this variable to False to stop <a href="#AdminCommandExecutor-prompt_loop">prompt_loop</a>() after a command dispatch<br>
self.<strong>promptheader</strong> : str<br>
Command prompt header. Defaults to 'nothing'<br>
self.<strong>promptarrow</strong> : str<br>
Command prompt arrow. Defaults to '>'<br>
Command prompt header and arrow are combined into a prompt<br>
self.<strong>history</strong> : list<br>
Last executed commands, can be cycled with an arrow keys.<br>
self.<strong>ainput</strong> : AsyncRawInput(history=self.<strong>history</strong>)<br>
AsyncRawInput class for reading user input in raw tty mode<br>
self.<strong>ainput</strong>.ctrl_c = self.<strong>full_cleanup</strong><br>
Async function for handling Ctrl + C<br>
self.<strong>disabledCmd</strong> : <a href="#AdminCommand">AdminCommand</a><br>
<a href="#AdminCommand">AdminCommand</a> that alerts the user that this command is disabled by the system<br>
Used by <a href="#AdminCommandExtension">AdminCommandExtension</a>.<a href="#AdminCommandExecutor-remove_command">remove_command</a>(name)<br>
self.<strong>prompt_format</strong> = {'bold': True, 'fgcolor': colors.GREEN}<br>
Formatting of the prompt header and arrow.<br>
self.<strong>input_format</strong> = {'fgcolor': 10}<br>
Formatting of the user input in terminal<br>
self.<strong>tab_complete_lastinp</strong> = ''<br>
Contains last input on last tabcomplete call<br>
self.<strong>tab_complete_seq</strong> = tuple()<br>
Contains last argument suggestions on tab complete call<br>
self.<strong>tab_complete_id</strong> = 0<br>
Contains currently cycled element ID in self.<strong>tab_complete_seq</strong><br>
<br>
Events<br>
self.<strong>events</strong> : collections.defaultdict(AIOHandlerChain)<br>
Main pool of events. Can be used to store custom events.<br>
self.<strong>tab_event</strong> : AIOHandlerChain<br>
Arguments: (executor: Union[<a href="#AdminCommandExecutor">AdminCommandExecutor</a>, <a href="#AdminCommandEWrapper">AdminCommandEWrapper</a>], suggestions: MutableSequence[str])<br>
Emits when user hits the TAB key without full command. Cancellable<br>
Event handlers must modify the suggestions list if needed. Otherwise, if event emission fails,<br>
this list is cleared and no results are shown<br>
self.<strong>cmdexec_event</strong> : AIOHandlerChain<br>
Arguments: (cmd: <a href="#AdminCommand">AdminCommand</a>, executor: Union[<a href="#AdminCommandExecutor">AdminCommandExecutor</a>, <a href="#AdminCommandEWrapper">AdminCommandEWrapper</a>], args: Sequence[Any])<br>
Emits when a command is executed through specific executor and with parsed arguments. Cancellable.<br>
self.<strong>cmdtab_event</strong> : AIOHandlerChain<br>
Arguments: (cmd: <a href="#AdminCommand">AdminCommand</a>, executor: Union[<a href="#AdminCommandExecutor">AdminCommandExecutor</a>, <a href="#AdminCommandEWrapper">AdminCommandEWrapper</a>], args: Sequence[Any], *, argl: str = "")<br>
Keyword arguments are received from handlers: {'override': Sequence[str]}<br>
Emits when TAB key is pressed with this command. Arguments are parsed until the text cursor.<br>
Cancellable. Set 'override' in keyword argument dictionary to explicitly set the list of suggested strings.<br>
self.<strong>cmdadd_event</strong> : AIOHandlerChain<br>
Arguments: (name: str, args: Sequence[(Type, name)], optargs: Sequence[(Type, name)], description: str)<br>
Emits when an extension adds the command or self.<strong>add_command</strong> is called. Emits asynchronously since <a href="#AdminCommandExtension">AdminCommandExtension</a>.add_command is not async. Not cancellable.<br>
self.<strong>cmdrm_event</strong> : AIOHandlerChain<br>
Arguments: (name: str)<br>
Emits when an extension removes the command or self.<strong>remove_command</strong> is called. Emits asynchronously since <a href="#AdminCommandExtension">AdminCommandExtension</a>.remove_command is not async. Not cancellable.<br>
self.<strong>extload_event</strong> : AIOHandlerChain<br>
Arguments: (name: str)<br>
Emits when an extension is loading. Cancellable.<br>
self.<strong>extunload_event</strong> : AIOHandlerChain<br>
Arguments: (name: str)<br>
Emits when an extension is unloading. Cancellable.<br>
<br>
Others:<br>
self.<strong>print</strong> = self.<strong>ainput</strong>.writeln<br>
self.<strong>logger</strong> = logger<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AdminCommandExecutor-__init__"><strong>__init__</strong></a>(self, stuff: Optional[Mapping] = None, use_config=True, logger: logging.Logger = None, extension_path='extensions/', backend: Optional[admin_console.ainput.AsyncRawInput] = None)</dt><dd><tt>Parameters<br>
----------<br>
stuff : dict<br>
Arbitrary data storage<br>
use_config : bool<br>
Whether or not a config.json file should be created or loaded in a working directory. Defaults to True<br>
logger : logging.Logger<br>
logging.Logger instance to handle all the log messages<br>
extension_path : str<br>
Relative or absolute path to the extensions directory. Defaults to "extensions/"</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-add_command"><strong>add_command</strong></a>(self, afunc: Callable[[Any], Coroutine[Any, Any, Any]], name: str, args: Sequence[Tuple[Type, str]] = (), optargs: Sequence[Tuple[Type, str]] = (), description: str = '', atabcomplete: Optional[Callable[[Any], Coroutine[Any, Any, Any]]] = None) -> bool</dt><dd><tt>Constructs an <a href="#AdminCommand">AdminCommand</a> instance with all the arguments passed.<br>
Adds the command to the first layer of the chainmap<br>
Emits cmdadd_event asynchronously.<br>
<br>
Note<br>
----<br>
This function will be transformed into an async function in the future versions<br>
<br>
Parameters<br>
----------<br>
see <a href="#AdminCommand">AdminCommand</a><br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-cmd_interruptor"><strong>cmd_interruptor</strong></a>(self)</dt><dd><tt>Listens for Ctrl + C event during command execution.<br>
Cancels the command execution task if Ctrl + C pressed.</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-dispatch"><strong>dispatch</strong></a>(self, cmdline: str) -> bool</dt><dd><tt>Executes a command. Shouldn't be used explicitly with input(). Use <a href="#AdminCommandExecutor-prompt_loop">prompt_loop</a>() instead.<br>
<br>
Parameters<br>
----------<br>
cmdline : str<br>
A whole line representing a command<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-error"><strong>error</strong></a>(self, msg: str, log=True)</dt><dd><tt>Shows a red error message in the console and logs.<br>
ERROR: msg<br>
<br>
Parameters<br>
----------<br>
msg : str<br>
Message</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-full_cleanup"><strong>full_cleanup</strong></a>(self)</dt><dd><tt>Perform cleanup steps in <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.full_cleanup_steps</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-info"><strong>info</strong></a>(self, msg: str)</dt><dd><tt>Shows a regular info message in the console and logs.<br>
<br>
Parameters<br>
----------<br>
msg : str<br>
Message</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-interrupt_command"><strong>interrupt_command</strong></a>(self)</dt><dd><tt>Cancels the command execution task.<br>
Ctrl + C is replaced during any command being executed.</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-load_config"><strong>load_config</strong></a>(self, path: str = 'config.json') -> bool</dt><dd><tt>Loads a configuration from a JSON file<br>
<br>
Parameters<br>
----------<br>
path : str<br>
Absolute or relative path to the config file. Defaults to "config.json"<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-load_extension"><strong>load_extension</strong></a>(self, name: str) -> bool</dt><dd><tt>Loads a Python script as an extension from its extension path and call await extension_init(<a href="#AdminCommandExtension">AdminCommandExtension</a>)<br>
Emits extload_event.<br>
<br>
Parameters<br>
----------<br>
name : str<br>
The extensionless name of a file containing a Python script<br>
<br>
Returns<br>
-------<br>
bool<br>
Success<br>
<br>
Note<br>
----<br>
Due to the Python's importlib limitation, extensions cannot "import" other extensions properly<br>
and that way can't be implemented in any non-destructible way. Temporary modifying sys.modules<br>
may cause interference between multiple ACE instances (possible name collisions in<br>
sys.modules) and race conditions in multithreaded application.<br>
The only way one extension can make use of another is through <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.extensions['name'].*<br>
Extension objects must not be stored anywhere except by the <a href="#AdminCommandExecutor">AdminCommandExecutor</a> owning it.<br>
Otherwise the garbage collection won't work and the extension wouldn't unload properly.<br>
Also, the Python module cannot be unloaded from the memory, in that particular case, the modules<br>
are cached, and if the same extension loads again, its module is taken from the known_modules and<br>
reloaded.</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-load_extensions"><strong>load_extensions</strong></a>(self)</dt><dd><tt>Loads extensions from an extension directory specified in <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.extpath</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-log"><strong>log</strong></a>(self, msg: str, level=10)</dt><dd><tt>Shows a log message in the console and logs<br>
<br>
Parameters<br>
----------<br>
msg : str<br>
Message<br>
level : <a href="builtins.html#int">int</a><br>
Level of the log message between 0 and 50</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-parse_args"><strong>parse_args</strong></a>(self, argl: str, argtypes: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]] = None, opt_argtypes: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]] = None, *, raise_exc=True, saved_matches: Optional[MutableSequence[re.Match]] = None, until: Optional[int] = None) -> (<class 'list'>, <class 'str'>)</dt><dd><tt>Smart split the argument line and convert all the arguments to its types<br>
Raises <a href="#InvalidArgument">InvalidArgument</a>(argname) if one of the arguments couldn't be converted<br>
Raises <a href="#NotEnoughArguments">NotEnoughArguments</a>(len(args)) if there isn't enough arguments provided<br>
<br>
Parameters<br>
----------<br>
argl : str<br>
Argument line with raw space-separated arguments<br>
argtypes : list<br>
Any collection containing a tuples (type, name) representing an argument name and type<br>
The arguments that are listed in there are mandatory.<br>
opt_argtypes : list<br>
Same as argtypes, but those arguments are parsed after mandatory and are optional.<br>
Doesn't cause <a href="#NotEnoughArguments">NotEnoughArguments</a> to be raise if there is not enough optional arguments<br>
<br>
Keyword-only parameters:<br>
raise_exc : bool<br>
Whether or not exceptions are raised. If False, data is returned as it is<br>
saved_matches : list<br>
If specified, the parser will append the re.Match objects for each argument<br>
to this list except the last NoneType argument (if present in args),<br>
which does not have any boundaries<br>
until : <a href="builtins.html#int">int</a><br>
If specified, will stop parsing arguments when passed more than n symbols.<br>
Useful when passing sliced string isn't good due to storing argument boundaries<br>
in saved_matches.<br>
<br>
Returns<br>
-------<br>
list, str<br>
A list of converted arguments and the remnant<br>
If remnant isn't an empty string, then there is probably too many arguments provided</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-print"><strong>print</strong></a>(self, *value, sep=' ', end='\n')</dt><dd><tt>Prints a message in the console, preserving the prompt and user input, if any<br>
Partially copies the Python <a href="#AdminCommandExecutor-print">print</a>() command</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-prompt_loop"><strong>prompt_loop</strong></a>(self)</dt><dd><tt>Asynchronously prompt for commands and dispatch them<br>
Blocks asynchronously until the prompt is closed.<br>
Prefer launching in asyncio.Task wrapper.</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-remove_command"><strong>remove_command</strong></a>(self, name: str)</dt><dd><tt>Permanently removes the command from the chainmap.<br>
Emits cmdrm_event asynchronously.<br>
<br>
Note<br>
----<br>
This function will be transformed into an async function in the future versions<br>
<br>
Parameters<br>
----------<br>
name : str<br>
name of the command<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-save_config"><strong>save_config</strong></a>(self, path: str = 'config.json') -> bool</dt><dd><tt>Saves a configuration into a JSON file<br>
<br>
Parameters<br>
----------<br>
path : str<br>
Absolute or relative path to the config file. Defaults to "config.json"<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-spawn_interruptor"><strong>spawn_interruptor</strong></a>(self)</dt><dd><tt>Spawn a listener for command cancellation keystroke.<br>
Useful when a command executes for an indefinite time and<br>
lets the user to bring back the prompt in emergency cases<br>
<br>
New in version 1.4.2</tt></dd></dl>
<dl><dt>async <a name="AdminCommandExecutor-unload_extension"><strong>unload_extension</strong></a>(self, name: str, keep_dict=False) -> bool</dt><dd><tt>Unload an extension and call await extension_cleanup(<a href="#AdminCommandExtension">AdminCommandExtension</a>)<br>
Emits extunload_event.<br>
<br>
Parameters<br>
----------<br>
name : str<br>
The name of an extension<br>
keep_dict : bool<br>
DEPRECATED: ignored in version 1.1.0<br>
Whether or not this extension should be kept in the list. Defaults to False<br>
<br>
Returns<br>
-------<br>
bool<br>
Success<br>
<br>
Note<br>
----<br>
Due to a Python limitation, it is impossible to unload a module from memory, but<br>
its possible to reload them with importlib.reload()</tt></dd></dl>
<dl><dt><a name="AdminCommandExecutor-usage"><strong>usage</strong></a>(self, cmdname: str, lang=True) -> str</dt><dd><tt>Get a formatted usage string for the command<br>
Raises KeyError if the command doesn't exist.<br>
<br>
Parameters<br>
----------<br>
cmdname : str<br>
Name of the command<br>
lang : bool<br>
Whether or not returned string should be formatted through lang['usage']<br>
<br>
Returns<br>
-------<br>
str<br>
Formatted string representing a usage of the command</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="AdminCommandExtension">class <strong>AdminCommandExtension</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#AdminCommandExtension">AdminCommandExtension</a>(ACE, name: str, module: module, logger: logging.Logger = &lt;Logger main (WARNING)&gt;)<br>
<br>
Extension data class. Constructed by <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.<br>
In extension scripts the instance is passed into:<br>
async def extension_init(<a href="#AdminCommandExtension">AdminCommandExtension</a>)<br>
called when an extension is loaded<br>
async def extension_cleanup(<a href="#AdminCommandExtension">AdminCommandExtension</a>)<br>
called when an extension is unloaded<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="AdminCommandExtension-__init__"><strong>__init__</strong></a>(self, ACE, name: str, module: module, logger: logging.Logger = <Logger main (WARNING)>)</dt><dd><tt>Parameters<br>
----------<br>
ACE : <a href="#AdminCommandExecutor">AdminCommandExecutor</a><br>
instance of the <a href="#AdminCommandExecutor">AdminCommandExecutor</a> class holding this extension.<br>
name : str<br>
name of the extension or extensionless filename of the extension<br>
module : types.ModuleType<br>
Python importlib module of the extension<br>
logger : logging.Logger<br>
logging.Logger instance attached to an extension</tt></dd></dl>
<dl><dt><a name="AdminCommandExtension-add_command"><strong>add_command</strong></a>(self, afunc: Callable[[Any], Coroutine[Any, Any, Any]], name: str, args: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]] = (), optargs: Sequence[Tuple[Union[str, int, float, bool, NoneType, admin_console.CustomType], str]] = (), description: str = '', atabcomplete: Optional[Callable[[str], Coroutine[Any, Any, Any]]] = None, replace=False) -> bool</dt><dd><tt>Registers a command and adds it to the <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.<br>
Constructs an <a href="#AdminCommand">AdminCommand</a> instance with all the arguments passed.<br>
Doesn't require <a href="#AdminCommandExtension-sync_local_commands">sync_local_commands</a>() to be run<br>
<br>
Note<br>
----<br>
This function will be transformed into an async function in the future versions<br>
<br>
Parameters<br>
----------<br>
see <a href="#AdminCommand">AdminCommand</a><br>
replace : bool<br>
Whether or not the command should be replaced if already exists. Defaults to False<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandExtension-clear_commands"><strong>clear_commands</strong></a>(self) -> bool</dt><dd><tt>Clear all the commands registered by this extension<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandExtension-logmsg"><strong>logmsg</strong></a>(self, msg: str, level: int = 20)</dt><dd><tt>Write a message into the log</tt></dd></dl>
<dl><dt><a name="AdminCommandExtension-msg"><strong>msg</strong></a>(self, msg: str)</dt><dd><tt>Show message in the console with the extension prefix</tt></dd></dl>
<dl><dt><a name="AdminCommandExtension-remove_command"><strong>remove_command</strong></a>(self, name: str, remove_native=False) -> bool</dt><dd><tt>Unregisters a command from the <a href="#AdminCommandExtension">AdminCommandExtension</a> and/or from an <a href="#AdminCommandExecutor">AdminCommandExecutor</a><br>
If remove_native is True, it doesn't check whether or not this command is owned by this extension<br>
Parameters<br>
----------<br>
remove_native : bool<br>
If False, delete only if this command is owned by self<br>
Assign a command to <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.disabledCmd in case of it already existing<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<dl><dt><a name="AdminCommandExtension-sync_local_commands"><strong>sync_local_commands</strong></a>(self, overwrite=False) -> bool</dt><dd><tt>DEPRECATED: since version 1.1.0 admin_console uses collections.ChainMap for command overrides<br>
Adds all the extension commands into <a href="#AdminCommandExecutor">AdminCommandExecutor</a> commands list<br>
Parameters<br>
----------<br>
overwrite : bool<br>
If True, already existing commands will be replaced<br>
If False, fails in case when any of the extension commands are overlapping with already existing.<br>
<br>
Returns<br>
-------<br>
bool<br>
Success</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="BaseContinuousScale">class <strong>BaseContinuousScale</strong></a>(<a href="builtins.html#float">builtins.float</a>, <a href="admin_console.html#CustomType">CustomType</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#BaseContinuousScale">BaseContinuousScale</a>(value, /, *args, **kwargs)<br>
<br>
Base class for defining types that are based on <a href="builtins.html#float">float</a>, but has boundaries<br>
Unlike <a href="#BaseDiscreteScale">BaseDiscreteScale</a>, this type doesn't have _step attribute as it is continuous.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="admin_console.html#BaseContinuousScale">BaseContinuousScale</a></dd>
<dd><a href="builtins.html#float">builtins.float</a></dd>
<dd><a href="admin_console.html#CustomType">CustomType</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="BaseContinuousScale-__init__"><strong>__init__</strong></a>(self, value, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-getValue"><strong>getValue</strong></a>(self) -> float</dt><dd><tt>Obtain a value from this type wrapper</tt></dd></dl>
<hr>
Class methods defined here:<br>
<dl><dt><a name="BaseContinuousScale-getMax"><strong>getMax</strong></a>() -> float<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Returns the highest point of a scale</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-getMin"><strong>getMin</strong></a>() -> float<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Returns the lowest point of a scale</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-getTypeName"><strong>getTypeName</strong></a>(ace) -> str<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Obtain a name for this type that is used in command usage<br>
Name is obtained from <a href="#AdminCommandExecutor">AdminCommandExecutor</a>.lang first, then from<br>
self.<strong>_typename</strong> if not found in former</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="builtins.html#float">builtins.float</a>:<br>
<dl><dt><a name="BaseContinuousScale-__abs__"><strong>__abs__</strong></a>(self, /)</dt><dd><tt>abs(self)</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__add__"><strong>__add__</strong></a>(self, value, /)</dt><dd><tt>Return self+value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__bool__"><strong>__bool__</strong></a>(self, /)</dt><dd><tt>True if self else False</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__ceil__"><strong>__ceil__</strong></a>(self, /)</dt><dd><tt>Return the ceiling as an Integral.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__divmod__"><strong>__divmod__</strong></a>(self, value, /)</dt><dd><tt>Return divmod(self, value).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__eq__"><strong>__eq__</strong></a>(self, value, /)</dt><dd><tt>Return self==value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__float__"><strong>__float__</strong></a>(self, /)</dt><dd><tt><a href="builtins.html#float">float</a>(self)</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__floor__"><strong>__floor__</strong></a>(self, /)</dt><dd><tt>Return the floor as an Integral.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__floordiv__"><strong>__floordiv__</strong></a>(self, value, /)</dt><dd><tt>Return self//value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__format__"><strong>__format__</strong></a>(self, format_spec, /)</dt><dd><tt>Formats the <a href="builtins.html#float">float</a> according to format_spec.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__ge__"><strong>__ge__</strong></a>(self, value, /)</dt><dd><tt>Return self>=value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__getnewargs__"><strong>__getnewargs__</strong></a>(self, /)</dt></dl>
<dl><dt><a name="BaseContinuousScale-__gt__"><strong>__gt__</strong></a>(self, value, /)</dt><dd><tt>Return self>value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__hash__"><strong>__hash__</strong></a>(self, /)</dt><dd><tt>Return hash(self).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__int__"><strong>__int__</strong></a>(self, /)</dt><dd><tt><a href="builtins.html#int">int</a>(self)</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__le__"><strong>__le__</strong></a>(self, value, /)</dt><dd><tt>Return self<=value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__lt__"><strong>__lt__</strong></a>(self, value, /)</dt><dd><tt>Return self<value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__mod__"><strong>__mod__</strong></a>(self, value, /)</dt><dd><tt>Return self%value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__mul__"><strong>__mul__</strong></a>(self, value, /)</dt><dd><tt>Return self*value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__ne__"><strong>__ne__</strong></a>(self, value, /)</dt><dd><tt>Return self!=value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__neg__"><strong>__neg__</strong></a>(self, /)</dt><dd><tt>-self</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__pos__"><strong>__pos__</strong></a>(self, /)</dt><dd><tt>+self</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__pow__"><strong>__pow__</strong></a>(self, value, mod=None, /)</dt><dd><tt>Return pow(self, value, mod).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__radd__"><strong>__radd__</strong></a>(self, value, /)</dt><dd><tt>Return value+self.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rdivmod__"><strong>__rdivmod__</strong></a>(self, value, /)</dt><dd><tt>Return divmod(value, self).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rfloordiv__"><strong>__rfloordiv__</strong></a>(self, value, /)</dt><dd><tt>Return value//self.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rmod__"><strong>__rmod__</strong></a>(self, value, /)</dt><dd><tt>Return value%self.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rmul__"><strong>__rmul__</strong></a>(self, value, /)</dt><dd><tt>Return value*self.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__round__"><strong>__round__</strong></a>(self, ndigits=None, /)</dt><dd><tt>Return the Integral closest to x, rounding half toward even.<br>
<br>
When an argument is passed, work like built-in round(x, ndigits).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rpow__"><strong>__rpow__</strong></a>(self, value, mod=None, /)</dt><dd><tt>Return pow(value, self, mod).</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rsub__"><strong>__rsub__</strong></a>(self, value, /)</dt><dd><tt>Return value-self.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__rtruediv__"><strong>__rtruediv__</strong></a>(self, value, /)</dt><dd><tt>Return value/self.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__sub__"><strong>__sub__</strong></a>(self, value, /)</dt><dd><tt>Return self-value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__truediv__"><strong>__truediv__</strong></a>(self, value, /)</dt><dd><tt>Return self/value.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-__trunc__"><strong>__trunc__</strong></a>(self, /)</dt><dd><tt>Return the Integral closest to x between 0 and x.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-as_integer_ratio"><strong>as_integer_ratio</strong></a>(self, /)</dt><dd><tt>Return integer ratio.<br>
<br>
Return a pair of integers, whose ratio is exactly equal to the original <a href="builtins.html#float">float</a><br>
and with a positive denominator.<br>
<br>
Raise OverflowError on infinities and a <a href="builtins.html#ValueError">ValueError</a> on NaNs.<br>
<br>
>>> (10.0).<a href="#BaseContinuousScale-as_integer_ratio">as_integer_ratio</a>()<br>
(10, 1)<br>
>>> (0.0).<a href="#BaseContinuousScale-as_integer_ratio">as_integer_ratio</a>()<br>
(0, 1)<br>
>>> (-.25).<a href="#BaseContinuousScale-as_integer_ratio">as_integer_ratio</a>()<br>
(-1, 4)</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-conjugate"><strong>conjugate</strong></a>(self, /)</dt><dd><tt>Return self, the complex conjugate of any <a href="builtins.html#float">float</a>.</tt></dd></dl>
<dl><dt><a name="BaseContinuousScale-hex"><strong>hex</strong></a>(self, /)</dt><dd><tt>Return a hexadecimal representation of a floating-point number.<br>
<br>
>>> (-0.1).<a href="#BaseContinuousScale-hex">hex</a>()<br>
'-0x1.999999999999ap-4'<br>
>>> 3.14159.<a href="#BaseContinuousScale-hex">hex</a>()<br>
'0x1.921f9f01b866ep+1'</tt></dd></dl>