mirror of
https://github.com/obskyr/khinsider.git
synced 2025-08-31 16:51:56 +02:00
Added version specifiers to pip installs.
This commit is contained in:
20
khinsider.py
20
khinsider.py
@@ -15,14 +15,15 @@ from __future__ import unicode_literals
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import imp # To check modules without importing them.
|
import imp # To check modules without importing them.
|
||||||
|
|
||||||
|
# User-friendly name, import name, pip specification.
|
||||||
requiredModules = [
|
requiredModules = [
|
||||||
['requests', 'requests'], # Some modules don't have the same pypi name as
|
['requests', 'requests', 'requests >= 2.0.0, < 3.0.0'],
|
||||||
['bs4', 'beautifulsoup4'] # import name. Therefore, two entries per module.
|
['Beautiful Soup 4', 'bs4', 'beautifulsoup4 >= 4.0.0, < 5.0.0']
|
||||||
]
|
]
|
||||||
|
|
||||||
def moduleExists(module):
|
def moduleExists(module):
|
||||||
try:
|
try:
|
||||||
imp.find_module(module[0])
|
imp.find_module(module[1])
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -38,8 +39,8 @@ if __name__ == '__main__':
|
|||||||
def installModules(modules, verbose=True):
|
def installModules(modules, verbose=True):
|
||||||
for module in modules:
|
for module in modules:
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Installing {}...".format(module[1]))
|
print("Installing {}...".format(module[0]))
|
||||||
install(module[1])
|
install(module[2])
|
||||||
def installRequiredModules(needed=None, verbose=True):
|
def installRequiredModules(needed=None, verbose=True):
|
||||||
needed = neededInstalls() if needed is None else needed
|
needed = neededInstalls() if needed is None else needed
|
||||||
installModules(neededInstalls(), verbose)
|
installModules(neededInstalls(), verbose)
|
||||||
@@ -56,14 +57,13 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
# ------
|
# ------
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re # For the syntax error in the HTML.
|
||||||
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
import re # For the syntax error in the HTML.
|
|
||||||
|
|
||||||
# Different printin' for different Pythons.
|
# Different printin' for different Pythons.
|
||||||
normalPrint = print
|
normalPrint = print
|
||||||
def print(*args, **kwargs):
|
def print(*args, **kwargs):
|
||||||
|
Reference in New Issue
Block a user