diff --git a/FileUtils.py b/FileUtils.py
deleted file mode 100644
index eddd169..0000000
--- a/FileUtils.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-04/06/2022
-"""
-
-import json
-
-__file__ = 'FileUtils.py'
-__author__ = 'Lucas Vbr'
-__version__ = '0.1'
-
-
-def getJsonData(fileName: str) -> str:
- with open(fileName) as file:
- data = json.load(file)
- return data
-
-
-def setFileData(fileName: str, content: str):
- with open(fileName, "w", encoding="utf8") as file:
- file.write(content)
diff --git a/README.md b/README.md
index f79587f..f53edaa 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,12 @@
# Hello there !
I'm Lucàs, a passionate developer from Rodez, France.
-
Currently, the weather is: ****, ****
+
Currently, the weather is: **17.4°C**, **Few showers**
### I code with

-
+
+



@@ -18,21 +19,21 @@ I'm Lucàs, a passionate developer from Rodez, France.



+




-



+

-

### Where to find me
-[](https://github.com/LucasVbr)
+[](https://github.com/LucasVbr)
[](https://www.linkedin.com/in/lucasvbr)
[](https://www.freecodecamp.org/LucasVbr)
@@ -41,10 +42,11 @@ I'm Lucàs, a passionate developer from Rodez, France.
This README is generated every day.
-Last refresh: **Sunday 05 June 22, 06:16**
+Last refresh: **Sunday 05 June 22, 12:07**


-

+
+
*inspired by [Thomas Guibert](https://github.com/thmsgbrt)*
diff --git a/Utils.py b/Utils.py
new file mode 100644
index 0000000..49d1cdc
--- /dev/null
+++ b/Utils.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+
+import os.path
+from flask import Flask, render_template
+from src.Badge import Badge, getBadgeColor
+from meteofrance_api import MeteoFranceClient
+from src.FileUtils import setFileData, getJsonData
+
+"""
+05/06/2022
+"""
+
+__file__ = 'Utils.py'
+__author__ = 'Lucas Vbr'
+__version__ = '0.1'
+
+
+def getDataSubfiles(files: list):
+ """
+
+ :param files:
+ :return:
+ """
+ contents = {}
+ for file in files:
+ baseName = os.path.basename(file)
+ fileName = os.path.splitext(baseName)[0]
+ contents[fileName] = getJsonData(file)
+ return contents
+
+
+def convertToolBadges(listToolName: list) -> list[dict[str, str]]:
+ tools = [Badge(toolName) for toolName in listToolName]
+ tools.sort(key=getBadgeColor) # Sort by color
+ return [{"url": badge.url, "name": badge.name} for badge in tools]
+
+
+def getWeather(city: str) -> dict:
+ meteoClient = MeteoFranceClient()
+ place = meteoClient.search_places(city)[0]
+ weather = meteoClient.get_forecast_for_place(place, language="en") \
+ .current_forecast
+
+ return {
+ "temperature": weather.get('T').get('value'),
+ "description": weather.get("weather").get("desc")
+ }
+
+
+def buildFile(templateFile: str, outputFile: str, data: dict) -> None:
+ app = Flask('my app')
+ with app.app_context():
+ rendered = render_template(templateFile, data=data)
+
+ setFileData(outputFile, rendered)
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..22b569e
--- /dev/null
+++ b/config.json
@@ -0,0 +1,13 @@
+{
+ "info": {
+ "name": "Lucàs",
+ "city": "Rodez"
+ },
+ "template_file": "index.md.jinja",
+ "output_file": "README.md",
+ "data_files": [
+ "data/tools.json",
+ "data/links.json",
+ "data/footer_badges.json"
+ ]
+}
\ No newline at end of file
diff --git a/data/footer_badges.json b/data/footer_badges.json
new file mode 100644
index 0000000..5759e85
--- /dev/null
+++ b/data/footer_badges.json
@@ -0,0 +1,14 @@
+[
+ {
+ "alt": "Profile Views",
+ "src": "https://komarev.com/ghpvc/?username=lucasvbr&label=Profile%20views&color=0e75b6&style=flat"
+ },
+ {
+ "alt": "FreeCodeCamp Points",
+ "src": "https://img.shields.io/freecodecamp/points/lucasvbr?label=FreeCodeCamp%20points"
+ },
+ {
+ "alt": "Made with love",
+ "src": "https://img.shields.io/badge/-made%20with%20%E2%9D%A4%EF%B8%8F-red"
+ }
+]
\ No newline at end of file
diff --git a/data/links.json b/data/links.json
new file mode 100644
index 0000000..26fa774
--- /dev/null
+++ b/data/links.json
@@ -0,0 +1,17 @@
+[
+ {
+ "src": "https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white",
+ "alt": "GitHub",
+ "href": "https://github.com/LucasVbr"
+ },
+ {
+ "src": "https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white",
+ "alt": "LinkedIn",
+ "href": "https://www.linkedin.com/in/lucasvbr"
+ },
+ {
+ "src": "https://img.shields.io/badge/freecodecamp-27273D?style=for-the-badge&logo=freecodecamp&logoColor=white",
+ "alt": "FreeCodeCamp",
+ "href": "https://www.freecodecamp.org/LucasVbr"
+ }
+]
\ No newline at end of file
diff --git a/tools.json b/data/tools.json
similarity index 75%
rename from tools.json
rename to data/tools.json
index dcb436a..5fe2615 100644
--- a/tools.json
+++ b/data/tools.json
@@ -3,8 +3,6 @@
"CSS3",
"JavaScript",
"Pug",
- "Sass",
- "TypeScript",
"PHP",
"Java",
"C",
@@ -17,11 +15,14 @@
"Figma",
"Git",
"MariaDB",
- "Microsoft SQL Server",
"MySQL",
"PostgreSQL",
"SQLite",
"Android",
"Linux",
- "Windows"
+ "Windows",
+ "Insomnia",
+ "JetBrains",
+ "Visual Studio Code",
+ "FileZilla"
]
\ No newline at end of file
diff --git a/main.py b/main.py
index 9749620..af19ec7 100644
--- a/main.py
+++ b/main.py
@@ -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
+ )
diff --git a/requirements.txt b/requirements.txt
index c04cc0d..3fbec87 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
flask~=2.1.2
-requests~=2.27.1
colour~=0.1.5
-simpleicons~=6.23.0
\ No newline at end of file
+simpleicons~=6.23.0
+meteofrance-api~=1.0.2
\ No newline at end of file
diff --git a/Badge.py b/src/Badge.py
similarity index 56%
rename from Badge.py
rename to src/Badge.py
index a5e5439..0d1606e 100644
--- a/Badge.py
+++ b/src/Badge.py
@@ -30,18 +30,20 @@ class Badge:
icon = icons.get(self.name)
- params = {
- "label": "",
- "message": icon.title,
- "color": f"#{icon.hex}",
- "logo": icon.slug,
- "logoColor": LOGO_COLOR
- }
- urlParams = urlencode(params)
-
- self.url = f"{BASE_URL}?{urlParams}"
- self.color = Color(params["color"]).hsl
+ try:
+ params = {
+ "label": "",
+ "message": icon.title,
+ "color": f"#{icon.hex}",
+ "logo": icon.slug,
+ "logoColor": LOGO_COLOR
+ }
+ urlParams = urlencode(params)
+ self.url = f"{BASE_URL}?{urlParams}"
+ self.color = Color(params["color"]).get_hue()
+ except Exception:
+ pass # Let default values
def getBadgeColor(badge: Badge) -> float:
- return badge.color[0]
+ return badge.color
diff --git a/src/FileUtils.py b/src/FileUtils.py
new file mode 100644
index 0000000..fa68ea9
--- /dev/null
+++ b/src/FileUtils.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+
+"""
+04/06/2022
+"""
+
+import json
+
+__file__ = 'FileUtils.py'
+__author__ = 'Lucas Vbr'
+__version__ = '0.1'
+
+DEFAULT_FILE_ENCODING = "utf8"
+
+
+def getJsonData(filePath: str) -> str:
+ """
+ Take data from JSON File
+ :param filePath: Path of the file to read
+ :return: The content of the JSON file
+ """
+ with open(filePath, encoding=DEFAULT_FILE_ENCODING) as file:
+ data = json.load(file)
+ return data
+
+
+def setFileData(filePath: str, content: str) -> None:
+ """
+ Create a new File or replace it content if already exist
+ :param filePath: Path of the file to fill
+ :param content: Content to place in the file
+ :return: None
+ """
+ with open(filePath, "w", encoding=DEFAULT_FILE_ENCODING) as file:
+ file.write(content)
diff --git a/templates/index.md.jinja b/templates/index.md.jinja
index ae504a4..c83bc9f 100644
--- a/templates/index.md.jinja
+++ b/templates/index.md.jinja
@@ -1,27 +1,26 @@
# Hello there !

-I'm Lucàs, a passionate developer from Rodez, France.
-
Currently, the weather is: **{{ weather.temperature }}**, **{{ weather.description }}**
+I'm {{ data.info.name }}, a passionate developer from {{ data.info.city }}, France.
+
Currently, the weather is: **{{ data.weather.temperature }}°C**, **{{ data.weather.description }}**
### I code with
-{% for image in tools -%}
+{% for image in data.tools -%}

{% endfor %}
### Where to find me
-[](https://github.com/LucasVbr)
-[](https://www.linkedin.com/in/lucasvbr)
-[](https://www.freecodecamp.org/LucasVbr)
-
+{% for image in data.links -%}
+ []({{ image.href }})
+{% endfor %}
---
This README is generated every day.
-Last refresh: **{{ today }}**
-
-
-

+Last refresh: **{{ data.today }}**
+{% for image in data.footer_badges -%}
+ 
+{% endfor %}
*inspired by [Thomas Guibert](https://github.com/thmsgbrt)*