datasheet added to bom
This commit is contained in:
parent
57ba627955
commit
03636b8964
|
@ -151,7 +151,8 @@ def bom2(schematic, attributes)
|
||||||
# generate bom2
|
# generate bom2
|
||||||
list = `gnetlist -g bom2 -Oattribs=#{attributes*','} -q -o - #{schematic}`
|
list = `gnetlist -g bom2 -Oattribs=#{attributes*','} -q -o - #{schematic}`
|
||||||
list.encode!("UTF-8","ISO-8859-1")
|
list.encode!("UTF-8","ISO-8859-1")
|
||||||
list.gsub!(/(\d[Mkmµ]?)\?/,'\1Ω')
|
list.gsub!(/(\d[Mkmµ]?)\?/,'\1Ω') # UTF-8 characters like Ω are replaced with ? by gnetlist
|
||||||
|
list.gsub!(/(https?:\/\/[^:]*):/,'"\1":') # ':' (like in links) are not protected
|
||||||
# parse bom2
|
# parse bom2
|
||||||
csv = CSV.parse(list,{:col_sep => ":"})
|
csv = CSV.parse(list,{:col_sep => ":"})
|
||||||
csv[1..-1].each do |row|
|
csv[1..-1].each do |row|
|
||||||
|
@ -215,10 +216,11 @@ def octopart(seller,sku)
|
||||||
return to_return
|
return to_return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
DIGIKEY_URL = "http://www.digikey.de/product-detail/en/all/"
|
||||||
def scrape_digikey(sku)
|
def scrape_digikey(sku)
|
||||||
to_return = {stock: nil, currency: "EUR", prices: []}
|
to_return = {stock: nil, currency: "EUR", prices: []}
|
||||||
# get page
|
# get page
|
||||||
url = "http://www.digikey.de/product-detail/en/all/#{sku}/"
|
url = DIGIKEY_URL+sku
|
||||||
doc = Nokogiri::HTML(open(URI.escape(url)))
|
doc = Nokogiri::HTML(open(URI.escape(url)))
|
||||||
# get stock
|
# get stock
|
||||||
stock_doc = doc.xpath('//td[@id="quantityavailable"]')[0]
|
stock_doc = doc.xpath('//td[@id="quantityavailable"]')[0]
|
||||||
|
@ -235,10 +237,11 @@ def scrape_digikey(sku)
|
||||||
return to_return
|
return to_return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FARNELL_URL = "http://de.farnell.com/"
|
||||||
def scrape_farnell(sku)
|
def scrape_farnell(sku)
|
||||||
to_return = {stock: nil, currency: "EUR", prices: []}
|
to_return = {stock: nil, currency: "EUR", prices: []}
|
||||||
# get page
|
# get page
|
||||||
url = "http://de.farnell.com/#{sku}"
|
url = FARNELL_URL+sku
|
||||||
doc = Nokogiri::HTML(open(URI.escape(url)))
|
doc = Nokogiri::HTML(open(URI.escape(url)))
|
||||||
# get stock
|
# get stock
|
||||||
stock_doc = doc.xpath('//td[@class="prodDetailAvailability"]')[0]
|
stock_doc = doc.xpath('//td[@class="prodDetailAvailability"]')[0]
|
||||||
|
@ -260,10 +263,11 @@ def scrape_farnell(sku)
|
||||||
return to_return
|
return to_return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
MOUSER_URL = "http://www.mouser.com/Search/ProductDetail.aspx?R=0virtualkey0virtualkey"
|
||||||
def scrape_mouser(sku)
|
def scrape_mouser(sku)
|
||||||
to_return = {stock: nil, currency: "EUR", prices: []}
|
to_return = {stock: nil, currency: "EUR", prices: []}
|
||||||
# get page
|
# get page
|
||||||
url = "http://www.mouser.com/Search/ProductDetail.aspx?R=0virtualkey0virtualkey#{sku}"
|
url = MOUSER_URL+sku
|
||||||
doc = Nokogiri::HTML(open(URI.escape(url),:allow_redirections => :all))
|
doc = Nokogiri::HTML(open(URI.escape(url),:allow_redirections => :all))
|
||||||
# get stock
|
# get stock
|
||||||
stock_doc = doc.xpath('//table[contains(@id,"availability")]/tr/td')[0]
|
stock_doc = doc.xpath('//table[contains(@id,"availability")]/tr/td')[0]
|
||||||
|
@ -363,7 +367,7 @@ end
|
||||||
desc "generate BOM file from schematic"
|
desc "generate BOM file from schematic"
|
||||||
targets.each do |target|
|
targets.each do |target|
|
||||||
file "#{target[:name]}_bom.csv" => target[:sch] do |t|
|
file "#{target[:name]}_bom.csv" => target[:sch] do |t|
|
||||||
attributes = ["category","device","value","description","manufacturer","manufacturer-id","digikey-id","farnell-id","mouser-id"]
|
attributes = ["category","device","value","description","manufacturer","manufacturer-id","datasheet","digikey-id","farnell-id","mouser-id"]
|
||||||
bom_data = bom2(t.prerequisites[0],attributes)
|
bom_data = bom2(t.prerequisites[0],attributes)
|
||||||
CSV.open(t.name, "wb") do |csv|
|
CSV.open(t.name, "wb") do |csv|
|
||||||
all_attributes = ["refdes","qty"]+attributes
|
all_attributes = ["refdes","qty"]+attributes
|
||||||
|
|
Loading…
Reference in New Issue