Skip to content

Commit

Permalink
Removed unused "log_level" parameter in distributor class.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmaisel committed Jun 6, 2018
1 parent 3aa0659 commit c2a89ed
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions kicost/distributors/digikey/digikey.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
import pycountry

class dist_digikey(distributor.distributor):
def __init__(self, name, scrape_retries, log_level, throttle_delay):
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_digikey, self).__init__(name, distributor_dict[name]['site']['url'],
scrape_retries, log_level, throttle_delay)
scrape_retries, throttle_delay)

def dist_get_price_tiers(self, html_tree):
'''@brief Get the pricing tiers from the parsed tree of the Digikey product page.
Expand Down
7 changes: 3 additions & 4 deletions kicost/distributors/distributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@

class distributor:
start_time = time.time()
def __init__(self, name, domain, scrape_retries, log_level, throttle_delay):
def __init__(self, name, domain, scrape_retries, throttle_delay):
self.name = name
self.scrape_retries = scrape_retries
self.logger = logger
self.log_level = log_level
self.domain = domain

# Don't create fake_browser for "local" distributor.
Expand Down Expand Up @@ -128,9 +127,9 @@ def scrape_part(self, id, part):
else:
self.logger = multiprocessing.get_logger()
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(self.log_level)
handler.setLevel(1)
self.logger.addHandler(handler)
self.logger.setLevel(self.log_level)
self.logger.setLevel(1)
self.browser.logger = self.logger

url = {}
Expand Down
4 changes: 2 additions & 2 deletions kicost/distributors/farnell/farnell.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
__author__='Giacinto Luigi Cerone'

class dist_farnell(distributor.distributor):
def __init__(self, name, scrape_retries, log_level, throttle_delay):
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_farnell, self).__init__(name, distributor_dict[name]['site']['url'],
scrape_retries, log_level, throttle_delay)
scrape_retries, throttle_delay)

def dist_get_price_tiers(self, html_tree):
'''@brief Get the pricing tiers from the parsed tree of the farnell product page.
Expand Down
4 changes: 2 additions & 2 deletions kicost/distributors/local/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class dist_local(distributor.distributor):
# Static variable which contains local part html.
html = None

def __init__(self, name, scrape_retries, log_level, throttle_delay):
super(dist_local, self).__init__(name, None, scrape_retries, log_level, throttle_delay)
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_local, self).__init__(name, None, scrape_retries, throttle_delay)

def create_part_html(parts, distributors, logger):
'''@brief Create HTML page containing info for local (non-webscraped) parts.
Expand Down
4 changes: 2 additions & 2 deletions kicost/distributors/mouser/mouser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
from urllib.parse import quote_plus as urlquote

class dist_mouser(distributor.distributor):
def __init__(self, name, scrape_retries, log_level, throttle_delay):
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_mouser, self).__init__(name, distributor_dict[name]['site']['url'],
scrape_retries, log_level, throttle_delay)
scrape_retries, throttle_delay)
self.browser.add_cookie('.mouser.com', 'preferences', 'ps=www2&pl=en-US&pc_www2=USDe')

def dist_get_price_tiers(self, html_tree):
Expand Down
4 changes: 2 additions & 2 deletions kicost/distributors/newark/newark.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
from urllib.parse import quote_plus as urlquote

class dist_newark(distributor.distributor):
def __init__(self, name, scrape_retries, log_level, throttle_delay):
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_newark, self).__init__(name, distributor_dict[name]['site']['url'],
scrape_retries, log_level, throttle_delay)
scrape_retries, throttle_delay)

def dist_get_price_tiers(self, html_tree):
'''@brief Get the pricing tiers from the parsed tree of the Newark product page.
Expand Down
4 changes: 2 additions & 2 deletions kicost/distributors/rs/rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
from urllib.parse import quote_plus as urlquote

class dist_rs(distributor.distributor):
def __init__(self, name, scrape_retries, log_level, throttle_delay):
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_rs, self).__init__(name, distributor_dict[name]['site']['url'],
scrape_retries, log_level, throttle_delay)
scrape_retries, throttle_delay)

def dist_get_price_tiers(self, html_tree):
'''@brief Get the pricing tiers from the parsed tree of the RS Components product page.
Expand Down
4 changes: 2 additions & 2 deletions kicost/distributors/tme/tme.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
from urllib.parse import quote_plus as urlquote, urlencode

class dist_tme(distributor.distributor):
def __init__(self, name, scrape_retries, log_level, throttle_delay):
def __init__(self, name, scrape_retries, throttle_delay):
super(dist_tme, self).__init__(name, distributor_dict[name]['site']['url'],
scrape_retries, log_level, throttle_delay)
scrape_retries, throttle_delay)

def __ajax_details(self, pn):
'''@brief Load part details from TME using XMLHttpRequest.
Expand Down
1 change: 1 addition & 0 deletions kicost/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
DEBUG_OBSESSIVE = logging.DEBUG-2
DEBUG_HTTP_HEADERS = logging.DEBUG-3
DEBUG_HTTP_RESPONSES = logging.DEBUG-4
# Minimum possible log level is logging.DEBUG-9 !

SEPRTR = ':' # Delimiter between library:component, distributor:field, etc.

Expand Down
2 changes: 1 addition & 1 deletion kicost/kicost.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def mt_init_dist(d, scrape):
ctor = globals()['dist_local']
else:
ctor = globals()['dist_'+d]
instance = ctor(d, scrape_retries, 5, throttling_delay) # TODO: log level
instance = ctor(d, scrape_retries, throttling_delay)
except Exception as ex:
logger.log(DEBUG_OVERVIEW, "Initialising %s failed with %s, exculding this distributor..." \
% (d, type(ex).__name__))
Expand Down

0 comments on commit c2a89ed

Please sign in to comment.