Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make executable #38

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parser_2gis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class Configuration(BaseModel):
writer: WriterOptions = WriterOptions()
chrome: ChromeOptions = ChromeOptions()
parser: ParserOptions = ParserOptions()
path: Optional[pathlib.Path]
path: Optional[pathlib.Path] = None
version: str = config_version

def __init__(self, *args, **kwargs) -> None:
def setup_config(model: BaseModel) -> None:
"""Recursively setup config."""
self.Config.validate_assignment = True
# self.Config.validate_assignment = True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignments validation is important for any settings changes, why have you turned it off?

for field in model.__fields__:
attr = getattr(model, field)
if isinstance(attr, BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion parser_2gis/writer/models/catalog_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CatalogItem(BaseModel):
type: str

# Признак удаленного объекта
is_deleted: Optional[bool]
# is_deleted: Optional[bool]

@property
def url(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion parser_2gis/writer/models/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def to_str(self, join_char: str, add_comment: bool = False) -> str:
Returns:
Schedule as a string.
"""
days_names = [x.name for x in self.__fields__.values() if x.type_ == ScheduleDay]
days_names = [x.name for x in self.__fields__.values() if type(x) == ScheduleDay]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quite sure what version of Pydantic you use, but type(x) should always return pydantic.fields.ModelField, that's why there is special attribute type_ for the fields.

days_mapping = dict(Mon='Пн', Tue='Вт', Wed='Ср', Thu='Чт', Fri='Пт', Sat='Сб', Sun='Вс')

slots_list = []
Expand Down