Cédric Krier pushed to branch branch/default at Tryton / Tryton
Commits:
dea9b5c4 by Cédric Krier at 2023-04-08T16:11:36+02:00
Do not slugify file extension when selecting file to save or create folder
Closes #12152
- - - - -
1 changed file:
- tryton/tryton/common/common.py
Changes:
=====================================
tryton/tryton/common/common.py
=====================================
@@ -444,6 +444,5 @@
win = Gtk.FileChooserNative(
title=title, transient_for=parent, action=action)
if filename:
- filename = slugify(filename)
if action in (Gtk.FileChooserAction.SAVE,
Gtk.FileChooserAction.CREATE_FOLDER):
@@ -448,5 +447,6 @@
if action in (Gtk.FileChooserAction.SAVE,
Gtk.FileChooserAction.CREATE_FOLDER):
+ filename = _slugify_filename(filename)
win.set_current_name(filename)
else:
win.set_filename(filename)
@@ -500,7 +500,15 @@
return _slugify_hyphenate_re.sub('-', value)
+def _slugify_filename(filename):
+ if not isinstance(filename, str):
+ name, ext = filename
+ else:
+ name, ext = os.path.splitext(filename)
+ return ''.join([slugify(name), os.extsep, slugify(ext)])
+
+
def file_write(filename, data):
if isinstance(data, str):
data = data.encode('utf-8')
dtemp = tempfile.mkdtemp(prefix='tryton_')
@@ -503,12 +511,8 @@
def file_write(filename, data):
if isinstance(data, str):
data = data.encode('utf-8')
dtemp = tempfile.mkdtemp(prefix='tryton_')
- if not isinstance(filename, str):
- name, ext = filename
- else:
- name, ext = os.path.splitext(filename)
- filename = ''.join([slugify(name), os.extsep, slugify(ext)])
+ filename = _slugify_filename(filename)
filepath = os.path.join(dtemp, filename)
with open(filepath, 'wb') as fp:
fp.write(data)
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/dea9b5c4b8f7e5a163c9115d123a265eb5394957
--
View it on Heptapod:
https://foss.heptapod.net/tryton/tryton/-/commit/dea9b5c4b8f7e5a163c9115d123a265eb5394957
You're receiving this email because of your account on foss.heptapod.net.