1 # gaf.netlist - gEDA Netlist Extraction and Generation
2 # Copyright (C) 1998-2010 Ales Hvezda
3 # Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
4 # Copyright (C) 2013-2020 Roland Lutz
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # Copyright (C) 2001-2010 MIYAMOTO Takanori
22 from partslist_common
import *
24 def count_same_parts(ls
):
30 for i
, l
in enumerate(reversed(ls
)):
32 match_length
= len(ls
) - i
34 rest_ls
= ls
[match_length
:]
35 uref_ls
= [l
[0] for l
in ls
[:match_length
]]
37 return [(uref_ls
, first_ls
+ (str(match_length
), ))] + \
38 count_same_parts(rest_ls
)
41 parts_table
= count_same_parts(marge_sort_with_multikey(
42 get_parts_table(netlist
), [1, 2, 3, 0]))
45 f
.write('..device\tvalue\tfootprint\tquantity\trefdes\n')
46 for a
, b
in parts_table
:
47 write_one_row(f
, b
, '\t', '\t')
48 write_one_row(f
, a
, ' ', '\n')