sniptools 0.1.0__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.
- sniptools-0.1.0/.gitattributes +5 -0
- sniptools-0.1.0/.gitignore +48 -0
- sniptools-0.1.0/LICENSE.md +188 -0
- sniptools-0.1.0/PKG-INFO +234 -0
- sniptools-0.1.0/README.md +27 -0
- sniptools-0.1.0/pyproject.toml +31 -0
- sniptools-0.1.0/src/sniptools/__init__.py +3 -0
- sniptools-0.1.0/src/sniptools/emoji/__init__.py +3 -0
- sniptools-0.1.0/src/sniptools/emoji/rename.py +414 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# === Local files and directories ===
|
|
2
|
+
.local
|
|
3
|
+
|
|
4
|
+
# === Environment variables ===
|
|
5
|
+
.env
|
|
6
|
+
.env*
|
|
7
|
+
*.env
|
|
8
|
+
|
|
9
|
+
# === virtual environment ===
|
|
10
|
+
.venv/
|
|
11
|
+
|
|
12
|
+
# === Cache ===
|
|
13
|
+
**/__pycache__
|
|
14
|
+
cache
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
|
|
18
|
+
# === Jetbrains ===
|
|
19
|
+
.idea/
|
|
20
|
+
|
|
21
|
+
# === Byte-compiled / optimized / DLL files ===
|
|
22
|
+
*.py[cod]
|
|
23
|
+
*$py.class
|
|
24
|
+
|
|
25
|
+
# === Distribution / packaging ===
|
|
26
|
+
.Python
|
|
27
|
+
build/
|
|
28
|
+
develop-eggs/
|
|
29
|
+
dist/
|
|
30
|
+
downloads/
|
|
31
|
+
eggs/
|
|
32
|
+
.eggs/
|
|
33
|
+
lib/
|
|
34
|
+
lib64/
|
|
35
|
+
parts/
|
|
36
|
+
sdist/
|
|
37
|
+
var/
|
|
38
|
+
wheels/
|
|
39
|
+
share/python-wheels/
|
|
40
|
+
*.egg-info/
|
|
41
|
+
.installed.cfg
|
|
42
|
+
*.egg
|
|
43
|
+
MANIFEST
|
|
44
|
+
|
|
45
|
+
# === Unit test / coverage reports ===
|
|
46
|
+
htmlcov/
|
|
47
|
+
.tox/
|
|
48
|
+
.coverage
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
**Copyright 2026 Micha Grandel**
|
|
2
|
+
|
|
3
|
+
Licensed under the **Apache License**, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
*Full license text:*
|
|
18
|
+
|
|
19
|
+
Apache License
|
|
20
|
+
==============
|
|
21
|
+
|
|
22
|
+
_Version 2.0, January 2004_
|
|
23
|
+
_<<http://www.apache.org/licenses/>>_
|
|
24
|
+
|
|
25
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
26
|
+
|
|
27
|
+
#### 1. Definitions
|
|
28
|
+
|
|
29
|
+
***“License”*** shall mean the terms and conditions for use, reproduction, and
|
|
30
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
31
|
+
|
|
32
|
+
***“Licensor”*** shall mean the copyright owner or entity authorized by
|
|
33
|
+
the copyright owner that is granting the License.
|
|
34
|
+
|
|
35
|
+
***“Legal Entity”*** shall mean the union of the acting entity and all other
|
|
36
|
+
entities that control, are controlled by, or are under common control with that
|
|
37
|
+
entity. For the purposes of this definition, “control” means **(i)** the power,
|
|
38
|
+
direct or indirect, to cause the direction or management of such entity,
|
|
39
|
+
whether by contract or otherwise, or **(ii)** ownership of fifty percent (50%)
|
|
40
|
+
or more of the outstanding shares, or **(iii)** beneficial ownership of such entity.
|
|
41
|
+
|
|
42
|
+
***“You”*** (or “Your”) shall mean an individual or Legal Entity exercising
|
|
43
|
+
permissions granted by this License.
|
|
44
|
+
|
|
45
|
+
***“Source”*** form shall mean the preferred form for making modifications,
|
|
46
|
+
including but not limited to software source code, documentation source, and
|
|
47
|
+
configuration files.
|
|
48
|
+
|
|
49
|
+
***“Object”*** form shall mean any form resulting from mechanical transformation
|
|
50
|
+
or translation of a Source form, including but not limited to compiled object code,
|
|
51
|
+
generated documentation, and conversions to other media types.
|
|
52
|
+
|
|
53
|
+
***“Work”*** shall mean the work of authorship, whether in Source or Object form,
|
|
54
|
+
made available under the License, as indicated by a copyright notice that is
|
|
55
|
+
included in or attached to the work (an example is provided in the Appendix below).
|
|
56
|
+
|
|
57
|
+
***“Derivative Works”*** shall mean any work, whether in Source or Object form,
|
|
58
|
+
that is based on (or derived from) the Work and for which the editorial revisions,
|
|
59
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
60
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
61
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
62
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
63
|
+
|
|
64
|
+
***“Contribution”*** shall mean any work of authorship, including the original
|
|
65
|
+
version of the Work and any modifications or additions to that Work or
|
|
66
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
67
|
+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
68
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this
|
|
69
|
+
definition, “submitted” means any form of electronic, verbal, or
|
|
70
|
+
written communication sent to the Licensor or its representatives, including
|
|
71
|
+
but not limited to communication on electronic mailing lists,
|
|
72
|
+
source code control systems, and issue tracking systems that are managed by, or
|
|
73
|
+
on behalf of, the Licensor for the purpose of discussing and improving the Work,
|
|
74
|
+
but excluding communication that is conspicuously marked or otherwise designated
|
|
75
|
+
in writing by the copyright owner as “Not a Contribution.”
|
|
76
|
+
|
|
77
|
+
***“Contributor”*** shall mean Licensor and any individual or Legal Entity
|
|
78
|
+
on behalf of whom a Contribution has been received by Licensor and subsequently
|
|
79
|
+
incorporated within the Work.
|
|
80
|
+
|
|
81
|
+
#### 2. Grant of Copyright License
|
|
82
|
+
|
|
83
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
84
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
85
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
86
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
87
|
+
Derivative Works in Source or Object form.
|
|
88
|
+
|
|
89
|
+
#### 3. Grant of Patent License
|
|
90
|
+
|
|
91
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
92
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
93
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
94
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
95
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
96
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
97
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
98
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
99
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
100
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
101
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
102
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
103
|
+
|
|
104
|
+
#### 4. Redistribution
|
|
105
|
+
|
|
106
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
107
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
108
|
+
provided that You meet the following conditions:
|
|
109
|
+
|
|
110
|
+
* **(a)** You must give any other recipients of the Work or Derivative Works
|
|
111
|
+
a copy of this License; and
|
|
112
|
+
* **(b)** You must cause any modified files to carry prominent notices stating
|
|
113
|
+
that You changed the files; and
|
|
114
|
+
* **(c)** You must retain, in the Source form of any Derivative Works that You
|
|
115
|
+
distribute, all copyright, patent, trademark, and attribution notices from
|
|
116
|
+
the Source form of the Work, excluding those notices that do not pertain to
|
|
117
|
+
any part of the Derivative Works; and
|
|
118
|
+
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution,
|
|
119
|
+
then any Derivative Works that You distribute must include a readable copy of the
|
|
120
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
121
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
122
|
+
following places: within a NOTICE text file distributed as part of the
|
|
123
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
124
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
125
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
126
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
127
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
128
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
129
|
+
provided that such additional attribution notices cannot be construed as
|
|
130
|
+
modifying the License.
|
|
131
|
+
|
|
132
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
133
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
134
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
135
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
136
|
+
with the conditions stated in this License.
|
|
137
|
+
|
|
138
|
+
#### 5. Submission of Contributions
|
|
139
|
+
|
|
140
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
141
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
142
|
+
conditions of this License, without any additional terms or conditions.
|
|
143
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
144
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
145
|
+
such Contributions.
|
|
146
|
+
|
|
147
|
+
#### 6. Trademarks
|
|
148
|
+
|
|
149
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
150
|
+
service marks, or product names of the Licensor, except as required for
|
|
151
|
+
reasonable and customary use in describing the origin of the Work and
|
|
152
|
+
reproducing the content of the NOTICE file.
|
|
153
|
+
|
|
154
|
+
#### 7. Disclaimer of Warranty
|
|
155
|
+
|
|
156
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
157
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
158
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
159
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
160
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
161
|
+
solely responsible for determining the appropriateness of using or
|
|
162
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
163
|
+
permissions under this License.
|
|
164
|
+
|
|
165
|
+
#### 8. Limitation of Liability
|
|
166
|
+
|
|
167
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
168
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
169
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
170
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
171
|
+
or consequential damages of any character arising as a result of this License or
|
|
172
|
+
out of the use or inability to use the Work (including but not limited to
|
|
173
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
174
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
175
|
+
been advised of the possibility of such damages.
|
|
176
|
+
|
|
177
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
178
|
+
|
|
179
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
180
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
181
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
182
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
183
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
184
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
185
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
186
|
+
accepting any such warranty or additional liability.
|
|
187
|
+
|
|
188
|
+
*END OF TERMS AND CONDITIONS*
|
sniptools-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: sniptools
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A collection of useful tools for developers.
|
|
5
|
+
Author-email: Micha Grandel <michagrandel@proton.me>
|
|
6
|
+
License: **Copyright 2026 Micha Grandel**
|
|
7
|
+
|
|
8
|
+
Licensed under the **Apache License**, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
*Full license text:*
|
|
23
|
+
|
|
24
|
+
Apache License
|
|
25
|
+
==============
|
|
26
|
+
|
|
27
|
+
_Version 2.0, January 2004_
|
|
28
|
+
_<<http://www.apache.org/licenses/>>_
|
|
29
|
+
|
|
30
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
31
|
+
|
|
32
|
+
#### 1. Definitions
|
|
33
|
+
|
|
34
|
+
***“License”*** shall mean the terms and conditions for use, reproduction, and
|
|
35
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
36
|
+
|
|
37
|
+
***“Licensor”*** shall mean the copyright owner or entity authorized by
|
|
38
|
+
the copyright owner that is granting the License.
|
|
39
|
+
|
|
40
|
+
***“Legal Entity”*** shall mean the union of the acting entity and all other
|
|
41
|
+
entities that control, are controlled by, or are under common control with that
|
|
42
|
+
entity. For the purposes of this definition, “control” means **(i)** the power,
|
|
43
|
+
direct or indirect, to cause the direction or management of such entity,
|
|
44
|
+
whether by contract or otherwise, or **(ii)** ownership of fifty percent (50%)
|
|
45
|
+
or more of the outstanding shares, or **(iii)** beneficial ownership of such entity.
|
|
46
|
+
|
|
47
|
+
***“You”*** (or “Your”) shall mean an individual or Legal Entity exercising
|
|
48
|
+
permissions granted by this License.
|
|
49
|
+
|
|
50
|
+
***“Source”*** form shall mean the preferred form for making modifications,
|
|
51
|
+
including but not limited to software source code, documentation source, and
|
|
52
|
+
configuration files.
|
|
53
|
+
|
|
54
|
+
***“Object”*** form shall mean any form resulting from mechanical transformation
|
|
55
|
+
or translation of a Source form, including but not limited to compiled object code,
|
|
56
|
+
generated documentation, and conversions to other media types.
|
|
57
|
+
|
|
58
|
+
***“Work”*** shall mean the work of authorship, whether in Source or Object form,
|
|
59
|
+
made available under the License, as indicated by a copyright notice that is
|
|
60
|
+
included in or attached to the work (an example is provided in the Appendix below).
|
|
61
|
+
|
|
62
|
+
***“Derivative Works”*** shall mean any work, whether in Source or Object form,
|
|
63
|
+
that is based on (or derived from) the Work and for which the editorial revisions,
|
|
64
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
65
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
66
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
67
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
68
|
+
|
|
69
|
+
***“Contribution”*** shall mean any work of authorship, including the original
|
|
70
|
+
version of the Work and any modifications or additions to that Work or
|
|
71
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
72
|
+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
73
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this
|
|
74
|
+
definition, “submitted” means any form of electronic, verbal, or
|
|
75
|
+
written communication sent to the Licensor or its representatives, including
|
|
76
|
+
but not limited to communication on electronic mailing lists,
|
|
77
|
+
source code control systems, and issue tracking systems that are managed by, or
|
|
78
|
+
on behalf of, the Licensor for the purpose of discussing and improving the Work,
|
|
79
|
+
but excluding communication that is conspicuously marked or otherwise designated
|
|
80
|
+
in writing by the copyright owner as “Not a Contribution.”
|
|
81
|
+
|
|
82
|
+
***“Contributor”*** shall mean Licensor and any individual or Legal Entity
|
|
83
|
+
on behalf of whom a Contribution has been received by Licensor and subsequently
|
|
84
|
+
incorporated within the Work.
|
|
85
|
+
|
|
86
|
+
#### 2. Grant of Copyright License
|
|
87
|
+
|
|
88
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
89
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
90
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
91
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
92
|
+
Derivative Works in Source or Object form.
|
|
93
|
+
|
|
94
|
+
#### 3. Grant of Patent License
|
|
95
|
+
|
|
96
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
97
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
98
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
99
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
100
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
101
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
102
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
103
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
104
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
105
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
106
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
107
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
108
|
+
|
|
109
|
+
#### 4. Redistribution
|
|
110
|
+
|
|
111
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
112
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
113
|
+
provided that You meet the following conditions:
|
|
114
|
+
|
|
115
|
+
* **(a)** You must give any other recipients of the Work or Derivative Works
|
|
116
|
+
a copy of this License; and
|
|
117
|
+
* **(b)** You must cause any modified files to carry prominent notices stating
|
|
118
|
+
that You changed the files; and
|
|
119
|
+
* **(c)** You must retain, in the Source form of any Derivative Works that You
|
|
120
|
+
distribute, all copyright, patent, trademark, and attribution notices from
|
|
121
|
+
the Source form of the Work, excluding those notices that do not pertain to
|
|
122
|
+
any part of the Derivative Works; and
|
|
123
|
+
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution,
|
|
124
|
+
then any Derivative Works that You distribute must include a readable copy of the
|
|
125
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
126
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
127
|
+
following places: within a NOTICE text file distributed as part of the
|
|
128
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
129
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
130
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
131
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
132
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
133
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
134
|
+
provided that such additional attribution notices cannot be construed as
|
|
135
|
+
modifying the License.
|
|
136
|
+
|
|
137
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
138
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
139
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
140
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
141
|
+
with the conditions stated in this License.
|
|
142
|
+
|
|
143
|
+
#### 5. Submission of Contributions
|
|
144
|
+
|
|
145
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
146
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
147
|
+
conditions of this License, without any additional terms or conditions.
|
|
148
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
149
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
150
|
+
such Contributions.
|
|
151
|
+
|
|
152
|
+
#### 6. Trademarks
|
|
153
|
+
|
|
154
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
155
|
+
service marks, or product names of the Licensor, except as required for
|
|
156
|
+
reasonable and customary use in describing the origin of the Work and
|
|
157
|
+
reproducing the content of the NOTICE file.
|
|
158
|
+
|
|
159
|
+
#### 7. Disclaimer of Warranty
|
|
160
|
+
|
|
161
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
162
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
163
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
164
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
165
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
166
|
+
solely responsible for determining the appropriateness of using or
|
|
167
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
168
|
+
permissions under this License.
|
|
169
|
+
|
|
170
|
+
#### 8. Limitation of Liability
|
|
171
|
+
|
|
172
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
173
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
174
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
175
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
176
|
+
or consequential damages of any character arising as a result of this License or
|
|
177
|
+
out of the use or inability to use the Work (including but not limited to
|
|
178
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
179
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
180
|
+
been advised of the possibility of such damages.
|
|
181
|
+
|
|
182
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
183
|
+
|
|
184
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
185
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
186
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
187
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
188
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
189
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
190
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
191
|
+
accepting any such warranty or additional liability.
|
|
192
|
+
|
|
193
|
+
*END OF TERMS AND CONDITIONS*
|
|
194
|
+
License-File: LICENSE.md
|
|
195
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
196
|
+
Classifier: Intended Audience :: Developers
|
|
197
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
198
|
+
Classifier: Operating System :: OS Independent
|
|
199
|
+
Classifier: Programming Language :: Python :: 3
|
|
200
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
201
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
202
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
203
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
204
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
205
|
+
Requires-Python: >=3.13
|
|
206
|
+
Description-Content-Type: text/markdown
|
|
207
|
+
|
|
208
|
+
# SnipTools
|
|
209
|
+
|
|
210
|
+
A collection of small utility tools.
|
|
211
|
+
|
|
212
|
+
## Emoji Renamer
|
|
213
|
+
|
|
214
|
+
Rename Unicode-named SVG emoji files to descriptive names and sort them into category folders.
|
|
215
|
+
|
|
216
|
+
### Requirements
|
|
217
|
+
|
|
218
|
+
- Python 3.13 or later
|
|
219
|
+
|
|
220
|
+
### Usage
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
python emoji_renamer.py path/to/svg-folder
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The tool processes SVG files in the specified folder (not its subfolders), renames them using Unicode emoji descriptions, and moves them into category folders such as `people_body` and `symbols`. Files without recognized Unicode code points and files that would overwrite an existing file are skipped.
|
|
227
|
+
|
|
228
|
+
This changes files in place. Keep a backup if you need to preserve the original filenames.
|
|
229
|
+
|
|
230
|
+
### Tests
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
python -m unittest discover -s tests
|
|
234
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# SnipTools
|
|
2
|
+
|
|
3
|
+
A collection of small utility tools.
|
|
4
|
+
|
|
5
|
+
## Emoji Renamer
|
|
6
|
+
|
|
7
|
+
Rename Unicode-named SVG emoji files to descriptive names and sort them into category folders.
|
|
8
|
+
|
|
9
|
+
### Requirements
|
|
10
|
+
|
|
11
|
+
- Python 3.13 or later
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python emoji_renamer.py path/to/svg-folder
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The tool processes SVG files in the specified folder (not its subfolders), renames them using Unicode emoji descriptions, and moves them into category folders such as `people_body` and `symbols`. Files without recognized Unicode code points and files that would overwrite an existing file are skipped.
|
|
20
|
+
|
|
21
|
+
This changes files in place. Keep a backup if you need to preserve the original filenames.
|
|
22
|
+
|
|
23
|
+
### Tests
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python -m unittest discover -s tests
|
|
27
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sniptools"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Micha Grandel", email = "michagrandel@proton.me" },
|
|
10
|
+
]
|
|
11
|
+
description = "A collection of useful tools for developers."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = { file = "LICENSE.md" }
|
|
14
|
+
requires-python = ">=3.13"
|
|
15
|
+
dependencies = []
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: Apache Software License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Software Development :: Libraries",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
rename-emoji = "sniptools.emoji.rename:main"
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Micha Grandel
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
import unicodedata
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Iterable
|
|
13
|
+
|
|
14
|
+
SKIN_TONE_MODIFIERS = {
|
|
15
|
+
"1f3fb": "light_skin_tone",
|
|
16
|
+
"1f3fc": "medium_light_skin_tone",
|
|
17
|
+
"1f3fd": "medium_skin_tone",
|
|
18
|
+
"1f3fe": "medium_dark_skin_tone",
|
|
19
|
+
"1f3ff": "dark_skin_tone",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
IGNORED_CODEPOINTS = {0x200D, 0xFE0F, 0x20E3}
|
|
23
|
+
SPECIAL_EMOJI_DESCRIPTIONS = {
|
|
24
|
+
(0x2764, 0x1F525): "heart_with_fire",
|
|
25
|
+
}
|
|
26
|
+
SPECIAL_EMOJI_CATEGORIES = {
|
|
27
|
+
(0x2764,): "symbols",
|
|
28
|
+
(0x2764, 0x1F525): "symbols",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
CATEGORY_KEYWORDS = {
|
|
32
|
+
"smileys_emotion": {
|
|
33
|
+
"FACE",
|
|
34
|
+
"SMILE",
|
|
35
|
+
"SMILING",
|
|
36
|
+
"GRIN",
|
|
37
|
+
"WINK",
|
|
38
|
+
"KISS",
|
|
39
|
+
"LOVE",
|
|
40
|
+
"HUG",
|
|
41
|
+
"THINK",
|
|
42
|
+
"CRY",
|
|
43
|
+
"SAD",
|
|
44
|
+
"ANGRY",
|
|
45
|
+
"SCREAM",
|
|
46
|
+
"TONGUE",
|
|
47
|
+
"SWEAT",
|
|
48
|
+
"DIZZY",
|
|
49
|
+
"SHOCK",
|
|
50
|
+
"SLEEP",
|
|
51
|
+
"ZANY",
|
|
52
|
+
"MELT",
|
|
53
|
+
"HUSH",
|
|
54
|
+
"PENSIVE",
|
|
55
|
+
"FROWN",
|
|
56
|
+
"TEARS",
|
|
57
|
+
"RAGE",
|
|
58
|
+
"DEVIL",
|
|
59
|
+
"ANGUISH",
|
|
60
|
+
},
|
|
61
|
+
"people_body": {
|
|
62
|
+
"HAND",
|
|
63
|
+
"PERSON",
|
|
64
|
+
"MAN",
|
|
65
|
+
"WOMAN",
|
|
66
|
+
"FAMILY",
|
|
67
|
+
"BABY",
|
|
68
|
+
"CHILD",
|
|
69
|
+
"OLDER",
|
|
70
|
+
"ELDER",
|
|
71
|
+
"BODY",
|
|
72
|
+
"LEG",
|
|
73
|
+
"ARM",
|
|
74
|
+
"FOOT",
|
|
75
|
+
"FINGER",
|
|
76
|
+
"NOSE",
|
|
77
|
+
"MOUTH",
|
|
78
|
+
"EAR",
|
|
79
|
+
"EYE",
|
|
80
|
+
"BRAIN",
|
|
81
|
+
"HUMAN",
|
|
82
|
+
"PEOPLE",
|
|
83
|
+
},
|
|
84
|
+
"food_drink": {
|
|
85
|
+
"FOOD",
|
|
86
|
+
"DRINK",
|
|
87
|
+
"BREAD",
|
|
88
|
+
"BURGER",
|
|
89
|
+
"PIZZA",
|
|
90
|
+
"PASTA",
|
|
91
|
+
"SUSHI",
|
|
92
|
+
"ICE",
|
|
93
|
+
"CAKE",
|
|
94
|
+
"COOKIE",
|
|
95
|
+
"CHOCOLATE",
|
|
96
|
+
"CUP",
|
|
97
|
+
"TEA",
|
|
98
|
+
"COFFEE",
|
|
99
|
+
"BEER",
|
|
100
|
+
"WINE",
|
|
101
|
+
"BOWL",
|
|
102
|
+
"SPOON",
|
|
103
|
+
"FORK",
|
|
104
|
+
"KNIFE",
|
|
105
|
+
"SANDWICH",
|
|
106
|
+
"DUMPLING",
|
|
107
|
+
"TACO",
|
|
108
|
+
"BURRITO",
|
|
109
|
+
"BENTO",
|
|
110
|
+
"CROISSANT",
|
|
111
|
+
},
|
|
112
|
+
"animals_nature": {
|
|
113
|
+
"ANIMAL",
|
|
114
|
+
"BIRD",
|
|
115
|
+
"CAT",
|
|
116
|
+
"DOG",
|
|
117
|
+
"PENGUIN",
|
|
118
|
+
"BUNNY",
|
|
119
|
+
"FOX",
|
|
120
|
+
"BEAR",
|
|
121
|
+
"PANDA",
|
|
122
|
+
"TIGER",
|
|
123
|
+
"LION",
|
|
124
|
+
"COW",
|
|
125
|
+
"PIG",
|
|
126
|
+
"FROG",
|
|
127
|
+
"MONKEY",
|
|
128
|
+
"MOUSE",
|
|
129
|
+
"RABBIT",
|
|
130
|
+
"FISH",
|
|
131
|
+
"WHALE",
|
|
132
|
+
"DOLPHIN",
|
|
133
|
+
"UNICORN",
|
|
134
|
+
"CHICKEN",
|
|
135
|
+
"DUCK",
|
|
136
|
+
"EAGLE",
|
|
137
|
+
"OWL",
|
|
138
|
+
"BEE",
|
|
139
|
+
"BUG",
|
|
140
|
+
"SPIDER",
|
|
141
|
+
"CLOUD",
|
|
142
|
+
"SUN",
|
|
143
|
+
"MOON",
|
|
144
|
+
"STAR",
|
|
145
|
+
"TREE",
|
|
146
|
+
"FLOWER",
|
|
147
|
+
"LEAF",
|
|
148
|
+
"MUSHROOM",
|
|
149
|
+
"MOUNTAIN",
|
|
150
|
+
"WAVE",
|
|
151
|
+
"ROCK",
|
|
152
|
+
"DESERT",
|
|
153
|
+
"OCEAN",
|
|
154
|
+
},
|
|
155
|
+
"travel_places": {
|
|
156
|
+
"CAR",
|
|
157
|
+
"TRUCK",
|
|
158
|
+
"BUS",
|
|
159
|
+
"TAXI",
|
|
160
|
+
"AUTO",
|
|
161
|
+
"AIRPLANE",
|
|
162
|
+
"ROCKET",
|
|
163
|
+
"SHIP",
|
|
164
|
+
"BOAT",
|
|
165
|
+
"BICYCLE",
|
|
166
|
+
"MOTORCYCLE",
|
|
167
|
+
"SCOOTER",
|
|
168
|
+
"TRAIN",
|
|
169
|
+
"STATION",
|
|
170
|
+
"TENT",
|
|
171
|
+
"BUILDING",
|
|
172
|
+
"HOUSE",
|
|
173
|
+
"HOTEL",
|
|
174
|
+
"ROAD",
|
|
175
|
+
"MAP",
|
|
176
|
+
"PARK",
|
|
177
|
+
"BEACH",
|
|
178
|
+
"ISLAND",
|
|
179
|
+
"CITY",
|
|
180
|
+
"TOWER",
|
|
181
|
+
"BRIDGE",
|
|
182
|
+
},
|
|
183
|
+
"activities": {
|
|
184
|
+
"SPORT",
|
|
185
|
+
"GAME",
|
|
186
|
+
"BALL",
|
|
187
|
+
"TROPHY",
|
|
188
|
+
"MEDAL",
|
|
189
|
+
"GUITAR",
|
|
190
|
+
"DRUM",
|
|
191
|
+
"MUSICAL",
|
|
192
|
+
"MARTIAL",
|
|
193
|
+
"FISHING",
|
|
194
|
+
"BOWLING",
|
|
195
|
+
"GOLF",
|
|
196
|
+
"SKI",
|
|
197
|
+
"SURF",
|
|
198
|
+
"RACING",
|
|
199
|
+
"RUGBY",
|
|
200
|
+
"BASKETBALL",
|
|
201
|
+
"CHESS",
|
|
202
|
+
},
|
|
203
|
+
"objects": {
|
|
204
|
+
"BAG",
|
|
205
|
+
"WATCH",
|
|
206
|
+
"PHONE",
|
|
207
|
+
"KEYBOARD",
|
|
208
|
+
"LAPTOP",
|
|
209
|
+
"MOUSE",
|
|
210
|
+
"COMPUTER",
|
|
211
|
+
"CAMERA",
|
|
212
|
+
"BOOK",
|
|
213
|
+
"PEN",
|
|
214
|
+
"PENCIL",
|
|
215
|
+
"SCISSORS",
|
|
216
|
+
"LOCK",
|
|
217
|
+
"KEY",
|
|
218
|
+
"HAMMER",
|
|
219
|
+
"TRUCK",
|
|
220
|
+
"BALLOON",
|
|
221
|
+
"GIFT",
|
|
222
|
+
"RIBBON",
|
|
223
|
+
"PRESENT",
|
|
224
|
+
"DART",
|
|
225
|
+
"BOW",
|
|
226
|
+
"ARROW",
|
|
227
|
+
"MEDICINE",
|
|
228
|
+
"MAGNET",
|
|
229
|
+
"MIRROR",
|
|
230
|
+
"FIRE",
|
|
231
|
+
},
|
|
232
|
+
"symbols": {
|
|
233
|
+
"HEART",
|
|
234
|
+
"SPARKLES",
|
|
235
|
+
"CROSS",
|
|
236
|
+
"CHECK",
|
|
237
|
+
"QUESTION",
|
|
238
|
+
"EXCLAMATION",
|
|
239
|
+
"PLUS",
|
|
240
|
+
"MINUS",
|
|
241
|
+
"ASTERISK",
|
|
242
|
+
"SIGN",
|
|
243
|
+
"SYMBOL",
|
|
244
|
+
"TICKET",
|
|
245
|
+
"MUSIC",
|
|
246
|
+
"NUMBER",
|
|
247
|
+
"BUTTON",
|
|
248
|
+
"LABEL",
|
|
249
|
+
"CURRENCY",
|
|
250
|
+
"PIN",
|
|
251
|
+
"JOKER",
|
|
252
|
+
"TOP",
|
|
253
|
+
"FLAG",
|
|
254
|
+
},
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def rename_svg_files(folder_path: str | Path) -> int:
|
|
259
|
+
folder = Path(folder_path)
|
|
260
|
+
if not folder.exists():
|
|
261
|
+
raise FileNotFoundError(f"Folder does not exist: {folder}")
|
|
262
|
+
if not folder.is_dir():
|
|
263
|
+
raise NotADirectoryError(f"Not a directory: {folder}")
|
|
264
|
+
|
|
265
|
+
renamed_count = 0
|
|
266
|
+
svg_files = sorted(
|
|
267
|
+
path for path in folder.iterdir() if path.is_file() and path.suffix.lower() == ".svg"
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
for source_path in svg_files:
|
|
271
|
+
try:
|
|
272
|
+
codepoints = _parse_codepoints(source_path.stem)
|
|
273
|
+
new_name = f"{_get_emoji_description(codepoints)}.svg"
|
|
274
|
+
category = _get_category(codepoints)
|
|
275
|
+
except ValueError as exc:
|
|
276
|
+
print(f"Skipping {source_path.name}: {exc}", file=sys.stderr)
|
|
277
|
+
continue
|
|
278
|
+
|
|
279
|
+
if source_path.name == new_name:
|
|
280
|
+
pass
|
|
281
|
+
else:
|
|
282
|
+
target_path = source_path.with_name(new_name)
|
|
283
|
+
if target_path.exists() and target_path != source_path:
|
|
284
|
+
print(f"Skipping {source_path.name}: target already exists ({target_path.name})", file=sys.stderr)
|
|
285
|
+
continue
|
|
286
|
+
source_path.rename(target_path)
|
|
287
|
+
source_path = target_path
|
|
288
|
+
renamed_count += 1
|
|
289
|
+
|
|
290
|
+
category_dir = folder / category
|
|
291
|
+
category_dir.mkdir(exist_ok=True)
|
|
292
|
+
destination_path = category_dir / source_path.name
|
|
293
|
+
if destination_path.exists() and destination_path != source_path:
|
|
294
|
+
print(f"Skipping {source_path.name}: target already exists ({destination_path.name})", file=sys.stderr)
|
|
295
|
+
continue
|
|
296
|
+
if source_path.parent != category_dir:
|
|
297
|
+
source_path.rename(destination_path)
|
|
298
|
+
|
|
299
|
+
return renamed_count
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def _parse_codepoints(file_name: str) -> list[int]:
|
|
303
|
+
stem = Path(file_name).stem
|
|
304
|
+
if stem.startswith("emoji_"):
|
|
305
|
+
stem = stem[len("emoji_") :]
|
|
306
|
+
|
|
307
|
+
parts = stem.split("_")
|
|
308
|
+
codepoints: list[int] = []
|
|
309
|
+
found_unicode_token = False
|
|
310
|
+
for part in parts:
|
|
311
|
+
if not part:
|
|
312
|
+
continue
|
|
313
|
+
if part.startswith("u"):
|
|
314
|
+
part = part[1:]
|
|
315
|
+
found_unicode_token = True
|
|
316
|
+
else:
|
|
317
|
+
if not re.fullmatch(r"[0-9a-fA-F]+", part):
|
|
318
|
+
continue
|
|
319
|
+
try:
|
|
320
|
+
codepoints.append(int(part, 16))
|
|
321
|
+
except ValueError:
|
|
322
|
+
raise ValueError(f"Unsupported emoji token: {part}") from None
|
|
323
|
+
|
|
324
|
+
if not found_unicode_token:
|
|
325
|
+
raise ValueError("No unicode token found in file name")
|
|
326
|
+
return codepoints
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def _get_emoji_description(codepoints: Iterable[int]) -> str:
|
|
330
|
+
codepoint_list = list(codepoints)
|
|
331
|
+
if not codepoint_list:
|
|
332
|
+
raise ValueError("No emoji codepoints found")
|
|
333
|
+
|
|
334
|
+
if codepoint_list[-1] in {0x1F3FB, 0x1F3FC, 0x1F3FD, 0x1F3FE, 0x1F3FF}:
|
|
335
|
+
modifier_codepoint = codepoint_list.pop()
|
|
336
|
+
modifier_name = SKIN_TONE_MODIFIERS.get(f"{modifier_codepoint:04x}")
|
|
337
|
+
if modifier_name is None:
|
|
338
|
+
raise ValueError(f"Unsupported skin tone modifier {modifier_codepoint:#x}")
|
|
339
|
+
else:
|
|
340
|
+
modifier_name = None
|
|
341
|
+
|
|
342
|
+
normalized_codepoints = tuple(
|
|
343
|
+
codepoint for codepoint in codepoint_list if codepoint not in IGNORED_CODEPOINTS
|
|
344
|
+
)
|
|
345
|
+
if normalized_codepoints in SPECIAL_EMOJI_DESCRIPTIONS:
|
|
346
|
+
description = SPECIAL_EMOJI_DESCRIPTIONS[normalized_codepoints]
|
|
347
|
+
else:
|
|
348
|
+
names: list[str] = []
|
|
349
|
+
for codepoint in normalized_codepoints:
|
|
350
|
+
try:
|
|
351
|
+
names.append(unicodedata.name(chr(codepoint)))
|
|
352
|
+
except ValueError:
|
|
353
|
+
continue
|
|
354
|
+
if not names:
|
|
355
|
+
raise ValueError(f"No Unicode name found for code point {codepoint_list[0]:#x}")
|
|
356
|
+
description = _slugify(" ".join(names))
|
|
357
|
+
|
|
358
|
+
if modifier_name:
|
|
359
|
+
description = f"{description}_{modifier_name}"
|
|
360
|
+
return description
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def _slugify(value: str) -> str:
|
|
364
|
+
return re.sub(r"[^a-z0-9]+", "_", value.lower()).strip("_")
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def _get_category(codepoints: Iterable[int]) -> str:
|
|
368
|
+
codepoint_list = list(codepoints)
|
|
369
|
+
if not codepoint_list:
|
|
370
|
+
raise ValueError("No emoji codepoints found")
|
|
371
|
+
|
|
372
|
+
if codepoint_list[-1] in {0x1F3FB, 0x1F3FC, 0x1F3FD, 0x1F3FE, 0x1F3FF}:
|
|
373
|
+
codepoint_list = codepoint_list[:-1]
|
|
374
|
+
|
|
375
|
+
significant_codepoints = [
|
|
376
|
+
codepoint for codepoint in codepoint_list if codepoint not in IGNORED_CODEPOINTS
|
|
377
|
+
]
|
|
378
|
+
|
|
379
|
+
if any(0x1F1E6 <= codepoint <= 0x1F1FF for codepoint in significant_codepoints):
|
|
380
|
+
return "flags"
|
|
381
|
+
|
|
382
|
+
normalized_codepoints = tuple(codepoint for codepoint in significant_codepoints if codepoint not in IGNORED_CODEPOINTS)
|
|
383
|
+
if normalized_codepoints in SPECIAL_EMOJI_CATEGORIES:
|
|
384
|
+
return SPECIAL_EMOJI_CATEGORIES[normalized_codepoints]
|
|
385
|
+
|
|
386
|
+
for category, keywords in CATEGORY_KEYWORDS.items():
|
|
387
|
+
for codepoint in significant_codepoints:
|
|
388
|
+
try:
|
|
389
|
+
name = unicodedata.name(chr(codepoint)).upper()
|
|
390
|
+
except ValueError:
|
|
391
|
+
continue
|
|
392
|
+
if any(keyword in name for keyword in keywords):
|
|
393
|
+
return category
|
|
394
|
+
|
|
395
|
+
if any(0x2600 <= codepoint <= 0x27BF for codepoint in significant_codepoints):
|
|
396
|
+
return "symbols"
|
|
397
|
+
if any(0x1F300 <= codepoint <= 0x1FAFF for codepoint in significant_codepoints):
|
|
398
|
+
return "symbols"
|
|
399
|
+
|
|
400
|
+
raise ValueError("No category found for emoji")
|
|
401
|
+
|
|
402
|
+
def main() -> int:
|
|
403
|
+
parser = argparse.ArgumentParser(description="Rename SVG emoji files to descriptive names.")
|
|
404
|
+
parser.add_argument("folder", help="Folder containing SVG emoji files")
|
|
405
|
+
args = parser.parse_args()
|
|
406
|
+
|
|
407
|
+
try:
|
|
408
|
+
renamed_count = rename_svg_files(args.folder)
|
|
409
|
+
except (FileNotFoundError, NotADirectoryError, ValueError) as exc:
|
|
410
|
+
print(str(exc), file=sys.stderr)
|
|
411
|
+
return 1
|
|
412
|
+
|
|
413
|
+
print(f"Renamed {renamed_count} files.")
|
|
414
|
+
return 0
|