Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9fef3a

Browse files
committed
Move check for ImageMagick Windows path to bin_path().
That's a perfectly reasonable place to put the registry check and avoidsintroducing an additional private helper method.
1 parent7bcf618 commitb9fef3a

File tree

1 file changed

+24
-36
lines changed

1 file changed

+24
-36
lines changed

‎lib/matplotlib/animation.py

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -724,42 +724,30 @@ def output_args(self):
724724
return [self.outfile]
725725

726726
@classmethod
727-
def_init_from_registry(cls):
728-
ifsys.platform!='win32'orrcParams[cls.exec_key]!='convert':
729-
return
730-
importwinreg
731-
forflagin (0,winreg.KEY_WOW64_32KEY,winreg.KEY_WOW64_64KEY):
732-
try:
733-
hkey=winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
734-
r'Software\Imagemagick\Current',
735-
0,winreg.KEY_QUERY_VALUE|flag)
736-
binpath=winreg.QueryValueEx(hkey,'BinPath')[0]
737-
winreg.CloseKey(hkey)
738-
break
739-
exceptException:
740-
binpath=''
741-
ifbinpath:
742-
forexein ('convert.exe','magick.exe'):
743-
path=os.path.join(binpath,exe)
744-
ifos.path.exists(path):
745-
binpath=path
746-
break
747-
else:
748-
binpath=''
749-
rcParams[cls.exec_key]=rcParamsDefault[cls.exec_key]=binpath
750-
751-
@classmethod
752-
defisAvailable(cls):
753-
'''
754-
Check to see if a ImageMagickWriter is actually available.
755-
756-
Done by first checking the windows registry (if applicable) and then
757-
running the commandline tool.
758-
'''
759-
bin_path=cls.bin_path()
760-
ifbin_path=="convert":
761-
cls._init_from_registry()
762-
returnsuper().isAvailable()
727+
defbin_path(cls):
728+
binpath=super().bin_path()
729+
ifsys.platform=='win32'andbinpath=='convert':
730+
# Check the registry to avoid confusing ImageMagick's convert with
731+
# Windows's builtin convert.exe.
732+
importwinreg
733+
binpath=''
734+
forflagin (0,winreg.KEY_WOW64_32KEY,winreg.KEY_WOW64_64KEY):
735+
try:
736+
withwinreg.OpenKeyEx(
737+
winreg.HKEY_LOCAL_MACHINE,
738+
r'Software\Imagemagick\Current',
739+
0,winreg.KEY_QUERY_VALUE|flag)ashkey:
740+
parent=winreg.QueryValueEx(hkey,'BinPath')[0]
741+
exceptOSError:
742+
pass
743+
ifbinpath:
744+
forexein ('convert.exe','magick.exe'):
745+
candidate=os.path.join(parent,exe)
746+
ifos.path.exists(candidate):
747+
binpath=candidate
748+
break
749+
rcParams[cls.exec_key]=rcParamsDefault[cls.exec_key]=binpath
750+
returnbinpath
763751

764752

765753
# Note: the base classes need to be in that order to get

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp