Visitar URL original
fix unintended adding of video directory to video list. · DeepLabCut/DeepLabCut@654abf9 · GitHub
Skip to content

Commit 654abf9

Browse files
committed
fix unintended adding of video directory to video list.
When providing an empty video directory to `create_new_project`, the empty directory was mistakenly treated as video file for which a symbolic link is created. The current commit fixes this unintended behaviour.
1 parent f96e3c5 commit 654abf9

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

  • deeplabcut/create_project

‎deeplabcut/create_project/new.py‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,37 +146,35 @@ def create_new_project(
146146
print('Created "{}"'.format(p))
147147

148148
# Add all videos in the folder. Multiple folders can be passed in a list, similar to the video files. Folders and video files can also be passed!
149-
vids = []
150-
for i in videos:
149+
collected_videos = []
150+
paths = [Path(p) for p in videos]
151+
for i in paths:
151152
# Check if it is a folder
152-
if os.path.isdir(i):
153+
if i.is_dir():
153154
vids_in_dir = [
154-
os.path.join(i, vp)
155-
for vp in os.listdir(i)
156-
if vp.lower().endswith(videotype)
155+
p for p in i.iterdir()
156+
if str(p).lower().endswith(videotype)
157157
]
158-
vids = vids + vids_in_dir
159158
if len(vids_in_dir) == 0:
160159
print("No videos found in", i)
161160
print(
162161
"Perhaps change the videotype, which is currently set to:",
163162
videotype,
164163
)
165164
else:
166-
videos = vids
165+
collected_videos += vids_in_dir
167166
print(
168167
len(vids_in_dir),
169168
" videos from the directory",
170169
i,
171170
"were added to the project.",
172171
)
173172
else:
174-
if os.path.isfile(i):
175-
vids = vids + [i]
176-
videos = vids
173+
if i.is_file():
174+
collected_videos.append(i)
177175

178-
videos = [Path(vp) for vp in videos]
179-
dirs = [data_path / Path(i.stem) for i in videos]
176+
videos = collected_videos
177+
dirs = [data_path / i.stem for i in videos]
180178
for p in dirs:
181179
"""
182180
Creates directory under data

0 commit comments

Comments
 (0)