Dropped csv field prefixes in scripts

The original idea was to allow merging a whole bunch of different csv
results into a single lfs.csv file, but this never really happened. It's
much easier to operate on smaller context-specific csv files, where the
field prefix:

- Doesn't really add much information
- Requires more typing
- Is confusing in how it doesn't match the table field names.

We can always use summary.py -fcode_size=size to add prefixes when
necessary anyways.
This commit is contained in:
Christopher Haster
2024-06-02 16:33:05 -05:00
parent dc7e7b9ab1
commit 54d77da2f5
10 changed files with 132 additions and 124 deletions

View File

@@ -532,15 +532,15 @@ def main(obj_paths, *,
if not all(k in r and r[k] in vs for k, vs in defines):
continue
if not any('code_'+k in r and r['code_'+k].strip()
if not any(k in r and r[k].strip()
for k in CodeResult._fields):
continue
try:
results.append(CodeResult(
**{k: r[k] for k in CodeResult._by
if k in r and r[k].strip()},
**{k: r['code_'+k] for k in CodeResult._fields
if 'code_'+k in r and r['code_'+k].strip()}))
**{k: r[k] for k in CodeResult._fields
if k in r and r[k].strip()}))
except TypeError:
pass
@@ -562,14 +562,14 @@ def main(obj_paths, *,
with openio(args['output'], 'w') as f:
writer = csv.DictWriter(f,
(by if by is not None else CodeResult._by)
+ ['code_'+k for k in (
+ [k for k in (
fields if fields is not None else CodeResult._fields)])
writer.writeheader()
for r in results:
writer.writerow(
{k: getattr(r, k) for k in (
by if by is not None else CodeResult._by)}
| {'code_'+k: getattr(r, k) for k in (
| {k: getattr(r, k) for k in (
fields if fields is not None else CodeResult._fields)})
# find previous results?
@@ -583,15 +583,15 @@ def main(obj_paths, *,
if not all(k in r and r[k] in vs for k, vs in defines):
continue
if not any('code_'+k in r and r['code_'+k].strip()
if not any(k in r and r[k].strip()
for k in CodeResult._fields):
continue
try:
diff_results.append(CodeResult(
**{k: r[k] for k in CodeResult._by
if k in r and r[k].strip()},
**{k: r['code_'+k] for k in CodeResult._fields
if 'code_'+k in r and r['code_'+k].strip()}))
**{k: r[k] for k in CodeResult._fields
if k in r and r[k].strip()}))
except TypeError:
pass
except FileNotFoundError: