Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim-plugins
Commits
8061974c
Commit
8061974c
authored
May 07, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[preview] Use if/then instead of multiple if conditions
parent
9c917844
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
30 deletions
+29
-30
url_image_preview/url_image_preview.py
url_image_preview/url_image_preview.py
+29
-30
No files found.
url_image_preview/url_image_preview.py
View file @
8061974c
...
...
@@ -198,35 +198,6 @@ class Base(object):
*
[(
ttt
.
lookup
(
t
)
if
isinstance
(
t
,
str
)
else
t
)
for
t
in
[
"url"
]])
repl_end
=
buffer_
.
create_mark
(
None
,
iter_
,
True
)
if
not
real_text
.
startswith
(
'geo:'
):
weburl
=
real_text
filename
=
os
.
path
.
basename
(
urlparts
.
path
)
ext
=
os
.
path
.
splitext
(
filename
)[
1
]
name
=
os
.
path
.
splitext
(
filename
)[
0
]
namehash
=
hashlib
.
sha1
(
real_text
.
encode
(
'utf-8'
)).
hexdigest
()
newfilename
=
name
+
'_'
+
namehash
+
ext
thumbfilename
=
name
+
'_'
+
namehash
+
'_thumb_'
\
+
str
(
self
.
plugin
.
config
[
'PREVIEW_SIZE'
])
+
ext
filepath
=
os
.
path
.
join
(
self
.
directory
,
newfilename
)
thumbpath
=
os
.
path
.
join
(
self
.
thumbpath
,
thumbfilename
)
filepaths
=
[
filepath
,
thumbpath
]
key
=
''
iv
=
''
encrypted
=
False
if
urlparts
.
fragment
:
fragment
=
binascii
.
unhexlify
(
urlparts
.
fragment
)
key
=
fragment
[
16
:]
iv
=
fragment
[:
16
]
if
len
(
key
)
==
32
and
len
(
iv
)
==
16
:
encrypted
=
True
if
not
encrypted
:
key
=
fragment
[
12
:]
iv
=
fragment
[:
12
]
if
len
(
key
)
==
32
and
len
(
iv
)
==
12
:
encrypted
=
True
# Handle geo:-URIs
if
real_text
.
startswith
(
'geo:'
):
if
self
.
plugin
.
config
[
'GEO_PREVIEW_PROVIDER'
]
==
'no_preview'
:
...
...
@@ -270,11 +241,39 @@ class Base(object):
'getmap?key={}¢er={}&zoom={}&size={},{}&type=map'
\
'&imagetype=png&pois={},{}&scalebar=false'
\
.
format
(
apikey
,
location
,
zoom
,
size
,
size
,
color
,
location
)
location
)
weburl
=
'http://www.openstreetmap.org/'
\
'?mlat={}&mlon={}#map={}/{}/{}&layers=N'
\
.
format
(
lat
,
lon
,
zoom
,
lat
,
lon
)
real_text
=
url
else
:
weburl
=
real_text
filename
=
os
.
path
.
basename
(
urlparts
.
path
)
ext
=
os
.
path
.
splitext
(
filename
)[
1
]
name
=
os
.
path
.
splitext
(
filename
)[
0
]
namehash
=
hashlib
.
sha1
(
real_text
.
encode
(
'utf-8'
)).
hexdigest
()
newfilename
=
name
+
'_'
+
namehash
+
ext
thumbfilename
=
name
+
'_'
+
namehash
+
'_thumb_'
\
+
str
(
self
.
plugin
.
config
[
'PREVIEW_SIZE'
])
+
ext
filepath
=
os
.
path
.
join
(
self
.
directory
,
newfilename
)
thumbpath
=
os
.
path
.
join
(
self
.
thumbpath
,
thumbfilename
)
filepaths
=
[
filepath
,
thumbpath
]
key
=
''
iv
=
''
encrypted
=
False
if
urlparts
.
fragment
:
fragment
=
binascii
.
unhexlify
(
urlparts
.
fragment
)
key
=
fragment
[
16
:]
iv
=
fragment
[:
16
]
if
len
(
key
)
==
32
and
len
(
iv
)
==
16
:
encrypted
=
True
if
not
encrypted
:
key
=
fragment
[
12
:]
iv
=
fragment
[:
12
]
if
len
(
key
)
==
32
and
len
(
iv
)
==
12
:
encrypted
=
True
# file exists but thumbnail got deleted
if
os
.
path
.
exists
(
filepath
)
and
not
os
.
path
.
exists
(
thumbpath
):
...
...
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