staticdatapy 0.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.
- staticdatapy/__init__.py +7 -0
- staticdatapy/alphabet.py +39 -0
- staticdatapy/binary.py +19 -0
- staticdatapy/morse.py +43 -0
- staticdatapy-0.1.0.dist-info/METADATA +11 -0
- staticdatapy-0.1.0.dist-info/RECORD +9 -0
- staticdatapy-0.1.0.dist-info/WHEEL +5 -0
- staticdatapy-0.1.0.dist-info/licenses/LICENSE +21 -0
- staticdatapy-0.1.0.dist-info/top_level.txt +1 -0
staticdatapy/__init__.py
ADDED
staticdatapy/alphabet.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import string
|
|
3
|
+
|
|
4
|
+
UPPERCASE = list(string.ascii_uppercase) # ['A', 'B', 'C', ...]
|
|
5
|
+
LOWERCASE = list(string.ascii_lowercase) # ['a', 'b', 'c', ...]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def alphabet(value):
|
|
9
|
+
"""
|
|
10
|
+
Returns the first N letters of the alphabet separated by spaces.
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
|
|
14
|
+
alphabet(5) → 'A B C D E' (uppercase by default)
|
|
15
|
+
|
|
16
|
+
alphabet('5X') → 'A B C D E' (uppercase)
|
|
17
|
+
|
|
18
|
+
alphabet('5x') → 'a b c d e' (lowercase)
|
|
19
|
+
"""
|
|
20
|
+
value = str(value)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if value.endswith('x'):
|
|
24
|
+
count = int(value[:-1])
|
|
25
|
+
letters = LOWERCASE
|
|
26
|
+
elif value.endswith('X'):
|
|
27
|
+
count = int(value[:-1])
|
|
28
|
+
letters = UPPERCASE
|
|
29
|
+
else:
|
|
30
|
+
count = int(value)
|
|
31
|
+
letters = UPPERCASE
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if count > 26:
|
|
35
|
+
raise ValueError(f"The alphabet only has 26 letters, you asked {count}.")
|
|
36
|
+
if count < 1:
|
|
37
|
+
raise ValueError("The number must be greater than 0.")
|
|
38
|
+
|
|
39
|
+
return ' '.join(letters[:count])
|
staticdatapy/binary.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
def to_binary(text):
|
|
4
|
+
"""Convierte texto normal a binario."""
|
|
5
|
+
result = []
|
|
6
|
+
for char in text:
|
|
7
|
+
binary_char = format(ord(char), '08b')
|
|
8
|
+
result.append(binary_char)
|
|
9
|
+
return ' '.join(result)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def binary_to_text(binary):
|
|
13
|
+
"""Convierte binario a texto normal."""
|
|
14
|
+
parts = binary.strip().split(' ')
|
|
15
|
+
result = ''
|
|
16
|
+
for part in parts:
|
|
17
|
+
if part:
|
|
18
|
+
result += chr(int(part, 2))
|
|
19
|
+
return result
|
staticdatapy/morse.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
MORSE_CODE = {
|
|
3
|
+
'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..',
|
|
4
|
+
'E': '.', 'F': '..-.', 'G': '--.', 'H': '....',
|
|
5
|
+
'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
|
|
6
|
+
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.',
|
|
7
|
+
'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-',
|
|
8
|
+
'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
|
|
9
|
+
'Y': '-.--', 'Z': '--..',
|
|
10
|
+
'0': '-----', '1': '.----', '2': '..---', '3': '...--',
|
|
11
|
+
'4': '....-', '5': '.....', '6': '-....', '7': '--...',
|
|
12
|
+
'8': '---..', '9': '----.',
|
|
13
|
+
'.': '.-.-.-', ',': '--..--', '?': '..--..', '!': '-.-.--',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
TEXT_CODE = {v: k for k, v in MORSE_CODE.items()}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def to_morse(text):
|
|
21
|
+
"""Convierte texto normal a código Morse."""
|
|
22
|
+
result = []
|
|
23
|
+
for char in text.upper():
|
|
24
|
+
if char == ' ':
|
|
25
|
+
result.append('/')
|
|
26
|
+
elif char in MORSE_CODE:
|
|
27
|
+
result.append(MORSE_CODE[char])
|
|
28
|
+
else:
|
|
29
|
+
result.append('Caracter invalid')
|
|
30
|
+
return ' '.join(result)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def morse_to_text(morse):
|
|
34
|
+
"""Convierte código Morse a texto normal."""
|
|
35
|
+
words = morse.strip().split(' / ')
|
|
36
|
+
result = []
|
|
37
|
+
for word in words:
|
|
38
|
+
letters = word.split(' ')
|
|
39
|
+
decoded_word = ''
|
|
40
|
+
for letter in letters:
|
|
41
|
+
decoded_word += TEXT_CODE.get(letter, '?')
|
|
42
|
+
result.append(decoded_word)
|
|
43
|
+
return ' '.join(result)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: staticdatapy
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library with static data utilities: morse, binary, alphabet and more.
|
|
5
|
+
Author: Robles
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: morse,binary,alphabet,static,data
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
staticdatapy/__init__.py,sha256=TPnshEWev-_w3nR1Bn2X-rKOWFnOx-FHoFvUARDh9yY,165
|
|
2
|
+
staticdatapy/alphabet.py,sha256=74vEPUbNV4D3E90mgON6JHzVWEhy3rn9UulyZdoAxvA,910
|
|
3
|
+
staticdatapy/binary.py,sha256=d5KBXLcUNRl83vHePZI6Vlx0E-TCro54qpyxSPbNWnQ,440
|
|
4
|
+
staticdatapy/morse.py,sha256=UNUMfWcGJWUI3X1vvZvR_CKUFCDSSViBriAyilWkAeU,1373
|
|
5
|
+
staticdatapy-0.1.0.dist-info/licenses/LICENSE,sha256=4qbORMei9AtFskQDMVzK_LTbnT2I_wb8tHVGoDjnxAo,1062
|
|
6
|
+
staticdatapy-0.1.0.dist-info/METADATA,sha256=EpIXXAR0FMOKok2viBs7Hg5ocoz32TrRoPpuP2baDL0,334
|
|
7
|
+
staticdatapy-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
8
|
+
staticdatapy-0.1.0.dist-info/top_level.txt,sha256=RkUGl9xJjnSqN9HFGiZi66nDaVaFT0NaekqK3kCdbHs,13
|
|
9
|
+
staticdatapy-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robles
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
staticdatapy
|