mirror of
https://github.com/gryf/slack-backup.git
synced 2025-12-17 11:30:25 +01:00
Use pathlib for providing uri
This commit is contained in:
@@ -8,6 +8,7 @@ import os
|
|||||||
import errno
|
import errno
|
||||||
import html.parser
|
import html.parser
|
||||||
import logging
|
import logging
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from slack_backup import objects as o
|
from slack_backup import objects as o
|
||||||
@@ -227,8 +228,9 @@ class TextReporter(Reporter):
|
|||||||
else:
|
else:
|
||||||
fpath = 'does_not_exists'
|
fpath = 'does_not_exists'
|
||||||
|
|
||||||
return {'msg': self.url_pat.sub('(file://' + fpath + ') ' +
|
return {'msg': self.url_pat.sub('(' +
|
||||||
msg.file.title, msg.text),
|
pathlib.PurePath(fpath).as_uri() +
|
||||||
|
') ' + msg.file.title, msg.text),
|
||||||
'nick': self._get_symbol('file')}
|
'nick': self._get_symbol('file')}
|
||||||
|
|
||||||
def _msg(self, msg):
|
def _msg(self, msg):
|
||||||
@@ -383,11 +385,11 @@ class StaticHtmlReporter(Reporter):
|
|||||||
|
|
||||||
_, ext = os.path.splitext(fpath)
|
_, ext = os.path.splitext(fpath)
|
||||||
if ext.lower() in ('.png', '.jpg', '.jpeg', '.gif'):
|
if ext.lower() in ('.png', '.jpg', '.jpeg', '.gif'):
|
||||||
url = ('<img src="file://' + fpath +
|
url = ('<img src="' + pathlib.PurePath(fpath).as_uri() +
|
||||||
'" height="300" alt="' + msg.file.title +
|
'" height="300" alt="' + msg.file.title + '">')
|
||||||
'">')
|
|
||||||
else:
|
else:
|
||||||
url = ('<a href="file://' + fpath + '">' + msg.file.title + '</a>')
|
url = ('<a href="' + pathlib.PurePath(fpath).as_uri() +
|
||||||
|
'">' + msg.file.title + '</a>')
|
||||||
|
|
||||||
return {'msg': self.url_pat.sub(url, msg.text),
|
return {'msg': self.url_pat.sub(url, msg.text),
|
||||||
'nick': self._get_symbol('file')}
|
'nick': self._get_symbol('file')}
|
||||||
|
|||||||
Reference in New Issue
Block a user