Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
0bc4f527
Commit
0bc4f527
authored
Mar 06, 2017
by
林檎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix except clause
except: will catch specific error.
parent
cf4816fc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
11 deletions
+12
-11
epub.py
cps/epub.py
+2
-2
fb2.py
cps/fb2.py
+2
-2
helper.py
cps/helper.py
+7
-6
web.py
cps/web.py
+1
-1
No files found.
cps/epub.py
View file @
0bc4f527
...
@@ -44,7 +44,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
...
@@ -44,7 +44,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
try
:
#maybe description isn't present
try
:
#maybe description isn't present
comments
=
tree
.
xpath
(
"//*[local-name() = 'description']/text()"
)[
0
]
comments
=
tree
.
xpath
(
"//*[local-name() = 'description']/text()"
)[
0
]
epub_metadata
[
'comments'
]
=
comments
epub_metadata
[
'comments'
]
=
comments
except
:
except
IndexError
as
e
:
epub_metadata
[
'comments'
]
=
""
epub_metadata
[
'comments'
]
=
""
for
s
in
[
'title'
,
'description'
,
'creator'
]:
for
s
in
[
'title'
,
'description'
,
'creator'
]:
...
@@ -64,7 +64,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
...
@@ -64,7 +64,7 @@ def get_epub_info(tmp_file_path, original_file_name, original_file_extension):
epub_metadata
[
'languages'
]
=
isoLanguages
.
get
(
part3
=
lang
)
.
name
epub_metadata
[
'languages'
]
=
isoLanguages
.
get
(
part3
=
lang
)
.
name
else
:
else
:
epub_metadata
[
'languages'
]
=
""
epub_metadata
[
'languages'
]
=
""
except
:
except
IndexError
as
e
:
epub_metadata
[
'languages'
]
=
""
epub_metadata
[
'languages'
]
=
""
coversection
=
tree
.
xpath
(
"/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href"
,
namespaces
=
ns
)
coversection
=
tree
.
xpath
(
"/pkg:package/pkg:manifest/pkg:item[@id='cover-image']/@href"
,
namespaces
=
ns
)
...
...
cps/fb2.py
View file @
0bc4f527
...
@@ -5,9 +5,9 @@ from lxml import etree
...
@@ -5,9 +5,9 @@ from lxml import etree
import
os
import
os
import
uploader
import
uploader
try
:
try
:
import
StringIO
except
:
from
io
import
StringIO
from
io
import
StringIO
except
ImportError
as
e
:
import
StringIO
def
get_fb2_info
(
tmp_file_path
,
original_file_extension
):
def
get_fb2_info
(
tmp_file_path
,
original_file_extension
):
...
...
cps/helper.py
View file @
0bc4f527
...
@@ -14,15 +14,15 @@ import traceback
...
@@ -14,15 +14,15 @@ import traceback
import
re
import
re
import
unicodedata
import
unicodedata
try
:
try
:
from
StringIO
import
StringIO
from
email.MIMEBase
import
MIMEBase
from
email.MIMEMultipart
import
MIMEMultipart
from
email.MIMEText
import
MIMEText
except
ImportError
:
from
io
import
StringIO
from
io
import
StringIO
from
email.mime.base
import
MIMEBase
from
email.mime.base
import
MIMEBase
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.multipart
import
MIMEMultipart
from
email.mime.text
import
MIMEText
from
email.mime.text
import
MIMEText
except
ImportError
as
e
:
from
StringIO
import
StringIO
from
email.MIMEBase
import
MIMEBase
from
email.MIMEMultipart
import
MIMEMultipart
from
email.MIMEText
import
MIMEText
from
email
import
encoders
from
email
import
encoders
from
email.generator
import
Generator
from
email.generator
import
Generator
from
email.utils
import
formatdate
from
email.utils
import
formatdate
...
@@ -247,8 +247,9 @@ def get_valid_filename(value, replace_whitespace=True):
...
@@ -247,8 +247,9 @@ def get_valid_filename(value, replace_whitespace=True):
re_slugify
=
re
.
compile
(
'[
\
W
\
s-]'
,
re
.
UNICODE
)
re_slugify
=
re
.
compile
(
'[
\
W
\
s-]'
,
re
.
UNICODE
)
try
:
try
:
value
=
str
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
value
=
str
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
except
:
#will exception on Python2.7
except
UnicodeEncodeError
as
e
:
#will exception on Python2.7
value
=
unicode
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
value
=
unicode
(
re_slugify
.
sub
(
''
,
value
)
.
strip
())
raise
if
replace_whitespace
:
if
replace_whitespace
:
#*+:\"/<>? werden durch _ ersetzt
#*+:\"/<>? werden durch _ ersetzt
value
=
re
.
sub
(
'[
\
*
\
+:
\\\"
/<>
\
?]+'
,
u'_'
,
value
,
flags
=
re
.
U
)
value
=
re
.
sub
(
'[
\
*
\
+:
\\\"
/<>
\
?]+'
,
u'_'
,
value
,
flags
=
re
.
U
)
...
...
cps/web.py
View file @
0bc4f527
...
@@ -53,7 +53,7 @@ try:
...
@@ -53,7 +53,7 @@ try:
from
urllib.parse
import
quote
from
urllib.parse
import
quote
from
imp
import
reload
from
imp
import
reload
from
past.builtins
import
xrange
from
past.builtins
import
xrange
except
:
except
ImportError
as
e
:
from
urllib
import
quote
from
urllib
import
quote
try
:
try
:
...
...
Write
Preview
Markdown
is supported
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