2019-05-01 16:25:46 +02:00
|
|
|
from os.path import dirname, join, realpath
|
|
|
|
|
2018-01-22 06:45:48 +01:00
|
|
|
import pydoc
|
|
|
|
try:
|
|
|
|
from urllib.request import urlretrieve
|
|
|
|
except ImportError:
|
|
|
|
from urllib import urlretrieve
|
|
|
|
|
2019-03-31 15:38:19 +02:00
|
|
|
url = ("http://raw.githubusercontent.com/satwikkansal/"
|
2018-01-22 06:45:48 +01:00
|
|
|
"wtfpython/master/README.md")
|
2019-05-01 16:25:46 +02:00
|
|
|
|
|
|
|
file_path = join(dirname(dirname(realpath(__file__))), "content.md")
|
2018-01-22 06:45:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
def fetch_updated_doc():
|
|
|
|
try:
|
|
|
|
print("Fetching the latest version...")
|
2019-05-01 16:25:46 +02:00
|
|
|
urlretrieve(url, file_path)
|
2018-01-22 06:45:48 +01:00
|
|
|
print("Done!")
|
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
print("Uh oh, failed to check for the latest version, "
|
|
|
|
"using the local version for now.")
|
|
|
|
|
|
|
|
|
|
|
|
def render_doc():
|
2019-05-01 16:25:46 +02:00
|
|
|
with open(file_path, 'r', encoding="utf-8") as f:
|
2018-01-22 06:45:48 +01:00
|
|
|
content = f.read()
|
|
|
|
pydoc.pager(content)
|
|
|
|
|
|
|
|
|
|
|
|
def load_and_read():
|
|
|
|
fetch_updated_doc()
|
|
|
|
render_doc()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__== "__main__":
|
|
|
|
load_and_read()
|