rayid 1.1.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.
- rayid/__init__.py +3 -0
- rayid/rayid.py +51 -0
- rayid-1.1.0.dist-info/METADATA +160 -0
- rayid-1.1.0.dist-info/RECORD +7 -0
- rayid-1.1.0.dist-info/WHEEL +5 -0
- rayid-1.1.0.dist-info/licenses/LICENSE +21 -0
- rayid-1.1.0.dist-info/top_level.txt +1 -0
rayid/__init__.py
ADDED
rayid/rayid.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import secrets
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
IDType = Literal["digit", "lower", "upper", "all"]
|
|
5
|
+
|
|
6
|
+
VALUES: dict[str, str] = {
|
|
7
|
+
"digit": "0123456789",
|
|
8
|
+
"lower": "abcdefghijklmnopqrstuvwxyz",
|
|
9
|
+
"upper": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
VALUES["all"] = "".join(VALUES.values())
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class RayID:
|
|
16
|
+
def __init__(self, type: IDType) -> None:
|
|
17
|
+
if type not in VALUES:
|
|
18
|
+
raise ValueError(
|
|
19
|
+
f"Invalid ID type: {type!r}. " f"Expected one of: {', '.join(VALUES)}"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
self.type: IDType = type
|
|
23
|
+
|
|
24
|
+
def characters(self) -> str:
|
|
25
|
+
return VALUES[self.type]
|
|
26
|
+
|
|
27
|
+
def engine(self, length: int) -> str:
|
|
28
|
+
if not isinstance(length, int) or isinstance(length, bool):
|
|
29
|
+
raise TypeError("Length must be an integer.")
|
|
30
|
+
|
|
31
|
+
if length <= 0:
|
|
32
|
+
raise ValueError("Length must be greater than zero.")
|
|
33
|
+
|
|
34
|
+
characters = self.characters()
|
|
35
|
+
|
|
36
|
+
return "".join(secrets.choice(characters) for _ in range(length))
|
|
37
|
+
|
|
38
|
+
def gen(self, length: int) -> str:
|
|
39
|
+
if not isinstance(length, int) or isinstance(length, bool):
|
|
40
|
+
raise TypeError("Length must be an integer.")
|
|
41
|
+
|
|
42
|
+
if length <= 0:
|
|
43
|
+
raise ValueError("Length must be greater than zero.")
|
|
44
|
+
|
|
45
|
+
characters = self.characters()
|
|
46
|
+
first_characters = characters.replace("0", "")
|
|
47
|
+
|
|
48
|
+
first = secrets.choice(first_characters)
|
|
49
|
+
remaining = "".join(secrets.choice(characters) for _ in range(length - 1))
|
|
50
|
+
|
|
51
|
+
return first + remaining
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rayid
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: RayID is a generated code that we use to track logs, posts or events.
|
|
5
|
+
Home-page: https://gitlab.com/blackiq-packages/pypi/rayid
|
|
6
|
+
Author: Amirhossein Mohammadi
|
|
7
|
+
Author-email: Amirhossein Mohammadi <amirhosseinmohammadi1380@yahoo.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2023 RayID
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Project-URL: Homepage, https://gitlab.com/blackiq-packages/pypi/rayid
|
|
31
|
+
Project-URL: Repository, https://gitlab.com/blackiq-packages/pypi/rayid
|
|
32
|
+
Project-URL: Issues, https://gitlab.com/blackiq-packages/pypi/rayid/-/issues
|
|
33
|
+
Keywords: rayid,id,generator,random,tracking
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
39
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
40
|
+
Requires-Python: >=3.8
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
License-File: LICENSE
|
|
43
|
+
Dynamic: author
|
|
44
|
+
Dynamic: home-page
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# RayID
|
|
48
|
+
|
|
49
|
+
**RayID** is a generated code that we use to track logs, posts or events. You can generate your own rayid, but we made your job easier!
|
|
50
|
+
|
|
51
|
+
In this instructure you will learn about how to use this package in your apps.
|
|
52
|
+
|
|
53
|
+
## Table of content
|
|
54
|
+
|
|
55
|
+
- [Languages](#languages)
|
|
56
|
+
- [Installation](#installation)
|
|
57
|
+
- [methods](#methods)
|
|
58
|
+
- [Development](#development)
|
|
59
|
+
|
|
60
|
+
## Languages
|
|
61
|
+
|
|
62
|
+
I created rayid for **JavaScript** too.
|
|
63
|
+
|
|
64
|
+
- [GitLab](https://gitlab.com/BlackIQ/rayid)
|
|
65
|
+
- [Npm](https://www.npmjs.com/package/rayid)
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
How to install **RayID**? To install this package, use **pip** or **pipenv**.
|
|
70
|
+
|
|
71
|
+
```shell
|
|
72
|
+
$ pip3 install rayid
|
|
73
|
+
# Or
|
|
74
|
+
$ pipenv install rayid
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Config
|
|
78
|
+
|
|
79
|
+
So, import the package.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from rayid import RayID
|
|
83
|
+
|
|
84
|
+
rayid = RayID("digit")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Now create your instance with what kind of rayid you want.
|
|
88
|
+
|
|
89
|
+
- digit: Numbers
|
|
90
|
+
- lower: Alphabet in lower case.
|
|
91
|
+
- upper: Alphabet in upper case.
|
|
92
|
+
- all: Combine of all types.
|
|
93
|
+
|
|
94
|
+
> No type means all combined togather.
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
rayid = RayID("digit")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Methods
|
|
101
|
+
|
|
102
|
+
Only one method! `gen(len)`.
|
|
103
|
+
|
|
104
|
+
### `gen(len)`
|
|
105
|
+
|
|
106
|
+
in **gen(len)** just say the length.
|
|
107
|
+
|
|
108
|
+
> There is no limit :)
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
id = rayid.gen(25);
|
|
112
|
+
print(id); # 9514992619709220193874433
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Examples
|
|
116
|
+
|
|
117
|
+
Create common instances.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
all = RayID("all"); # All values
|
|
121
|
+
str = RayID("lower"); # Loercase generator
|
|
122
|
+
int = RayID("digit"); # Only int generator
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Now use them:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
print(all.gen(10)); # Z*jVQ3c:+H
|
|
129
|
+
print(str.gen(10)); # ksixvpqohi
|
|
130
|
+
print(int.gen(10)); # 4748182066
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
All done!
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
If you want to develop the package, it is so simple. just follow steps below.
|
|
140
|
+
|
|
141
|
+
- Clone the project
|
|
142
|
+
- Start changing!
|
|
143
|
+
|
|
144
|
+
> Before you start: **Remember the base or code are stored in `rayid/rayid.py`**. You need to edit there.
|
|
145
|
+
|
|
146
|
+
### Cloning the project
|
|
147
|
+
|
|
148
|
+
To clone the project, you need to have git installed. Ok, now clone it same as command below.
|
|
149
|
+
|
|
150
|
+
```shell
|
|
151
|
+
$ git clone https:#github.com/BlackIQ/rayid
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Changing
|
|
155
|
+
|
|
156
|
+
To change package or anything, your need a testing environment to use linked package. Just change `rayid/rayid.py`.
|
|
157
|
+
|
|
158
|
+
#### Test
|
|
159
|
+
|
|
160
|
+
Your test app is linked. Change anything in package and test it in `test.py` file.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
rayid/__init__.py,sha256=Ve_caw0pvZVLOVFbw8oOQdWUbJaYY6Lh9qb72mvVby4,51
|
|
2
|
+
rayid/rayid.py,sha256=EGmGq-ap86RQRI_bprXkzg-KKpFlKVockwfhxQ9L9Mk,1497
|
|
3
|
+
rayid-1.1.0.dist-info/licenses/LICENSE,sha256=3d0_ccpx_bKFz0ECGZZfVGZ2Tqf7-UG6Wj--9KQluDM,1062
|
|
4
|
+
rayid-1.1.0.dist-info/METADATA,sha256=PmgJUHTjTvo03kz0UqUJqRjar3d0cCBbx7GpE6mEhVw,4420
|
|
5
|
+
rayid-1.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
rayid-1.1.0.dist-info/top_level.txt,sha256=3R7ai9mCikxcxmR_VjLDHprN6npUOUMf0fer8w573ww,6
|
|
7
|
+
rayid-1.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 RayID
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rayid
|