Skip to content

Commit 79b45ae

Browse files
Made a script for it xd
1 parent d7261fd commit 79b45ae

File tree

4 files changed

+131
-15
lines changed

4 files changed

+131
-15
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
2+
.env
23
dist
34
build
45
rites/test.py

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cSpell.words": [
3+
"Reclipse",
4+
"Reclipse's"
5+
]
6+
}

rites/rituals.py

+23-15
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ def __mul__(self, other):
7878
return Math.ComplexNumber(self.real * other.real - self.imaginary * other.imaginary, self.real * other.imaginary + self.imaginary * other.real)
7979
return Math.ComplexNumber(self.real * other.real - self.imaginary * other.imaginary, self.real * other.imaginary + self.imaginary * other.real, self.complex_letter)
8080

81+
def __pow__(self, power):
82+
if power == 0:
83+
return Math.ComplexNumber(1, 0)
84+
result = Math.ComplexNumber(self.real, self.imaginary)
85+
for i in range(power - 1):
86+
result *= self
87+
return result
88+
8189
def __str__(self):
8290
if self.imaginary == 0:
8391
return f"{self.real}"
@@ -255,15 +263,15 @@ def __mul__(self, other: Union['Math.Matrix', int]) -> 'Math.Matrix':
255263
def __rmul__(self, other: int) -> 'Math.Matrix':
256264
# int * matrix fix
257265
return self.__mul__(other)
258-
266+
259267
def __str__(self):
260268
# Spaghetti code goes hard <3
261269

262270
__temp = []
263271
for i in range(0, self.height):
264272
__temp.append([])
265273

266-
# Iterate through the collumns
274+
# Iterate through the columns
267275
for i in range(0, self.width):
268276

269277
# Get longest number in characters used (- included etc.) per column
@@ -336,15 +344,15 @@ def __pow__(self, power: int) -> 'Math.Matrix':
336344
for i in range(power):
337345
result *= self
338346
return result
339-
347+
340348
def transpose(self) -> 'Math.Matrix':
341349
result = []
342350
for i in range(self.width):
343351
result.append([])
344352
for j in range(self.height):
345353
result[i].append(self.matrix[j][i])
346354
return Math.Matrix(result)
347-
355+
348356
def diagonal(self) -> list:
349357
if self.width != self.height:
350358
raise ValueError("Matrix is not a square matrix")
@@ -353,7 +361,7 @@ def diagonal(self) -> list:
353361
for i in range(self.width):
354362
result.append(self.matrix[i][i])
355363
return result
356-
364+
357365
def secondary_diagonal(self) -> list:
358366
if self.width != self.height:
359367
raise ValueError("Matrix is not a square matrix")
@@ -362,7 +370,7 @@ def secondary_diagonal(self) -> list:
362370
for i in range(self.width):
363371
result.append(self.matrix[i][self.width - i - 1])
364372
return result
365-
373+
366374
def inferior_triangular_matrix(self, offset=0):
367375
if self.width != self.height:
368376
raise ValueError("Matrix is not a square matrix")
@@ -375,12 +383,12 @@ def inferior_triangular_matrix(self, offset=0):
375383
for j in range(self.height):
376384
line.append(0)
377385
result.append(line)
378-
386+
379387
for i in range(offset, self.height):
380388
for j in range(i + 1 - offset):
381389
result[i][j] = self.matrix[i][j]
382390
return Math.Matrix(result)
383-
391+
384392
def superior_triangular_matrix(self, offset=0):
385393
if self.width != self.height:
386394
raise ValueError("Matrix is not a square matrix")
@@ -393,12 +401,11 @@ def superior_triangular_matrix(self, offset=0):
393401
for j in range(self.height):
394402
line.append(0)
395403
result.append(line)
396-
404+
397405
for i in range(self.height):
398406
for j in range(i + offset, self.width):
399407
result[i][j] = self.matrix[i][j]
400408
return Math.Matrix(result)
401-
402409

403410
@staticmethod
404411
def unit_matrix(size: int) -> 'Math.Matrix':
@@ -445,7 +452,7 @@ def transpose_of(matrix: Union[list, 'Math.Matrix']) -> 'Math.Matrix':
445452
for j in range(matrix.height):
446453
result[i].append(matrix.matrix[j][i])
447454
return Math.Matrix(result)
448-
455+
449456
@staticmethod
450457
def inferior_triangular_matrix_of(matrix: Union[list, 'Math.Matrix'], offset=0) -> 'Math.Matrix':
451458
if not isinstance(matrix, Math.Matrix):
@@ -462,12 +469,12 @@ def inferior_triangular_matrix_of(matrix: Union[list, 'Math.Matrix'], offset=0)
462469
for j in range(matrix.height):
463470
line.append(0)
464471
result.append(line)
465-
472+
466473
for i in range(offset, matrix.height):
467474
for j in range(i + 1 - offset):
468475
result[i][j] = matrix.matrix[i][j]
469476
return Math.Matrix(result)
470-
477+
471478
@staticmethod
472479
def superior_triangular_matrix_of(matrix: Union[list, 'Math.Matrix'], offset=0) -> 'Math.Matrix':
473480
if not isinstance(matrix, Math.Matrix):
@@ -484,7 +491,7 @@ def superior_triangular_matrix_of(matrix: Union[list, 'Math.Matrix'], offset=0)
484491
for j in range(matrix.height):
485492
line.append(0)
486493
result.append(line)
487-
494+
488495
for i in range(matrix.height):
489496
for j in range(i + offset, matrix.width):
490497
result[i][j] = matrix.matrix[i][j]
@@ -496,5 +503,6 @@ def from_terminal(height, width) -> 'Math.Matrix':
496503
for i in range(height):
497504
matrix.append([])
498505
for j in range(width):
499-
matrix[i].append(int(input(f"Enter the value for [{i}][{j}]: ")))
506+
matrix[i].append(
507+
int(input(f"Enter the value for [{i}][{j}]: ")))
500508
return Math.Matrix(matrix)

upload.py

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import os
2+
from dotenv import load_dotenv
3+
from setuptools import setup, find_packages
4+
5+
load_dotenv()
6+
pypi_token = os.getenv('PYPI_TOKEN')
7+
8+
cached_lines = []
9+
with open("./rites/_version.py", "r") as f:
10+
cached_lines = f.readlines()
11+
f.close()
12+
13+
14+
def increment_version():
15+
cloned_lines = cached_lines.copy()
16+
17+
cached_version = cloned_lines[2].split('=')[1].strip().replace('\"', '')
18+
new_version = ''
19+
20+
print(f"Current version: {cached_version}")
21+
choice = input(f'''
22+
1. Increment patch version
23+
2. Increment minor version and set patch to 0
24+
3. Increment major version and set patch and minor to 0
25+
4. Don't increment version
26+
5. Custom
27+
>''')
28+
add_label = input(f'''Add Label? (y/n)
29+
>''').lower()
30+
31+
if add_label == 'y':
32+
label = input('Label: ')
33+
else:
34+
label = ''
35+
36+
if choice == '1':
37+
new_version = cloned_lines[2].split('=')[1].strip().replace('\"', '').split('.')
38+
new_version[2] = str(int(new_version[2]) + 1)
39+
new_version = '.'.join(new_version) + label
40+
cloned_lines[2] = f'__version__ = "{new_version}"\n'
41+
42+
elif choice == '2':
43+
new_version = cloned_lines[2].split('=')[1].strip().replace('\"', '').split('.')
44+
new_version[1] = str(int(new_version[1]) + 1)
45+
new_version[2] = '0'
46+
new_version = '.'.join(new_version) + label
47+
cloned_lines[2] = f'__version__ = "{new_version}"\n'
48+
49+
elif choice == '3':
50+
new_version = cloned_lines[2].split('=')[1].strip().replace('\"', '').split('.')
51+
new_version[0] = str(int(new_version[0]) + 1)
52+
new_version[1] = '0'
53+
new_version[2] = '0'
54+
new_version = '.'.join(new_version) + label
55+
cloned_lines[2] = f'__version__ = "{new_version}"\n'
56+
57+
elif choice == '4':
58+
new_version = cached_version + label
59+
cloned_lines[2] = f'__version__ = "{new_version}"\n'
60+
61+
elif choice == '5':
62+
new_version = input('Version: ')
63+
cloned_lines[2] = f'__version__ = "{new_version}"\n'
64+
65+
accept_changes = input(f'''Old version: {cached_version} - New version: {new_version}
66+
Accept changes? (y/n)
67+
>''').lower()
68+
if accept_changes == 'y':
69+
with open("./rites/_version.py", "w") as f:
70+
f.writelines(cloned_lines)
71+
f.close()
72+
build_package(new_version)
73+
os.system(f'twine upload dist/* -u __token__ -p {pypi_token}')
74+
else:
75+
print('Aborted')
76+
77+
78+
def build_package(pkgVersion):
79+
setup(
80+
name="rites",
81+
version=pkgVersion,
82+
description="Reclipse's Initial Try at Enhanced Simplicity or R.I.T.E.S. A simple and lightweight QoL module.",
83+
long_description=open('README.md').read(),
84+
long_description_content_type='text/markdown',
85+
author="Reclipse",
86+
maintainer="Reclipse",
87+
url="https://github.com/ReclipseTheOne/rites",
88+
packages=find_packages(),
89+
classifiers=[
90+
"Programming Language :: Python :: 3",
91+
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
92+
"Operating System :: OS Independent",
93+
],
94+
python_requires='>=3.6',
95+
install_requires=[
96+
'colored>=2.2.4'
97+
]
98+
)
99+
100+
101+
increment_version()

0 commit comments

Comments
 (0)