symbolinfo 1.0.1__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.
- symbolinfo-1.0.1/PKG-INFO +7 -0
- symbolinfo-1.0.1/README.md +25 -0
- symbolinfo-1.0.1/pyproject.toml +29 -0
- symbolinfo-1.0.1/setup.cfg +4 -0
- symbolinfo-1.0.1/symbolinfo/__init__.py +1 -0
- symbolinfo-1.0.1/symbolinfo/symbolinfo.py +107 -0
- symbolinfo-1.0.1/symbolinfo.egg-info/PKG-INFO +7 -0
- symbolinfo-1.0.1/symbolinfo.egg-info/SOURCES.txt +9 -0
- symbolinfo-1.0.1/symbolinfo.egg-info/dependency_links.txt +1 -0
- symbolinfo-1.0.1/symbolinfo.egg-info/requires.txt +1 -0
- symbolinfo-1.0.1/symbolinfo.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Hello!
|
|
2
|
+
This module help you to get information of symbol!
|
|
3
|
+
## Installing
|
|
4
|
+
```Bash
|
|
5
|
+
pip install symbolinfo
|
|
6
|
+
```
|
|
7
|
+
## Importing
|
|
8
|
+
```Python
|
|
9
|
+
from symbolinfo import Symbol
|
|
10
|
+
```
|
|
11
|
+
## The rule
|
|
12
|
+
```Python
|
|
13
|
+
info=Symbol(">")
|
|
14
|
+
print(info.is_ascii) # True
|
|
15
|
+
print(info.html.entity) # ['>', '>"]
|
|
16
|
+
|
|
17
|
+
# e. t. c.
|
|
18
|
+
```
|
|
19
|
+
You can see all attributes with `help` or `__doc__`:
|
|
20
|
+
```Python
|
|
21
|
+
help(Symbol)
|
|
22
|
+
# or
|
|
23
|
+
print(Symbol.__doc__)
|
|
24
|
+
```
|
|
25
|
+
This class have approximately 40 attributes. All in docstring!
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "symbolinfo"
|
|
7
|
+
version = "1.0.1"
|
|
8
|
+
description = "Unicode symbol identification and information"
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "Muhəmməd Zeynallı", email = "bildiris15@gmail.com"}
|
|
11
|
+
]
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"unicodedataplus"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .symbolinfo import *
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
from unicodedata import name, category, bidirectional, combining, mirrored, decomposition, normalize
|
|
2
|
+
from html.entities import html5
|
|
3
|
+
from json import dumps
|
|
4
|
+
from urllib.parse import quote
|
|
5
|
+
from base64 import b64encode
|
|
6
|
+
from unicodedataplus import script, block, age, grapheme_cluster_break, is_emoji, is_extended_pictographic
|
|
7
|
+
class Symbol:
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
The attributes(example: Symbol("a").name)
|
|
11
|
+
• char — Original character
|
|
12
|
+
• unicode — Unicode code point
|
|
13
|
+
• name — Unicode character name
|
|
14
|
+
• decimal — Decimal representation
|
|
15
|
+
• hex — Hexadecimal representation
|
|
16
|
+
• html — HTML encoding information
|
|
17
|
+
• html.entity — HTML named entity
|
|
18
|
+
• html.decimal — HTML decimal entity
|
|
19
|
+
• html.hex — HTML hexadecimal entity
|
|
20
|
+
• utf8 — UTF-8 hexadecimal representation
|
|
21
|
+
• octal — Octal representation
|
|
22
|
+
• binary — Binary representation
|
|
23
|
+
• is_ascii — Whether the character belongs to ASCII
|
|
24
|
+
• xml — XML encoding information
|
|
25
|
+
• xml.decimal — XML decimal entity
|
|
26
|
+
• xml.hex — XML hexadecimal entity
|
|
27
|
+
• encode — Encode using the specified encoding
|
|
28
|
+
• python — Python ASCII representation
|
|
29
|
+
• json — JSON representation
|
|
30
|
+
• url — URL percent-encoding
|
|
31
|
+
• base64 — Base64 encoding
|
|
32
|
+
• css — CSS hexadecimal escape
|
|
33
|
+
• c — C-style Unicode escape
|
|
34
|
+
• category — Unicode general category
|
|
35
|
+
• bidirectional — Unicode bidirectional class
|
|
36
|
+
• combining_class — Canonical combining class
|
|
37
|
+
• combining — Combining class value
|
|
38
|
+
• mirrored — Whether the character is mirrored
|
|
39
|
+
• decomposition — Unicode decomposition mapping
|
|
40
|
+
• normalize — Unicode normalization
|
|
41
|
+
• script — Unicode script
|
|
42
|
+
• block — Unicode block
|
|
43
|
+
• version — Unicode version
|
|
44
|
+
• age — Unicode character age
|
|
45
|
+
• grapheme_cluster_break — Grapheme cluster break property
|
|
46
|
+
• is_emoji — Whether the character is an emoji
|
|
47
|
+
• is_pictograph — Whether the character is an extended pictographic character
|
|
48
|
+
• ordinal — Unicode code point as an integer
|
|
49
|
+
• upper — Uppercase form
|
|
50
|
+
• lower — Lowercase form
|
|
51
|
+
• is_upper — Whether the character is uppercase
|
|
52
|
+
• is_lower — Whether the character is lowercase
|
|
53
|
+
• is_digit — Whether the character is a digit
|
|
54
|
+
• is_letter — Whether the character is alphabetic
|
|
55
|
+
"""
|
|
56
|
+
def __init__(self, s):
|
|
57
|
+
if len(s)!=1:
|
|
58
|
+
raise ValueError("The symbol length must be equal to 1, no "+str(len(s)))
|
|
59
|
+
|
|
60
|
+
self.char=s
|
|
61
|
+
self.unicode=f"U+{hex(ord(s))[2:].upper().zfill(4)}"
|
|
62
|
+
self.name=name(s)
|
|
63
|
+
self.decimal=str(ord(s))
|
|
64
|
+
self.hex=hex(ord(s))
|
|
65
|
+
class html:
|
|
66
|
+
def __init__(self):
|
|
67
|
+
e=["&" + name for name, value in html5.items() if value == s and name.endswith(";")]
|
|
68
|
+
self.entity=e[0] if len(e)==1 else e or None
|
|
69
|
+
self.decimal=f"&#{ord(s)};"
|
|
70
|
+
self.hex=f"&#x{hex(ord(s))[2:]};"
|
|
71
|
+
self.html=html()
|
|
72
|
+
self.utf8=s.encode("utf-8").hex(" ").upper()
|
|
73
|
+
self.octal=oct(ord(s))
|
|
74
|
+
self.binary=bin(ord(s))
|
|
75
|
+
self.is_ascii=ord(s)<128
|
|
76
|
+
class xml:
|
|
77
|
+
def __init__(self):
|
|
78
|
+
self.decimal=f"&#{ord(s)};"
|
|
79
|
+
self.hex=f"&#x{hex(ord(s))[2:]};"
|
|
80
|
+
self.xml=xml()
|
|
81
|
+
self.encode=lambda x: s.encode(x).hex(" ").upper()
|
|
82
|
+
self.python=ascii(s)
|
|
83
|
+
self.json=dumps(s, ensure_ascii=True)
|
|
84
|
+
self.url=quote(s)
|
|
85
|
+
self.base64=b64encode(s.encode()).decode()
|
|
86
|
+
self.css=f"\\{hex(ord(s))[2:]}"
|
|
87
|
+
self.c=f"\\U{hex(ord(s))[2:].zfill(8)}"
|
|
88
|
+
self.category=category(s)
|
|
89
|
+
self.bidirectional=bidirectional(s)
|
|
90
|
+
self.combining_class, self.combining=combining(s), combining(s)
|
|
91
|
+
self.mirrored=bool(mirrored(s))
|
|
92
|
+
self.decomposition=decomposition(s) or None
|
|
93
|
+
self.normalize=lambda t: normalize(t, s)
|
|
94
|
+
self.script=script(s)
|
|
95
|
+
self.block=block(s)
|
|
96
|
+
self.version=age(s)
|
|
97
|
+
self.age=age(s)
|
|
98
|
+
self.grapheme_cluster_break=grapheme_cluster_break(s)
|
|
99
|
+
self.is_emoji=is_emoji(s)
|
|
100
|
+
self.is_pictograph=is_extended_pictographic(s)
|
|
101
|
+
self.ordinal=ord(s)
|
|
102
|
+
self.upper=s.upper()
|
|
103
|
+
self.lower=s.lower()
|
|
104
|
+
self.is_upper=s.isupper()
|
|
105
|
+
self.is_lower=s.islower()
|
|
106
|
+
self.is_digit=s.isdigit()
|
|
107
|
+
self.is_letter=s.isalpha()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
unicodedataplus
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
symbolinfo
|