-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathsetup.py
More file actions
76 lines (67 loc) · 2.59 KB
/
Copy pathsetup.py
File metadata and controls
76 lines (67 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
import os
import re
import shutil
import sys
from setuptools import find_packages, setup
# Read version from __init__.py without importing
def get_version():
init_path = os.path.join(os.path.dirname(__file__), "waymore", "__init__.py")
with open(init_path, encoding="utf-8") as f:
content = f.read()
match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', content)
if match:
return match.group(1)
raise RuntimeError("Unable to find version string.")
target_directory = (
os.path.join(os.getenv("APPDATA", ""), "waymore")
if os.name == "nt"
else (
os.path.join(os.path.expanduser("~"), "Library", "Application Support", "waymore")
if sys.platform == "darwin"
else os.path.join(os.path.expanduser("~"), ".config", "waymore")
)
)
# Copy the config.yml file to the target directory if it exists
configNew = False
if target_directory and os.path.isfile("config.yml"):
os.makedirs(target_directory, exist_ok=True)
# If file already exists, create a new one
if os.path.isfile(target_directory + "/config.yml"):
configNew = True
os.rename(target_directory + "/config.yml", target_directory + "/config.yml.OLD")
shutil.copy("config.yml", target_directory)
os.rename(target_directory + "/config.yml", target_directory + "/config.yml.NEW")
os.rename(target_directory + "/config.yml.OLD", target_directory + "/config.yml")
else:
shutil.copy("config.yml", target_directory)
setup(
name="waymore",
packages=find_packages(),
version=get_version(),
description="Find way more from the Wayback Machine, Common Crawl, Alien Vault OTX, URLScan & VirusTotal!",
long_description=open("README.md", encoding="utf-8").read(),
long_description_content_type="text/markdown",
author="@xnl-h4ck3r",
url="https://github.com/xnl-h4ck3r/waymore",
install_requires=[
"requests",
"pyyaml",
"termcolor",
"psutil",
"tldextract",
],
entry_points={
"console_scripts": [
"waymore = waymore.waymore:main",
],
},
)
if configNew:
print(
"\n\033[33mIMPORTANT: The file "
+ target_directory
+ "/config.yml already exists.\nCreating config.yml.NEW but leaving existing config.\nIf you need the new file, then remove the current one and rename config.yml.NEW to config.yml\n\033[0m"
)
else:
print("\n\033[92mThe file " + target_directory + "/config.yml has been created.\n\033[0m")