py-simple-wrap 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.
py_simple/__init__.py ADDED
@@ -0,0 +1,32 @@
1
+ from .easy_file_manager import (
2
+ make_blank_file, is_file_there, add_a_line, read_file_to_list,
3
+ remove_file, rename_file, list_files, copy_file,
4
+ )
5
+ from .easy_date_formatter import (
6
+ get_pretty_date, get_past_pretty_date, get_future_pretty_date,
7
+ dd_mm_yyyy, past_dd_mm_yyyy, future_dd_mm_yyyy,
8
+ mm_dd_yyyy, past_mm_dd_yyyy, future_mm_dd_yyyy,
9
+ slash_dd_mm_yyyy, past_slash_dd_mm_yyyy, future_slash_dd_mm_yyyy,
10
+ slash_mm_dd_yyyy, past_slash_mm_dd_yyyy, future_slash_mm_dd_yyyy,
11
+ list_available_formats,
12
+ )
13
+ from .easy_converter import (
14
+ seconds_to_hh_mm_ss, miles_to_km, km_to_mile, fluid_oz_to_ml,
15
+ ml_to_fluid_oz, celsius_to_fahrenheit, fahrenheit_to_celsius, kg_to_lb,
16
+ lb_to_kg, meters_to_feet, feet_to_meters, cm_to_inches, inches_to_cm,
17
+ sq_feet_to_sq_meters, sq_meters_to_sq_feet
18
+ )
19
+ from .easy_numbers import (
20
+ is_even, is_odd, is_evenly_divisible, is_negative, is_positive,
21
+ average, is_prime, percentage_of
22
+ )
23
+ from .easy_validator import (
24
+ is_valid_email, is_valid_username, is_valid_zipcode, is_valid_url,
25
+ is_password_secure,
26
+ )
27
+ from .easy_web import (
28
+ get_page_content, is_page_up,
29
+ )
30
+ from .easy_strings import (
31
+ is_palindrome, remove_extra_spaces, to_kebab_case, to_snake_case,
32
+ )
@@ -0,0 +1,302 @@
1
+ """
2
+ easy_converter is built to simplify different types of conversions
3
+ """
4
+
5
+ from datetime import timedelta
6
+
7
+
8
+ def seconds_to_hh_mm_ss(seconds: int) -> str:
9
+ """
10
+ Returns seconds in HH:MM:SS format.
11
+
12
+ Arguments:
13
+ seconds (int) -- number of seconds to convert
14
+
15
+ Example:
16
+ seconds_to_hh_mm_ss(90)
17
+ (00:01:30)
18
+ """
19
+ return str(timedelta(seconds=seconds))
20
+
21
+
22
+ def hh_mm_ss_to_seconds(hours: int = 0, minutes: int = 0, seconds: int = 0) \
23
+ -> int:
24
+ """
25
+ Returns hours, minutes and seconds converted to seconds.
26
+
27
+ Arguments:
28
+ hours (int) -- number of hours to convert. Defaults to 0.
29
+ minutes (int) -- number of minutes to convert. Defaults to 0.
30
+ seconds (int) -- number of seconds to convert. Defaults to 0.
31
+
32
+ Example:
33
+ hh_mm_ss_to_seconds(1, 1, 1)
34
+ (3661)
35
+ """
36
+ total_seconds = seconds
37
+ total_seconds += hours * 3600
38
+ total_seconds += minutes * 60
39
+ return total_seconds
40
+
41
+
42
+ def km_to_mile(km: float) -> float:
43
+ """
44
+ Converts kilometers to miles. Returns miles as a float.
45
+
46
+ Arguments:
47
+ km (float) -- kilometers
48
+
49
+ Example:
50
+ km_to_mile(100)
51
+ (62.13)
52
+ """
53
+ return float(f"{km * 0.621371:.2f}")
54
+
55
+
56
+ def miles_to_km(miles: float) -> float:
57
+ """
58
+ Converts miles to kilometers. Returns kilometers as a float.
59
+
60
+ Arguments:
61
+ miles (float) -- miles
62
+
63
+ Example:
64
+ miles_to_km(100)
65
+ (160.93)
66
+ """
67
+ return float(f"{miles * 1.60934:.2f}")
68
+
69
+
70
+ def fluid_oz_to_ml(oz: float, standard = 'us') -> float | None:
71
+ """
72
+ Converts fluid ounces to milliliters. Returns milliliters as a float.
73
+
74
+ :param:
75
+ oz (float) -- fluid ounces
76
+ standard -- us or uk
77
+
78
+ Example:
79
+ standard = 'us'
80
+ fluid_oz_to_ml(1)
81
+ (29.6)
82
+ standard = 'uk'
83
+ fluid_oz_to_ml(1)
84
+ (28.4)
85
+
86
+ """
87
+ match standard:
88
+ case "uk":
89
+ return float(f"{oz * 28.4:.2f}")
90
+ case "us":
91
+ return float(f"{oz * 29.6:.2f}")
92
+ return None
93
+
94
+
95
+ def ml_to_fluid_oz(milliliters: float, standard = 'us') -> float | None:
96
+ """
97
+ Converts milliliters to fluid ounces. Returns fluid ounces as a
98
+ float.
99
+
100
+ :param:
101
+ milliliters (float) -- milliliters
102
+ standard -- us or uk
103
+
104
+ Example:
105
+ standard = 'us'
106
+ ml_to_fluid_oz(1)
107
+ (0.03)
108
+ standard = 'uk'
109
+ ml_to_fluid_oz(1)
110
+ (0.04)
111
+
112
+ """
113
+ match standard:
114
+ case "uk":
115
+ return float(f"{milliliters * 0.035:.2f}")
116
+ case "us":
117
+ return float(f"{milliliters * 0.034:.2f}")
118
+ return None
119
+
120
+
121
+ def celsius_to_fahrenheit(temp_celsius: float) -> float:
122
+ """
123
+ Converts temperature in Celsius to temperature in Fahrenheit.
124
+ Returns degrees Fahrenheit as float.
125
+
126
+ :param:
127
+ temp_celsius (float) -- temperature in Celsius
128
+
129
+ Example:
130
+ celsius_to_fahrenheit(40)
131
+ (104.0)
132
+
133
+ """
134
+ return float(f"{((temp_celsius * 9 / 5) + 32):.2f}")
135
+
136
+
137
+ def fahrenheit_to_celsius(temp_fahrenheit: float) -> float:
138
+ """
139
+ Converts temperature in Fahrenheit to temperature in Celsius.
140
+ Returns degrees Celsius as float.
141
+
142
+ :param:
143
+ temp_fahrenheit (float) -- temperature in Fahrenheit
144
+
145
+ Example:
146
+ fahrenheit_to_celsius(104)
147
+ (40.0)
148
+ """
149
+ return float(f"{((temp_fahrenheit - 32) * 5 / 9):.2f}")
150
+
151
+
152
+ def kg_to_lb(kg: float) -> float:
153
+ """
154
+ Converts kilograms to pounds.
155
+ Returns pounds as float.
156
+
157
+ :param:
158
+ kg (float) -- kilograms
159
+
160
+ Example:
161
+ kg_to_lb(50)
162
+ (110.23)
163
+ """
164
+ return float(f"{kg * 2.20462:.2f}")
165
+
166
+
167
+ def lb_to_kg(lb: float) -> float:
168
+ """
169
+ Converts pounds to kilograms.
170
+ Returns kilograms as float.
171
+
172
+ :param:
173
+ lb (float) -- pounds
174
+
175
+ Example:
176
+ lb_to_kg(110.23)
177
+ (50.0)
178
+ """
179
+ return float(f"{(lb * 0.453592):.2f}")
180
+
181
+
182
+ def meters_to_feet(meters: float) -> float:
183
+ """
184
+ Converts meters to feet.
185
+ Returns feet as float.
186
+
187
+ Arguments:
188
+ meters (float) -- meters to be converted to feet.
189
+
190
+ Example:
191
+ meters_to_feet(100)
192
+ (328.08)
193
+ """
194
+ return float(f"{(meters * 3.28084):.2f}")
195
+
196
+
197
+ def feet_to_meters(feet: float) -> float:
198
+ """
199
+ Converts feet to meters.
200
+ Returns meters as float.
201
+
202
+ Arguments:
203
+ feet (float) -- feet to be converted to meters.
204
+
205
+ Example:
206
+ feet_to_meters(328.08)
207
+ (100.0)
208
+ """
209
+ return float(f"{(feet * 0.3048):.2f}")
210
+
211
+
212
+ def cm_to_inches(cm: float) -> float:
213
+ """
214
+ Converts centimeters to inches.
215
+ Returns inches as float.
216
+
217
+ Arguments:
218
+ cm (float) -- centimeters to be converted to inches.
219
+
220
+ Example:
221
+ cm_to_inches(100)
222
+ (39.37)
223
+ """
224
+ return float(f"{(cm / 2.54):.2f}")
225
+
226
+
227
+ def inches_to_cm(inches: float) -> float:
228
+ """
229
+ Converts centimeters to inches.
230
+ Returns inches as float.
231
+
232
+ Arguments:
233
+ inches (float) -- inches to be converted to centimeters.
234
+
235
+ Example:
236
+ inches_to_cm(39.37)
237
+ (100.0)
238
+ """
239
+ return float(f"{(inches * 2.54):.2f}")
240
+
241
+
242
+ def sq_meters_to_sq_feet(sq_meters: float) -> float:
243
+ """
244
+ Converts square meters to square feet.
245
+ Returns square feet as float.
246
+
247
+ Arguments:
248
+ sq_meters (float) -- square meters to be converted to
249
+ square feet.
250
+
251
+ Example:
252
+ sq_meters_to_sq_feet(10)
253
+ (107.64)
254
+ """
255
+ return float(f"{(sq_meters * 10.7639):.2f}")
256
+
257
+
258
+ def sq_feet_to_sq_meters(sq_feet: float) -> float:
259
+ """
260
+ Converts square feet to square meters.
261
+ Returns square meters as float.
262
+
263
+ Arguments:
264
+ sq_feet (float) -- square feet to be converted to
265
+ square meters.
266
+
267
+ Example:
268
+ sq_feet_to_sq_meters(107.64)
269
+ (10.0)
270
+ """
271
+ return float(f"{(sq_feet * 0.092903):.2f}")
272
+
273
+ def mph_to_kph(mph):
274
+ """
275
+ Converts mph speed to kph speed.
276
+ Returns kph speed as float.
277
+
278
+ Arguments:
279
+ mph (float) -- mph speed to be converted to
280
+ kph speed.
281
+
282
+ Example:
283
+ mph_to_kph(0.621371)
284
+ (1.0)
285
+ """
286
+ return float(f"{(mph * 1.60934):.2f}")
287
+
288
+
289
+ def kph_to_mph(kph):
290
+ """
291
+ Converts kph speed to mph speed.
292
+ Returns mph speed as float.
293
+
294
+ Arguments:
295
+ kph (float) -- kph speed to be converted to
296
+ kph speed.
297
+
298
+ Example:
299
+ kph_to_mph(1.60934)
300
+ (1.0)
301
+ """
302
+ return float(f"{(kph * 0.621371):.2f}")
@@ -0,0 +1,139 @@
1
+ """
2
+ easy_date_formatter is meant to simplify getting formatted dates.
3
+ Built on top of the datetime module — no more memorizing strftime codes.
4
+ """
5
+
6
+ from datetime import datetime, timedelta
7
+
8
+
9
+ # ── Format registry (strftime pattern → readable name) ──────────────
10
+ _FORMATS = {
11
+ "pretty": "%A, %B %d, %Y",
12
+ "dd-mm-yyyy": "%d-%m-%Y",
13
+ "mm-dd-yyyy": "%m-%d-%Y",
14
+ "dd/mm/yyyy": "%d/%m/%Y",
15
+ "mm/dd/yyyy": "%m/%d/%Y",
16
+ }
17
+
18
+
19
+ def list_available_formats():
20
+ """Return the supported format names for reference."""
21
+ return list(_FORMATS.keys())
22
+
23
+
24
+ def _format_date(date_obj, fmt_key: str) -> str:
25
+ """Apply a named format to a datetime object."""
26
+ return date_obj.strftime(_FORMATS[fmt_key])
27
+
28
+
29
+ def _get_past_date(num_days_ago: int):
30
+ """Calculate and return a past date."""
31
+ return datetime.now() - timedelta(days=num_days_ago)
32
+
33
+
34
+ def _get_future_date(num_days_from_now: int):
35
+ """Calculate and return a future date."""
36
+ return datetime.now() + timedelta(days=num_days_from_now)
37
+
38
+
39
+ # ── Pretty dates ────────────────────────────────────────────────────
40
+
41
+ def get_pretty_date():
42
+ """
43
+ Returns the current date in a human-friendly format.
44
+
45
+ Returns:
46
+ str: Current date formatted as 'Weekday, Month Day, Year'
47
+ (e.g., 'Monday, July 20, 2026').
48
+ """
49
+ return _format_date(datetime.now(), "pretty")
50
+
51
+
52
+ def get_past_pretty_date(num_days_ago: int):
53
+ """
54
+ Calculates a date from the past in pretty format.
55
+
56
+ Args:
57
+ num_days_ago (int): Number of days to subtract from today.
58
+
59
+ Returns:
60
+ str: Past date as 'Weekday, Month Day, Year'.
61
+ """
62
+ return _format_date(_get_past_date(num_days_ago), "pretty")
63
+
64
+
65
+ def get_future_pretty_date(num_days_from_now: int):
66
+ """
67
+ Calculates a future date in pretty format.
68
+
69
+ Args:
70
+ num_days_from_now (int): Number of days to add to today.
71
+
72
+ Returns:
73
+ str: Future date as 'Weekday, Month Day, Year'.
74
+ """
75
+ return _format_date(_get_future_date(num_days_from_now), "pretty")
76
+
77
+
78
+ # ── Hyphenated formats (DD-MM-YYYY or MM-DD-YYYY) ───────────────────
79
+
80
+ def dd_mm_yyyy():
81
+ """Current date in 'DD-MM-YYYY' format (e.g., '20-07-2026')."""
82
+ return _format_date(datetime.now(), "dd-mm-yyyy")
83
+
84
+
85
+ def past_dd_mm_yyyy(num_days_ago: int):
86
+ """Past date in 'DD-MM-YYYY' format."""
87
+ return _format_date(_get_past_date(num_days_ago), "dd-mm-yyyy")
88
+
89
+
90
+ def future_dd_mm_yyyy(num_days_from_now: int):
91
+ """Future date in 'DD-MM-YYYY' format."""
92
+ return _format_date(_get_future_date(num_days_from_now), "dd-mm-yyyy")
93
+
94
+
95
+ def mm_dd_yyyy():
96
+ """Current date in 'MM-DD-YYYY' format (e.g., '07-20-2026')."""
97
+ return _format_date(datetime.now(), "mm-dd-yyyy")
98
+
99
+
100
+ def past_mm_dd_yyyy(num_days_ago: int):
101
+ """Past date in 'MM-DD-YYYY' format."""
102
+ return _format_date(_get_past_date(num_days_ago), "mm-dd-yyyy")
103
+
104
+
105
+ def future_mm_dd_yyyy(num_days_from_now: int):
106
+ """Future date in 'MM-DD-YYYY' format."""
107
+ return _format_date(_get_future_date(num_days_from_now), "mm-dd-yyyy")
108
+
109
+
110
+ # ── Slashed formats (DD/MM/YYYY or MM/DD/YYYY) ──────────────────────
111
+
112
+ def slash_dd_mm_yyyy():
113
+ """Current date in 'DD/MM/YYYY' format (e.g., '20/07/2026')."""
114
+ return _format_date(datetime.now(), "dd/mm/yyyy")
115
+
116
+
117
+ def past_slash_dd_mm_yyyy(num_days_ago: int):
118
+ """Past date in 'DD/MM/YYYY' format."""
119
+ return _format_date(_get_past_date(num_days_ago), "dd/mm/yyyy")
120
+
121
+
122
+ def future_slash_dd_mm_yyyy(num_days_from_now: int):
123
+ """Future date in 'DD/MM/YYYY' format."""
124
+ return _format_date(_get_future_date(num_days_from_now), "dd/mm/yyyy")
125
+
126
+
127
+ def slash_mm_dd_yyyy():
128
+ """Current date in 'MM/DD/YYYY' format (e.g., '07/20/2026')."""
129
+ return _format_date(datetime.now(), "mm/dd/yyyy")
130
+
131
+
132
+ def past_slash_mm_dd_yyyy(num_days_ago: int):
133
+ """Past date in 'MM/DD/YYYY' format."""
134
+ return _format_date(_get_past_date(num_days_ago), "mm/dd/yyyy")
135
+
136
+
137
+ def future_slash_mm_dd_yyyy(num_days_from_now: int):
138
+ """Future date in 'MM/DD/YYYY' format."""
139
+ return _format_date(_get_future_date(num_days_from_now), "mm/dd/yyyy")
@@ -0,0 +1,240 @@
1
+ """
2
+ easy_file_manager is meant to simplify working with files.
3
+ """
4
+
5
+ import os
6
+ import shutil
7
+
8
+
9
+ VALID_EXTENSIONS = ['txt', 'md', 'log', 'csv']
10
+
11
+
12
+ class InvalidExtension(Exception):
13
+ """Exception raised for invalid extension"""
14
+
15
+ def __init__(self, message):
16
+ self.message = message
17
+ super().__init__(self.message)
18
+
19
+
20
+ def _is_valid_extension(extension):
21
+ """Check if extension is valid"""
22
+ return extension in VALID_EXTENSIONS
23
+
24
+
25
+ def _get_extension(filename: str) -> str:
26
+ """Extract the lowercased extension from a filename."""
27
+ return filename.split('.')[-1].lower()
28
+
29
+
30
+ def is_file_there(filename: str) -> bool:
31
+ """
32
+ Check if file exists in current working directory.
33
+
34
+ Args:
35
+ filename (str): Name of the file to be checked.
36
+
37
+ Returns:
38
+ bool: True if file exists, False otherwise.
39
+
40
+ Example:
41
+ is_file_there("new_file.txt")
42
+ """
43
+ return os.path.isfile(filename)
44
+
45
+
46
+ def make_blank_file(filename: str, file_extension: str):
47
+ """
48
+ Creates a blank file in current working directory.
49
+ If file already exists, nothing is done.
50
+
51
+ Args:
52
+ filename (str): The name of the file to be created.
53
+ file_extension (str): The extension without '.'.
54
+ Allowed: ['txt', 'csv', 'md', 'log']
55
+
56
+ Example:
57
+ make_blank_file("new_file", "txt")
58
+ """
59
+ if _is_valid_extension(file_extension.lower()):
60
+ file = f"{filename}.{file_extension.lower()}"
61
+ if is_file_there(file):
62
+ print(f"File {file} already exists in current working directory.")
63
+ else:
64
+ with open(file, 'w', encoding='utf-8'):
65
+ pass
66
+ else:
67
+ raise InvalidExtension(
68
+ f"\n'{file_extension}' is not a valid extension.\n"
69
+ f"Please enter a valid extension and try again.\n"
70
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
71
+ )
72
+
73
+
74
+ def add_a_line(filename: str, line: str):
75
+ """
76
+ Add line to existing file. If file does not exist, create it.
77
+
78
+ Args:
79
+ filename (str): File to write to.
80
+ line (str): Line to write.
81
+
82
+ Example:
83
+ add_a_line("new_file.txt", "hello world!")
84
+ """
85
+ ext = _get_extension(filename)
86
+ if _is_valid_extension(ext):
87
+ with open(filename, 'a', encoding='utf-8') as f:
88
+ f.write(line + '\n')
89
+ else:
90
+ raise InvalidExtension(
91
+ f"\n'{ext}' is not a valid extension.\n"
92
+ f"Please enter a valid extension and try again.\n"
93
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
94
+ )
95
+
96
+
97
+ def read_file_to_list(filename: str) -> list:
98
+ """
99
+ Reads lines of existing file to list.
100
+
101
+ Args:
102
+ filename (str): File to read from.
103
+
104
+ Returns:
105
+ list: List of lines.
106
+
107
+ Example:
108
+ read_file_to_list("new_file.txt")
109
+ """
110
+ ext = _get_extension(filename)
111
+ if _is_valid_extension(ext):
112
+ try:
113
+ with open(filename, 'r', encoding='utf-8') as f:
114
+ return [line.strip() for line in f.readlines()]
115
+ except FileNotFoundError:
116
+ print(f"\nFile '{filename}' not found.")
117
+ return []
118
+ else:
119
+ raise InvalidExtension(
120
+ f"\n'{ext}' is not a valid extension.\n"
121
+ f"Please enter a valid extension and try again.\n"
122
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
123
+ )
124
+
125
+
126
+ def remove_file(filename: str):
127
+ """
128
+ Removes file from current working directory.
129
+
130
+ Args:
131
+ filename (str): File to delete.
132
+
133
+ Example:
134
+ remove_file("new_file.txt")
135
+ """
136
+ ext = _get_extension(filename)
137
+ if _is_valid_extension(ext):
138
+ if is_file_there(filename):
139
+ os.remove(filename)
140
+ else:
141
+ print(f"File {filename} does not exist!")
142
+ else:
143
+ raise InvalidExtension(
144
+ f"\n'{ext}' is not a valid extension.\n"
145
+ f"Please enter a valid extension and try again.\n"
146
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
147
+ )
148
+
149
+
150
+ def rename_file(old_name: str, new_name: str):
151
+ """
152
+ Rename file in the current working directory.
153
+
154
+ Args:
155
+ old_name (str): Current filename.
156
+ new_name (str): New filename.
157
+
158
+ Example:
159
+ rename_file("old_name.txt", "new_name.txt")
160
+ """
161
+ ext_old = _get_extension(old_name)
162
+ ext_new = _get_extension(new_name)
163
+ if _is_valid_extension(ext_old) and _is_valid_extension(ext_new):
164
+ if is_file_there(old_name):
165
+ if not is_file_there(new_name):
166
+ os.rename(old_name, new_name)
167
+ else:
168
+ print(f"File '{new_name}' already exists in current working directory.")
169
+ else:
170
+ print(f"File {old_name} does not exist in current working directory.")
171
+ else:
172
+ raise InvalidExtension(
173
+ f"\n'{ext_old}' or '{ext_new}' is not a valid extension.\n"
174
+ f"Please enter a valid extension and try again.\n"
175
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
176
+ )
177
+
178
+
179
+ def list_files(extension: str = None) -> list:
180
+ """
181
+ List files in the current working directory that have valid extensions.
182
+ Optionally filter by a specific extension.
183
+
184
+ Args:
185
+ extension (str, optional): Filter by extension (e.g., 'txt').
186
+ If None, all valid extension files are listed.
187
+
188
+ Returns:
189
+ list: Sorted list of filenames matching the filter.
190
+
191
+ Example:
192
+ list_files()
193
+ list_files("txt")
194
+ """
195
+ if extension is not None and not _is_valid_extension(extension.lower()):
196
+ raise InvalidExtension(
197
+ f"\n'{extension}' is not a valid extension.\n"
198
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
199
+ )
200
+
201
+ matches = []
202
+ for fname in os.listdir('.'):
203
+ if os.path.isfile(fname):
204
+ ext = _get_extension(fname)
205
+ if _is_valid_extension(ext):
206
+ if extension is None or ext == extension.lower():
207
+ matches.append(fname)
208
+ return sorted(matches)
209
+
210
+
211
+ def copy_file(source: str, destination: str):
212
+ """
213
+ Copy a file to a new location or name.
214
+
215
+ Args:
216
+ source (str): File to copy.
217
+ destination (str): Destination path or filename.
218
+
219
+ Example:
220
+ copy_file("notes.txt", "notes_backup.txt")
221
+ """
222
+ ext_src = _get_extension(source)
223
+ ext_dst = _get_extension(destination)
224
+ if not _is_valid_extension(ext_src):
225
+ raise InvalidExtension(
226
+ f"\n'{ext_src}' is not a valid extension.\n"
227
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
228
+ )
229
+ if not _is_valid_extension(ext_dst):
230
+ raise InvalidExtension(
231
+ f"\n'{ext_dst}' is not a valid extension.\n"
232
+ f"\nVALID EXTENSIONS: {VALID_EXTENSIONS}"
233
+ )
234
+ if not is_file_there(source):
235
+ print(f"File '{source}' does not exist.")
236
+ return
237
+ if is_file_there(destination):
238
+ print(f"File '{destination}' already exists — not overwriting.")
239
+ return
240
+ shutil.copy2(source, destination)
@@ -0,0 +1,151 @@
1
+ """
2
+ easy_numbers is built to simplify different types of number operations.
3
+ """
4
+
5
+
6
+ def is_even(number: int) -> bool:
7
+ """
8
+ Returns true if the number is even and false if it is odd.
9
+
10
+ Arguments:
11
+ number (int) -- number to check if odd or even.
12
+
13
+ Example:
14
+ is_even(90)
15
+ (True)
16
+ is_even(67)
17
+ (False)
18
+ """
19
+ return number % 2 == 0
20
+
21
+
22
+ def is_odd(number: int) -> bool:
23
+ """
24
+ Returns true if the number is odd and false if it is even.
25
+
26
+ Arguments:
27
+ number (int) -- number to check if odd or even.
28
+
29
+ Example:
30
+ is_odd(90)
31
+ (False)
32
+ is_odd(67)
33
+ (True)
34
+ """
35
+ return number % 2 == 1
36
+
37
+
38
+ def is_evenly_divisible(number: int, divisor: int) -> bool:
39
+ """
40
+ Returns true if the number can be evenly divided by divisor.
41
+
42
+ Arguments:
43
+ number (int) -- number to check if evenly divided by divisor.
44
+ divisor (int) -- divisor to check if number can be
45
+ evenly divided by divisor.
46
+
47
+ Example:
48
+ is_evenly_divisible(90, 9)
49
+ (True)
50
+ is_evenly_divisible(67, 2)
51
+ (False)
52
+ """
53
+ return number % divisor == 0
54
+
55
+
56
+ def is_positive(number: int) -> bool:
57
+ """
58
+ Returns true if the number is positive and false if it is
59
+ negative.
60
+
61
+ Arguments:
62
+ number (int) -- number to check if positive.
63
+
64
+ Example:
65
+ is_positive(90)
66
+ (True)
67
+ is_positive(-10)
68
+ (False)
69
+ """
70
+ return number > 0
71
+
72
+
73
+ def is_negative(number: int) -> bool:
74
+ """
75
+ Returns true if the number is negative and false if it is
76
+ positive.
77
+
78
+ Arguments:
79
+ number (int) -- number to check if negative.
80
+
81
+ Example:
82
+ is_negative(90)
83
+ (False)
84
+ is_negative(-10)
85
+ (True)
86
+ """
87
+ return number < 0
88
+
89
+
90
+ def average(nums: list[float]) -> float:
91
+ """
92
+ Returns the average of a list of numbers.
93
+
94
+ Arguments:
95
+ nums (list[float]) -- list of numbers to average.
96
+
97
+ Example:
98
+ average([1.5, 2, 3])
99
+ (2.17)
100
+ average([3, 5, 2.3, 6.24])
101
+ (4.13)
102
+ """
103
+ return float(f"{(sum(nums) / len(nums)):.2f}")
104
+
105
+
106
+ def is_prime(number: int) -> bool:
107
+ """
108
+ Returns true if the number is prime and false if it is.
109
+
110
+ Arguments:
111
+ number (int) -- number to check if prime.
112
+
113
+ Example:
114
+ is_prime(2)
115
+ (True)
116
+ is_prime(15)
117
+ (False)
118
+ """
119
+ if number > 0:
120
+ limit = int((number ** 0.5) + 1)
121
+ else:
122
+ return False
123
+ if number < 2:
124
+ return False
125
+ elif number == 2:
126
+ return True
127
+ elif is_even(number):
128
+ return False
129
+ else:
130
+ for i in range(3, limit, 2):
131
+ if is_evenly_divisible(number, i):
132
+ return False
133
+ return True
134
+
135
+
136
+ def percentage_of(number: int, percentage: float) -> float:
137
+ """
138
+ Returns percentage of number as a float.
139
+
140
+ Arguments:
141
+ number (int) -- number to get percentage of.
142
+ percentage (float) -- percentage to get.
143
+ Must be between 0 and 1 (e.g. 0.5, 0.75)
144
+
145
+ Example:
146
+ percentage_of(100, 0.5)
147
+ (50.0)
148
+ percentage_of(19, 0.4)
149
+ (7.6)
150
+ """
151
+ return float(f"{(number * percentage):.2f}")
@@ -0,0 +1,62 @@
1
+ """Beginner-friendly helpers for common string operations."""
2
+
3
+ import re
4
+
5
+
6
+ def remove_extra_spaces(text: str) -> str:
7
+ """
8
+ Removes leading, trailing, and repeated spaces from text.
9
+
10
+ Example:
11
+ remove_extra_spaces(" hello world ")
12
+ "hello world"
13
+ """
14
+ return " ".join(text.split())
15
+
16
+
17
+ def to_snake_case(text: str) -> str:
18
+ """
19
+ Converts text to snake_case.
20
+
21
+ Example:
22
+ to_snake_case("Hello World")
23
+ "hello_world"
24
+ """
25
+ cleaned_text = _separate_words(text)
26
+ return cleaned_text.lower().replace(" ", "_")
27
+
28
+
29
+ def to_kebab_case(text: str) -> str:
30
+ """
31
+ Converts text to kebab-case.
32
+
33
+ Example:
34
+ to_kebab_case("Hello World")
35
+ "hello-world"
36
+ """
37
+ cleaned_text = _separate_words(text)
38
+ return cleaned_text.lower().replace(" ", "-")
39
+
40
+
41
+ def is_palindrome(text: str) -> bool:
42
+ """
43
+ Returns True when text reads the same forwards and backwards.
44
+
45
+ Spaces, punctuation, and letter casing are ignored.
46
+
47
+ Example:
48
+ is_palindrome("Never odd or even")
49
+ True
50
+ """
51
+ cleaned_text = "".join(
52
+ character.lower() for character in text if character.isalnum()
53
+ )
54
+ return cleaned_text == cleaned_text[::-1]
55
+
56
+
57
+ def _separate_words(text: str) -> str:
58
+ """Normalizes common word separators and separates camel-case words."""
59
+ text = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", text)
60
+ text = re.sub(r"[_\-]+", " ", text)
61
+ text = re.sub(r"[^\w\s]", " ", text)
62
+ return remove_extra_spaces(text)
@@ -0,0 +1,139 @@
1
+ """
2
+ easy_validator is built to simplify validation.
3
+ """
4
+ import re
5
+ from string import punctuation
6
+
7
+
8
+ def is_valid_email(email: str) -> bool:
9
+ """
10
+ Returns true if email is valid.
11
+
12
+ Arguments:
13
+ email (str) -- email address to validate.
14
+
15
+ Example:
16
+ is_valid_email("mymail@gmail.com")
17
+ (True)
18
+ is_valid_email("email.com")
19
+ (False)
20
+ """
21
+ pattern = r'[a-zA-Z_.%+-]+@[a-zA-Z0-9-]+\.[a-zA-Z]+'
22
+ return bool(re.fullmatch(pattern, email))
23
+
24
+
25
+ def is_valid_username(username: str) -> bool:
26
+ """
27
+ Returns true if username is valid.
28
+
29
+ Arguments:
30
+ username (str) -- username to validate.
31
+
32
+ Example:
33
+ is_valid_username("user_name")
34
+ (True)
35
+ is_valid_username("user.name")
36
+ (False)
37
+ """
38
+ pattern = r'^[a-zA-Z0-9_]+'
39
+ return bool(re.fullmatch(pattern, username))
40
+
41
+
42
+ def is_valid_zipcode(zipcode: int) -> bool:
43
+ """
44
+ Returns true if US zip code is valid.
45
+
46
+ Arguments:
47
+ zipcode (int) -- US zipcode to validate.
48
+
49
+ Example:
50
+ is_valid_zipcode(12345)
51
+ (True)
52
+ is_valid_zipcode(1248721)
53
+ (False)
54
+ """
55
+ pattern = r'^[0-9]{5}$'
56
+ return bool(re.fullmatch(pattern, str(zipcode)))
57
+
58
+
59
+ def is_valid_url(url: str) -> bool:
60
+ """
61
+ Returns true if url is valid.
62
+
63
+ Arguments:
64
+ url (str) -- URL to validate.
65
+
66
+ Example:
67
+ is_valid_url("www.google.com")
68
+ (True)
69
+ is_valid_url("something.com")
70
+ (False)
71
+ """
72
+ pattern = r'(https://|http://|www\.)[a-zA-Z0-9]+\.[a-zA-Z]+'
73
+ return bool(re.fullmatch(pattern, url))
74
+
75
+
76
+ def is_password_secure(password: str) -> bool:
77
+ """
78
+ Returns true if password is valid.
79
+
80
+ Validation checks:
81
+ - minimum length of 8 characters
82
+ - at least one special character
83
+ - at least one upper case letter
84
+ - at least two lowercase letters
85
+ - at least two digits
86
+ - no repeating characters
87
+
88
+ Arguments:
89
+ password (str) -- password to validate.
90
+
91
+ Example:
92
+ is_password_secure("1andkrf!AG5")
93
+ (True)
94
+ is_password_secure("111mskagowd")
95
+ (False)
96
+ """
97
+ min_length = 8
98
+ upper_letters = 0
99
+ lower_letters = 0
100
+ digits = 0
101
+ special_characters = 0
102
+ last_char = ''
103
+
104
+ if len(password) > min_length:
105
+ for char in password:
106
+ if char.isdigit():
107
+ digits += 1
108
+ if char == last_char:
109
+ return False
110
+ else:
111
+ last_char = char
112
+ elif char.isalpha():
113
+ if char.upper() == char:
114
+ upper_letters += 1
115
+ if char == last_char:
116
+ return False
117
+ else:
118
+ last_char = char
119
+ elif char.lower() == char:
120
+ lower_letters += 1
121
+ if char == last_char:
122
+ return False
123
+ else:
124
+ last_char = char
125
+ elif char in punctuation:
126
+ special_characters += 1
127
+ if char == last_char:
128
+ return False
129
+ else:
130
+ last_char = char
131
+ else:
132
+ pass
133
+ if (upper_letters >= 1 and lower_letters >= 2 and digits >= 2 and
134
+ special_characters >= 1):
135
+ return True
136
+ else:
137
+ return False
138
+ else:
139
+ return False
py_simple/easy_web.py ADDED
@@ -0,0 +1,39 @@
1
+ """
2
+ easy_web is built to simplify getting information from the web.
3
+ """
4
+ import requests
5
+ from bs4 import BeautifulSoup
6
+
7
+
8
+ def get_page_content(url: str) -> str | None:
9
+ """
10
+ Returns content of the website or None if an error occurs.
11
+
12
+ Arguments:
13
+ url (str) -- website to be parsed.
14
+ """
15
+ try:
16
+ response = requests.get(url, timeout=10)
17
+ if response.ok:
18
+ return BeautifulSoup(response.text, 'html.parser').prettify()
19
+ else:
20
+ return None
21
+ except Exception as e:
22
+ print(f"Something went wrong with {url}\nERROR: {e}")
23
+ return None
24
+
25
+
26
+ def is_page_up(url: str) -> bool:
27
+ """
28
+ Returns true if HTTP status code is 200 else returns false.
29
+
30
+ Arguments:
31
+ url (str) -- website to check.
32
+ """
33
+ try:
34
+ response = requests.get(url, timeout=10)
35
+ response.raise_for_status()
36
+ return bool(response.status_code == 200)
37
+ except Exception as e:
38
+ print(f"Something went wrong with {url}\nERROR: {e}")
39
+ return False
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: py_simple_wrap
3
+ Version: 0.1.0
4
+ Summary: A package to make complex python functionality simple
5
+ Author-email: Sara Czasak <sara.p.czasak.m@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Sara Czasak
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
+ Project-URL: Homepage, https://github.com/sara-czasak/py_simple
28
+ Project-URL: Repository, https://github.com/sara-czasak/py_simple
29
+ Project-URL: Bug Tracker, https://github.com/sara-czasak/py_simple/issues
30
+ Keywords: python,beginner-friendly,wrapper,education
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: Intended Audience :: Education
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python :: 3
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Education
41
+ Classifier: Topic :: Utilities
42
+ Requires-Python: >=3.10
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE.md
45
+ Requires-Dist: requests>=2.25.0
46
+ Requires-Dist: beautifulsoup4>=4.9.0
47
+ Provides-Extra: test
48
+ Requires-Dist: pytest>=7.0; extra == "test"
49
+ Dynamic: license-file
50
+
51
+ # Py_simple 🚀
52
+
53
+ Making Python feel like plain English.
54
+
55
+ Py_simple is a beginner-friendly Python wrapper package designed to help beginners and developers perform common tasks using simple, intuitive functions.
56
+
57
+ The goal of this project is to remove the need for memorizing complex syntax or writing repetitive boilerplate code, making Python more accessible and enjoyable for everyone.
58
+
59
+ ---
60
+
61
+ ## 🛠️ Module Menu
62
+
63
+ Py_simple provides simple modules designed to make common Python tasks easier.
64
+
65
+ ### 📂 Easy File Manager
66
+
67
+ Simplify everyday file operations with beginner-friendly utilities.
68
+
69
+ Features include:
70
+
71
+ - File management helpers
72
+ - Easier file operations
73
+ - Cleaner Python workflows
74
+
75
+ ---
76
+
77
+ ### 🕰️ Easy Date Formatter
78
+
79
+ Make working with dates simpler and more readable.
80
+
81
+ Features include:
82
+
83
+ - Date formatting utilities
84
+ - Easier date manipulation
85
+ - Simple date-related functions
86
+
87
+ ---
88
+
89
+ ### 🔢 Easy Numbers
90
+
91
+ Perform common number operations using simple and readable functions.
92
+
93
+ Features include:
94
+
95
+ - Number utilities
96
+ - Beginner-friendly calculations
97
+ - Cleaner mathematical operations
98
+
99
+ ---
100
+ ### 🔤 Easy Strings
101
+
102
+ Handle common string operations using clear, beginner-friendly functions.
103
+
104
+ Features include:
105
+
106
+ - Removing repeated spaces
107
+ - Converting text to `snake_case`
108
+ - Converting text to `kebab-case`
109
+ - Checking whether text is a palindrome
110
+
111
+ ### 🔄 Easy Converter
112
+
113
+ Convert values easily using simple utility functions.
114
+
115
+ Features include:
116
+
117
+ - Simple conversions
118
+ - Easy-to-use helpers
119
+ - Less repetitive code
120
+
121
+ ---
122
+
123
+ ### ✅ Easy Validator
124
+
125
+ Validate common input formats using simple, readable functions.
126
+
127
+ Features include:
128
+
129
+ - Email, username, and URL validation
130
+ - US zip code validation
131
+ - Password strength validation
132
+
133
+ ---
134
+
135
+ ### 🌐 Easy Web
136
+ [Easy Web Documentation](docs/easy_web.md)
137
+
138
+ Make getting data from the web less complex.
139
+
140
+ Features include:
141
+
142
+ - Checking if website is up
143
+ - Getting page content
144
+
145
+ More examples and documentation will be added as the project grows.
146
+
147
+ ---
148
+
149
+ ## 🤝 Contributing
150
+
151
+ I would love to have your help in making Python simpler for everyone!
152
+
153
+ Contributions of all sizes are welcome:
154
+
155
+ - Fix documentation
156
+ - Improve existing modules
157
+ - Suggest new features
158
+ - Add new functionality
159
+ - Improve examples
160
+
161
+ Please check [CONTRIBUTING.md](CONTRIBUTING.md) before submitting changes.
162
+
163
+ Every contribution helps make Py_simple better for beginners and developers.
164
+
165
+ ---
166
+
167
+ ## 🌟 Hall of Fame
168
+
169
+ A huge thank you to the wonderful people who have helped build Py_simple:
170
+
171
+ - **Sara Czasak** (Creator)
172
+ - **ghostfix-pm** (Major features & Refactoring)
173
+ - **jagjitkaur0000** (Added tests for easy_numbers module)
174
+ - **Onion0121** (Improved documentation)
175
+ - **averyquinnhq** (Added tests for easy_converter.py)
176
+ - **gaoharimran29-glitch** (Added tests for easy_validator.py)
177
+ - **mmaxjr** (Improved documentation)
178
+ - **sol4nki** (Expanded easy_converter.py module)
179
+ - **shivams786** (Added easy_strings.py)
180
+ - **HeaTTap** (Added tests for easy_web module)
181
+
182
+ See the full list of contributions in [CONTRIBUTORS.md](CONTRIBUTORS.md).
183
+
184
+ ---
185
+
186
+ ## ⚖️ License
187
+
188
+ This project is licensed under the MIT License.
189
+
190
+ You are free to use, modify, and distribute it.
191
+
192
+ See the [LICENSE.md](LICENSE.md) file for the full legal text.
@@ -0,0 +1,13 @@
1
+ py_simple/__init__.py,sha256=XHrkE1J8ka270vJ4aibXfvmWcaKenw52HUznudTVJ0w,1278
2
+ py_simple/easy_converter.py,sha256=M8uTmL0zkYHzP3nUZTDsCpuj8_-1YLyVK2vlIEaIBds,7198
3
+ py_simple/easy_date_formatter.py,sha256=Pr0NpXuD4YX4uuifC21K3_w3Rpfhf7IkuWnRN9B-yU0,4426
4
+ py_simple/easy_file_manager.py,sha256=w_hz3frtUspUXc42d0lDO-B4xLmeA_rNvR2Hs3l2Dfw,7191
5
+ py_simple/easy_numbers.py,sha256=P0n8s0WB5xVtHGLHdRJzfiUqYiFx5sjPPWbsx9OIe8A,3651
6
+ py_simple/easy_strings.py,sha256=IkkAjwjuxGsVGawpvti-xWp4Ux1AN-JcfJDE0oAJZxY,1572
7
+ py_simple/easy_validator.py,sha256=PfCMMhKnwPVgAZUB1BFDcdRLxymIN5QfPFCe69g1hfQ,3808
8
+ py_simple/easy_web.py,sha256=rIhcjR1PZ8aWddfSxYXS1l-J5VHLppXl31JDhCsN1fo,1102
9
+ py_simple_wrap-0.1.0.dist-info/licenses/LICENSE.md,sha256=W77s9qaGad9KmOHxFfXCI2DDM2AAvhXcUpK1TrjgERI,1087
10
+ py_simple_wrap-0.1.0.dist-info/METADATA,sha256=fU5n4ZM9w6-UMVuo2nhzcfHWMN463z9r95uxK9cvrV0,5819
11
+ py_simple_wrap-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
12
+ py_simple_wrap-0.1.0.dist-info/top_level.txt,sha256=K7f28_hUQjHjTl5yt3GsS_FL4XHvymdpWqF5ZBc819Q,10
13
+ py_simple_wrap-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sara Czasak
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.
@@ -0,0 +1 @@
1
+ py_simple