brumpy 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {brumpy-0.1.3 → brumpy-0.1.4}/PKG-INFO +3 -1
- brumpy-0.1.4/brumpy/__init__.py +106 -0
- {brumpy-0.1.3 → brumpy-0.1.4}/brumpy.egg-info/PKG-INFO +3 -1
- {brumpy-0.1.3 → brumpy-0.1.4}/pyproject.toml +6 -3
- brumpy-0.1.3/brumpy/__init__.py +0 -29
- {brumpy-0.1.3 → brumpy-0.1.4}/brumpy.egg-info/SOURCES.txt +0 -0
- {brumpy-0.1.3 → brumpy-0.1.4}/brumpy.egg-info/dependency_links.txt +0 -0
- {brumpy-0.1.3 → brumpy-0.1.4}/brumpy.egg-info/top_level.txt +0 -0
- {brumpy-0.1.3 → brumpy-0.1.4}/setup.cfg +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brumpy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: first published package. plz do not copy
|
|
5
5
|
Author: fkl69_lolzers68
|
|
6
|
+
License: MIT
|
|
6
7
|
Classifier: Programming Language :: Python :: 3
|
|
7
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
8
9
|
Classifier: Operating System :: OS Independent
|
|
9
10
|
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#larpy
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
from os.path import exists
|
|
5
|
+
from urllib.request import urlopen
|
|
6
|
+
import shutil
|
|
7
|
+
from urllib.error import HTTPError, URLError
|
|
8
|
+
HOME = os.path.expanduser("~")
|
|
9
|
+
brumpy_downloads = os.path.join(HOME, "brumpy_downloads/")
|
|
10
|
+
os.makedirs(brumpy_downloads, exist_ok=True)
|
|
11
|
+
def download(
|
|
12
|
+
filename,
|
|
13
|
+
showurl=False, showpath=True, *,
|
|
14
|
+
urllink="https://raw.githubusercontent.com/victorialadica1978-eng/brumpy/main/"):
|
|
15
|
+
"""
|
|
16
|
+
downloads files, however be careful with it and do not download malicious files
|
|
17
|
+
"""
|
|
18
|
+
dest = brumpy_downloads
|
|
19
|
+
if os.path.exists(dest + filename):
|
|
20
|
+
print(f"{filename} Installed already")
|
|
21
|
+
print(dest + filename)
|
|
22
|
+
return
|
|
23
|
+
print(f"Downloading {filename}")
|
|
24
|
+
currpath = urllink + filename
|
|
25
|
+
try:
|
|
26
|
+
content = urlopen(currpath, timeout=15).read().decode()
|
|
27
|
+
with open(dest + filename, "w", encoding="utf-8") as f:
|
|
28
|
+
f.write(content)
|
|
29
|
+
print(f"{filename} Successfully downloaded")
|
|
30
|
+
if showurl: print(dest + filename)
|
|
31
|
+
except Exception as e:
|
|
32
|
+
print(f"Error while loading {filename}: {e}")
|
|
33
|
+
def find(path=".", *, find):
|
|
34
|
+
"""
|
|
35
|
+
finds a file inside a directory, useful for big directories if you do not wanna scroll looking for it
|
|
36
|
+
"""
|
|
37
|
+
if not os.path.isdir(path): print("Warning: is not a directory"); return
|
|
38
|
+
search_dir = os.listdir(path)
|
|
39
|
+
return find in search_dir
|
|
40
|
+
|
|
41
|
+
def read_contents(url):
|
|
42
|
+
"""
|
|
43
|
+
reads contents of a url, needs to be a file.
|
|
44
|
+
"""
|
|
45
|
+
try:
|
|
46
|
+
content = urlopen(url, timeout=15).read().decode()
|
|
47
|
+
return content
|
|
48
|
+
except Exception as e:
|
|
49
|
+
print(e)
|
|
50
|
+
def mv(source, destination, overwrite=False):
|
|
51
|
+
try:
|
|
52
|
+
if not os.path.exists(source):
|
|
53
|
+
print("Warning: does not exist")
|
|
54
|
+
return False
|
|
55
|
+
if os.path.exists(destination) and overwrite:
|
|
56
|
+
print(f"Notice: {destination} exists, skipped, please enable overwrite next time")
|
|
57
|
+
return False
|
|
58
|
+
shutil.move(source, destination)
|
|
59
|
+
return True
|
|
60
|
+
except Exception as e:
|
|
61
|
+
print(f"Failed: {str(e)}")
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
def cp(source, destination, overwrite=False):
|
|
65
|
+
try:
|
|
66
|
+
if not os.path.exists(source):
|
|
67
|
+
print("Warning: does not exist")
|
|
68
|
+
return False
|
|
69
|
+
if os.path.exists(destination) and overwrite:
|
|
70
|
+
print(f"Notice: {destination} exists, skipped, please enable overwrite next time")
|
|
71
|
+
return False
|
|
72
|
+
if os.path.isfile(source):
|
|
73
|
+
shutil.copy2(source, destination)
|
|
74
|
+
else:
|
|
75
|
+
shutil.copytree(source, destination, dirs_exist_ok=overwrite)
|
|
76
|
+
return True
|
|
77
|
+
except Exception as e:
|
|
78
|
+
print(f"Failed: {str(e)}")
|
|
79
|
+
return False
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def rm(path, *, missing_ok=False):
|
|
83
|
+
"""
|
|
84
|
+
This function is able to delete both files and folders however is dangerous. Please use with caution.
|
|
85
|
+
"""
|
|
86
|
+
path = os.path.normpath(path)
|
|
87
|
+
if path.startswith(".") and path.endswith("."):
|
|
88
|
+
print(f"\033[33mWARNING: '{path}' will delete the current directory. \nskipped for your safety.\033[0m"); return False
|
|
89
|
+
if path.strip() == brumpy_downloads: print("Can not delete downloaded folder"); return False
|
|
90
|
+
if not os.path.exists(path) and not missing_ok:
|
|
91
|
+
print(f"{path} does not exist"); return False
|
|
92
|
+
if os.path.isfile(path) or os.path.islink(path):
|
|
93
|
+
os.remove(path)
|
|
94
|
+
else:
|
|
95
|
+
shutil.rmtree(path)
|
|
96
|
+
return True
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def url_exists(url):
|
|
100
|
+
try:
|
|
101
|
+
urlopen(url, timeout=20)
|
|
102
|
+
return True
|
|
103
|
+
except (HTTPError, URLError):
|
|
104
|
+
return False
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
download("test.py", True, True)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brumpy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: first published package. plz do not copy
|
|
5
5
|
Author: fkl69_lolzers68
|
|
6
|
+
License: MIT
|
|
6
7
|
Classifier: Programming Language :: Python :: 3
|
|
7
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
8
9
|
Classifier: Operating System :: OS Independent
|
|
9
10
|
Requires-Python: >=3.8
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
@@ -4,11 +4,14 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "brumpy"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
authors = [
|
|
7
|
+
version = "0.1.4"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="fkl69_lolzers68" }
|
|
10
|
+
]
|
|
9
11
|
description = "first published package. plz do not copy"
|
|
12
|
+
readme = "README.md" # adjust if your readme has different name/extension
|
|
13
|
+
license = { text = "MIT" }
|
|
10
14
|
requires-python = ">=3.8"
|
|
11
|
-
|
|
12
15
|
classifiers = [
|
|
13
16
|
"Programming Language :: Python :: 3",
|
|
14
17
|
"License :: OSI Approved :: MIT License",
|
brumpy-0.1.3/brumpy/__init__.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#larpy
|
|
2
|
-
import os
|
|
3
|
-
import sys
|
|
4
|
-
from os.path import exists
|
|
5
|
-
from urllib.request import urlopen
|
|
6
|
-
path = "https://raw.githubusercontent.com/victorialadica1978-eng/brumpy/main/"
|
|
7
|
-
def download(filename, showurl=False):
|
|
8
|
-
if os.path.exists(filename):
|
|
9
|
-
print(f"{filename} Installed already")
|
|
10
|
-
return
|
|
11
|
-
print(f"Downloading {filename}")
|
|
12
|
-
currpath = path + filename
|
|
13
|
-
try:
|
|
14
|
-
content = urlopen(currpath, timeout=15).read().decode()
|
|
15
|
-
with open(filename, "w", encoding="utf-8") as f:
|
|
16
|
-
f.write(content)
|
|
17
|
-
print(f"{filename} Successfully downloaded")
|
|
18
|
-
if showurl: print(path + filename)
|
|
19
|
-
except Exception as e:
|
|
20
|
-
print(f"Error while loading {filename}: {e}")
|
|
21
|
-
def find(path, to_find):
|
|
22
|
-
if not os.path.isdir(path): print("Warning: is not a directory"); return
|
|
23
|
-
search_dir = os.listdir(path)
|
|
24
|
-
return to_find in search_dir
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if __name__ == "__main__":
|
|
28
|
-
findit = find(".", "__pycache__")
|
|
29
|
-
print(findit)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|