models package¶
Subpackages¶
Submodules¶
models.alert module¶
This module contains the Alert Model
class.
-
models.alert.
logger
¶ The logger used to log information of module.
- Type
-
class
models.alert.
Alert
(name: str, price_limit: float, user_email: str, item_id: dataclasses.InitVar[typing.Union[str, bson.objectid.ObjectId]], _id: dataclasses.InitVar[typing.Union[str, bson.objectid.ObjectId]] = None)[source]¶ Bases:
models.model.Model
Class that models an Alert.
-
item_id
: dataclasses.InitVar[typing.Union[str, bson.objectid.ObjectId]]¶
-
json
() → dict[source]¶ Returns the json representation of the alert.
- Returns
The json representation of the alert.
- Return type
-
load_item_price
() → float[source]¶ Returns the current price of the alert’s corresponding item.
- Returns
The current price of the alert’s item.
- Return type
-
models.item module¶
This module contains the Item Model
class.
-
models.item.
logger
¶ The logger used to log information of module.
- Type
-
class
models.item.
Item
(url: str, tag_name: str, query: Dict[str, Any], price: float = None, _id: InitVar[Union[str, ObjectId]] = None)[source]¶ Bases:
models.model.Model
Class that models an item.
-
query
¶ The CSS selector used to find the item.
- Type
-
json
() → dict[source]¶ Returns the json representation of the item.
- Returns
The json representation of the item.
- Return type
-
models.model module¶
This module contains the Model model class.
-
models.model.
logger
¶ The logger used to log information of module.
- Type
-
class
models.model.
Model
(_id: Optional[Union[str, bson.objectid.ObjectId]] = None)[source]¶ Bases:
object
Class that models a generic model.
-
classmethod
all
() → List[models.model.Model][source]¶ Finds and returns all the models corresponding to the model’s collection.
- Returns
The list of all the models of the model’s collection.
- Return type
List[Model]
-
classmethod
find_many_by
(attribute: str, value: Union[str, dict]) → List[models.model.Model][source]¶ Finds and returns all the models corresponding to an attribute value query.
Parameters attribute : str
The attribute to query by.
- valueUnion[str, dict]
The value of the attribute to query by.
- Returns
The list of models corresponding to the query.
- Return type
-
classmethod
find_one_by
(attribute: str, value: Union[str, dict]) → models.model.Model[source]¶ Finds and returns the model corresponding to an attribute value query.
-
classmethod
get_by_id
(_id: Union[str, bson.objectid.ObjectId]) → models.model.Model[source]¶ Finds and returns a model by id from the database.
-
abstract
json
() → dict[source]¶ Returns the json representation of the model.
- Returns
The json representation of the model
- Return type
- Raises
NotImplementedError – If the method is called without being implemented.
-
classmethod
models.store module¶
This module contains the Store Model
class.
-
models.store.
logger
¶ The logger used to log information of module.
- Type
-
class
models.store.
Store
(name: str, url_prefix: str, tag_name: str, query: Dict[str, Any], _id: InitVar[Union[str, ObjectId]] = None)[source]¶ Bases:
models.model.Model
” Class that models a store.
-
query
¶ The CSS selector used to find the item.
- Type
-
classmethod
find_by_url
(url: str) → models.store.Store[source]¶ Gets a store by URL.
-
classmethod
fix_pre_and_post_url_prefix
(url: str) → str[source]¶ Tries to fix pre and post url prefix.
-
classmethod
fix_url_prefix
(url: str) → str[source]¶ Tries to fix the URL prefix.
- Parameters
url (str) – The URL to be fixed.
- Returns
The fixed URL if it was fixed, otherwise the original URL is returned.
- Return type
- Raises
ValueError – If the URL is invalid or unfixable.
-
classmethod
get_by_name
(store_name: str) → models.store.Store[source]¶ Gets a store by name.
-
classmethod
get_by_url_prefix
(url_prefix: str) → models.store.Store[source]¶ Gets a store by URL prefix.
-