4 from UserDict
import UserDict
6 from collections
import UserDict
9 class InterfacesBase(UserDict
):
10 """ contains a list of interface definitions
13 def __init__(self
, ifacekls
, pth
=None):
16 UserDict
.__init
__(self
, {})
19 ift
= 'interfaces.txt'
21 ift
= os
.path
.join(pth
, ift
)
22 with
open(ift
, 'r') as ifile
:
23 for ln
in ifile
.readlines():
26 name
= ln
[0] # will have uart
27 count
= int(ln
[1]) # will have count of uart
28 # spec looks like this:
30 [{'name': 'sda', 'outen': True},
31 {'name': 'scl', 'outen': True},
34 spec
, ganged
= self
.read_spec(pth
, name
)
35 iface
= ifacekls(name
, spec
, ganged
, count
== 1)
36 self
.ifaceadd(name
, count
, iface
)
38 def getifacetype(self
, fname
):
39 # finds the interface type, e.g sd_d0 returns "inout"
40 for iface
in self
.values():
41 typ
= iface
.getifacetype(fname
)
46 def ifaceadd(self
, name
, count
, iface
, at
=None):
48 at
= len(self
.ifacecount
) # ifacecount is a list
49 self
.ifacecount
.insert(at
, (name
, count
)) # appends the list
50 # with (name,count) *at* times
54 will check specific files of kind peripheral.txt like spi.txt,
55 uart.txt in test directory
58 def read_spec(self
, pth
, name
):
61 fname
= '%s.txt' % name
63 ift
= os
.path
.join(pth
, fname
)
64 with
open(ift
, 'r') as sfile
:
65 for ln
in sfile
.readlines():
69 d
= {'name': name
, # here we start to make the dictionary
72 d
['action'] = True # adding element to the dict
73 elif ln
[1] == 'inout':
79 ganged
[bus
].append(name
)