Skip to content

Commit

Permalink
space
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaM-TL committed Oct 1, 2024
1 parent 3109521 commit fc670c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
21 changes: 7 additions & 14 deletions fotokilof/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"""

import fnmatch
from pathlib import PurePosixPath, PureWindowsPath
import os
import os.path
import re


Expand Down Expand Up @@ -113,22 +115,13 @@ def mouse_crop_calculation(x_orig, y_orig, size):

def spacja(file_path, operating_system):
"""escaping space and special char in pathname"""
if len(file_path) == 0:
result = file_path
else:
file_path = os.path.normpath(file_path)
if len(file_path):
if operating_system == 'Windows':
czy_spacja = re.search(" ", file_path)
if czy_spacja is not None:
file_path = '"' + file_path + '"'
result = PureWindowsPath(os.path.normpath(file_path))
else:
path = os.path.splitext(file_path)
path_splitted = path[0].split("/")
path_escaped = []
for i in path_splitted:
path_escaped.append(re.escape(i))
file_path = "/".join(path_escaped) + path[1]
result = file_path
result = PurePosixPath(os.path.normpath(file_path))
else:
result = None
return result


Expand Down
7 changes: 5 additions & 2 deletions fotokilof/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@
import re
from PIL import Image

import common

if platform.system() == 'Windows':
import win32clipboard
elif platform.system() == 'Darwin':
import subprocess


module_logger = logging.getLogger(__name__)


Expand All @@ -48,7 +51,7 @@ def copy_to_clipboard(file_in, operating_system):
https://stackoverflow.com/questions/54008175/copy-an-image-to-macos-clipboard-using-python?rq=4
debug needed!
"""
image = Image.open(file_in)
image = Image.open(common.spacja(file_in, operating_system))
# Create an in-memory file-like object
image_buffer = BytesIO()
if operating_system == 'Windows':
Expand All @@ -67,7 +70,7 @@ def copy_to_clipboard(file_in, operating_system):
"osascript",
"-e",
'set the clipboard to (read (POSIX file "'
+ file_in
+ common.spacja(file_in, operating_system)
+ '") as JPEG picture)',
]
)
Expand Down

0 comments on commit fc670c7

Please sign in to comment.