ToolVerse 1.2.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.
- ToolVerse/__init__.py +25 -0
- ToolVerse/calculator.py +188 -0
- ToolVerse/conversion_tools.py +111 -0
- ToolVerse/date_time_tools.py +75 -0
- ToolVerse/file_tools.py +86 -0
- ToolVerse/number_tools.py +67 -0
- ToolVerse/password_tools.py +88 -0
- ToolVerse/random_tools.py +55 -0
- ToolVerse/string_tools.py +47 -0
- ToolVerse/student_tools.py +169 -0
- ToolVerse/system_tools.py +155 -0
- toolverse-1.2.0.dist-info/METADATA +198 -0
- toolverse-1.2.0.dist-info/RECORD +16 -0
- toolverse-1.2.0.dist-info/WHEEL +5 -0
- toolverse-1.2.0.dist-info/licenses/LICENSE +22 -0
- toolverse-1.2.0.dist-info/top_level.txt +1 -0
ToolVerse/__init__.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from .calculator import Calculator
|
|
2
|
+
from .conversion_tools import ConversionTools
|
|
3
|
+
from .date_time_tools import DateTimeTools
|
|
4
|
+
from .file_tools import FileTools
|
|
5
|
+
from .number_tools import NumberTools
|
|
6
|
+
from .password_tools import PasswordTools
|
|
7
|
+
from .random_tools import RandomTools
|
|
8
|
+
from .string_tools import StringTools
|
|
9
|
+
from .student_tools import StudentTools
|
|
10
|
+
from .system_tools import SystemTools
|
|
11
|
+
|
|
12
|
+
__version__ = "1.1.0"
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Calculator",
|
|
16
|
+
"ConversionTools",
|
|
17
|
+
"DateTimeTools",
|
|
18
|
+
"FileTools",
|
|
19
|
+
"NumberTools",
|
|
20
|
+
"PasswordTools",
|
|
21
|
+
"RandomTools",
|
|
22
|
+
"StringTools",
|
|
23
|
+
"StudentTools",
|
|
24
|
+
"SystemTools",
|
|
25
|
+
]
|
ToolVerse/calculator.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
class Calculator:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
self.a = 0
|
|
4
|
+
self.b = 0
|
|
5
|
+
|
|
6
|
+
def add(self, a, b):
|
|
7
|
+
self.a = a
|
|
8
|
+
self.b = b
|
|
9
|
+
result = self.a + self.b
|
|
10
|
+
return result
|
|
11
|
+
|
|
12
|
+
def mul(self, a, b):
|
|
13
|
+
self.a = a
|
|
14
|
+
self.b = b
|
|
15
|
+
result = self.a * self.b
|
|
16
|
+
return result
|
|
17
|
+
|
|
18
|
+
def div(self, a, b):
|
|
19
|
+
self.a = a
|
|
20
|
+
self.b = b
|
|
21
|
+
if self.b != 0:
|
|
22
|
+
result = self.a / self.b
|
|
23
|
+
return result
|
|
24
|
+
else:
|
|
25
|
+
return "Division by zero is not allowed"
|
|
26
|
+
|
|
27
|
+
def sub(self, a, b):
|
|
28
|
+
self.a = a
|
|
29
|
+
self.b = b
|
|
30
|
+
result = self.a - self.b
|
|
31
|
+
return result
|
|
32
|
+
|
|
33
|
+
def percentage(self, a, b):
|
|
34
|
+
self.a = a
|
|
35
|
+
self.b = b
|
|
36
|
+
if self.b != 0:
|
|
37
|
+
result = (self.a * self.b) / 100
|
|
38
|
+
return result
|
|
39
|
+
else:
|
|
40
|
+
return "Percentage by zero is not allowed"
|
|
41
|
+
|
|
42
|
+
def sqrt(self, a):
|
|
43
|
+
self.a = a
|
|
44
|
+
if self.a >= 0:
|
|
45
|
+
result = self.a ** 0.5
|
|
46
|
+
return result
|
|
47
|
+
else:
|
|
48
|
+
return "Square root of negative number is not allowed"
|
|
49
|
+
|
|
50
|
+
def square(self, a):
|
|
51
|
+
self.a = a
|
|
52
|
+
result = self.a ** 2
|
|
53
|
+
return result
|
|
54
|
+
|
|
55
|
+
def power(self, a, b):
|
|
56
|
+
self.a = a
|
|
57
|
+
self.b = b
|
|
58
|
+
result = self.a ** self.b
|
|
59
|
+
return result
|
|
60
|
+
|
|
61
|
+
def factorial(self, a):
|
|
62
|
+
self.a = a
|
|
63
|
+
if self.a < 0:
|
|
64
|
+
return "Factorial of negative number is not allowed"
|
|
65
|
+
elif self.a == 0 or self.a == 1:
|
|
66
|
+
return 1
|
|
67
|
+
else:
|
|
68
|
+
result = 1
|
|
69
|
+
for i in range(2, self.a + 1):
|
|
70
|
+
result *= i
|
|
71
|
+
return result
|
|
72
|
+
|
|
73
|
+
def gcd(self, a, b):
|
|
74
|
+
self.a = a
|
|
75
|
+
self.b = b
|
|
76
|
+
while self.b:
|
|
77
|
+
self.a, self.b = self.b, self.a % self.b
|
|
78
|
+
return abs(self.a)
|
|
79
|
+
|
|
80
|
+
def lcm(self, a, b):
|
|
81
|
+
self.a = a
|
|
82
|
+
self.b = b
|
|
83
|
+
if self.a == 0 or self.b == 0:
|
|
84
|
+
return 0
|
|
85
|
+
else:
|
|
86
|
+
return abs(self.a * self.b) // self.gcd(self.a, self.b)
|
|
87
|
+
|
|
88
|
+
def hcf(self, a, b):
|
|
89
|
+
return self.gcd(a, b)
|
|
90
|
+
|
|
91
|
+
def lcm_hcf(self, a, b):
|
|
92
|
+
hcf = self.hcf(a, b)
|
|
93
|
+
lcm = self.lcm(a, b)
|
|
94
|
+
return hcf, lcm
|
|
95
|
+
|
|
96
|
+
def is_prime(self, a):
|
|
97
|
+
self.a = a
|
|
98
|
+
if self.a <= 1:
|
|
99
|
+
return False
|
|
100
|
+
for i in range(2, int(self.a ** 0.5) + 1):
|
|
101
|
+
if self.a % i == 0:
|
|
102
|
+
return False
|
|
103
|
+
return True
|
|
104
|
+
|
|
105
|
+
def prime_factors(self, a):
|
|
106
|
+
self.a = a
|
|
107
|
+
factors = []
|
|
108
|
+
for i in range(2, int(self.a ** 0.5) + 1):
|
|
109
|
+
while self.a % i == 0:
|
|
110
|
+
factors.append(i)
|
|
111
|
+
self.a //= i
|
|
112
|
+
if self.a > 1:
|
|
113
|
+
factors.append(self.a)
|
|
114
|
+
return factors
|
|
115
|
+
|
|
116
|
+
def gst_calculator(self, price, gst_rate):
|
|
117
|
+
self.price = price
|
|
118
|
+
self.gst_rate = gst_rate
|
|
119
|
+
gst_amount = (self.price * self.gst_rate) / 100
|
|
120
|
+
total_price = self.price + gst_amount
|
|
121
|
+
return gst_amount, total_price
|
|
122
|
+
|
|
123
|
+
def discount_calculator(self, price, discount_rate):
|
|
124
|
+
self.price = price
|
|
125
|
+
self.discount_rate = discount_rate
|
|
126
|
+
discount_amount = (self.price * self.discount_rate) / 100
|
|
127
|
+
final_price = self.price - discount_amount
|
|
128
|
+
return discount_amount, final_price
|
|
129
|
+
|
|
130
|
+
def simple_interest(self, principal, rate, time):
|
|
131
|
+
self.principal = principal
|
|
132
|
+
self.rate = rate
|
|
133
|
+
self.time = time
|
|
134
|
+
interest = (self.principal * self.rate * self.time) / 100
|
|
135
|
+
return interest
|
|
136
|
+
|
|
137
|
+
def compound_interest(self, principal, rate, time, n=1):
|
|
138
|
+
self.principal = principal
|
|
139
|
+
self.rate = rate
|
|
140
|
+
self.time = time
|
|
141
|
+
self.n = n
|
|
142
|
+
amount = self.principal * (1 + (self.rate / (100 * self.n))) ** (self.n * self.time)
|
|
143
|
+
return amount - self.principal
|
|
144
|
+
|
|
145
|
+
def percentage_increase(self, original, new):
|
|
146
|
+
self.original = original
|
|
147
|
+
self.new = new
|
|
148
|
+
if self.original != 0:
|
|
149
|
+
increase = self.new - self.original
|
|
150
|
+
percentage_increase = (increase / self.original) * 100
|
|
151
|
+
return percentage_increase
|
|
152
|
+
else:
|
|
153
|
+
return "Original value cannot be zero for percentage increase calculation"
|
|
154
|
+
|
|
155
|
+
def percentage_decrease(self, original, new):
|
|
156
|
+
self.original = original
|
|
157
|
+
self.new = new
|
|
158
|
+
if self.original != 0:
|
|
159
|
+
decrease = self.original - self.new
|
|
160
|
+
percentage_decrease = (decrease / self.original) * 100
|
|
161
|
+
return percentage_decrease
|
|
162
|
+
else:
|
|
163
|
+
return "Original value cannot be zero for percentage decrease calculation"
|
|
164
|
+
|
|
165
|
+
def average(self, numbers):
|
|
166
|
+
self.numbers = numbers
|
|
167
|
+
if len(self.numbers) > 0:
|
|
168
|
+
return sum(self.numbers) / len(self.numbers)
|
|
169
|
+
else:
|
|
170
|
+
return "No numbers provided for average calculation"
|
|
171
|
+
|
|
172
|
+
def median(self, numbers):
|
|
173
|
+
self.numbers = sorted(numbers)
|
|
174
|
+
n = len(self.numbers)
|
|
175
|
+
if n % 2 == 0:
|
|
176
|
+
median = (self.numbers[n // 2 - 1] + self.numbers[n // 2]) / 2
|
|
177
|
+
else:
|
|
178
|
+
median = self.numbers[n // 2]
|
|
179
|
+
return median
|
|
180
|
+
|
|
181
|
+
def mode(self, numbers):
|
|
182
|
+
self.numbers = numbers
|
|
183
|
+
from collections import Counter
|
|
184
|
+
count = Counter(self.numbers)
|
|
185
|
+
mode_data = count.most_common()
|
|
186
|
+
mode = [num for num, freq in mode_data if freq == mode_data[0][1]]
|
|
187
|
+
return mode
|
|
188
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
class ConversionTools:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
def celsius_to_fahrenheit(self, celsius):
|
|
6
|
+
return (celsius * 9/5) + 32
|
|
7
|
+
|
|
8
|
+
def fahrenheit_to_celsius(self, fahrenheit):
|
|
9
|
+
return (fahrenheit - 32) * 5/9
|
|
10
|
+
|
|
11
|
+
def kilometers_to_miles(self, kilometers):
|
|
12
|
+
return kilometers * 0.621371
|
|
13
|
+
|
|
14
|
+
def miles_to_kilometers(self, miles):
|
|
15
|
+
return miles / 0.621371
|
|
16
|
+
|
|
17
|
+
def pounds_to_kilograms(self, pounds):
|
|
18
|
+
return pounds * 0.453592
|
|
19
|
+
|
|
20
|
+
def kilograms_to_pounds(self, kilograms):
|
|
21
|
+
return kilograms / 0.453592
|
|
22
|
+
|
|
23
|
+
def inches_to_centimeters(self, inches):
|
|
24
|
+
return inches * 2.54
|
|
25
|
+
|
|
26
|
+
def centimeters_to_inches(self, centimeters):
|
|
27
|
+
return centimeters / 2.54
|
|
28
|
+
|
|
29
|
+
def liters_to_gallons(self, liters):
|
|
30
|
+
return liters * 0.264172
|
|
31
|
+
|
|
32
|
+
def gallons_to_liters(self, gallons):
|
|
33
|
+
return gallons / 0.264172
|
|
34
|
+
|
|
35
|
+
def kilograms_to_grams(self, kilograms):
|
|
36
|
+
return kilograms * 1000
|
|
37
|
+
|
|
38
|
+
def grams_to_kilograms(self, grams):
|
|
39
|
+
return grams / 1000
|
|
40
|
+
|
|
41
|
+
def meters_to_feet(self, meters):
|
|
42
|
+
return meters * 3.28084
|
|
43
|
+
|
|
44
|
+
def feet_to_meters(self, feet):
|
|
45
|
+
return feet / 3.28084
|
|
46
|
+
|
|
47
|
+
def centimeters_to_meters(self, centimeters):
|
|
48
|
+
return centimeters / 100
|
|
49
|
+
|
|
50
|
+
def meters_to_centimeters(self, meters):
|
|
51
|
+
return meters * 100
|
|
52
|
+
|
|
53
|
+
def meters_to_kilometers(self, meters):
|
|
54
|
+
return meters / 1000
|
|
55
|
+
|
|
56
|
+
def kilometers_to_meters(self, kilometers):
|
|
57
|
+
return kilometers * 1000
|
|
58
|
+
|
|
59
|
+
def seconds_to_minutes(self, seconds):
|
|
60
|
+
return seconds / 60
|
|
61
|
+
|
|
62
|
+
def minutes_to_seconds(self, minutes):
|
|
63
|
+
return minutes * 60
|
|
64
|
+
|
|
65
|
+
def hours_to_minutes(self, hours):
|
|
66
|
+
return hours * 60
|
|
67
|
+
|
|
68
|
+
def minutes_to_hours(self, minutes):
|
|
69
|
+
return minutes / 60
|
|
70
|
+
|
|
71
|
+
def days_to_weeks(self, days):
|
|
72
|
+
return days / 7
|
|
73
|
+
|
|
74
|
+
def weeks_to_days(self, weeks):
|
|
75
|
+
return weeks * 7
|
|
76
|
+
|
|
77
|
+
def years_to_months(self, years):
|
|
78
|
+
return years * 12
|
|
79
|
+
|
|
80
|
+
def months_to_years(self, months):
|
|
81
|
+
return months / 12
|
|
82
|
+
|
|
83
|
+
def years_to_days(self, years):
|
|
84
|
+
return years * 365.25
|
|
85
|
+
|
|
86
|
+
def days_to_years(self, days):
|
|
87
|
+
return days / 365.25
|
|
88
|
+
|
|
89
|
+
def hours_to_seconds(self, hours):
|
|
90
|
+
return hours * 3600
|
|
91
|
+
|
|
92
|
+
def seconds_to_hours(self, seconds):
|
|
93
|
+
return seconds / 3600
|
|
94
|
+
|
|
95
|
+
def liters_to_milliliters(self, liters):
|
|
96
|
+
return liters * 1000
|
|
97
|
+
|
|
98
|
+
def milliliters_to_liters(self, milliliters):
|
|
99
|
+
return milliliters / 1000
|
|
100
|
+
|
|
101
|
+
def celsius_to_kelvin(self, celsius):
|
|
102
|
+
return celsius + 273.15
|
|
103
|
+
|
|
104
|
+
def kelvin_to_celsius(self, kelvin):
|
|
105
|
+
return kelvin - 273.15
|
|
106
|
+
|
|
107
|
+
def fahrenheit_to_kelvin(self, fahrenheit):
|
|
108
|
+
return (fahrenheit - 32) * 5/9 + 273.15
|
|
109
|
+
|
|
110
|
+
def kelvin_to_fahrenheit(self, kelvin):
|
|
111
|
+
return (kelvin - 273.15) * 9/5 + 32
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
class DateTimeTools:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
def get_date(self):
|
|
6
|
+
from datetime import date
|
|
7
|
+
return date.today()
|
|
8
|
+
|
|
9
|
+
def get_time(self):
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
return datetime.now().time()
|
|
12
|
+
|
|
13
|
+
def get_datetime(self):
|
|
14
|
+
from datetime import datetime
|
|
15
|
+
return datetime.now()
|
|
16
|
+
|
|
17
|
+
def format_date(self, date_obj, format_str="%Y-%m-%d"):
|
|
18
|
+
return date_obj.strftime(format_str)
|
|
19
|
+
|
|
20
|
+
def format_time(self, time_obj, format_str="%H:%M:%S"):
|
|
21
|
+
return time_obj.strftime(format_str)
|
|
22
|
+
|
|
23
|
+
def format_datetime(self, datetime_obj, format_str="%Y-%m-%d %H:%M:%S"):
|
|
24
|
+
return datetime_obj.strftime(format_str)
|
|
25
|
+
|
|
26
|
+
def days_between_dates(self, start_date, end_date):
|
|
27
|
+
from datetime import datetime
|
|
28
|
+
start = datetime.strptime(start_date, "%Y-%m-%d")
|
|
29
|
+
end = datetime.strptime(end_date, "%Y-%m-%d")
|
|
30
|
+
delta = end - start
|
|
31
|
+
return delta.days
|
|
32
|
+
|
|
33
|
+
def age_calculator(self, birth_date):
|
|
34
|
+
from datetime import datetime
|
|
35
|
+
birth = datetime.strptime(birth_date, "%Y-%m-%d")
|
|
36
|
+
today = datetime.now()
|
|
37
|
+
age = today.year - birth.year - ((today.month, today.day) < (birth.month, birth.day))
|
|
38
|
+
return age
|
|
39
|
+
|
|
40
|
+
def add_days(self, date_str, days):
|
|
41
|
+
from datetime import datetime, timedelta
|
|
42
|
+
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
|
|
43
|
+
new_date = date_obj + timedelta(days=days)
|
|
44
|
+
return new_date.strftime("%Y-%m-%d")
|
|
45
|
+
|
|
46
|
+
def subtract_days(self, date_str, days):
|
|
47
|
+
from datetime import datetime, timedelta
|
|
48
|
+
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
|
|
49
|
+
new_date = date_obj - timedelta(days=days)
|
|
50
|
+
return new_date.strftime("%Y-%m-%d")
|
|
51
|
+
|
|
52
|
+
def is_leap_year(self, year):
|
|
53
|
+
return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
|
|
54
|
+
|
|
55
|
+
def get_weekday(self, date_str):
|
|
56
|
+
from datetime import datetime
|
|
57
|
+
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
|
|
58
|
+
return date_obj.strftime("%A")
|
|
59
|
+
|
|
60
|
+
def get_month_name(self, month_number):
|
|
61
|
+
import calendar
|
|
62
|
+
if 1 <= month_number <= 12:
|
|
63
|
+
return calendar.month_name[month_number]
|
|
64
|
+
else:
|
|
65
|
+
return "Invalid month number"
|
|
66
|
+
|
|
67
|
+
def get_day_of_year(self, date_str):
|
|
68
|
+
from datetime import datetime
|
|
69
|
+
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
|
|
70
|
+
return date_obj.timetuple().tm_yday
|
|
71
|
+
|
|
72
|
+
def get_week_number(self, date_str):
|
|
73
|
+
from datetime import datetime
|
|
74
|
+
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
|
|
75
|
+
return date_obj.isocalendar()[1]
|
ToolVerse/file_tools.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
class FileTools:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
def read_file(self, file_path):
|
|
9
|
+
with open(file_path, 'r') as file:
|
|
10
|
+
return file.read()
|
|
11
|
+
|
|
12
|
+
def write_file(self, file_path, content):
|
|
13
|
+
with open(file_path, 'w') as file:
|
|
14
|
+
file.write(content)
|
|
15
|
+
|
|
16
|
+
def append_to_file(self, file_path, content):
|
|
17
|
+
with open(file_path, 'a') as file:
|
|
18
|
+
file.write(content)
|
|
19
|
+
|
|
20
|
+
def count_lines(self, file_path):
|
|
21
|
+
with open(file_path, 'r') as file:
|
|
22
|
+
return len(file.readlines())
|
|
23
|
+
|
|
24
|
+
def count_words(self, file_path):
|
|
25
|
+
with open(file_path, 'r') as file:
|
|
26
|
+
text = file.read()
|
|
27
|
+
words = text.split()
|
|
28
|
+
return len(words)
|
|
29
|
+
|
|
30
|
+
def count_characters(self, file_path):
|
|
31
|
+
with open(file_path, 'r') as file:
|
|
32
|
+
text = file.read()
|
|
33
|
+
return len(text)
|
|
34
|
+
|
|
35
|
+
def find_and_replace(self, file_path, find_str, replace_str):
|
|
36
|
+
with open(file_path, 'r') as file:
|
|
37
|
+
text = file.read()
|
|
38
|
+
new_text = text.replace(find_str, replace_str)
|
|
39
|
+
with open(file_path, 'w') as file:
|
|
40
|
+
file.write(new_text)
|
|
41
|
+
|
|
42
|
+
def create_file(self, file_path):
|
|
43
|
+
with open(file_path, 'w') as file:
|
|
44
|
+
pass # Just create an empty file
|
|
45
|
+
|
|
46
|
+
def delete_file(self, file_path):
|
|
47
|
+
if os.path.exists(file_path):
|
|
48
|
+
os.remove(file_path)
|
|
49
|
+
else:
|
|
50
|
+
return "File does not exist"
|
|
51
|
+
|
|
52
|
+
def file_exists(self, file_path):
|
|
53
|
+
return os.path.exists(file_path)
|
|
54
|
+
|
|
55
|
+
def get_file_size(self, file_path):
|
|
56
|
+
if os.path.exists(file_path):
|
|
57
|
+
return os.path.getsize(file_path)
|
|
58
|
+
else:
|
|
59
|
+
return "File does not exist"
|
|
60
|
+
|
|
61
|
+
def get_file_extension(self, file_path):
|
|
62
|
+
return os.path.splitext(file_path)[1]
|
|
63
|
+
|
|
64
|
+
def list_files_in_directory(self, directory_path):
|
|
65
|
+
if os.path.exists(directory_path) and os.path.isdir(directory_path):
|
|
66
|
+
return os.listdir(directory_path)
|
|
67
|
+
else:
|
|
68
|
+
return "Directory does not exist"
|
|
69
|
+
|
|
70
|
+
def copy_file(self, source_path, destination_path):
|
|
71
|
+
if os.path.exists(source_path):
|
|
72
|
+
shutil.copy(source_path, destination_path)
|
|
73
|
+
else:
|
|
74
|
+
return "Source file does not exist"
|
|
75
|
+
|
|
76
|
+
def move_file(self, source_path, destination_path):
|
|
77
|
+
if os.path.exists(source_path):
|
|
78
|
+
shutil.move(source_path, destination_path)
|
|
79
|
+
else:
|
|
80
|
+
return "Source file does not exist"
|
|
81
|
+
|
|
82
|
+
def rename_file(self, old_path, new_path):
|
|
83
|
+
if os.path.exists(old_path):
|
|
84
|
+
os.rename(old_path, new_path)
|
|
85
|
+
else:
|
|
86
|
+
return "File does not exist"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
class NumberTools:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
def is_even(self, number):
|
|
6
|
+
return number % 2 == 0
|
|
7
|
+
|
|
8
|
+
def is_odd(self, number):
|
|
9
|
+
return number % 2 != 0
|
|
10
|
+
|
|
11
|
+
def is_prime(self, number):
|
|
12
|
+
if number <= 1:
|
|
13
|
+
return False
|
|
14
|
+
for i in range(2, int(number ** 0.5) + 1):
|
|
15
|
+
if number % i == 0:
|
|
16
|
+
return False
|
|
17
|
+
return True
|
|
18
|
+
|
|
19
|
+
def prime_factors(self, number):
|
|
20
|
+
factors = []
|
|
21
|
+
for i in range(2, int(number ** 0.5) + 1):
|
|
22
|
+
while number % i == 0:
|
|
23
|
+
factors.append(i)
|
|
24
|
+
number //= i
|
|
25
|
+
if number > 1:
|
|
26
|
+
factors.append(number)
|
|
27
|
+
return factors
|
|
28
|
+
|
|
29
|
+
def is_perfect_square(self, number):
|
|
30
|
+
return int(number ** 0.5) ** 2 == number
|
|
31
|
+
|
|
32
|
+
def fibonacci(self, n):
|
|
33
|
+
if n <= 0:
|
|
34
|
+
return []
|
|
35
|
+
elif n == 1:
|
|
36
|
+
return [0]
|
|
37
|
+
elif n == 2:
|
|
38
|
+
return [0, 1]
|
|
39
|
+
else:
|
|
40
|
+
fib_sequence = [0, 1]
|
|
41
|
+
for i in range(2, n):
|
|
42
|
+
next_fib = fib_sequence[-1] + fib_sequence[-2]
|
|
43
|
+
fib_sequence.append(next_fib)
|
|
44
|
+
return fib_sequence
|
|
45
|
+
|
|
46
|
+
def multiplication_table(self, number, up_to=10):
|
|
47
|
+
table = []
|
|
48
|
+
for i in range(1, up_to + 1):
|
|
49
|
+
table.append(f"{number} x {i} = {number * i}")
|
|
50
|
+
return table
|
|
51
|
+
|
|
52
|
+
def decimal_to_binary(self, number):
|
|
53
|
+
return bin(number)[2:]
|
|
54
|
+
|
|
55
|
+
def binary_to_decimal(self, binary_str):
|
|
56
|
+
return int(binary_str, 2)
|
|
57
|
+
|
|
58
|
+
def fectorial(self, number):
|
|
59
|
+
if number < 0:
|
|
60
|
+
return "Factorial of negative number is not allowed"
|
|
61
|
+
elif number == 0 or number == 1:
|
|
62
|
+
return 1
|
|
63
|
+
else:
|
|
64
|
+
result = 1
|
|
65
|
+
for i in range(2, number + 1):
|
|
66
|
+
result *= i
|
|
67
|
+
return result
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
class PasswordTools:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
pass
|
|
4
|
+
|
|
5
|
+
def generate_password(self, length=12):
|
|
6
|
+
import random
|
|
7
|
+
import string
|
|
8
|
+
characters = string.ascii_letters + string.digits + string.punctuation
|
|
9
|
+
password = ''.join(random.choice(characters) for _ in range(length))
|
|
10
|
+
return password
|
|
11
|
+
|
|
12
|
+
def password_strength(self, password):
|
|
13
|
+
import re
|
|
14
|
+
if len(password) < 8:
|
|
15
|
+
return "Weak"
|
|
16
|
+
elif re.search(r'[A-Z]', password) and re.search(r'[a-z]', password) and re.search(r'[0-9]', password) and re.search(r'[@$!%*?&]', password):
|
|
17
|
+
return "Strong"
|
|
18
|
+
else:
|
|
19
|
+
return "Moderate"
|
|
20
|
+
|
|
21
|
+
def hash_password(self, password):
|
|
22
|
+
import hashlib
|
|
23
|
+
return hashlib.sha256(password.encode()).hexdigest()
|
|
24
|
+
|
|
25
|
+
def verify_password(self, password, hashed_password):
|
|
26
|
+
return self.hash_password(password) == hashed_password
|
|
27
|
+
|
|
28
|
+
def password_contains_uppercase(self, password):
|
|
29
|
+
return any(char.isupper() for char in password)
|
|
30
|
+
|
|
31
|
+
def password_contains_lowercase(self, password):
|
|
32
|
+
return any(char.islower() for char in password)
|
|
33
|
+
|
|
34
|
+
def password_contains_digit(self, password):
|
|
35
|
+
return any(char.isdigit() for char in password)
|
|
36
|
+
|
|
37
|
+
def password_contains_special_char(self, password):
|
|
38
|
+
import string
|
|
39
|
+
return any(char in string.punctuation for char in password)
|
|
40
|
+
|
|
41
|
+
def password_length(self, password):
|
|
42
|
+
return len(password)
|
|
43
|
+
|
|
44
|
+
def generate_strong_password(self, length=12):
|
|
45
|
+
while True:
|
|
46
|
+
password = self.generate_password(length)
|
|
47
|
+
if self.password_strength(password) == "Strong":
|
|
48
|
+
return password
|
|
49
|
+
|
|
50
|
+
def generate_password_with_criteria(self, length=12, uppercase=True, lowercase=True, digits=True, special_chars=True):
|
|
51
|
+
import random
|
|
52
|
+
import string
|
|
53
|
+
characters = ''
|
|
54
|
+
if uppercase:
|
|
55
|
+
characters += string.ascii_uppercase
|
|
56
|
+
if lowercase:
|
|
57
|
+
characters += string.ascii_lowercase
|
|
58
|
+
if digits:
|
|
59
|
+
characters += string.digits
|
|
60
|
+
if special_chars:
|
|
61
|
+
characters += string.punctuation
|
|
62
|
+
if not characters:
|
|
63
|
+
return "At least one character type must be selected"
|
|
64
|
+
password = ''.join(random.choice(characters) for _ in range(length))
|
|
65
|
+
return password
|
|
66
|
+
|
|
67
|
+
def password_meets_criteria(self, password, uppercase=True, lowercase=True, digits=True, special_chars=True):
|
|
68
|
+
if uppercase and not self.password_contains_uppercase(password):
|
|
69
|
+
return False
|
|
70
|
+
if lowercase and not self.password_contains_lowercase(password):
|
|
71
|
+
return False
|
|
72
|
+
if digits and not self.password_contains_digit(password):
|
|
73
|
+
return False
|
|
74
|
+
if special_chars and not self.password_contains_special_char(password):
|
|
75
|
+
return False
|
|
76
|
+
return True
|
|
77
|
+
|
|
78
|
+
def generate_password_with_all_criteria(self, length=12):
|
|
79
|
+
while True:
|
|
80
|
+
password = self.generate_password(length)
|
|
81
|
+
if self.password_meets_criteria(password):
|
|
82
|
+
return password
|
|
83
|
+
|
|
84
|
+
def generate_pin(self, length=4):
|
|
85
|
+
import random
|
|
86
|
+
digits = '0123456789'
|
|
87
|
+
pin = ''.join(random.choice(digits) for _ in range(length))
|
|
88
|
+
return pin
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import random
|
|
2
|
+
class RandomTools:
|
|
3
|
+
def __init__(self):
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
def random_integer(self, start, end):
|
|
7
|
+
return random.randint(start, end)
|
|
8
|
+
|
|
9
|
+
def random_float(self, start, end):
|
|
10
|
+
return random.uniform(start, end)
|
|
11
|
+
|
|
12
|
+
def random_choice(self, sequence):
|
|
13
|
+
return random.choice(sequence)
|
|
14
|
+
|
|
15
|
+
def random_sample(self, population, k):
|
|
16
|
+
return random.sample(population, k)
|
|
17
|
+
|
|
18
|
+
def shuffle_list(self, lst):
|
|
19
|
+
random.shuffle(lst)
|
|
20
|
+
return lst
|
|
21
|
+
|
|
22
|
+
def generate_random_string(self, length=8):
|
|
23
|
+
import string
|
|
24
|
+
characters = string.ascii_letters + string.digits + string.punctuation
|
|
25
|
+
return ''.join(random.choice(characters) for _ in range(length))
|
|
26
|
+
|
|
27
|
+
def random_number_with_digits(self, digits):
|
|
28
|
+
if digits <= 0:
|
|
29
|
+
return "Number of digits must be positive"
|
|
30
|
+
start = 10 ** (digits - 1)
|
|
31
|
+
end = (10 ** digits) - 1
|
|
32
|
+
return random.randint(start, end)
|
|
33
|
+
|
|
34
|
+
def dice_roll(self, sides=6):
|
|
35
|
+
return random.randint(1, sides)
|
|
36
|
+
|
|
37
|
+
def coin_flip(self):
|
|
38
|
+
return random.choice(['Heads', 'Tails'])
|
|
39
|
+
|
|
40
|
+
def random_color(self):
|
|
41
|
+
return "#{:06x}".format(random.randint(0, 0xFFFFFF))
|
|
42
|
+
|
|
43
|
+
def random_date(self, start_year=2000, end_year=2020):
|
|
44
|
+
from datetime import datetime, timedelta
|
|
45
|
+
start_date = datetime(start_year, 1, 1)
|
|
46
|
+
end_date = datetime(end_year, 12, 31)
|
|
47
|
+
delta = end_date - start_date
|
|
48
|
+
random_days = random.randint(0, delta.days)
|
|
49
|
+
random_date = start_date + timedelta(days=random_days)
|
|
50
|
+
return random_date.strftime("%Y-%m-%d")
|
|
51
|
+
|
|
52
|
+
def random_password(self, length=12):
|
|
53
|
+
import string
|
|
54
|
+
characters = string.ascii_letters + string.digits + string.punctuation
|
|
55
|
+
return ''.join(random.choice(characters) for _ in range(length))
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class StringTools:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
self.string = ""
|
|
4
|
+
|
|
5
|
+
def set_string(self, string):
|
|
6
|
+
self.string = string
|
|
7
|
+
|
|
8
|
+
def get_string(self):
|
|
9
|
+
return self.string
|
|
10
|
+
|
|
11
|
+
def reverse_string(self):
|
|
12
|
+
return self.string[::-1]
|
|
13
|
+
|
|
14
|
+
def is_palindrome(self):
|
|
15
|
+
return self.string == self.reverse_string()
|
|
16
|
+
|
|
17
|
+
def to_uppercase(self):
|
|
18
|
+
return self.string.upper()
|
|
19
|
+
|
|
20
|
+
def to_lowercase(self):
|
|
21
|
+
return self.string.lower()
|
|
22
|
+
|
|
23
|
+
def count_vowels(self):
|
|
24
|
+
vowels = "aeiouAEIOU"
|
|
25
|
+
count = sum(1 for char in self.string if char in vowels)
|
|
26
|
+
return count
|
|
27
|
+
|
|
28
|
+
def count_consonants(self):
|
|
29
|
+
vowels = "aeiouAEIOU"
|
|
30
|
+
count = sum(1 for char in self.string if char.isalpha() and char not in vowels)
|
|
31
|
+
return count
|
|
32
|
+
|
|
33
|
+
def count_words(self):
|
|
34
|
+
words = self.string.split()
|
|
35
|
+
return len(words)
|
|
36
|
+
|
|
37
|
+
def count_characters(self):
|
|
38
|
+
return len(self.string)
|
|
39
|
+
|
|
40
|
+
def is_anagram(self, other_string):
|
|
41
|
+
return sorted(self.string) == sorted(other_string)
|
|
42
|
+
|
|
43
|
+
def capitalize_words(self):
|
|
44
|
+
return ' '.join(word.capitalize() for word in self.string.split())
|
|
45
|
+
|
|
46
|
+
def remove_spaces(self):
|
|
47
|
+
return self.string.replace(" ", "")
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
class StudentTools:
|
|
2
|
+
def __init__(self):
|
|
3
|
+
self.students = {}
|
|
4
|
+
|
|
5
|
+
def add_student(self, student_id, name, age):
|
|
6
|
+
self.students[student_id] = {'name': name, 'age': age}
|
|
7
|
+
|
|
8
|
+
def get_student(self, student_id):
|
|
9
|
+
return self.students.get(student_id, "Student not found")
|
|
10
|
+
|
|
11
|
+
def remove_student(self, student_id):
|
|
12
|
+
if student_id in self.students:
|
|
13
|
+
del self.students[student_id]
|
|
14
|
+
else:
|
|
15
|
+
return "Student not found"
|
|
16
|
+
|
|
17
|
+
def update_student(self, student_id, name=None, age=None):
|
|
18
|
+
if student_id in self.students:
|
|
19
|
+
if name is not None:
|
|
20
|
+
self.students[student_id]['name'] = name
|
|
21
|
+
if age is not None:
|
|
22
|
+
self.students[student_id]['age'] = age
|
|
23
|
+
else:
|
|
24
|
+
return "Student not found"
|
|
25
|
+
|
|
26
|
+
def list_students(self):
|
|
27
|
+
return self.students
|
|
28
|
+
|
|
29
|
+
def count_students(self):
|
|
30
|
+
return len(self.students)
|
|
31
|
+
|
|
32
|
+
def calculate_percentage(self, student_id, marks_obtained, total_marks):
|
|
33
|
+
if student_id in self.students:
|
|
34
|
+
percentage = (marks_obtained / total_marks) * 100
|
|
35
|
+
self.students[student_id]['percentage'] = percentage
|
|
36
|
+
return percentage
|
|
37
|
+
else:
|
|
38
|
+
return "Student not found"
|
|
39
|
+
|
|
40
|
+
def calculate_grade(self, student_id):
|
|
41
|
+
if student_id in self.students:
|
|
42
|
+
percentage = self.students[student_id].get('percentage', None)
|
|
43
|
+
if percentage is not None:
|
|
44
|
+
if percentage >= 90:
|
|
45
|
+
grade = 'A'
|
|
46
|
+
elif percentage >= 80:
|
|
47
|
+
grade = 'B'
|
|
48
|
+
elif percentage >= 70:
|
|
49
|
+
grade = 'C'
|
|
50
|
+
elif percentage >= 60:
|
|
51
|
+
grade = 'D'
|
|
52
|
+
else:
|
|
53
|
+
grade = 'F'
|
|
54
|
+
self.students[student_id]['grade'] = grade
|
|
55
|
+
return grade
|
|
56
|
+
else:
|
|
57
|
+
return "Percentage not calculated for this student"
|
|
58
|
+
else:
|
|
59
|
+
return "Student not found"
|
|
60
|
+
|
|
61
|
+
def calculate_cgpa(self, student_id, grades):
|
|
62
|
+
if student_id in self.students:
|
|
63
|
+
grade_points = {'A': 4.0, 'B': 3.0, 'C': 2.0, 'D': 1.0, 'F': 0.0}
|
|
64
|
+
total_points = sum(grade_points.get(grade, 0) for grade in grades)
|
|
65
|
+
gpa = total_points / len(grades)
|
|
66
|
+
self.students[student_id]['gpa'] = gpa
|
|
67
|
+
return gpa
|
|
68
|
+
else:
|
|
69
|
+
return "Student not found"
|
|
70
|
+
|
|
71
|
+
def get_student_report(self, student_id):
|
|
72
|
+
if student_id in self.students:
|
|
73
|
+
student = self.students[student_id]
|
|
74
|
+
report = f"Student ID: {student_id}\n"
|
|
75
|
+
report += f"Name: {student['name']}\n"
|
|
76
|
+
report += f"Age: {student['age']}\n"
|
|
77
|
+
report += f"Percentage: {student.get('percentage', 'Not calculated')}\n"
|
|
78
|
+
report += f"Grade: {student.get('grade', 'Not calculated')}\n"
|
|
79
|
+
report += f"GPA: {student.get('gpa', 'Not calculated')}\n"
|
|
80
|
+
return report
|
|
81
|
+
else:
|
|
82
|
+
return "Student not found"
|
|
83
|
+
|
|
84
|
+
def get_all_students_report(self):
|
|
85
|
+
report = ""
|
|
86
|
+
for student_id, student in self.students.items():
|
|
87
|
+
report += f"Student ID: {student_id}\n"
|
|
88
|
+
report += f"Name: {student['name']}\n"
|
|
89
|
+
report += f"Age: {student['age']}\n"
|
|
90
|
+
report += f"Percentage: {student.get('percentage', 'Not calculated')}\n"
|
|
91
|
+
report += f"Grade: {student.get('grade', 'Not calculated')}\n"
|
|
92
|
+
report += f"GPA: {student.get('gpa', 'Not calculated')}\n"
|
|
93
|
+
report += "-------------------------\n"
|
|
94
|
+
return report
|
|
95
|
+
|
|
96
|
+
def get_top_student(self):
|
|
97
|
+
top_student_id = None
|
|
98
|
+
top_percentage = -1
|
|
99
|
+
for student_id, student in self.students.items():
|
|
100
|
+
percentage = student.get('percentage', None)
|
|
101
|
+
if percentage is not None and percentage > top_percentage:
|
|
102
|
+
top_percentage = percentage
|
|
103
|
+
top_student_id = student_id
|
|
104
|
+
if top_student_id is not None:
|
|
105
|
+
return self.get_student_report(top_student_id)
|
|
106
|
+
else:
|
|
107
|
+
return "No students with calculated percentage"
|
|
108
|
+
|
|
109
|
+
def get_bottom_student(self):
|
|
110
|
+
bottom_student_id = None
|
|
111
|
+
bottom_percentage = float('inf')
|
|
112
|
+
for student_id, student in self.students.items():
|
|
113
|
+
percentage = student.get('percentage', None)
|
|
114
|
+
if percentage is not None and percentage < bottom_percentage:
|
|
115
|
+
bottom_percentage = percentage
|
|
116
|
+
bottom_student_id = student_id
|
|
117
|
+
if bottom_student_id is not None:
|
|
118
|
+
return self.get_student_report(bottom_student_id)
|
|
119
|
+
else:
|
|
120
|
+
return "No students with calculated percentage"
|
|
121
|
+
|
|
122
|
+
def get_average_percentage(self):
|
|
123
|
+
total_percentage = 0
|
|
124
|
+
count = 0
|
|
125
|
+
for student in self.students.values():
|
|
126
|
+
percentage = student.get('percentage', None)
|
|
127
|
+
if percentage is not None:
|
|
128
|
+
total_percentage += percentage
|
|
129
|
+
count += 1
|
|
130
|
+
if count > 0:
|
|
131
|
+
return total_percentage / count
|
|
132
|
+
else:
|
|
133
|
+
return "No students with calculated percentage"
|
|
134
|
+
|
|
135
|
+
def get_average_gpa(self):
|
|
136
|
+
total_gpa = 0
|
|
137
|
+
count = 0
|
|
138
|
+
for student in self.students.values():
|
|
139
|
+
gpa = student.get('gpa', None)
|
|
140
|
+
if gpa is not None:
|
|
141
|
+
total_gpa += gpa
|
|
142
|
+
count += 1
|
|
143
|
+
if count > 0:
|
|
144
|
+
return total_gpa / count
|
|
145
|
+
else:
|
|
146
|
+
return "No students with calculated GPA"
|
|
147
|
+
|
|
148
|
+
def get_students_with_grade(self, grade):
|
|
149
|
+
students_with_grade = []
|
|
150
|
+
for student_id, student in self.students.items():
|
|
151
|
+
if student.get('grade', None) == grade:
|
|
152
|
+
students_with_grade.append(student_id)
|
|
153
|
+
return students_with_grade
|
|
154
|
+
|
|
155
|
+
def get_students_above_percentage(self, percentage):
|
|
156
|
+
students_above = []
|
|
157
|
+
for student_id, student in self.students.items():
|
|
158
|
+
student_percentage = student.get('percentage', None)
|
|
159
|
+
if student_percentage is not None and student_percentage > percentage:
|
|
160
|
+
students_above.append(student_id)
|
|
161
|
+
return students_above
|
|
162
|
+
|
|
163
|
+
def get_students_below_percentage(self, percentage):
|
|
164
|
+
students_below = []
|
|
165
|
+
for student_id, student in self.students.items():
|
|
166
|
+
student_percentage = student.get('percentage', None)
|
|
167
|
+
if student_percentage is not None and student_percentage < percentage:
|
|
168
|
+
students_below.append(student_id)
|
|
169
|
+
return students_below
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import psutil
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class SystemTools:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
def get_os_name(self):
|
|
10
|
+
return os.name
|
|
11
|
+
|
|
12
|
+
def get_current_working_directory(self):
|
|
13
|
+
return os.getcwd()
|
|
14
|
+
|
|
15
|
+
def list_directory_contents(self, path='.'):
|
|
16
|
+
return os.listdir(path)
|
|
17
|
+
|
|
18
|
+
def create_directory(self, path):
|
|
19
|
+
os.makedirs(path, exist_ok=True)
|
|
20
|
+
|
|
21
|
+
def remove_directory(self, path):
|
|
22
|
+
os.rmdir(path)
|
|
23
|
+
|
|
24
|
+
def get_environment_variable(self, var_name):
|
|
25
|
+
return os.environ.get(var_name)
|
|
26
|
+
|
|
27
|
+
def set_environment_variable(self, var_name, value):
|
|
28
|
+
os.environ[var_name] = value
|
|
29
|
+
|
|
30
|
+
def delete_environment_variable(self, var_name):
|
|
31
|
+
if var_name in os.environ:
|
|
32
|
+
del os.environ[var_name]
|
|
33
|
+
|
|
34
|
+
def get_Python_version(self):
|
|
35
|
+
import sys
|
|
36
|
+
return sys.version
|
|
37
|
+
|
|
38
|
+
def get_current_directory(self):
|
|
39
|
+
return os.getcwd()
|
|
40
|
+
|
|
41
|
+
def change_directory(self, path):
|
|
42
|
+
os.chdir(path)
|
|
43
|
+
|
|
44
|
+
def get_file_permissions(self, file_path):
|
|
45
|
+
import stat
|
|
46
|
+
if os.path.exists(file_path):
|
|
47
|
+
permissions = stat.filemode(os.stat(file_path).st_mode)
|
|
48
|
+
return permissions
|
|
49
|
+
else:
|
|
50
|
+
return "File does not exist"
|
|
51
|
+
|
|
52
|
+
def set_file_permissions(self, file_path, mode):
|
|
53
|
+
import os
|
|
54
|
+
if os.path.exists(file_path):
|
|
55
|
+
os.chmod(file_path, mode)
|
|
56
|
+
else:
|
|
57
|
+
return "File does not exist"
|
|
58
|
+
|
|
59
|
+
def get_system_info(self):
|
|
60
|
+
import platform
|
|
61
|
+
return {
|
|
62
|
+
"system": platform.system(),
|
|
63
|
+
"node": platform.node(),
|
|
64
|
+
"release": platform.release(),
|
|
65
|
+
"version": platform.version(),
|
|
66
|
+
"machine": platform.machine(),
|
|
67
|
+
"processor": platform.processor()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
def get_environment_variables(self):
|
|
71
|
+
return dict(os.environ)
|
|
72
|
+
|
|
73
|
+
def get_process_id(self):
|
|
74
|
+
import os
|
|
75
|
+
return os.getpid()
|
|
76
|
+
|
|
77
|
+
def get_parent_process_id(self):
|
|
78
|
+
import os
|
|
79
|
+
return os.getppid()
|
|
80
|
+
|
|
81
|
+
def get_user_id(self):
|
|
82
|
+
import os
|
|
83
|
+
return os.getuid() if hasattr(os, 'getuid') else None
|
|
84
|
+
|
|
85
|
+
def get_group_id(self):
|
|
86
|
+
import os
|
|
87
|
+
return os.getgid() if hasattr(os, 'getgid') else None
|
|
88
|
+
|
|
89
|
+
def get_current_user(self):
|
|
90
|
+
import getpass
|
|
91
|
+
return getpass.getuser()
|
|
92
|
+
|
|
93
|
+
def get_home_directory(self):
|
|
94
|
+
return os.path.expanduser("~")
|
|
95
|
+
|
|
96
|
+
def get_temp_directory(self):
|
|
97
|
+
import tempfile
|
|
98
|
+
return tempfile.gettempdir()
|
|
99
|
+
|
|
100
|
+
def get_current_timestamp(self):
|
|
101
|
+
import time
|
|
102
|
+
return time.time()
|
|
103
|
+
|
|
104
|
+
def get_current_datetime(self):
|
|
105
|
+
from datetime import datetime
|
|
106
|
+
return datetime.now()
|
|
107
|
+
|
|
108
|
+
def get_system_uptime(self):
|
|
109
|
+
import time
|
|
110
|
+
if hasattr(time, 'monotonic'):
|
|
111
|
+
return time.monotonic()
|
|
112
|
+
else:
|
|
113
|
+
return "System uptime not available"
|
|
114
|
+
|
|
115
|
+
def get_cpu_count(self):
|
|
116
|
+
import os
|
|
117
|
+
return os.cpu_count()
|
|
118
|
+
|
|
119
|
+
def get_memory_info(self):
|
|
120
|
+
import psutil
|
|
121
|
+
mem = psutil.virtual_memory()
|
|
122
|
+
return {
|
|
123
|
+
"total": mem.total,
|
|
124
|
+
"available": mem.available,
|
|
125
|
+
"used": mem.used,
|
|
126
|
+
"free": mem.free
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
def get_disk_usage(self, path='/'):
|
|
130
|
+
import shutil
|
|
131
|
+
total, used, free = shutil.disk_usage(path)
|
|
132
|
+
return {
|
|
133
|
+
"total": total,
|
|
134
|
+
"used": used,
|
|
135
|
+
"free": free
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
def get_network_info(self):
|
|
139
|
+
net_if_addrs = psutil.net_if_addrs()
|
|
140
|
+
net_if_stats = psutil.net_if_stats()
|
|
141
|
+
network_info = {}
|
|
142
|
+
for interface, addrs in net_if_addrs.items():
|
|
143
|
+
network_info[interface] = {
|
|
144
|
+
"addresses": [addr.address for addr in addrs],
|
|
145
|
+
"is_up": net_if_stats[interface].isup if interface in net_if_stats else None
|
|
146
|
+
}
|
|
147
|
+
return network_info
|
|
148
|
+
|
|
149
|
+
def get_system_load(self):
|
|
150
|
+
import os
|
|
151
|
+
if hasattr(os, 'getloadavg'):
|
|
152
|
+
return os.getloadavg()
|
|
153
|
+
else:
|
|
154
|
+
return "System load not available"
|
|
155
|
+
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ToolVerse
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: A personal Python utility library
|
|
5
|
+
Author: Mohammed Ayaz
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Mohammed Ayaz
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/gaderjimrs-creator/MyPythonLibrary
|
|
30
|
+
Project-URL: Repository, https://github.com/gaderjimrs-creator/MyPythonLibrary
|
|
31
|
+
Project-URL: Issues, https://github.com/gaderjimrs-creator/MyPythonLibrary/issues
|
|
32
|
+
Keywords: python,utilities,calculator,password-generator,string-tools,file-tools
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Requires-Python: >=3.10
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
Requires-Dist: psutil
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# ToolVerse
|
|
43
|
+
|
|
44
|
+
A powerful Python utility library created by **Mohammed Ayaz**.
|
|
45
|
+
This library provides ready-to-use tools for calculations, string operations, number utilities, password generation, file handling, date & time operations, random generators, student management, system utilities, and more.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
| Module | Description |
|
|
52
|
+
| ---------------- | ----------------------------------------------- |
|
|
53
|
+
| calculator | Mathematical calculations and utility functions |
|
|
54
|
+
| conversion_tools | Unit and measurement conversions |
|
|
55
|
+
| date_time_tools | Date and time utilities |
|
|
56
|
+
| file_tools | File management operations |
|
|
57
|
+
| number_tools | Number-related utilities |
|
|
58
|
+
| password_tools | Password generation and security tools |
|
|
59
|
+
| random_tools | Random values, strings, dates, and passwords |
|
|
60
|
+
| string_tools | String manipulation utilities |
|
|
61
|
+
| student_tools | Student management and reporting system |
|
|
62
|
+
| system_tools | System and OS information utilities |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
Install directly from GitHub:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install git+https://github.com/gaderjimrs-creator/MyPythonLibrary.git
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Or clone the repository:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git clone https://github.com/gaderjimrs-creator/MyPythonLibrary.git
|
|
78
|
+
|
|
79
|
+
cd MyPythonLibrary
|
|
80
|
+
|
|
81
|
+
pip install .
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Usage Examples
|
|
87
|
+
|
|
88
|
+
### Calculator
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from ToolVerse.calculator import MyCalculator
|
|
92
|
+
|
|
93
|
+
calc = MyCalculator()
|
|
94
|
+
|
|
95
|
+
print(calc.add(10, 5))
|
|
96
|
+
print(calc.sub(10, 5))
|
|
97
|
+
print(calc.mul(10, 5))
|
|
98
|
+
print(calc.div(10, 5))
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Password Generator
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from ToolVerse.password_tools import MyPasswordTools
|
|
105
|
+
|
|
106
|
+
pwd = MyPasswordTools()
|
|
107
|
+
|
|
108
|
+
print(pwd.generate_password())
|
|
109
|
+
print(pwd.generate_strong_password())
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### String Tools
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from ToolVerse.string_tools import MyStringTools
|
|
116
|
+
|
|
117
|
+
s = MyStringTools()
|
|
118
|
+
|
|
119
|
+
s.set_string("Hello World")
|
|
120
|
+
|
|
121
|
+
print(s.reverse_string())
|
|
122
|
+
print(s.to_uppercase())
|
|
123
|
+
print(s.count_words())
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Modules Included
|
|
129
|
+
|
|
130
|
+
* calculator
|
|
131
|
+
* conversion_tools
|
|
132
|
+
* date_time_tools
|
|
133
|
+
* file_tools
|
|
134
|
+
* number_tools
|
|
135
|
+
* password_tools
|
|
136
|
+
* random_tools
|
|
137
|
+
* string_tools
|
|
138
|
+
* student_tools
|
|
139
|
+
* system_tools
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Running Tests
|
|
144
|
+
|
|
145
|
+
Run all tests using:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
pytest
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Expected result:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
25 passed
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Project Structure
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
MyPythonLibrary/
|
|
163
|
+
│
|
|
164
|
+
├── src/
|
|
165
|
+
│ └── MyPythonLibrary/
|
|
166
|
+
│
|
|
167
|
+
├── tests/
|
|
168
|
+
│
|
|
169
|
+
├── README.md
|
|
170
|
+
├── LICENSE
|
|
171
|
+
├── pyproject.toml
|
|
172
|
+
├── pytest.ini
|
|
173
|
+
└── setup.py
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Continuous Integration
|
|
179
|
+
|
|
180
|
+
GitHub Actions automatically runs all tests on every push and pull request.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
This project is licensed under the terms of the LICENSE file included in this repository.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Author
|
|
191
|
+
|
|
192
|
+
**Mohammed Ayaz**
|
|
193
|
+
|
|
194
|
+
GitHub:
|
|
195
|
+
https://github.com/gaderjimrs-creator
|
|
196
|
+
|
|
197
|
+
Python Developer | Open Source Enthusiast
|
|
198
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
ToolVerse/__init__.py,sha256=u2nR3Dq-ma6NyPkNVOzMqchi60juCBGqCjt8XwwOpQI,649
|
|
2
|
+
ToolVerse/calculator.py,sha256=1zh3bNOY9VTP1wQvd_K9OpsdGQ_ZsocaqykABZBKbV8,5644
|
|
3
|
+
ToolVerse/conversion_tools.py,sha256=doQ_Bd-btQEzaJlbP46Y_W7CyF_qfIS2xUVlCjWZgVk,2983
|
|
4
|
+
ToolVerse/date_time_tools.py,sha256=qhNvCYAikBvKuKugIcZtDgmARCig8ncoy2tkRw7EDfg,2691
|
|
5
|
+
ToolVerse/file_tools.py,sha256=K15WBpwf9ZDEdLAKTCjMV4jjziCo4iPTVFaV-pSV-KU,2766
|
|
6
|
+
ToolVerse/number_tools.py,sha256=79HpwyYXAwJ2-TpFI_zXgNx1CMgjmYPRwAMuxmQ3pwo,1921
|
|
7
|
+
ToolVerse/password_tools.py,sha256=ZugzleFCe6E5rBceI9GjkVmMOM6uwBC0Z367LcgORVc,3401
|
|
8
|
+
ToolVerse/random_tools.py,sha256=LJsNA9CCn4fiAIXsSGIACIH9oIV-eBp01Kcu8mykTvQ,1877
|
|
9
|
+
ToolVerse/string_tools.py,sha256=aWYjzH2xKUiiFnYEQFyu16uIBbnJtPffkqN0g_vCLms,1269
|
|
10
|
+
ToolVerse/student_tools.py,sha256=CdRxev7UbA_zZNAByl1_iwA57Emgt29fSfynWR-IfdU,6789
|
|
11
|
+
ToolVerse/system_tools.py,sha256=IGyOI8kwovZUYCaChpb_--B49MYJQQxPB1pRvlohiD4,4263
|
|
12
|
+
toolverse-1.2.0.dist-info/licenses/LICENSE,sha256=QxUUOGPgWdzjeNp6376uCzNbGx6rZBmhyslYzer3uzw,1093
|
|
13
|
+
toolverse-1.2.0.dist-info/METADATA,sha256=6iBx-lMXakEtCBvDoYyiBJxVAU6SFbJYvRxPVcNVHJ0,5101
|
|
14
|
+
toolverse-1.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
15
|
+
toolverse-1.2.0.dist-info/top_level.txt,sha256=7SiRMqgTEM9U7E_9XhZnhuOTd73Rbzfopbn6WXvussI,10
|
|
16
|
+
toolverse-1.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohammed Ayaz
|
|
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.
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ToolVerse
|