Skip to content

Commit eca5a32

Browse files
committed
Lint and refactor bin/ci.py
1 parent 5d2a1d5 commit eca5a32

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

bin/ci.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@
1212
$ python bin/ci.py src/data_morph/shapes/bases/line_collection.py
1313
high_lines h_lines slant_down slant_up v_lines wide_lines x diamond rectangle star
1414
15+
$ python bin/ci.py src/data_morph/shapes/points/heart.py
16+
heart spade
17+
1518
$ python bin/ci.py src/data_morph/data/starter_shapes/superdatascience.csv
1619
SDS
1720
"""
18-
from data_morph.shapes.factory import ShapeFactory
19-
from data_morph.data.loader import DataLoader
21+
2022
import sys
21-
from os.path import basename
23+
from pathlib import Path
24+
25+
from data_morph.data.loader import DataLoader
26+
from data_morph.shapes.factory import ShapeFactory
2227

2328
new_paths = sys.argv[1:]
2429

@@ -31,16 +36,21 @@
3136
args.append(dataset)
3237

3338
# Figure out argument of shapes based on .py filename
34-
new_files = [basename(x).split('/')[-1] for x in new_paths]
35-
for shape, c in ShapeFactory._SHAPE_MAPPING.items():
36-
for new_file in new_files:
37-
# Find the class and all parent classes and get their module name
38-
# We get the module name because it ends in the python file without .py extension
39-
# To make it easy to compare, we just add the extension onto the end
40-
parents = [x.__module__ for x in c.__mro__]
41-
all_modules = parents + [c.__module__]
42-
all_modules = [f'{x}.py' for x in all_modules]
39+
new_files = [Path(x).name for x in new_paths]
40+
for shape, shape_cls in ShapeFactory._SHAPE_MAPPING.items():
41+
# Find the class and all parent classes and get their module name
42+
# We get the module name because it ends in the python file without .py extension
43+
# To make it easy to compare, we just add the extension onto the end
44+
mro = [
45+
x.__module__ for x in shape_cls.__mro__ if x.__module__.startswith('data_morph')
46+
]
47+
48+
if shape == 'spade':
49+
mro.append('heart')
4350

51+
all_modules = [f'{x}.py' for x in mro]
52+
53+
for new_file in new_files:
4454
for module in all_modules:
4555
if module.endswith(new_file):
4656
args.append(shape)

0 commit comments

Comments
 (0)