Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jovuit
funkwhale
Commits
8116e733
Commit
8116e733
authored
Jun 05, 2020
by
Ciarán Ainsworth
Committed by
Agate
Jun 05, 2020
Browse files
Fix support for Python 3.5 in import script
parent
79753d77
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/music/management/commands/import_files.py
View file @
8116e733
...
...
@@ -23,21 +23,30 @@ from funkwhale_api.common import utils as common_utils
from
funkwhale_api.music
import
models
,
tasks
,
utils
def
dir_scanner
(
scanner
,
extensions
,
recursive
,
ignored
):
for
entry
in
scanner
:
if
entry
.
is_file
():
for
e
in
extensions
:
if
entry
.
name
.
lower
().
endswith
(
".{}"
.
format
(
e
.
lower
())):
if
entry
.
path
not
in
ignored
:
yield
entry
.
path
elif
recursive
and
entry
.
is_dir
():
yield
from
dir_scanner
(
entry
,
extensions
,
recursive
=
recursive
,
ignored
=
ignored
)
def
crawl_dir
(
dir
,
extensions
,
recursive
=
True
,
ignored
=
[]):
if
os
.
path
.
isfile
(
dir
):
yield
dir
return
with
os
.
scandir
(
dir
)
as
scanner
:
for
entry
in
scanner
:
if
entry
.
is_file
():
for
e
in
extensions
:
if
entry
.
name
.
lower
().
endswith
(
".{}"
.
format
(
e
.
lower
())):
if
entry
.
path
not
in
ignored
:
yield
entry
.
path
elif
recursive
and
entry
.
is_dir
():
yield
from
crawl_dir
(
entry
,
extensions
,
recursive
=
recursive
,
ignored
=
ignored
)
else
:
try
:
scanner
=
os
.
scandir
(
dir
)
yield
from
dir_scanner
(
scanner
,
extensions
,
recursive
,
ignored
)
finally
:
if
hasattr
(
scanner
,
"close"
):
scanner
.
close
()
def
batch
(
iterable
,
n
=
1
):
...
...
changes/changelog.d/1147.bugfix
0 → 100644
View file @
8116e733
Fixed an issue where in-place importing didn't work for directories on machines running Python 3.5 (#1148, #1147)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment