Merge branch 'release' into pillow

This commit is contained in:
2023-10-15 17:57:56 +03:00
103 changed files with 4724 additions and 1677 deletions

View File

@@ -20,6 +20,7 @@ class MetaUtils(LionCog):
'cmd:page|desc',
"Jump to a given page of the ouput of a previous command in this channel."
),
with_app_command=False
)
async def page_group(self, ctx: LionContext):
"""

View File

@@ -765,7 +765,7 @@ class Timezoned:
Return the start of the current month in the object's timezone
"""
today = self.today
return today - datetime.timedelta(days=(today.day - 1))
return today.replace(day=1)
def replace_multiple(format_string, mapping):

View File

@@ -32,7 +32,7 @@ class TaskMonitor(Generic[Taskid]):
self.executor: Optional[Callable[[Taskid], Coroutine[Any, Any, None]]] = executor
self._wakeup: asyncio.Event = asyncio.Event()
self._monitor_task: Optional[self.Task] = None
self._monitor_task: Optional[asyncio.Task] = None
# Task data
self._tasklist: list[Taskid] = []
@@ -42,6 +42,19 @@ class TaskMonitor(Generic[Taskid]):
# And allows simpler external cancellation if required
self._running: dict[Taskid, asyncio.Future] = {}
def __repr__(self):
return (
"<"
f"{self.__class__.__name__}"
f" tasklist={len(self._tasklist)}"
f" taskmap={len(self._taskmap)}"
f" wakeup={self._wakeup.is_set()}"
f" bucket={self._bucket}"
f" running={len(self._running)}"
f" task={self._monitor_task}"
f">"
)
def set_tasks(self, *tasks: tuple[Taskid, int]) -> None:
"""
Similar to `schedule_tasks`, but wipe and reset the tasklist.

View File

@@ -69,12 +69,12 @@ class DurationTransformer(Transformer):
name=t(_p(
'util:Duration|acmpl|error',
"Cannot extract duration from \"{partial}\""
)).format(partial=partial),
)).format(partial=partial)[:100],
value=partial
)
else:
choice = appcmds.Choice(
name=strfdur(duration, short=False, show_days=True),
name=strfdur(duration, short=False, show_days=True)[:100],
value=partial
)
return [choice]

View File

@@ -108,6 +108,9 @@ class ConfigUI(LeoUI):
# Filter out settings which don't have input fields
items = [item for item in items if item][:5]
strings = [item.value for item in items]
if not items:
raise ValueError("Cannot make Config edit modal with no editable instances.")
modal = ConfigEditor(*items, title=t(self.edit_modal_title))
@modal.submit_callback()

View File

@@ -307,17 +307,17 @@ class Pager(BasePager):
"Current: Page {page}/{total}"
)).format(page=num+1, total=total)
choices = [
appcmds.Choice(name=string, value=str(num+1))
appcmds.Choice(name=string[:100], value=str(num+1))
for num, string in sorted(page_choices.items(), key=lambda t: t[0])
]
else:
# Particularly support page names here
choices = [
appcmds.Choice(
name='> ' * (i == num) + t(_p(
name=('> ' * (i == num) + t(_p(
'cmd:page|acmpl|pager:Pager|choice:general',
"Page {page}"
)).format(page=i+1),
)).format(page=i+1))[:100],
value=str(i+1)
)
for i in range(0, total)
@@ -351,7 +351,7 @@ class Pager(BasePager):
name=t(_p(
'cmd:page|acmpl|pager:Page|choice:select',
"Selected: Page {page}/{total}"
)).format(page=page_num+1, total=total),
)).format(page=page_num+1, total=total)[:100],
value=str(page_num + 1)
)
return [choice, *choices]
@@ -361,7 +361,7 @@ class Pager(BasePager):
name=t(_p(
'cmd:page|acmpl|pager:Page|error:parse',
"No matching pages!"
)).format(page=page_num, total=total),
)).format(page=page_num, total=total)[:100],
value=partial
)
]