JobSpy/jobspy/core/jobs/__init__.py

76 lines
1.5 KiB
Python
Raw Normal View History

2023-09-03 07:29:25 -07:00
from typing import Union, Optional
2023-08-31 08:29:43 -07:00
from datetime import date
2023-07-06 16:44:38 -07:00
from enum import Enum
from pydantic import BaseModel, validator
2023-07-11 06:24:59 -07:00
2023-07-06 16:44:38 -07:00
class JobType(Enum):
2023-07-11 06:24:59 -07:00
FULL_TIME = "fulltime"
PART_TIME = "parttime"
CONTRACT = "contract"
2023-07-07 19:00:59 -07:00
TEMPORARY = "temporary"
2023-07-11 06:24:59 -07:00
INTERNSHIP = "internship"
PER_DIEM = "perdiem"
2023-07-08 04:57:36 -07:00
NIGHTS = "nights"
OTHER = "other"
2023-07-11 07:50:44 -07:00
SUMMER = "summer"
2023-08-31 12:01:47 -07:00
VOLUNTEER = "volunteer"
2023-07-06 16:44:38 -07:00
2023-09-03 07:29:25 -07:00
2023-07-06 16:44:38 -07:00
class Location(BaseModel):
country: str = "USA"
city: str = None
2023-09-03 07:29:25 -07:00
state: Optional[str] = None
2023-07-06 16:44:38 -07:00
2023-07-08 04:57:36 -07:00
class CompensationInterval(Enum):
YEARLY = "yearly"
MONTHLY = "monthly"
WEEKLY = "weekly"
DAILY = "daily"
HOURLY = "hourly"
2023-07-06 16:44:38 -07:00
class Compensation(BaseModel):
interval: CompensationInterval
2023-09-03 07:29:25 -07:00
min_amount: int = None
max_amount: int = None
2023-08-31 08:29:43 -07:00
currency: str = "USD"
2023-07-06 16:44:38 -07:00
class JobPost(BaseModel):
title: str
company_name: str
2023-07-11 03:42:20 -07:00
job_url: str
2023-09-03 07:29:25 -07:00
location: Optional[Location]
2023-07-11 03:42:20 -07:00
description: str = None
2023-09-03 07:29:25 -07:00
job_type: Optional[JobType] = None
compensation: Optional[Compensation] = None
2023-08-31 08:29:43 -07:00
date_posted: date = None
2023-07-06 17:12:01 -07:00
class JobResponse(BaseModel):
success: bool
error: str = None
2023-09-03 07:29:25 -07:00
total_results: Optional[int] = None
2023-08-27 18:32:46 -07:00
2023-07-11 10:30:13 -07:00
jobs: list[JobPost] = []
returned_results: int = None
2023-08-27 18:32:46 -07:00
@validator("returned_results", pre=True, always=True)
def set_returned_results(cls, v, values):
2023-09-03 07:29:25 -07:00
jobs_list = values.get("jobs")
if v is None:
if jobs_list is not None:
return len(jobs_list)
else:
return 0
return v