|
24 | 24 | from niworkflows.utils.misc import check_valid_fs_license |
25 | 25 |
|
26 | 26 | from petutils.petutils import collect_anat_and_pet |
| 27 | +from importlib.metadata import version |
27 | 28 |
|
28 | 29 |
|
29 | 30 | try: |
|
42 | 43 | pathlib.Path(__file__).parent.parent.absolute(), |
43 | 44 | ] |
44 | 45 |
|
45 | | -__version__ = "unable to locate version number in pyproject.toml" |
| 46 | +__version__ = "unable to locate version number" |
46 | 47 | # we use the default version at the time of this writing, but the most current version |
47 | 48 | # can be found in the pyproject.toml file under the [tool.bids] section |
48 | 49 | __bids_version__ = "1.8.0" |
49 | 50 |
|
50 | 51 |
|
51 | | -# search for toml file |
52 | | -for place in places_to_look: |
53 | | - for root, folders, files in os.walk(place): |
54 | | - for file in files: |
55 | | - if file.endswith("pyproject.toml") and "petdeface" in os.path.join( |
56 | | - root, file |
57 | | - ): |
58 | | - toml_file = os.path.join(root, file) |
59 | | - |
60 | | - with open(toml_file, "r") as f: |
61 | | - for line in f.readlines(): |
62 | | - if ( |
63 | | - "version" in line |
64 | | - and len(line.split("=")) > 1 |
65 | | - and "bids_version" not in line |
66 | | - ): |
67 | | - __version__ = line.split("=")[1].strip().replace('"', "") |
68 | | - if "bids_version" in line and len(line.split("=")) > 1: |
69 | | - __bids_version__ = ( |
70 | | - line.split("=")[1].strip().replace('"', "") |
71 | | - ) |
72 | | - # if the version number is found and is formatted with major.minor.patch formating we can break |
73 | | - # we check the version with a regex expression to see if all of the parts are there |
74 | | - if re.match(r"\d+\.\d+\.\d+", __version__): |
75 | | - break |
76 | | - |
77 | | - if __version__ != "unable to locate version number in pyproject.toml": |
78 | | - # we try to load the version using import lib |
79 | | - __version__ = importlib.metadata.version("petdeface") |
80 | | - if re.match(r"\d+\.\d+\.\d+", __version__): |
81 | | - break |
| 52 | +if __version__ == "unable to locate version number": |
| 53 | + # we try to load the version using import lib |
| 54 | + __version__ = version(__package__) |
82 | 55 |
|
83 | 56 |
|
84 | 57 | def locate_freesurfer_license(): |
@@ -257,7 +230,9 @@ def deface(args: Union[dict, argparse.Namespace]) -> None: |
257 | 230 | subject.replace("sub-", "") for subject in args.participant_label_exclude |
258 | 231 | ] |
259 | 232 | subjects = [ |
260 | | - subject for subject in subjects if subject not in args.participant_label_exclude |
| 233 | + subject |
| 234 | + for subject in subjects |
| 235 | + if subject not in args.participant_label_exclude |
261 | 236 | ] |
262 | 237 |
|
263 | 238 | print(f"Subjects remaining in the defacing workflow: {subjects}") |
|
0 commit comments