staticdatapy 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.
@@ -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,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
File without changes
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "staticdatapy"
7
+ version = "0.1.0"
8
+ description = "A Python library with static data utilities: morse, binary, alphabet and more."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ { name = "Robles" }
13
+ ]
14
+ requires-python = ">=3.8"
15
+ keywords = ["morse", "binary", "alphabet", "static", "data"]
16
+
17
+ [tool.setuptools.packages.find]
18
+ where = ["."]
19
+ include = ["staticdatapy*"]
20
+ exclude = ["tests*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+
2
+ from .morse import to_morse, morse_to_text
3
+ from .binary import to_binary, binary_to_text
4
+ from .alphabet import alphabet
5
+
6
+ __version__ = "0.1.0"
7
+ __author__ = "Robles"
@@ -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])
@@ -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
@@ -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,15 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ staticdatapy/__init__.py
5
+ staticdatapy/alphabet.py
6
+ staticdatapy/binary.py
7
+ staticdatapy/morse.py
8
+ staticdatapy.egg-info/PKG-INFO
9
+ staticdatapy.egg-info/SOURCES.txt
10
+ staticdatapy.egg-info/dependency_links.txt
11
+ staticdatapy.egg-info/top_level.txt
12
+ tests/test_alphabet.py
13
+ tests/test_ascii.py
14
+ tests/test_binary.py
15
+ tests/test_morse.py
@@ -0,0 +1 @@
1
+ staticdatapy
@@ -0,0 +1,15 @@
1
+ from staticdatapy import to_morse, morse_to_text
2
+ from staticdatapy import to_binary, binary_to_text
3
+ from staticdatapy import alphabet
4
+
5
+ # Prueba Morse
6
+ print(to_morse("Hola"))
7
+ print(morse_to_text(".... --- .-.. .-"))
8
+
9
+ # Prueba Binary
10
+ print(to_binary("Hola"))
11
+ print(binary_to_text("01001000 01101111 01101100 01100001"))
12
+
13
+ # Prueba Alphabet
14
+ print(alphabet(5))
15
+ print(alphabet('5x'))
File without changes
File without changes
File without changes