Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
0x43
eBookHub-backend
Commits
06bcb034
Verified
Commit
06bcb034
authored
Mar 15, 2019
by
Patrick van der Leer
Browse files
temp fix for blackhole crap
parent
54978156
Pipeline
#293
passed with stage
in 5 minutes and 9 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
eBookHub/jobs/blackhole.py
View file @
06bcb034
...
...
@@ -114,27 +114,34 @@ def save_book_edition_file(base_path, filename, result):
def
handle
(
base_path
,
full_path
):
"""
:param base_path:
:param full_path:
:return: saved, new, book
:rtype: tuple(bool, bool, Book)
"""
from
eBookHub.models
import
BookEditionFile
if
BookEditionFile
.
is_known_files
(
full_path
):
return
Tru
e
,
BookEditionFile
.
lookup_by_checksum
(
full_path
).
first
()
return
False
,
Fals
e
,
BookEditionFile
.
lookup_by_checksum
(
full_path
).
first
()
filename
=
full_path
.
replace
(
base_path
,
""
,
1
).
lstrip
(
"/"
)
resultset
=
process_file
(
filename
)
if
not
resultset
or
len
(
resultset
)
<
0
:
# enter as no f'ing clue
return
False
,
None
return
False
,
False
,
None
if
len
(
resultset
)
==
1
:
return
True
,
save_book_edition_file
(
base_path
,
filename
,
resultset
[
0
])
return
True
,
True
,
save_book_edition_file
(
base_path
,
filename
,
resultset
[
0
])
return
True
,
save_book_edition_file
(
base_path
,
filename
,
resultset
)
return
True
,
True
,
save_book_edition_file
(
base_path
,
filename
,
resultset
)
def
process_blackhole
(
blackhole_path
):
for
file
in
glob
.
iglob
(
'{}/*'
.
format
(
blackhole_path
),
recursive
=
True
):
saved
,
book_edition_file
=
handle
(
blackhole_path
,
file
)
if
saved
:
saved
,
new
,
book_edition_file
=
handle
(
blackhole_path
,
file
)
if
saved
and
new
:
from
eBookHub.models
import
BookEditionFile
assert
isinstance
(
book_edition_file
,
BookEditionFile
)
if
book_edition_file
.
book_edition
is
None
:
...
...
eBookHub/managers/parser.py
View file @
06bcb034
...
...
@@ -14,10 +14,4 @@ def blackhole(path=None): # pragma: no cover
path
=
app
.
config
[
'BLACKHOLE_PATH'
]
for
saved
,
book_edition_file
,
filename
in
process_blackhole
(
path
):
cleaned_fn
=
filename
.
replace
(
path
,
""
,
1
).
lstrip
(
"/"
)
if
saved
:
if
book_edition_file
.
book_edition
is
None
:
print
(
"TEMP SAVED: {}"
.
format
(
cleaned_fn
))
else
:
print
(
"SAVED: {}"
.
format
(
cleaned_fn
))
else
:
print
(
"No clue what this is: {}"
.
format
(
cleaned_fn
))
print
(
"Processed {}"
.
format
(
cleaned_fn
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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