coallib 1.0.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.
coallib-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Erkhembayr Batjargal
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.
coallib-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: coallib
3
+ Version: 1.0.0
4
+ Summary: Python Tools Library
5
+ Author-email: Erkhembayr Batjargal <ericwasepic127@outlook.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ericwasepic127/coallib
8
+ Project-URL: Issues, https://github.com/ericwasepic127/coallib/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ ### Coallib - Tools, packages, items to make coding simpler
17
+
18
+ When you coding,you might have *repeated codes* across your packages, projects and even apps you made
19
+
20
+ > I get this too SO I made A **PIP PACKAGE** TO SOLVE!
21
+
22
+ ### Usage:
23
+
24
+ ##### Install:
25
+
26
+ ```bash
27
+ pip install coallib
28
+ ```
29
+
30
+ ##### Use:
31
+
32
+ ```python
33
+ import coallib
34
+ coallib.loadBar() # A Loadbar
35
+ ```
36
+
37
+ ### Credits:
38
+
39
+ - @Ericwasepic127
40
+
@@ -0,0 +1,25 @@
1
+ ### Coallib - Tools, packages, items to make coding simpler
2
+
3
+ When you coding,you might have *repeated codes* across your packages, projects and even apps you made
4
+
5
+ > I get this too SO I made A **PIP PACKAGE** TO SOLVE!
6
+
7
+ ### Usage:
8
+
9
+ ##### Install:
10
+
11
+ ```bash
12
+ pip install coallib
13
+ ```
14
+
15
+ ##### Use:
16
+
17
+ ```python
18
+ import coallib
19
+ coallib.loadBar() # A Loadbar
20
+ ```
21
+
22
+ ### Credits:
23
+
24
+ - @Ericwasepic127
25
+
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+ [project]
5
+ name = "coallib"
6
+ version = "1.0.0"
7
+ authors = [
8
+ { name="Erkhembayr Batjargal", email="ericwasepic127@outlook.com" },
9
+ ]
10
+ description = "Python Tools Library"
11
+ readme = "README.md"
12
+ requires-python = ">=3.6"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent",
16
+ ]
17
+ license = "MIT"
18
+ license-files = ["LICEN[CS]E*"]
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/ericwasepic127/coallib"
22
+ Issues = "https://github.com/ericwasepic127/coallib/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ from . import loady, itertool, lostool, iftool, filetool, termtool, versioner, animlib, timer
5
+ import platform
6
+
7
+ imports = [loady, itertool, lostool, versioner, iftool, filetool, animlib, timer]
8
+
9
+ if "wasm32" in platform.architecture():
10
+ from . import pyscripter, pagerfix, m2w
11
+ imports.append(pyscripter, pagerfix, m2w)
12
+
13
+ every = []
14
+ for mod in imports:
15
+ if hasattr(mod, "__all__"):
16
+ every.append(mod.__all__)
17
+ else:
18
+ every.append(dir(mod))
19
+
20
+ __all__ = []
21
+ for x in every:
22
+ for y in x:
23
+ if y in __all__:
24
+ raise RuntimeError(f"Imports are conflicting: {y} {x}")
25
+ __all__.append(y) if not y.startswith("_") else None
26
+ __version__ = "V1.0"
27
+
28
+ def __getattr__(name):
29
+ for mod in imports:
30
+ if hasattr(mod, name):
31
+ return getattr(mod, name)
32
+ raise AttributeError(f"module 'ericutils' has no attribute {repr(name)}")
33
+
34
+ del platform, every
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ from .termtool import confirm, MODE_YN
5
+ from . import loady
6
+
7
+ if __name__ == '__main__':
8
+ print("Welcome to @Ericwasepic127 library!")
9
+ print("Name Coallib made from Minecraft [Coal] + Python [Lib]rary")
10
+ print("Version: 1.0\nThanks for using my library!")
11
+ if confirm("Would you rather open help for loady project?", mode=MODE_YN):
12
+ help(loady)
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ '''
5
+ File: coallib/animlib.py
6
+ Author: Ericwasepic127
7
+ Description: Animation library at terminal
8
+ '''
9
+
10
+ import itertools as _iter, time as _t
11
+
12
+ def _build(full):
13
+ """Prepairer"""
14
+ frames = []
15
+ for i in range(len(full)):
16
+ frames.append(full[i:] + full[:i])
17
+ return frames
18
+
19
+ def _loop(frames, delay, withRev=False):
20
+ """Loop frames"""
21
+ if withRev:
22
+ frames = frames + frames[::-1]
23
+ for frame in _iter.cycle(frames):
24
+ print(frame, end="\r")
25
+ _t.sleep(delay)
26
+
27
+ def scrollText(text: str, space=" ", delay=0.1):
28
+ """Text scroling to X"""
29
+ full = text + space
30
+ frames = _build(full)
31
+ _loop(frames, delay)
32
+
33
+ def scrollList(List: list, space=" ", delay=0.1):
34
+ """List of texts scrolling to x"""
35
+ full = space.join(List) + space
36
+ frames = _build(full)
37
+ _loop(frames, delay)
38
+
39
+ def pingPongText(text: str, space=" ", delay=0.1):
40
+ """Ping-pong like text"""
41
+ full = text + space
42
+ frames = _build(full)
43
+ _loop(frames, delay, withRev=True)
44
+
45
+ def mainfunc():
46
+ scrollText("Hello, World!")
47
+
48
+ if __name__ == '__main__':
49
+ mainfunc()
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ from os import chdir as create_dir, remove as _rf
5
+ from shutil import rmtree as _sd
6
+ from os.path import isfile as check_file, exists as check_there
7
+ from platform import system as t
8
+
9
+ platform = t().lower()
10
+ del t
11
+
12
+ DIRECTORY_DELETE = "directory delete"
13
+ FILE_DELETE = "file delete"
14
+
15
+ def remove(path, safe=True):
16
+ """Removes safely"""
17
+ assert path, "Path doesn't specified"
18
+ if safe and not check_there(path):
19
+ raise FileNotFoundError(f"Path {path} does not exists")
20
+ if safe is DIRECTORY_DELETE:
21
+ _sd(path)
22
+ if safe is FILE_DELETE:
23
+ _sf(path)
24
+ if check_file(path) and safe:
25
+ _sf(path)
26
+ elif safe and exists(path):
27
+ _sd(path)
28
+ else:
29
+ _sf(path)
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ """
5
+ Functions to make if statements smaller
6
+ Made by @Ericwasepic127, Licensed under MIT
7
+ """
8
+
9
+ def check_type(obj, classCheck):
10
+ """Check instances"""
11
+ return isinstance(obj, classCheck) or type(obj) == classCheck
12
+
13
+ def raise_type(obj, classCheck, where="<unknown>", exc=TypeError, explain=None):
14
+ """Raises exc (kwarg) exception when obj attribute (1st argument) is not inherted from classCheck (2nd attribute)
15
+ Arguments:
16
+ POS 1: obj - Object to check
17
+ POS 2: classCheck - Class of 1st arguments's should match or Inherted/Subclassed/Instanced from it
18
+ POS 3: where="<unknown>" - String argument to say in function's what argument was invaild
19
+ POS 4: exc=TypeError - Exception to raise
20
+ POS 5: explain=None - Exception message, defaults to f"argument {where} must {classCheck.__name__!r}, got {obj.__name__!r}"
21
+ Epilog:
22
+ def multipy(num):
23
+ coallib.raise_type(num, int, where='num')
24
+ return num * 2
25
+ # This function only gets integer, if not given integer, it raises as
26
+ # TypeError: argument num must 'int', got 'str'
27
+ # when you do multipy('test')"""
28
+ if explain is None or not explain:
29
+ explain = f"argument {where} must {classCheck.__name__!r}, got {obj.__name__!r}"
30
+ if not check_type(obj, classCheck):
31
+ raise exc(explain)
32
+
33
+ def raise_callable(obj, where="<unknown>", exc=TypeError, explain=None):
34
+ """Raises exc (kwarg) exception when obj attribute (1st argument) is not callable
35
+ Arguments:
36
+ POS 1: obj - Object to check
37
+ POS 2: where="<unknown>" - String argument to say in function's what argument was invaild
38
+ POS 3: exc=TypeError - Exception to raise
39
+ POS 4: explain=None - Exception message, defaults to f"argument {where} must {classCheck.__name__!r}, got {obj.__name__!r}"
40
+ Epilog:
41
+ def wrapper(func):
42
+ coallib.raise_callable(func, where='num')
43
+ def wrap():
44
+ return func()
45
+ return wrap
46
+ # This wrapper only gets functions, if not it raises as
47
+ # TypeError: argument num must callable, got 'str'
48
+ # when you do wrapper('test')"""
49
+ if explain is None or not explain:
50
+ explain = f"argument {where} must callable, got {obj.__name__!r} object"
51
+ if not callable(obj) or not hasattr(obj, "__call__"):
52
+ raise exc(explain)
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ """
5
+ Iterable things helper
6
+ """
7
+
8
+ def get_last_index(iterable) -> int:
9
+ """Returns last index of iterable"""
10
+ assert iterable, "Iterable is empty!"
11
+ assert hasattr(iterable, "__iter__"), "Gave non-iterable object!"
12
+ return len(iterable) - 1
13
+
14
+ def get_fixed_string(string: str, remove: str=" ") -> str:
15
+ """Deletes trailing spaces or from remove argument"""
16
+ from .iftool import raise_type
17
+ raise_type(string, str)
18
+ raise_type(remove, str)
19
+ return string.strip().rstrip()
20
+
21
+ def full_fix_str(string: str) -> str:
22
+ """Removes any trailing space and newlines"""
23
+ return get_fixed_string(get_fixed_string(string), "\n")
24
+
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env python3
2
+ # Made by @Ericwasepic127
3
+
4
+ from datetime import datetime as dt
5
+ from shutil import get_terminal_size as gt
6
+ from ..itertool import get_last_index as i
7
+ from ..pager import get_pager as gp, set_fallback as sf
8
+ import argparse, os, sys, getpass, json, sys
9
+
10
+ set_unable_pager = False
11
+ def previewer(text="", title=""):
12
+ global set_unable_pager
13
+ set_unable_pager = True
14
+ show_split()
15
+ print(text)
16
+ show_split("_")
17
+
18
+ def preview(text):
19
+ in_use = gp()
20
+ in_use(text)
21
+ if not set_unable_pager:
22
+ previewer(text)
23
+
24
+ sf(previewer)
25
+ current = dt.now()
26
+ length = gt().columns
27
+ save = os.getcwd()
28
+ cur = os.path.dirname(__file__)
29
+ if not cur and sys.platform == "win32":
30
+ x = __file__.split("\\")
31
+ x.remove(x[i(x)])
32
+ cur = "\\".join(x)
33
+ del x
34
+ elif not cur:
35
+ cur = os.path.join(save, __name__)
36
+ os.chdir(save)
37
+ del save
38
+ del i
39
+
40
+ with open(os.path.join(cur, "use.json")) as x:
41
+ setup = json.load(x)
42
+
43
+ def show_split(icon="="):
44
+ print(icon*length)
45
+
46
+ def parse(rhytm: str) -> list:
47
+ return [int(x) for x in rhytm.split("-")]
48
+
49
+ def get_year() -> int:
50
+ year = current.year
51
+ print("Current year: %d" % year)
52
+ change = input("Would you rather change (type year to change if want to)? ")
53
+ if change:
54
+ if change.isdigit():
55
+ return int(change)
56
+ else:
57
+ print("Gave non-integer!")
58
+ return year
59
+
60
+ def get_name() -> str:
61
+ try:
62
+ name = getpass.getuser()
63
+ print(f"Found name: {name}")
64
+ change = input("Would you rather change name (type name to change if want to)? ").strip().rstrip()
65
+ if change:
66
+ name = change
67
+ except OSError:
68
+ name = ""
69
+ while not name:
70
+ name = input("Please set name! ").strip().rstrip()
71
+ email = input("Would you rather add email (type email to add if want to)? ").strip().rstrip()
72
+ if email:
73
+ name += f"<{email}>"
74
+ return name
75
+
76
+ def gather_licenses() -> dict:
77
+ lics = [os.path.join(cur, x) for x in os.listdir(cur) if x.endswith(".license")]
78
+ files = []
79
+ for lic in lics:
80
+ with open(lic) as y:
81
+ files.append(y.read())
82
+ t = ([os.path.basename(z)[:-8] for z in lics], files)
83
+ templates = {}
84
+ for d in range(0, len(t[0])):
85
+ templates[t[0][d]] = t[1][d]
86
+ return templates
87
+
88
+ templates = gather_licenses()
89
+ names = list(templates.keys())
90
+
91
+ def handle_algo(year: int, name: str, licname: str) -> str:
92
+ templ = templates.get(licname)
93
+ algorhytm = parse(setup.get(licname))
94
+ send = []
95
+ for detect in algorhytm:
96
+ if detect:
97
+ send.append(year)
98
+ else:
99
+ send.append(name)
100
+ return templ.format(*send)
101
+
102
+ def save_to(location: str, lic: str):
103
+ try:
104
+ with open(location, "w") as file:
105
+ file.write(lic)
106
+ except (BaseException, Exception) as e:
107
+ print("FAILED:", e)
108
+
109
+ def generate(year, name, nameto, filepath=None):
110
+ licenser = handle_algo(year, name, nameto)
111
+ if filepath:
112
+ save_to(filepath, licenser)
113
+ else:
114
+ preview(licenser)
115
+
116
+ def greet():
117
+ show_split()
118
+ print("Welcome to License generator")
119
+
120
+ def get_license(mode=False) -> str:
121
+ print("Please select type of your license:")
122
+ c = 1
123
+ for name in names:
124
+ print(f"{c}. {name}")
125
+ c += 1
126
+ select = input(f"Select (1~{c-1}): ")
127
+ if select == "quit" and mode:
128
+ raise KeyboardInterrupt
129
+ if select and select.isdigit():
130
+ return names[int(select) - 1]
131
+ else:
132
+ print("Not number")
133
+ show_split("-")
134
+ return 1 / 0 if mode else 0
135
+
136
+ def loop():
137
+ show_split("-")
138
+ nameto = get_license(mode=True)
139
+ year = get_year()
140
+ name = get_name()
141
+ filepath = input("Enter filepath to save (or nothing to preview only): ").rstrip().strip()
142
+ generate(year, name, nameto, filepath)
143
+
144
+ if __name__ == '__main__':
145
+ greet()
146
+ parser = argparse.ArgumentParser(description="A program to generate Licenses easily")
147
+ parser.add_argument("-n", "--name", help="Name input")
148
+ parser.add_argument("-y", "--year", help="Year input")
149
+ parser.add_argument("-l", "--license", help="License type")
150
+ parser.add_argument("-o", "--output", help="File to write output")
151
+ args = parser.parse_args()
152
+ if args.name or args.year or args.license or args.output:
153
+ if args.year and not args.year.isdigit():
154
+ parser.error("Failed to parse argument of year: Not integer")
155
+ parser.exit(1)
156
+ if args.license and not (args.license in names):
157
+ parser.error(f"No license named {args.license}")
158
+ parser.exit(1)
159
+ name = args.name or get_name()
160
+ year = int(args.year or get_year())
161
+ nameto = args.license or get_license() or sys.exit(1)
162
+ filepath = args.output or input("Enter filepath to save (or nothing to preview only): ").rstrip().strip()
163
+ generate(year, name, nameto, filepath)
164
+ else:
165
+ print("Press Ctrl-C or type 'quit' to exit!")
166
+ while 1:
167
+ try:
168
+ loop()
169
+ except KeyboardInterrupt:
170
+ print("Interrupted, exiting ...")
171
+ break
172
+ except ZeroDivisionError:
173
+ pass
174
+ print("Bye!")