Download:
0:348ebdb8777c default tip
Anton Shestakov <engored@ya.ru>, Sat, 17 Mar 2018 12:18:25 +0000
(none)

1 файлов изменено, 18 вставок(+), 0 удалений(-) [+]
path2url.py file | annotate | diff | comparison | revisions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/path2url.py Sat Mar 17 12:18:25 2018 +0000
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+from argparse import ArgumentParser
+from os.path import abspath
+from urllib.parse import quote, urlunsplit
+
+
+def tourl(path):
+ """ Make path absolute and turn it into file: URL.
+ Useful for creating thumbnails (following freedesktop.org spec).
+ """
+ return urlunsplit(('file', '', quote(abspath(path)), '', ''))
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument('path', help='file path')
+ args = parser.parse_args()
+ print(tourl(args.path))