50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
import json
|
|
import os
|
|
|
|
def load_vacancies(filepath: str) -> list[dict]:
|
|
try:
|
|
with open(filepath,"r") as file:
|
|
return json.load(file)
|
|
except:
|
|
print()
|
|
return []
|
|
|
|
def filter_by_city(vacancies: list[dict], city: str) -> list[dict]:
|
|
return [i for i in vacancies if i.get('city').lower() == city.lower()]
|
|
def filter_by_skills(vacancies: list[dict], required_skills: list[str]) -> list[dict]:
|
|
return [i for i in vacancies if i.get('skills')]
|
|
def filter_by_salary(vacancies: list[dict], min_salary: int) -> list[dict]:
|
|
return []
|
|
def extract_unique_companies(vacancies: list[dict]) -> list[str]:
|
|
return []
|
|
def extract_top_skills(vacancies: list[dict], top_n: int) -> list[tuple[str, int]]:
|
|
return []
|
|
def calculate_average_salary(vacancies: list[dict]) -> float:
|
|
return 0.0
|
|
def group_by_company(vacancies: list[dict]) -> dict[str, int]:
|
|
return {}
|
|
def format_vacancy_short(vacancy: dict) -> str:
|
|
return
|
|
def save_filtered_results(vacancies: list[dict], filename: str) -> bool:
|
|
return
|
|
def interface():
|
|
os.system('cls' if os.name == 'nt' else 'clear')
|
|
print ("Your command:")
|
|
print ("1. Load form json\n2. Filter by city\n3. Filter by skils\n4. Filter by salary")
|
|
print ("5. Extract unique companies\n6. Extract top skills\n7. Calculate average salary")
|
|
print ("8. Group by company\n9. Format vacancy short\n10. Save filtred results")
|
|
def user_chouse(user_input:int):
|
|
match user_input:
|
|
case 1:
|
|
|
|
return load_vacancies(input("Path for json: "))
|
|
case _:
|
|
print ("Error uncorrecteble number")
|
|
def main():
|
|
interface()
|
|
user_input = int(input("Chouse command: "))
|
|
user_chouse(user_input)
|
|
|
|
if __name__ =="__main__":
|
|
#вход проги
|
|
main() |