-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TextClip.list("color") returning an incorrect list of byte object…
…s, not strings (#1119) * Fix TextClip.list("color") returning an incorrect list of byte objects, not strings, causing TextClip.find("", "color") to fail as well.
- Loading branch information
1 parent
7353216
commit 4106b4c
Showing
3 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1269,8 +1269,8 @@ def __init__( | |
|
||
@staticmethod | ||
def list(arg): | ||
"""Returns the list of all valid entries for the argument of | ||
``TextClip`` given (can be ``font``, ``color``, etc...) """ | ||
"""Returns a list of all valid entries for the ``font`` or ``color`` argument of | ||
``TextClip``""" | ||
|
||
popen_params = {"stdout": sp.PIPE, "stderr": sp.DEVNULL, "stdin": sp.DEVNULL} | ||
|
||
|
@@ -1280,23 +1280,23 @@ def list(arg): | |
process = sp.Popen( | ||
[get_setting("IMAGEMAGICK_BINARY"), "-list", arg], **popen_params | ||
) | ||
result = process.communicate()[0] | ||
result = process.communicate()[0].decode() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
lines = result.splitlines() | ||
|
||
if arg == "font": | ||
return [l.decode("UTF-8")[8:] for l in lines if l.startswith(b" Font:")] | ||
return [l[8:] for l in lines if l.startswith(" Font:")] | ||
elif arg == "color": | ||
return [l.split(b" ")[0] for l in lines[2:]] | ||
return [l.split(" ")[0] for l in lines[5:]] | ||
This comment has been minimized.
Sorry, something went wrong.
mgaitan
Collaborator
|
||
else: | ||
raise Exception("Moviepy:Error! Argument must equal " "'font' or 'color'") | ||
raise Exception("Moviepy Error: Argument must equal 'font' or 'color'") | ||
|
||
@staticmethod | ||
def search(string, arg): | ||
"""Returns the of all valid entries which contain ``string`` for the | ||
argument ``arg`` of ``TextClip``, for instance | ||
>>> # Find all the available fonts which contain "Courier" | ||
>>> print ( TextClip.search('Courier', 'font') ) | ||
>>> print(TextClip.search('Courier', 'font')) | ||
""" | ||
string = string.lower() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
would be better to pass
encoding="utf8"
in thepopen_params