Digi-Key Vendor Module (tendril.sourcing.digikey)

‘Standalone’ Usage

This module can be imported by itself to provide limited but potentially useful functionality.

>>> from tendril.sourcing import digikey

Search

Search for Digi-Key part numbers given a Tendril-compatible ident string :

>>> digikey.dvobj.search_vpnos('IC SMD W5300 LQFP100-14')
(['1278-1009-ND'], 'EXACT_MATCH_FFP')
>>> digikey.dvobj.search_vpnos('IC SMD LM311 8-TSSOP')
(['296-13719-2-ND', '296-13719-1-ND'], 'NAIVE_FP_MATCH')

Note that only certain types of components are supported by the search. The device component of the ident string is used to determine whether or not a search will even be attempted. See VendorDigiKey._devices for a list of supported device classes. For all device classes, search is supported only for components whose value is a manufacturer part number, or enough of one to sufficiently identify the part in question.

For certain (very specific) device classes, the search can be done using generic descriptions of the component. These ‘jelly bean’ components must have a correctly formatted value, as per the details listed in the gEDA Symbol Conventions.

>>> digikey.dvobj.search_vpnos('CAP CER SMD 22uF/35V 0805')
(['445-14428-2-ND', '445-14428-1-ND', '445-11527-2-ND', '445-11527-1-ND'],
 'CONSENSUS_FP_MATCH')
>>> digikey.dvobj.search_vpnos('RES SMD 1.15E/0.125W 0805')
(['311-1.15CRTR-ND', '311-1.15CRCT-ND', '541-1.15CCTR-ND', '541-1.15CCCT-ND'],
'CONSENSUS_FP_MATCH')
>>> digikey.dvobj.search_vpnos('RES ARRAY SMD 102E/0.0625W 1206-4')
(['TC164-FR-07102RL-ND', 'AF164-FR-07102RL-ND'], 'NAIVE_FP_MATCH_ALLOW_NS')
>>> digikey.dvobj.search_vpnos('CRYSTAL AT 13MHz HC49')
(['887-2036-ND'], 'EXACT_MATCH')

See also

Implementation of VendorDigiKey._get_pas_vpnos() and the functions that it uses to perform this search.

Even with supported device types, remember that this search is nowhere near bulletproof. The more generic a device and/or its name is, the less likely it is to work. The intended use for this type of search is in concert with an organization’s engineering policies and an instance administrator who can make the necessary tweaks to the search algortihms and maintain a low error rate for component types commonly used within the instance.

Tweaks and improvements to the search process are welcome as pull requests to the tendril github repository, though their inclusion will be predicated on them causing minimal breakage to what already exists.

Retrieve

Obtain information for a given Digi-Key part number :

>>> p = digikey.DigiKeyElnPart('800-2146-ND')
>>> p.manufacturer
'IDT, Integrated Device Technology Inc'
>>> p.mpartno
'72V2113L10PFI'
>>> p.vqtyavail
185
>>> p.datasheet
'http://www.idt.com/document/72v2103-72v2113-datasheet'
>>> p.package
'80-LQFP'
>>> p.vpartdesc
'IC FIFO SUPERSYNCII 10NS 80TQFP'

The pricing information is also populated by this time, and can be accessed though the part object using the interfaces defined in those class definitions.

>>> for b in p._prices:
...     print b
...
<VendorPrice INR 7,610.18 @1(1)>
<VendorPrice INR 6,801.37 @25(1)>
<VendorPrice INR 6,420.86 @100(1)>
<VendorPrice INR 6,183.05 @250(1)>
<VendorPrice INR 6,087.93 @500(1)>
<VendorPrice INR 5,802.56 @1000(1)>
<VendorPrice INR 5,707.43 @2500(1)>

Hint

By default, the vendors.VendorPrice instances are represented by the unit price in the currency defined by the tendril.utils.types.currency.native_currency_defn.

Additionally, the contents of the Overview and Attributes tables are available, though not parsed, in the form of BS4 trees. Note, however, that these contents are only available when part details are obtained from the soup itself, and not when reconstructed from the Tendril database.

>>> for k in p.attributes_table.keys():
...     print(k)
...
Category
Operating Temperature
Memory Size
Package / Case
Function
Product Photos
Datasheets
Current - Supply (Max)
Data Rate
Programmable Flags Support
FWFT Support
Standard Package
Bus Directional
Access Time
Online Catalog
Expansion Type
Family
Mounting Type
Series
Supplier Device Package
Packaging
Voltage - Supply
Other Names
Retransmit Capability
>>> for k in p.overview_table.keys():
...     print k
...
Description
Digi-Key Part Number
Manufacturer Part Number
Moisture Sensitivity Level (MSL)
Lead Free Status / RoHS Status
Quantity Available
Manufacturer
Price Break
class tendril.sourcing.digikey.DigiKeyElnPart(dkpartno, ident=None, vendor=None, max_age=-1)[source]

Bases: tendril.sourcing.vendors.VendorElnPartBase

This class acquires and contains information about a single DigiKey part number, specified by the dkpartno parameter.

Parameters:
  • dkpartno (str) – The DigiKey part number.
  • ident (str) – (Optional) Allows the caller to include the canonical representation within Tendril for the part represented by the object. This is required for use with the Tendril database.
  • vendor (VendorDigiKey) – (Optional) Allows the caller to ‘bind’ the part to the pre-existing vendor objects in Tendril’s sourcing infrastructure. This is required for use with the Tendril database.
vparturl
_get_data()[source]

This function downloads the part page from Digi-Key, scrapes the page, and populates the object with all the necessary information.

_get_prices(soup)[source]

Given the BS4 parsed soup of the Digi-Key product page, this function extracts the prices and breaks and returns them as a list of vendors.VendorPrice instances.

Price listings containing only ‘Call’ are ignored. Any other non-numeric content for the price or break quantity listing results in an error message from the logger and the corresponding price / break quantity is returned as 0.

static _get_table(table)[source]

Parses tabular data in the format of Digi-Key’s part detail tables, obtained from a BS4 parsed tree.

The tables parsed are of the format :

<table>
    ...
    <tr>
        <th> [HEAD] </th>
        <td> [DATA] </th>
    </tr>
    ...
</table>

The parsed table is returned as a dictionary. For each row in the table, the extracted [HEAD] is stripped, encoded to ascii and used as a key, and value is the corresponding [DATA] in it’s BS4 parsed form.

_get_overview_table(soup)[source]

Given the BS4 parsed soup of the Digi-Key product page, this function extracts and returns the overview / product-detail table using _get_table().

_get_attributes_table(soup)[source]

Given the BS4 parsed soup of the Digi-Key product page, this function extracts and returns the product attributes table using _get_table().

_get_mpartno()[source]

Extracts the Manufacturer Part Number from the overview table.

_get_manufacturer()[source]

Extracts the Manufacturer from the overview table.

_get_package()[source]

Extracts the Package from the attributes table. If Package / Case is not found in the table, returns None.

_get_datasheet()[source]

Extracts the first datasheet link from the attributes table. If Datasheets is not found in the table, returns None.

_regex_vqtyavail = <_sre.SRE_Pattern object>
_regex_vqty_vai = <_sre.SRE_Pattern object>
_get_vqtyavail()[source]

Extracts the Quantity Available from the overview table. If Value Added Item is found in the available quantity cell, returns -2. If any other non integral value is found in the cell, returns -1.

_get_vpartdesc()[source]

Extracts the Description from the overview table.

class tendril.sourcing.digikey.DigiKeyInvoice(vendor=None, inv_yaml=None, working_folder=None)[source]

Bases: tendril.sourcing.customs.CustomsInvoice

_acquire_lines()[source]
class tendril.sourcing.digikey.VendorDigiKey(name, dname, pclass, mappath=None, currency_code='USD', currency_symbol='US$', **kwargs)[source]

Bases: tendril.sourcing.vendors.VendorBase

_partclass

alias of DigiKeyElnPart

_invoiceclass

alias of DigiKeyInvoice

_devices = ['IC SMD', 'IC THRU', 'IC PLCC', 'FERRITE BEAD SMD', 'TRANSISTOR THRU', 'TRANSISTOR SMD', 'MOSFET SMD', 'CONN DF13', 'CONN DF13 HOUS', 'CONN DF13 WIRE', 'CONN DF13 CRIMP', 'DIODE SMD', 'DIODE THRU', 'LED SMD', 'BRIDGE RECTIFIER', 'ZENER SMD', 'RES SMD', 'RES THRU', 'RES ARRAY SMD', 'VARISTOR', 'CAP CER SMD', 'CAP TANT SMD', 'CAP AL SMD', 'CAP MICA SMD', 'CAP ELEC THRU', 'TRANSFORMER SMD', 'INDUCTOR SMD', 'RELAY', 'CRYSTAL AT', 'CRYSTAL OSC', 'CRYSTAL VCXO', 'CONN MODULAR', 'CONN SECII', 'CONN TERMINAL DMC', 'LIGHT PIPE', 'MODULE SMPS', 'SWITCH TACT']

Supported Device Classes

Hint

This handles instance-specific tweaks, and should be modified to match your instance’s nomenclature guidelines.

_url_base = 'http://www.digikey.com'
_search_url_base = 'http://www.digikey.com/product-search/en/'
_default_urlparams = [('stock', '0'), ('mnonly', '0'), ('newproducts', '0'), ('ColumnSort', '0'), ('page', '1'), ('quantity', '0'), ('ptm', '0'), ('fid', '0'), ('pagesize', '500'), ('pbfree', '0'), ('rohs', '0')]
_type = 'DIGIKEY'
session
get_soup(url)[source]

Retrieve the soup for a particular url. This function is factored out to allow switching between the urllib2 and requests based implementations in tendril.utils.www.

Currently, the requests based implementation is about two times slower for vendor map generation. The cache provided by cachecontrol in that implementation is not very well suited to this application. Additional changes to the underlying implementation or configuration thereof (perhaps in the heuristic) may change this in the future.

search_vpnos(ident)[source]
rex_to_package = <_sre.SRE_Pattern object>
_search_preprocess(device, value, footprint)[source]

Pre-processes and returns the (device, value, footprint) tuple parsed from the part ident, making tweaks necessary to translate the names into those more likely to be found on Digi-Key.

Hint

This function handles instance-specific tweaks, and should be modified to match your instance’s nomenclature guidelines.

Todo

The content of this function should be moved out of the core and into the instance folder.

static _process_product_page(soup)[source]

Given the BS4 parsed soup of a Digi-Key product page, returns a vendors.SearchResult instance, whose parts variable includes a list of exactly one vendors.SearchPart instance, with relevant data parsed from the page contained within it. The strategy for the returned result is set to EXACT_MATCH.

In case any of the following exclusion criteria are met, the part is not returned within the vendors.SearchResult, its success parameter is set to False, and its strategy parameter is set as listed below :

Listed as Obsolete on the Product Page OBSOLETE_NOTAVAIL
No Part Number Found NO_PNO_CELL
Product Details Table Not Found NO_PDTABLE

Todo

The current approach of handling catergories and subcategories can result in these seemingly ‘exact match’ results to be put into a comparison. If that were to happen, the Package/Case, Unit Price, and MOQ are all necessary pieces of information to determine inclusion. These are not currently parsed from the page soup and should be handled here, preferably without instantiating a full digikey part instance.

static _get_device_catstrings(device)[source]

Given a certain device string, returns the known Digi-Key categories which should be searched in case the first search attempt returns an Index Page.

Returns a tuple, the first element being success (True or False) and the second being the list of recognized category strings for the given device string.

Hint

This function handles instance-specific tweaks, and should be modified to match your instance’s engineering and nomenclature guidelines.

Todo

The content of this function should be moved out of the core and into the instance folder.

static _get_device_subcatstrings(device)[source]

Given a certain device string, returns the known Digi-Key sub-categories which should be searched in case the a search attempt returns a Secondary Index Page.

Returns a tuple, the first element being success (True or False) and the second being the list of recognized sub-category strings for the given device string.

Hint

This function handles instance-specific tweaks, and should be modified to match your instance’s engineering and nomenclature guidelines.

Todo

The content of this function should be moved out of the core and into the instance folder.

_process_secondary_index_page(soup, device)[source]
_process_index_page(soup, device)[source]
static _process_resultpage_row(row)[source]

Given a row from a CSV file obtained from Digi-Key’s search interface and read in using csv.DictReader, convert it into a vendors.SearchPart instance.

If the unit price for the row is not readily parseable into a float, or if the minqty field includes a Non-Stock note, the returned SearchPart has it’s ns attribute set to True.

Return type:vendors.SearchPart
_get_resultpage_parts(rows)[source]

Given a list of table rows obtained using a _get_resultpage_table(), or a combined list from multiple calls thereof with multiple result pages, returns a vendors.SearchResult instance whose parts variable is a list of all Digi-Key parts found in those result pages, each represented by a vendors.SearchPart instance and generated using _process_resultpage_row().

_get_resultpage_table(soup)[source]

Given the BS4 parsed soup of a Digi-Key search page, returns a list of rows in the table.

This function uses the ‘Download table as CSV’ feature of Digi-Keys website to obtain the table as CSV, and then uses csv.DictReader to parse the CSV file and returns a list of dictionaries - one for each row.

Each row is intended for later processing into a vendors.SearchPart instance using _process_resultpage_row().

_get_search_vpnos(device, value, footprint)[source]
_regex_fo_res = <_sre.SRE_Pattern object>
_tf_resistance_to_canonical(rstr)[source]
static _tf_tolerance_to_canonical(tstr)[source]
_regex_fo_cap = <_sre.SRE_Pattern object>
_tf_capacitance_to_canonical(cstr)[source]
static _tf_option_base(ostr)[source]
_filter_otf
_get_searchpage_filters(soup)[source]
_get_searchurl_filters(searchurl)[source]
static _tf_package_tant_smd(footprint)[source]
static _tf_package_crystal_at(footprint)[source]
static _tf_package_res_array_smd(footprint)[source]
_searchurl_res_smd
_searchurl_res_thru
_searchurl_res_array_smd
_searchurl_cap_cer_smd
_searchurl_cap_tant_smd
_searchurl_crystal
_get_device_searchparams(device)[source]
static _get_value_options(devtype, value)[source]
static _process_value_options(filters, loptions, lvalues)[source]
static _process_package_options(filters, package_header, package_filter_type, footprint)[source]
static _process_extraparams(filters, extraparams)[source]
_get_pas_vpnos(device, value, footprint)[source]