drivers/comedi/drivers/ni_routing/tools/convert_py_to_csv.py
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_routing/tools/convert_py_to_csv.py
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_routing/tools/convert_py_to_csv.py- Extension
.py- Size
- 1646 bytes
- Lines
- 67
- Domain
- Driver Families
- Bucket
- drivers/comedi
- Inferred role
- Driver Families: drivers/comedi
- Status
- atlas-only
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0+
from os import path
import os, csv
from itertools import chain
from csv_collection import CSVCollection
from ni_names import value_to_name
import ni_values
CSV_DIR = 'csv'
def iter_src_values(D):
return D.items()
def iter_src(D):
for dest in D:
yield dest, 1
def create_csv(name, D, src_iter):
# have to change dest->{src:val} to src->{dest:val}
fieldnames = [value_to_name[i] for i in sorted(D.keys())]
fieldnames.insert(0, CSVCollection.source_column_name)
S = dict()
for dest, srcD in D.items():
for src,val in src_iter(srcD):
S.setdefault(src,{})[dest] = val
S = sorted(S.items(), key = lambda src_destD : src_destD[0])
csv_fname = path.join(CSV_DIR, name + '.csv')
with open(csv_fname, 'w') as F_csv:
dR = csv.DictWriter(F_csv, fieldnames, delimiter=';', quotechar='"')
dR.writeheader()
# now change the json back into the csv dictionaries
rows = [
dict(chain(
((CSVCollection.source_column_name,value_to_name[src]),),
*(((value_to_name[dest],v),) for dest,v in destD.items())
))
for src, destD in S
]
dR.writerows(rows)
def to_csv():
for d in ['route_values', 'device_routes']:
try:
os.makedirs(path.join(CSV_DIR,d))
except:
pass
for family, dst_src_map in ni_values.ni_route_values.items():
create_csv(path.join('route_values',family), dst_src_map, iter_src_values)
for device, dst_src_map in ni_values.ni_device_routes.items():
create_csv(path.join('device_routes',device), dst_src_map, iter_src)
if __name__ == '__main__':
to_csv()
Annotation
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.