From f9fb3ce86e3c6a0c3c33b45392b8d7288bceba76 Mon Sep 17 00:00:00 2001 From: Simon Sawicki Date: Sat, 30 Dec 2023 22:27:36 +0100 Subject: [cleanup] Misc (#8598) Authored by: bashonly, pukkandan, seproDev, Grub4K Co-authored-by: bashonly Co-authored-by: pukkandan Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com> --- yt_dlp/utils/_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'yt_dlp/utils/_utils.py') 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): -- cgit v1.2.3