mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #22480 from gr8jam/fix/pattern_tools:undesiarabe_behaviour_on_windows
Save output file to local directory instead of desktop (for windows)
This commit is contained in:
commit
65d66a05dd
@ -34,18 +34,6 @@ try:
|
||||
except NameError:
|
||||
xrange = range # Python 3
|
||||
|
||||
|
||||
if re.search("windows", platform.system(), re.I):
|
||||
try:
|
||||
import _winreg
|
||||
_default_directory = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
|
||||
r"Software\Microsoft\Windows\Current Version\Explorer\Shell Folders"), "Desktop")[0]
|
||||
# tmpdir = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Environment"), "TEMP")[0]
|
||||
# if tmpdir[0:13] != "%USERPROFILE%":
|
||||
# tmpdir = os.path.expanduser("~") + tmpdir[13:]
|
||||
except:
|
||||
_default_directory = os.path.expanduser("~") + os.sep + "Desktop"
|
||||
|
||||
_default_fileName = "tmp.svg"
|
||||
|
||||
_hacks = {}
|
||||
@ -449,12 +437,9 @@ class SVG:
|
||||
|
||||
return output
|
||||
|
||||
def interpret_fileName(self, fileName=None):
|
||||
if fileName is None:
|
||||
fileName = _default_fileName
|
||||
if re.search("windows", platform.system(), re.I) and not os.path.isabs(fileName):
|
||||
fileName = _default_directory + os.sep + fileName
|
||||
return fileName
|
||||
@staticmethod
|
||||
def interpret_fileName(fileName=None):
|
||||
return fileName or _default_fileName
|
||||
|
||||
def save(self, fileName=None, encoding="utf-8", compresslevel=None):
|
||||
"""Save to a file for viewing. Note that svg.save() overwrites the file named _default_fileName.
|
||||
|
Loading…
Reference in New Issue
Block a user