bTagScript 5.0.0__py3-none-any.whl
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.
- bTagScript/__init__.py +66 -0
- bTagScript/adapter/__init__.py +16 -0
- bTagScript/adapter/discord_adapters.py +275 -0
- bTagScript/adapter/function_adapter.py +33 -0
- bTagScript/adapter/int_adapter.py +30 -0
- bTagScript/adapter/object_adapter.py +41 -0
- bTagScript/adapter/string_adapter.py +69 -0
- bTagScript/block/__init__.py +67 -0
- bTagScript/block/break_block.py +41 -0
- bTagScript/block/case_block.py +62 -0
- bTagScript/block/comment_block.py +33 -0
- bTagScript/block/control_block.py +161 -0
- bTagScript/block/counting_blocks.py +88 -0
- bTagScript/block/digitshorthand_block.py +38 -0
- bTagScript/block/discord_blocks/__init__.py +20 -0
- bTagScript/block/discord_blocks/command_block.py +52 -0
- bTagScript/block/discord_blocks/cooldown_block.py +101 -0
- bTagScript/block/discord_blocks/delete_block.py +47 -0
- bTagScript/block/discord_blocks/embed_block.py +248 -0
- bTagScript/block/discord_blocks/override_block.py +61 -0
- bTagScript/block/discord_blocks/react_block.py +49 -0
- bTagScript/block/discord_blocks/redirect_block.py +42 -0
- bTagScript/block/discord_blocks/requirement_blocks.py +83 -0
- bTagScript/block/helpers.py +121 -0
- bTagScript/block/math_blocks.py +257 -0
- bTagScript/block/random_block.py +65 -0
- bTagScript/block/range_block.py +54 -0
- bTagScript/block/replace_block.py +110 -0
- bTagScript/block/stop_block.py +38 -0
- bTagScript/block/strf_block.py +70 -0
- bTagScript/block/url_blocks.py +76 -0
- bTagScript/block/util_blocks/__init__.py +3 -0
- bTagScript/block/util_blocks/debug_block.py +107 -0
- bTagScript/block/var_block.py +49 -0
- bTagScript/block/vargetter_blocks.py +91 -0
- bTagScript/exceptions.py +139 -0
- bTagScript/interface/__init__.py +4 -0
- bTagScript/interface/adapter.py +43 -0
- bTagScript/interface/block.py +136 -0
- bTagScript/interpreter.py +614 -0
- bTagScript/utils.py +65 -0
- bTagScript/verb.py +129 -0
- btagscript-5.0.0.dist-info/METADATA +109 -0
- btagscript-5.0.0.dist-info/RECORD +47 -0
- btagscript-5.0.0.dist-info/WHEEL +5 -0
- btagscript-5.0.0.dist-info/licenses/LICENSE +1 -0
- btagscript-5.0.0.dist-info/top_level.txt +1 -0
bTagScript/verb.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
__all__ = ("Verb",)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Verb:
|
|
7
|
+
"""
|
|
8
|
+
Represents the passed TagScript block.
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
verb_string: Optional[str]
|
|
13
|
+
The string to parse into a verb.
|
|
14
|
+
limit: int
|
|
15
|
+
The maximum number of characters to parse.
|
|
16
|
+
|
|
17
|
+
Attributes
|
|
18
|
+
----------
|
|
19
|
+
declaration: Optional[str]
|
|
20
|
+
The text used to declare the block.
|
|
21
|
+
parameter: Optional[str]
|
|
22
|
+
The text passed to the block parameter in the parentheses.
|
|
23
|
+
payload: Optional[str]
|
|
24
|
+
The text passed to the block payload after the colon.
|
|
25
|
+
|
|
26
|
+
Example
|
|
27
|
+
-------
|
|
28
|
+
Below is a visual representation of a block and its attributes::
|
|
29
|
+
|
|
30
|
+
.. tagscript::
|
|
31
|
+
|
|
32
|
+
Normally
|
|
33
|
+
{declaration(parameter):payload}
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
__slots__ = (
|
|
37
|
+
"declaration",
|
|
38
|
+
"parameter",
|
|
39
|
+
"payload",
|
|
40
|
+
"parsed_string",
|
|
41
|
+
"parsed_length",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def __init__(self, verb_string: Optional[str] = None, *, limit: int = 2000) -> None:
|
|
45
|
+
"""
|
|
46
|
+
Constructor for the class
|
|
47
|
+
"""
|
|
48
|
+
self.declaration: Optional[str] = None
|
|
49
|
+
self.parameter: Optional[str] = None
|
|
50
|
+
self.payload: Optional[str] = None
|
|
51
|
+
if verb_string is None:
|
|
52
|
+
return
|
|
53
|
+
self.__parse(verb_string, limit)
|
|
54
|
+
|
|
55
|
+
def __str__(self) -> str:
|
|
56
|
+
"""
|
|
57
|
+
This makes Verb compatible with str(x)
|
|
58
|
+
"""
|
|
59
|
+
response = "{"
|
|
60
|
+
if self.declaration is not None:
|
|
61
|
+
response += self.declaration
|
|
62
|
+
if self.parameter is not None:
|
|
63
|
+
response += f"({self.parameter})"
|
|
64
|
+
if self.payload is not None:
|
|
65
|
+
response += ":" + self.payload
|
|
66
|
+
return response + "}"
|
|
67
|
+
|
|
68
|
+
def __repr__(self) -> str:
|
|
69
|
+
"""
|
|
70
|
+
String represent
|
|
71
|
+
"""
|
|
72
|
+
attrs = ("declaration", "parameter", "payload")
|
|
73
|
+
inner = " ".join(f"{attr}={getattr(self, attr)!r}" for attr in attrs)
|
|
74
|
+
return f"<Verb {inner}>"
|
|
75
|
+
|
|
76
|
+
def __parse(self, verb_string: str, limit: int) -> None:
|
|
77
|
+
"""
|
|
78
|
+
Parse the string into a verb
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
verb_string: str
|
|
83
|
+
The string to parse into a verb.
|
|
84
|
+
limit: int
|
|
85
|
+
The maximum number of characters to parse.
|
|
86
|
+
|
|
87
|
+
Returns
|
|
88
|
+
-------
|
|
89
|
+
None
|
|
90
|
+
"""
|
|
91
|
+
parsed = self.parsed_string = verb_string[1:-1][:limit]
|
|
92
|
+
parsed_length = self.parsed_length = len(parsed)
|
|
93
|
+
dec_depth = 0
|
|
94
|
+
dec_start = 0
|
|
95
|
+
skip_next = False
|
|
96
|
+
|
|
97
|
+
for i, v in enumerate(parsed):
|
|
98
|
+
if skip_next:
|
|
99
|
+
skip_next = False
|
|
100
|
+
continue
|
|
101
|
+
if v == "\\":
|
|
102
|
+
skip_next = True
|
|
103
|
+
continue
|
|
104
|
+
|
|
105
|
+
if v == ":" and not dec_depth:
|
|
106
|
+
self.set_payload()
|
|
107
|
+
return
|
|
108
|
+
if v == "(":
|
|
109
|
+
dec_depth += 1
|
|
110
|
+
if not dec_start:
|
|
111
|
+
dec_start = i
|
|
112
|
+
self.declaration = parsed[:i]
|
|
113
|
+
elif v == ")" and dec_depth:
|
|
114
|
+
dec_depth -= 1
|
|
115
|
+
if dec_depth == 0:
|
|
116
|
+
self.parameter = parsed[dec_start + 1 : i]
|
|
117
|
+
if i + 1 < parsed_length and parsed[i + 1] == ":":
|
|
118
|
+
self.payload = parsed[i + 2 :]
|
|
119
|
+
return
|
|
120
|
+
self.set_payload()
|
|
121
|
+
|
|
122
|
+
def set_payload(self) -> None:
|
|
123
|
+
"""
|
|
124
|
+
Set the payload
|
|
125
|
+
"""
|
|
126
|
+
res = self.parsed_string.split(":", 1)
|
|
127
|
+
if len(res) == 2:
|
|
128
|
+
self.payload = res[1]
|
|
129
|
+
self.declaration = res[0]
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bTagScript
|
|
3
|
+
Version: 5.0.0
|
|
4
|
+
Summary: An easy drop in user-provided Templating system.
|
|
5
|
+
Author-email: Leg3ndary <bleg3ndary@gmail.com>
|
|
6
|
+
Maintainer-email: Leg3ndary <bleg3ndary@gmail.com>
|
|
7
|
+
License: Creative Commons Attribution 4.0 International License
|
|
8
|
+
Project-URL: Homepage, https://github.com/Leg3ndary/bTagScript
|
|
9
|
+
Project-URL: Documentation, https://btagscript.readthedocs.io/
|
|
10
|
+
Keywords: tagscript
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: Freely Distributable
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: discord.py>=2.0.0
|
|
26
|
+
Requires-Dist: pyparsing>=3.0.9
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# bTagScript
|
|
30
|
+
|
|
31
|
+
<a href='https://btagscript.readthedocs.io/en/latest/?badge=latest'>
|
|
32
|
+
<img src='https://readthedocs.org/projects/btagscript/badge/?version=latest' alt='Documentation Status' />
|
|
33
|
+
</a>
|
|
34
|
+
|
|
35
|
+
TagScript, but better, with more features then you could ever need!
|
|
36
|
+
|
|
37
|
+
**Features:**
|
|
38
|
+
- Extra Syntax Options
|
|
39
|
+
- More Blocks
|
|
40
|
+
|
|
41
|
+
<img width="851" alt="bTagScriptBasic" src="https://i.imgur.com/wHxbwxw.png">
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Documentation on the bTagScript library can be [found here](https://btagscript.readthedocs.io/en/latest/).
|
|
45
|
+
|
|
46
|
+
## What?
|
|
47
|
+
|
|
48
|
+
TagScript allows you to create low level code, quickly, and easily. This is meant to be used with discord.py 2.0 and is not compatible with other versions.
|
|
49
|
+
|
|
50
|
+
## Credits
|
|
51
|
+
|
|
52
|
+
This repository is a fork of Phenom4n4n's fork of JonSnowbd's [TagScript](https://github.com/JonSnowbd/TagScript), a string templating language.
|
|
53
|
+
|
|
54
|
+
## Dependencies
|
|
55
|
+
|
|
56
|
+
`Python 3.8+`
|
|
57
|
+
|
|
58
|
+
`discord.py 2.0`
|
|
59
|
+
|
|
60
|
+
`pyparsing`
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
Download through pip
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
pip(3) install bTagScript
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Download the latest version through github:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
pip(3) install https://github.com/Leg3ndary/bTagScript
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Download from a commit:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
pip(3) install git+https://github.com/Leg3ndary/bTagScript.git@<COMMIT_HASH>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Install for editing/development:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
git clone https://github.com/Leg3ndary/bTagScript.git
|
|
87
|
+
pip(3) install -e ./bTagScript
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Benchmarks (Performance Testing)
|
|
91
|
+
|
|
92
|
+
### July 08, 2022
|
|
93
|
+
|
|
94
|
+
Testing for this benchmark used the following seeds and test strings, this was ran `1,000` times.
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
Seeds: {message: Hello, this is my message.}
|
|
98
|
+
Test String: {message} {#:1,2,3,4,5,6,7,8,9,10} {range:1-9} {$variablename:Hello World} {variablename} {message} {strf:Its %A}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Note that this was adjusted for different syntax, {=(variablename):Hello World} vs {$variablename:Hello World}
|
|
102
|
+
|
|
103
|
+
bTagScript will likely get worse and worse as more blocks are added...
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
2.6.9 bTagScript: 0.08033132553100586 Seconds
|
|
107
|
+
|
|
108
|
+
2.6.2 TagScript: 0.08630657196044922 Seconds
|
|
109
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
bTagScript/__init__.py,sha256=FgkSZ5YPP2tSlb6HuyLfpAg9s5_tYPWHxES4_8bVDIw,1622
|
|
2
|
+
bTagScript/exceptions.py,sha256=5rcuvtDdO90_IqJhA3br62fAWvOJ0Xn68pdeHk9ZDJA,3256
|
|
3
|
+
bTagScript/interpreter.py,sha256=nPfHdzZlio6XZ9YfgswkE2VqhcbnRewaxOBy1Lq3Xkg,18221
|
|
4
|
+
bTagScript/utils.py,sha256=t-5GNoa8q75NiYel1TGUjbIoGxuzgTX6ytWJJJ-_w9I,1428
|
|
5
|
+
bTagScript/verb.py,sha256=dkHTDCh6g1kGqREWsmwqD80YbcvKGccY8vFcojH9N-k,3521
|
|
6
|
+
bTagScript/adapter/__init__.py,sha256=qtzoo7mvzJSgcnEaOL8cZDaceT4iYU14TD39RXfBJls,391
|
|
7
|
+
bTagScript/adapter/discord_adapters.py,sha256=Ccqlghf6wPPYt0BTYv4u06H67WZxaypCOkUaMqQPSrQ,7880
|
|
8
|
+
bTagScript/adapter/function_adapter.py,sha256=-X27ydb_tqcuySz2iTZ0VLolSY9Y6EjRnW9QZuul05E,698
|
|
9
|
+
bTagScript/adapter/int_adapter.py,sha256=xjwhLZaQwc3POC92meZNPTT1cpbca8RcE-6ESFGWRC8,689
|
|
10
|
+
bTagScript/adapter/object_adapter.py,sha256=qPCzjG26hfnV1eMcfwynFhfB7Y_bMGdNQLecZkwBe1Y,1053
|
|
11
|
+
bTagScript/adapter/string_adapter.py,sha256=Geg_TQBy6nxh4Erub3NPyX_v_1Nqq5FIyFta7xIngB0,2228
|
|
12
|
+
bTagScript/block/__init__.py,sha256=Qf_9k5VOutdbq1KbwzIeFvYWcK_WIYoUw_td8cW0jO0,1683
|
|
13
|
+
bTagScript/block/break_block.py,sha256=rwgL2ZIfl7BNU6y0eNBIn8kOHCJyUp9XrkDtcDEj_nM,1205
|
|
14
|
+
bTagScript/block/case_block.py,sha256=87pPDOjn9qmcYnoKeqB1ftYSUeA4WrqxQyV3_SySp9g,1319
|
|
15
|
+
bTagScript/block/comment_block.py,sha256=3oe27l_pdqLdebPH3VMW5Zq6ODguJsc7Bb7hHXU7S6k,664
|
|
16
|
+
bTagScript/block/control_block.py,sha256=SAITk32y2Vntvnfyc_LDP-IrZVew5dxs21r3PtrPn14,5556
|
|
17
|
+
bTagScript/block/counting_blocks.py,sha256=2h4z0tmgfPRpe_x6YPrkQ6qQzX4TmZMqpU26817R5iw,2210
|
|
18
|
+
bTagScript/block/digitshorthand_block.py,sha256=bjctnK8Vf7nf_Pr1Kgg8o5eecqAddQilZGu-w7c27EE,1061
|
|
19
|
+
bTagScript/block/helpers.py,sha256=Q5AXFQJJdTRdzLWhtsaXpENAop7eLCG4hTS6Gnv8Ir8,3188
|
|
20
|
+
bTagScript/block/math_blocks.py,sha256=efWUuYlqy1BP5mvoab41NEpzvkIxeEIiyHA7Wpcmh7A,7799
|
|
21
|
+
bTagScript/block/random_block.py,sha256=QZLrRJbr6kb9a3dKDx-Ak5F7PQnvzh2OebluTHQIFKU,2036
|
|
22
|
+
bTagScript/block/range_block.py,sha256=screhqVFIeTGOcbJb0ZLkVOFFM9RrfOkL-52av2e-e0,1690
|
|
23
|
+
bTagScript/block/replace_block.py,sha256=8NRTD8oKaqJC3YM2DEjhUBLyZHlun4X_wVMnIF8oTp4,3042
|
|
24
|
+
bTagScript/block/stop_block.py,sha256=k1fWvMVFSohSoIDsv4bxAVtPTvLOKMLxrunuf1MUIlM,971
|
|
25
|
+
bTagScript/block/strf_block.py,sha256=1sIlDckr4NKbL3z5o16l2kbo3LfStYYzYDGrZMDGXjY,1952
|
|
26
|
+
bTagScript/block/url_blocks.py,sha256=lbygTJa1-VNy2MK2CnoU6ZoAsSgEp4FbYLB-qmFe-WU,2139
|
|
27
|
+
bTagScript/block/var_block.py,sha256=PONWeluJ5QtkaTRzsmimogZ2hdVFqvD5qp87kTeYR6A,1390
|
|
28
|
+
bTagScript/block/vargetter_blocks.py,sha256=Oe4NHP3v6TxaAVv7WsVVx6at3OcbSpYnsGgROPdxY9U,3133
|
|
29
|
+
bTagScript/block/discord_blocks/__init__.py,sha256=4I0WwVuXfKn2k1NmccuwmQI2G6BROIYULHKe3u0Tz_Y,532
|
|
30
|
+
bTagScript/block/discord_blocks/command_block.py,sha256=3ZrRmyVvuMI5B2jcy5eWd0Eq5x6uWRdd7xd2GdepebI,1365
|
|
31
|
+
bTagScript/block/discord_blocks/cooldown_block.py,sha256=cA1vuj40y60X0KCkNjtTKNXjCeCk67tnu8FCJVRjzGE,3912
|
|
32
|
+
bTagScript/block/discord_blocks/delete_block.py,sha256=9etFWnynHcuR_obZOwq9rUKbO5TlUaS5-YH-scyjSZw,1159
|
|
33
|
+
bTagScript/block/discord_blocks/embed_block.py,sha256=D2pGXMdTZ-O0uf4BbOPbJc7bAnI_b-5qVfcwoH0YUnc,7445
|
|
34
|
+
bTagScript/block/discord_blocks/override_block.py,sha256=9uvsFZQXhgqoIZJnA5o9SjGus5sXXbqyVv2Fj7cTgLI,1821
|
|
35
|
+
bTagScript/block/discord_blocks/react_block.py,sha256=PsAwUBCMqFlBthOiAxKb5DYWX8xd7WUZUcZ8cTR9zWo,1172
|
|
36
|
+
bTagScript/block/discord_blocks/redirect_block.py,sha256=922cpMG5Xx0u1KIpgYpm4viX4_Rb_Ah_18zZ0is4sTo,1058
|
|
37
|
+
bTagScript/block/discord_blocks/requirement_blocks.py,sha256=Ye2dJfz5rkKlm0gpFtYlXQ6miqi1_lN8U_R_pa6FkgM,2705
|
|
38
|
+
bTagScript/block/util_blocks/__init__.py,sha256=nW8p-hVzfe4x7JFdquxsXYJ986R3RCEoS5JWp9bFgKA,63
|
|
39
|
+
bTagScript/block/util_blocks/debug_block.py,sha256=qgbctMsiTYfbwczrKAs2t09UNPyOTC0SimZWH-_7vkg,3648
|
|
40
|
+
bTagScript/interface/__init__.py,sha256=5cucWLD_IOaY_4ieBFKrXRD7hMjq3_1Lkngu5QrSiIo,130
|
|
41
|
+
bTagScript/interface/adapter.py,sha256=MHxNpxxH1TGCkz63oTJy4uJn7AySGG9w_6jL2aZfiMo,1034
|
|
42
|
+
bTagScript/interface/block.py,sha256=ArLJfzwqOb0lHmC6PFC7eaz1cPuDwb53r2k1KOwnwpg,3989
|
|
43
|
+
btagscript-5.0.0.dist-info/licenses/LICENSE,sha256=2JAqKbLuI4fB064W9rysng3PBsiXmGQlVhL58RdydfA,251
|
|
44
|
+
btagscript-5.0.0.dist-info/METADATA,sha256=xfxYuLwY6tGS3oVA9Qm8Bv82yVEUXZQU2PgR45CaPmY,3072
|
|
45
|
+
btagscript-5.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
46
|
+
btagscript-5.0.0.dist-info/top_level.txt,sha256=4O2u2BGSi-nTv5pHpNd16yMrxkp0wSmhG6I5e0fEm-U,11
|
|
47
|
+
btagscript-5.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bTagScript
|