|
12 | 12 | $ python bin/ci.py src/data_morph/shapes/bases/line_collection.py |
13 | 13 | high_lines h_lines slant_down slant_up v_lines wide_lines x diamond rectangle star |
14 | 14 |
|
| 15 | +$ python bin/ci.py src/data_morph/shapes/points/heart.py |
| 16 | +heart spade |
| 17 | +
|
15 | 18 | $ python bin/ci.py src/data_morph/data/starter_shapes/superdatascience.csv |
16 | 19 | SDS |
17 | 20 | """ |
18 | | -from data_morph.shapes.factory import ShapeFactory |
19 | | -from data_morph.data.loader import DataLoader |
| 21 | + |
20 | 22 | 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 |
22 | 27 |
|
23 | 28 | new_paths = sys.argv[1:] |
24 | 29 |
|
|
31 | 36 | args.append(dataset) |
32 | 37 |
|
33 | 38 | # 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') |
43 | 50 |
|
| 51 | + all_modules = [f'{x}.py' for x in mro] |
| 52 | + |
| 53 | + for new_file in new_files: |
44 | 54 | for module in all_modules: |
45 | 55 | if module.endswith(new_file): |
46 | 56 | args.append(shape) |
|
0 commit comments