This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Add more providers #22
Open
orlin369
wants to merge
14
commits into
develop
Choose a base branch
from
add_more_providers
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c74953c
Refactoring the main file
orlin369 ca9b74f
Update requirements just in case.
orlin369 5150ab2
Create setup file.
orlin369 4a8abba
Migrate code to library folder.
orlin369 17ee123
Refactoring the main file
orlin369 0c93e80
Merge branch 'add_more_providers' of https://github.com/wectrl-io/bg_…
orlin369 5223f67
Move exception namespace library to application library folder
orlin369 5367cff
Fix import
orlin369 cce2e7d
Update setup
orlin369 3a5eee7
Update git ignore
orlin369 bd589a7
Fix init files
orlin369 530a998
Fix libs imports
orlin369 d872398
Get text data for outages
orlin369 e70fc73
Add todos
orlin369 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf8 -*- | ||
|
|
||
| from bg_ED_data.providers.base.base_provider import BaseProvider | ||
|
|
||
| # Suppress ssl warnings | ||
| import requests | ||
|
|
||
| # requests.urllib3.disable_warnings(requests.urllib3.exceptions.InsecureRequestWarning) | ||
|
|
||
| #region File Attributes | ||
|
|
||
| __author__ = "Orlin Dimitrov" | ||
| """Author of the file.""" | ||
|
|
||
| __copyright__ = "" | ||
| """Copyrighted""" | ||
|
|
||
| __credits__ = [] | ||
| """Credits""" | ||
|
|
||
| __license__ = "" | ||
| """License | ||
| @see """ | ||
|
|
||
| __version__ = "1.0.0" | ||
| """Version of the file.""" | ||
|
|
||
| __maintainer__ = ["Orlin Dimitrov", "Martin Maslyankov", "Nikola Atanasov"] | ||
| """Name of the maintainer.""" | ||
|
|
||
| __email__ = "" | ||
| """E-mail of the author.""" | ||
|
|
||
| __class_name__ = "ERPSever" | ||
| """Provider class name.""" | ||
|
|
||
| #endregion | ||
|
|
||
| class ERPSever(BaseProvider): | ||
|
|
||
| def get_outages(self, **kwargs): | ||
| cookies = { | ||
| 'STDXFWSID': '3prf6nchustns3phuq1om0o881', | ||
| } | ||
|
|
||
| headers = { | ||
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0', | ||
| 'Accept': 'application/json, text/javascript, */*; q=0.01', | ||
| 'Accept-Language': 'en-US,en;q=0.5', | ||
| # 'Accept-Encoding': 'gzip, deflate, br', | ||
| 'Referer': 'https://www.erpsever.bg/bg/prekysvanija', | ||
| 'Content-Type': 'application/json; charset=utf-8', | ||
| 'X-Requested-With': 'XMLHttpRequest', | ||
| 'Connection': 'keep-alive', | ||
| # 'Cookie': 'STDXFWSID=3prf6nchustns3phuq1om0o881', | ||
| 'Sec-Fetch-Dest': 'empty', | ||
| 'Sec-Fetch-Mode': 'cors', | ||
| 'Sec-Fetch-Site': 'same-origin', | ||
| } | ||
|
|
||
| params = { | ||
| 'method': 'get_interruptions', | ||
| 'region_id': '2', # TODO: To be an argument of the method. Create enum for all IDs. | ||
| 'type': 'for_next_48_hours', # TODO: To be an argument of the method. | ||
| 'offset': '0', | ||
| 'archive_from_date': '', # TODO: To be an argument of the method. | ||
| 'archive_to_date': '', # TODO: To be an argument of the method. | ||
| } | ||
|
|
||
| response = requests.get('https://www.erpsever.bg/bg/profil/xhr/', params=params, cookies=cookies, headers=headers) | ||
|
|
||
| response_data_raw = response.text.encode().decode('utf-8-sig') | ||
|
|
||
| print(response_data_raw) | ||
|
|
||
|
|
||
| def get_prices(self, **kwargs): | ||
| url = "https://erpsever.bg/bg/ceni/ceni-za-prenos-i-dostyp" | ||
| response = requests.get(url) | ||
| print(response.text) | ||
| pass |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf8 -*- | ||
|
|
||
| from bg_ED_data.providers.electrohold.electrohold import Electrohold | ||
| from bg_ED_data.providers.erp_sever.erp_sever import ERPSever | ||
|
|
||
| #region File Attributes | ||
|
|
||
| __author__ = "Orlin Dimitrov" | ||
| """Author of the file.""" | ||
|
|
||
| __copyright__ = "" | ||
| """Copyrighted""" | ||
|
|
||
| __credits__ = [] | ||
| """Credits""" | ||
|
|
||
| __license__ = "" | ||
| """License | ||
| @see """ | ||
|
|
||
| __version__ = "1.0.0" | ||
| """Version of the file.""" | ||
|
|
||
| __maintainer__ = ["Orlin Dimitrov", "Martin Maslyankov", "Nikola Atanasov"] | ||
| """Name of the maintainer.""" | ||
|
|
||
| __email__ = "" | ||
| """E-mail of the author.""" | ||
|
|
||
| __class_name__ = "ERPSever" | ||
| """Provider class name.""" | ||
|
|
||
| #endregion | ||
|
|
||
| class Factory(): | ||
| """Providers factory. | ||
| """ | ||
|
|
||
| @staticmethod | ||
| def create(provider: str): | ||
| """Providers creator method. | ||
|
|
||
| Args: | ||
| provider (str): The name of wanted provider. | ||
|
|
||
| Raises: | ||
| NotImplementedError: It raise when unknown provider name is passed. | ||
|
|
||
| Returns: | ||
| any: Instance of the target provider. | ||
| """ | ||
| provider_instance = None | ||
|
|
||
| if provider == "erp_sever": | ||
| provider_instance = ERPSever() | ||
|
|
||
| elif provider == "electro_hold": | ||
| provider_instance = Electrohold() | ||
|
|
||
| else: | ||
| raise NotImplementedError("provider not implemented.") | ||
|
|
||
| return provider_instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #!/usr/bin/env python | ||
| # -*- coding: utf8 -*- |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| requests==2.27.1 | ||
| certifi==2022.12.7 | ||
| charset-normalizer==3.1.0 | ||
| idna==3.4 | ||
| requests==2.28.2 | ||
| urllib3==1.26.15 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls do not remove this for users of MacOS