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

Cleans the kicost/distributors/distributor.py code #439

Merged
merged 1 commit into from
Mar 10, 2021
Merged
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
29 changes: 12 additions & 17 deletions kicost/distributors/distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,38 @@
__webpage__ = 'https://github.com/mmmaisel/'

# Libraries.
import sys, time, os, re
import logging
import time

#from . import fake_browser
#import http.client # For web scraping exceptions.
#from ..global_vars import PartHtmlError
# from . import fake_browser
# import http.client # For web scraping exceptions.
# from ..global_vars import PartHtmlError
# Kept this for future use.

from ..edas.tools import order_refs # To better print the warnings about the parts.

from .global_vars import *

from currency_converter import CurrencyConverter
from .global_vars import DEFAULT_CURRENCY, distributors_modules_dict


__all__ = ['distributor_class']


class distributor_class(object):
start_time = time.time()

def __init__(self, name, logger):
self.name = name
self.logger = logger

# Don't create fake_browser for "local" distributor.
#if self.domain != None:
# self.browser = fake_browser.fake_browser \
# (self.domain, self.logger, self.scrape_retries, throttle_delay)
# if self.domain != None:
# self.browser = fake_browser.fake_browser \
# (self.domain, self.logger, self.scrape_retries, throttle_delay)
# Kept this for future use.


def get_dist_parts_info(self, parts, distributors, currency=DEFAULT_CURRENCY):
''' Get the parts info using the modules API/Scrape/Local.'''
for d in distributors_modules:
for d in list(distributors_modules_dict):
globals()[d].query_part_info(parts, distributors, currency)
#dist_local_template.query_part_info(parts, distributors, currency)
#api_partinfo_kitspace.query_part_info(parts, distributors, currency)
# dist_local_template.query_part_info(parts, distributors, currency)
# api_partinfo_kitspace.query_part_info(parts, distributors, currency)

# Abstract methods, implemented in distributor specific modules.
@staticmethod
Expand Down