mirror of
https://github.com/LucasVbr/LucasVbr.git
synced 2026-07-09 14:27:46 +00:00
Using config.json
This commit is contained in:
@@ -3,42 +3,23 @@
|
||||
__author__ = "LucasVbr"
|
||||
__version__ = "3.0.0"
|
||||
|
||||
import requests
|
||||
from flask import render_template
|
||||
import flask
|
||||
from Badge import *
|
||||
from FileUtils import *
|
||||
from Utils import *
|
||||
from src.FileUtils import getJsonData
|
||||
from datetime import datetime
|
||||
|
||||
TEMPLATE_FILE = "index.md.jinja"
|
||||
TOOLS_DATA = "tools.json"
|
||||
OUTPUT_FILE = "README.md"
|
||||
|
||||
app = flask.Flask('my app')
|
||||
CONFIG_FILE = "config.json"
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get tools badges
|
||||
toolsData = getJsonData(TOOLS_DATA)
|
||||
tools = [Badge(toolName) for toolName in toolsData]
|
||||
tools.sort(key=getBadgeColor) # Sort by color
|
||||
configData = getJsonData(CONFIG_FILE)
|
||||
|
||||
# Get Weather
|
||||
request = requests.get("https://goweather.herokuapp.com/weather/rodez")
|
||||
weather_status = request.status_code
|
||||
weather = request.json()
|
||||
data = getDataSubfiles(configData.get("data_files"))
|
||||
data["info"] = configData.get("info")
|
||||
data["tools"] = convertToolBadges(data.get("tools"))
|
||||
data["weather"] = getWeather(data.get("info").get('city'))
|
||||
data['today'] = datetime.today().strftime("%A %d %B %y, %H:%M")
|
||||
|
||||
# Get current datetime
|
||||
today = datetime.today().strftime("%A %d %B %y, %H:%M")
|
||||
|
||||
# Build from template and data
|
||||
with app.app_context():
|
||||
rendered = render_template(
|
||||
TEMPLATE_FILE,
|
||||
tools=tools,
|
||||
weather_status=weather_status,
|
||||
weather=weather,
|
||||
today=today
|
||||
)
|
||||
|
||||
# Generate Markdown file
|
||||
setFileData(OUTPUT_FILE, rendered)
|
||||
buildFile(
|
||||
configData.get("template_file"),
|
||||
configData.get("output_file"),
|
||||
data
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user