Skip to content
Snippets Groups Projects
Commit ac7b9257 authored by Oliwer Mattsson's avatar Oliwer Mattsson :headphones:
Browse files

Uppdaterade med fler funktioner.

parent 8c8acbd6
No related branches found
No related tags found
No related merge requests found
{"projects" :
[
{
"title": "My First Project",
"project_id": 0,
"course_code": "TDP003",
"course_name": "Projekt: Egna datormiljön",
"course_points": 6,
"techniques": ["python", "jinja2", "flask", "html", "css", "javascript"],
"short_desc": "Ett portfolio program.",
"long_desc": "Ett längre portfolio program.",
"img_url_big": "",
"img_url_small": "",
"group_size": 1,
"url": ""
},
{
"title": "My Second Project",
"project_id": 1,
"course_code": "TDP003",
"course_name": "Projekt: Egna datormiljön",
"course_points": 6,
"techniques": ["python", "java", "flask", "html", "css", "javascript"],
"short_desc": "Ett portfolio program.",
"long_desc": "Ett längre portfolio program.",
"img_url_big": "",
"img_url_small": "",
"group_size": 1,
"url": ""
}
]
}
{
"projects": [
{
"title": "project_title",
"project_id": 0,
"techniques": "techniques",
"desc": "description",
"img_url": "img_url",
"url": "url"
},
{
"title": "MyProject",
"project_id": 1,
"techniques": [
"python",
"css",
"html",
"flask"
],
"desc": "It's great!",
"img_url": "logo.jpg",
"url": "https://www.github.com/"
}
]
}
\ No newline at end of file
#!/.venv/bin/python
# ---- IMPORTS ---- #
import os
import json
import pprint
import re
# ---- IMPORTS ---- #
def load():
with open('data.json', 'r') as file:
with open('data.json', 'r', encoding='utf-8') as file:
data = json.load(file)
# Closing file
file.close()
return data
def save(data):
with open('data.json', 'w', encoding='utf-8') as file:
json.dump(data, file, ensure_ascii=False, indent=4)
file.close()
def get_project(data, id):
pass
......@@ -28,20 +43,133 @@ def get_techniques(data, id):
for n in range(0, get_project_count(data)):
if data["projects"][n]["project_id"] == id:
print(data["projects"][n]["techniques"])
return (data["projects"][n]["techniques"])
def get_techniques_stats(data, id):
def get_techniques_stats(data):
techniques = []
for n in range(0, get_project_count(data)):
if data["projects"][n]["project_id"] == id:
print(data["projects"][n]["techniques"])
tech = get_techniques(data, n)
for t in tech:
if t not in techniques:
techniques.append(t)
return techniques
def search():
pass
def cls():
os.system('cls' if os.name == 'nt' else 'clear')
pass
def new_project(data):
cls()
# ---- COLLECT INFO ----
project_title = input("Project title: ")
project_id = get_project_count(data)
techniques = input("\nWhat techniques does your project use? Write them out in the following format: python, java, html, css\n\nTechniques: ").replace(" ", "").lower().split(",")
description = input("Provide a description of your project: ")
url = input("Provide a link to the source code/demo of your project: ")
img_url = input("Image source (ex: logo.jpg): ")
# ---- COLLECT INFO ----
new_project = {
"title": project_title,
"project_id": project_id,
"techniques": techniques,
"desc": description,
"img_url": img_url,
"url": url
}
cls()
print("\n\nProject preview:\n")
pprint.pp(new_project)
option = int(input("\n1: Create\n2: Cancel\n> "))
if option == 1:
data['projects'].append(new_project)
save(data)
pass
def edit_project(data):
pass
def delete_project(data):
pass
def menu(data):
menu_items = ["Add new project", "Edit existing project", "Delete project", "Quit"]
menu_index = 0
while True:
cls()
titular = r"""
____ _ __ _ _
| _ \ ___ _ __ | |_ / _| ___ | | (_) ___
| |_) | / _ \ | '__| | __| | |_ / _ \ | | | | / _ \
| __/ | (_) | | | | |_ | _| | (_) | | | | | | (_) |
|_| \___/ |_| \__| |_| \___/ |_| |_| \___/
"""
print(titular)
for i in menu_items:
print(f"{menu_items.index(i)+1}: {i}")
try:
option = int(input(f"> "))
if option == 1:
new_project(data)
print("1")
elif option == 2:
edit_project(data)
elif option == 3:
delete_project(data)
elif option == 4:
cls()
break
except:
print("")
def main():
data = load()
get_project_count(data)
menu(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment