diff options
author | Simon Sawicki <contact@grub4k.xyz> | 2023-12-30 22:27:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-30 22:27:36 +0100 |
commit | f9fb3ce86e3c6a0c3c33b45392b8d7288bceba76 (patch) | |
tree | 4238cec16764841f1c61b4d8860b87615dfedd6b /yt_dlp/utils/_utils.py | |
parent | 5f009a094f0e8450792b097c4c8273622778052d (diff) |
[cleanup] Misc (#8598)
Authored by: bashonly, pukkandan, seproDev, Grub4K
Co-authored-by: bashonly <bashonly@protonmail.com>
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
Diffstat (limited to 'yt_dlp/utils/_utils.py')
-rw-r--r-- | yt_dlp/utils/_utils.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py index 361617c02..89a0d4cff 100644 --- a/yt_dlp/utils/_utils.py +++ b/yt_dlp/utils/_utils.py @@ -558,7 +558,7 @@ class LenientJSONDecoder(json.JSONDecoder): s = self._close_object(e) if s is not None: continue - raise type(e)(f'{e.msg} in {s[e.pos-10:e.pos+10]!r}', s, e.pos) + raise type(e)(f'{e.msg} in {s[e.pos - 10:e.pos + 10]!r}', s, e.pos) assert False, 'Too many attempts to decode JSON' @@ -1885,6 +1885,7 @@ def setproctitle(title): buf = ctypes.create_string_buffer(len(title_bytes)) buf.value = title_bytes try: + # PR_SET_NAME = 15 Ref: /usr/include/linux/prctl.h libc.prctl(15, buf, 0, 0, 0) except AttributeError: return # Strange libc, just skip this @@ -2260,6 +2261,9 @@ class PagedList: raise self.IndexError() return entries[0] + def __bool__(self): + return bool(self.getslice(0, 1)) + class OnDemandPagedList(PagedList): """Download pages until a page with less than maximum results""" @@ -5070,7 +5074,7 @@ def truncate_string(s, left, right=0): assert left > 3 and right >= 0 if s is None or len(s) <= left + right: return s - return f'{s[:left-3]}...{s[-right:] if right else ""}' + return f'{s[:left - 3]}...{s[-right:] if right else ""}' def orderedSet_from_options(options, alias_dict, *, use_regex=False, start=None): |