scripts: Renamed summary.py -> csv.py

This seems like a more fitting name now that this script has evolved
into more of a general purpose high-level CSV tool.

Unfortunately this does conflict with the standard csv module in Python,
breaking every script that imports csv (which is most of them).
Fortunately, Python is flexible enough to let us remove the current
directory before imports with a bit of an ugly hack:

  # prevent local imports
  __import__('sys').path.pop(0)

These scripts are intended to be standalone anyways, so this is probably
a good pattern to adopt.
This commit is contained in:
Christopher Haster
2024-11-09 12:31:16 -06:00
parent a0ab7bda26
commit 7cfcc1af1d
33 changed files with 128 additions and 32 deletions
+3
View File
@@ -3,6 +3,9 @@
# Amortize benchmark measurements
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import itertools as it
+3
View File
@@ -3,6 +3,9 @@
# Compute averages/etc of benchmark measurements
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import itertools as it
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import errno
+3
View File
@@ -11,6 +11,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import glob
import itertools
import os
+3
View File
@@ -12,6 +12,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import difflib
+3
View File
@@ -12,6 +12,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import itertools as it
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import io
import os
import struct
+7 -4
View File
@@ -1,17 +1,20 @@
#!/usr/bin/env python3
#
# Script to summarize the outputs of other scripts. Operates on CSV files.
# Script to manipulate CSV files.
#
# Example:
# ./scripts/code.py lfs.o lfs_util.o -q -o lfs.code.csv
# ./scripts/data.py lfs.o lfs_util.o -q -o lfs.data.csv
# ./scripts/summary.py lfs.code.csv lfs.data.csv -q -o lfs.csv
# ./scripts/summary.py -Y lfs.csv -f code=code_size,data=data_size
# ./scripts/csv.py lfs.code.csv lfs.data.csv -q -o lfs.csv
# ./scripts/csv.py -Y lfs.csv -f code=code_size,data=data_size
#
# Copyright (c) 2022, The littlefs authors.
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import functools as ft
@@ -739,7 +742,7 @@ if __name__ == "__main__":
import argparse
import sys
parser = argparse.ArgumentParser(
description="Summarize measurements in CSV files.",
description="Script to manipulate CSV files.",
allow_abbrev=False)
parser.add_argument(
'csv_paths',
+3
View File
@@ -12,6 +12,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import difflib
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import os
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import functools as ft
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import itertools as it
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import os
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
ERRS = [
('OK', 0, "No error" ),
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import functools as ft
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import itertools as it
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import itertools as it
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import io
import os
import struct
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import io
import os
import struct
+3
View File
@@ -10,6 +10,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import csv
+3
View File
@@ -11,6 +11,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import collections as co
import csv
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import bisect
import codecs
import collections as co
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import codecs
import collections as co
import csv
+3
View File
@@ -10,6 +10,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import re
import sys
+3
View File
@@ -1,5 +1,8 @@
#!/usr/bin/env python3
# prevent local imports
__import__('sys').path.pop(0)
import subprocess as sp
+3
View File
@@ -10,6 +10,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import itertools as it
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import difflib
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import io
import os
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import os
import io
import time
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import csv
import errno
+3
View File
@@ -9,6 +9,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import functools as ft
import io
+3
View File
@@ -10,6 +10,9 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# prevent local imports
__import__('sys').path.pop(0)
import collections as co
import errno
import fcntl