dronefly-core 0.5.0.dev0__tar.gz → 0.5.0.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/PKG-INFO +2 -2
  2. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/clients/inat.py +20 -1
  3. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/commands/__init__.py +138 -56
  4. dronefly_core-0.5.0.dev1/dronefly/core/controllers/inat/__init__.py +1 -0
  5. dronefly_core-0.5.0.dev1/dronefly/core/controllers/inat/user_controller.py +33 -0
  6. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/formatters/generic.py +159 -20
  7. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/menus/__init__.py +1 -0
  8. dronefly_core-0.5.0.dev1/dronefly/core/menus/count.py +65 -0
  9. dronefly_core-0.5.0.dev1/dronefly/core/menus/counts.py +146 -0
  10. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/menus/menu.py +3 -2
  11. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/menus/taxon.py +32 -5
  12. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/menus/taxon_list.py +8 -4
  13. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/models/__init__.py +1 -1
  14. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/models/base_formatters.py +5 -5
  15. dronefly_core-0.5.0.dev1/dronefly/core/models/config.py +65 -0
  16. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/models/context.py +3 -0
  17. dronefly_core-0.5.0.dev1/dronefly/core/models/place_count.py +38 -0
  18. dronefly_core-0.5.0.dev1/dronefly/core/paginator.py +19 -0
  19. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/parsers/constants.py +4 -0
  20. dronefly_core-0.5.0.dev1/dronefly/core/query/formatters.py +94 -0
  21. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/query/query.py +311 -38
  22. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/pyproject.toml +3 -3
  23. dronefly_core-0.5.0.dev0/dronefly/core/models/config.py +0 -58
  24. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/LICENSE +0 -0
  25. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/README.md +0 -0
  26. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/__init__.py +0 -0
  27. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/clients/__init__.py +0 -0
  28. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/constants.py +0 -0
  29. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/formatters/__init__.py +0 -0
  30. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/formatters/constants.py +0 -0
  31. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/menus/source.py +0 -0
  32. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/models/controlled_terms.py +0 -0
  33. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/models/taxon_list.py +0 -0
  34. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/models/user.py +0 -0
  35. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/parsers/__init__.py +0 -0
  36. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/parsers/natural.py +0 -0
  37. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/parsers/unixlike.py +0 -0
  38. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/parsers/url.py +0 -0
  39. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/query/__init__.py +0 -0
  40. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/query/base.py +0 -0
  41. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/query/taxon.py +0 -0
  42. {dronefly_core-0.5.0.dev0 → dronefly_core-0.5.0.dev1}/dronefly/core/utils/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dronefly-core
3
- Version: 0.5.0.dev0
3
+ Version: 0.5.0.dev1
4
4
  Summary: Core dronefly components
5
5
  License: AGPL-3.0-or-later
6
6
  Author: Ben Armstrong
@@ -14,7 +14,7 @@ Requires-Dist: dateparser (>=1.1.1,<2.0.0)
14
14
  Requires-Dist: filelock (>=3.13.3,<4.0.0)
15
15
  Requires-Dist: html2markdown (>=0.1.7,<0.2.0)
16
16
  Requires-Dist: inflect (>=5.3.0,<6.0.0)
17
- Requires-Dist: pyinaturalist (>=0.20.0,<0.21.0)
17
+ Requires-Dist: pyinaturalist (>=0.20.2,<0.21.0)
18
18
  Requires-Dist: rich (>=13.4)
19
19
  Description-Content-Type: text/markdown
20
20
 
@@ -3,7 +3,7 @@ import asyncio
3
3
  from contextlib import contextmanager
4
4
  from functools import partial
5
5
  from inspect import signature
6
- from typing import Optional
6
+ from typing import Callable, Optional, Type
7
7
 
8
8
  from pyinaturalist import (
9
9
  ClientSession,
@@ -11,8 +11,11 @@ from pyinaturalist import (
11
11
  iNatClient as pyiNatClient,
12
12
  )
13
13
  from pyinaturalist.constants import RequestParams
14
+ from pyinaturalist.models import T
14
15
 
15
16
  from ..constants import INAT_DEFAULTS, RATELIMIT_FILE, RATELIMIT_LOCK_FILE, CACHE_FILE
17
+ from ..controllers.inat import UserController
18
+ from ..paginator import Paginator
16
19
 
17
20
 
18
21
  DRONEFLY_SESSION = ClientSession(
@@ -43,12 +46,16 @@ class iNatClient(pyiNatClient):
43
46
  **kwargs,
44
47
  }
45
48
  super().__init__(*args, **_kwargs)
49
+ self.users = UserController(self)
46
50
  self.annotations.async_all = asyncify(self, self.annotations.all)
47
51
  self.taxa.populate = asyncify(self, self.taxa.populate)
48
52
  self.observations.taxon_summary = asyncify(
49
53
  self, self.observations.taxon_summary
50
54
  )
51
55
  self.observations.life_list = asyncify(self, self.observations.life_list)
56
+ self.observations.species_count = asyncify(
57
+ self, self.observations.species_count
58
+ )
52
59
 
53
60
  def add_defaults(
54
61
  self,
@@ -66,6 +73,18 @@ class iNatClient(pyiNatClient):
66
73
 
67
74
  return _kwargs
68
75
 
76
+ def paginate(
77
+ self,
78
+ request_function: Callable,
79
+ model: Type[T],
80
+ auth: bool = False,
81
+ cls: Type[Paginator] = Paginator,
82
+ **kwargs,
83
+ ) -> Paginator[T]:
84
+ """Return our own Paginator instead of pyiNat's."""
85
+ kwargs = self.add_defaults(request_function, kwargs, auth)
86
+ return cls(request_function, model, loop=self.loop, **kwargs)
87
+
69
88
  @contextmanager
70
89
  def set_ctx(self, ctx):
71
90
  self.ctx = ctx
@@ -1,10 +1,12 @@
1
1
  import asyncio
2
2
  from enum import Enum
3
+ from inspect import signature
3
4
  import re
4
5
  from typing import Union
5
6
 
6
7
  from requests import HTTPError
7
8
  from rich.markdown import Markdown
9
+ from pyinaturalist import UserCount
8
10
 
9
11
  from ..clients.inat import iNatClient
10
12
  from ..constants import (
@@ -17,16 +19,27 @@ from ..constants import (
17
19
 
18
20
  from ..parsers import NaturalParser
19
21
  from ..parsers.constants import VALID_OBS_SORT_BY
20
- from ..query import prepare_query
22
+ from ..query import (
23
+ get_place_count,
24
+ get_user_count,
25
+ get_user_count_total,
26
+ match_place,
27
+ match_user,
28
+ prepare_query,
29
+ QueryResponse,
30
+ )
31
+ from ..query.formatters import get_query_taxon_formatter
21
32
  from ..formatters.generic import (
33
+ format_obs_spp_count,
22
34
  ObservationFormatter,
23
35
  TaxonListFormatter,
24
- TaxonFormatter,
36
+ CountsFormatter,
25
37
  UserFormatter,
26
38
  p,
27
39
  )
40
+ from ..menus.counts import CountsSource
28
41
  from ..menus.taxon_list import TaxonListSource
29
- from ..models import BaseFormatter, Config, Context, ListFormatter
42
+ from ..models import BaseFormatter, load_config, Context, ListFormatter
30
43
 
31
44
 
32
45
  RICH_BQ_NEWLINE_PAT = re.compile(r"^(\> .*?)\n(?=\> )", re.MULTILINE)
@@ -75,7 +88,7 @@ class Commands:
75
88
  self.format = format
76
89
  self.inat_client = iNatClient(loop=loop)
77
90
  self.parser = NaturalParser()
78
- self.dronefly_config = Config()
91
+ self.dronefly_config = load_config()
79
92
 
80
93
  def _parse(self, query_str):
81
94
  return self.parser.parse(query_str)
@@ -92,10 +105,16 @@ class Commands:
92
105
  if getattr(formatter, "format_page", None):
93
106
  if source:
94
107
  page = await source.get_page(page_number)
95
- markdown_text = formatter.format_page(page, page_number, selected)
108
+ sig = signature(formatter.format_page)
109
+ if len(sig.parameters) == 3:
110
+ markdown_text = formatter.format_page(page, page_number, selected)
111
+ last_page = formatter.last_page()
112
+ else:
113
+ markdown_text = formatter.format_page(page)
114
+ last_page = 0
96
115
  else:
97
116
  markdown_text = formatter.format_page(page_number, selected)
98
- last_page = formatter.last_page()
117
+ last_page = formatter.last_page()
99
118
  if last_page > 0:
100
119
  markdown_text = "\n\n".join(
101
120
  [markdown_text, f"Page {page_number + 1}/{last_page + 1}"]
@@ -106,7 +125,7 @@ class Commands:
106
125
  markdown_text = "\n\n".join(
107
126
  [item for item in (header, markdown_text, footer) if item is not None]
108
127
  )
109
- return self._format_markdown(markdown_text)
128
+ return markdown_text
110
129
 
111
130
  def _format_markdown(self, markdown_text: str):
112
131
  """Format Rich vs. Discord markdown."""
@@ -152,6 +171,7 @@ class Commands:
152
171
  return response
153
172
 
154
173
  async def life(self, ctx: Context, *args):
174
+ """List lifelist of taxa"""
155
175
  _args = " ".join(args) or "by me"
156
176
  query = self._parse(_args)
157
177
  per_rank = query.per or "main"
@@ -165,7 +185,7 @@ class Commands:
165
185
  raise ArgumentError("Specify `order asc` or `order desc`")
166
186
 
167
187
  with self.inat_client.set_ctx(ctx) as client:
168
- query_response = await prepare_query(client, self.dronefly_config, query)
188
+ query_response = await prepare_query(client, query)
169
189
  obs_args = query_response.obs_args()
170
190
  life_list = await client.observations.life_list(**obs_args)
171
191
 
@@ -193,11 +213,13 @@ class Commands:
193
213
  ctx.page_number = 0
194
214
  ctx.selected = 0
195
215
  title = formatter.format_title() if source.meta.taxon_count > 0 else None
196
- return await self._get_formatted_page(
216
+ formatted_page = await self._get_formatted_page(
197
217
  ctx.page_formatter, ctx.page_number, ctx.selected, header=title
198
218
  )
219
+ return self._format_markdown(formatted_page)
199
220
 
200
221
  async def taxon_list(self, ctx: Context, *args):
222
+ """List child taxa"""
201
223
  query = self._parse(" ".join(args))
202
224
  per_rank = query.per or "child"
203
225
  if per_rank not in [*RANK_KEYWORDS, "child"]:
@@ -216,7 +238,7 @@ class Commands:
216
238
  short_description = ""
217
239
  msg = None
218
240
  with self.inat_client.set_ctx(ctx) as client:
219
- query_response = await prepare_query(client, self.dronefly_config, query)
241
+ query_response = await prepare_query(client, query)
220
242
  taxon = query_response.taxon
221
243
  if not taxon:
222
244
  raise LookupError(f"No taxon {query_response.obs_query_description()}")
@@ -309,22 +331,26 @@ class Commands:
309
331
  if title:
310
332
  title_lines.append(title)
311
333
  title = "\n".join(title_lines)
312
- return await self._get_formatted_page(
334
+ formatted_page = await self._get_formatted_page(
313
335
  ctx.page_formatter, ctx.page_number, ctx.selected, header=title
314
336
  )
337
+ return self._format_markdown(formatted_page)
315
338
 
316
339
  async def next(self, ctx: Context):
340
+ """Go to next page"""
317
341
  if not ctx.page_formatter:
318
342
  raise CommandError("Type a command that has pages first")
319
343
  ctx.page_number += 1
320
344
  if ctx.page_number > ctx.page_formatter.last_page():
321
345
  ctx.page_number = 0
322
346
  ctx.selected = 0
323
- return await self._get_formatted_page(
347
+ formatted_page = await self._get_formatted_page(
324
348
  ctx.page_formatter, ctx.page_number, ctx.selected
325
349
  )
350
+ return self._format_markdown(formatted_page)
326
351
 
327
352
  async def page(self, ctx: Context, page_number: int = 1):
353
+ """Go to specified page"""
328
354
  if not ctx.page_formatter:
329
355
  raise CommandError("Type a command that has pages first")
330
356
  last_page = ctx.page_formatter.last_page() + 1
@@ -335,11 +361,13 @@ class Commands:
335
361
  raise ArgumentError(msg)
336
362
  ctx.page_number = page_number - 1
337
363
  ctx.selected = 0
338
- return await self._get_formatted_page(
364
+ formatted_page = await self._get_formatted_page(
339
365
  ctx.page_formatter, ctx.page_number, ctx.selected
340
366
  )
367
+ return self._format_markdown(formatted_page)
341
368
 
342
369
  async def sel(self, ctx: Context, sel: int = 1):
370
+ """Select entry on current page"""
343
371
  if not ctx.page_formatter:
344
372
  raise CommandError("Type a command that has pages first")
345
373
  _page = await ctx.page_formatter.source.get_page(ctx.page_number)
@@ -350,60 +378,117 @@ class Commands:
350
378
  msg += f" through {page_len}"
351
379
  raise ArgumentError(msg)
352
380
  ctx.selected = sel - 1
353
- return await self._get_formatted_page(
381
+ formatted_page = await self._get_formatted_page(
354
382
  ctx.page_formatter, ctx.page_number, ctx.selected
355
383
  )
384
+ return self._format_markdown(formatted_page)
356
385
 
357
386
  async def prev(self, ctx: Context):
387
+ """Go to previous page"""
358
388
  if not ctx.page_formatter:
359
389
  raise CommandError("Type a command that has pages first")
360
390
  ctx.page_number -= 1
361
391
  if ctx.page_number < 0:
362
392
  ctx.page_number = ctx.page_formatter.last_page()
363
393
  ctx.selected = 0
364
- return await self._get_formatted_page(
394
+ formatted_page = await self._get_formatted_page(
365
395
  ctx.page_formatter, ctx.page_number, ctx.selected
366
396
  )
397
+ return self._format_markdown(formatted_page)
367
398
 
368
- async def taxon(self, ctx: Context, *args):
399
+ async def _get_taxon_query(self, client, *args):
400
+ """Prepare a query with taxon required."""
401
+ query_response = None
402
+ query = self._parse(" ".join(args))
403
+ if not query.main or not query.main.terms:
404
+ raise ArgumentError("Not a taxon")
405
+ query_response = await prepare_query(client, query)
406
+ if not query_response.taxon:
407
+ raise LookupError("Nothing found")
408
+ query_response.taxon = await client.taxa.populate(query_response.taxon)
409
+ return query_response
410
+
411
+ async def _get_selected_taxon(self, client):
412
+ """Get the currently selected taxon."""
413
+ ctx = client.ctx
414
+ formatter = ctx.page_formatter
415
+ if formatter and getattr(formatter, "source", None):
416
+ page = await formatter.source.get_page(ctx.page_number)
417
+ taxon = await client.taxa.populate(page[ctx.selected])
418
+ else:
419
+ raise CommandError("Select a taxon first")
420
+ return taxon
421
+
422
+ def _get_counts_formatter(self, client, query_response, count):
423
+ counts_formatter = CountsFormatter()
424
+ ctx = client.ctx
425
+ counts_source = CountsSource(
426
+ entries=[count],
427
+ query_response=query_response,
428
+ counts_formatter=counts_formatter,
429
+ per_page=ctx.per_page,
430
+ )
431
+ counts_formatter.source = counts_source
432
+ return counts_formatter
433
+
434
+ async def _get_query_response_from_args(self, client, *args):
369
435
  taxon = None
370
436
  if len(args) == 0 or args[0] == "sel":
371
- formatter = ctx.page_formatter
372
- if formatter and getattr(formatter, "source", None):
373
- page = await formatter.source.get_page(ctx.page_number)
374
- with self.inat_client.set_ctx(ctx) as client:
375
- taxon = await client.taxa.populate(page[ctx.selected])
376
- else:
377
- raise CommandError("Select a taxon first")
437
+ taxon = await self._get_selected_taxon(client.ctx)
438
+ query_response = QueryResponse(taxon=taxon)
378
439
  else:
379
- query = self._parse(" ".join(args))
380
- # TODO: Handle all query clauses, not just main.terms
381
- # TODO: Doesn't do any ranking or filtering of results
382
- if not query.main or not query.main.terms:
383
- raise ArgumentError("Not a taxon")
384
-
385
- with self.inat_client.set_ctx(ctx) as client:
386
- query_response = await prepare_query(
387
- client, self.dronefly_config, query
388
- )
389
- if not query_response.taxon:
390
- raise LookupError("Nothing found")
391
- taxon = await client.taxa.populate(query_response.taxon)
392
-
393
- formatter = TaxonFormatter(
394
- taxon,
395
- lang=ctx.get_inat_user_default("inat_lang"),
396
- with_url=True,
397
- )
398
- response = await self._get_formatted_page(formatter)
440
+ query_response = await self._get_taxon_query(client, *args)
441
+ return query_response
399
442
 
400
- return response
443
+ async def taxon(self, ctx: Context, *args):
444
+ """Show taxon"""
445
+ with self.inat_client.set_ctx(ctx) as client:
446
+ query_response = await self._get_query_response_from_args(client, *args)
447
+ taxon_formatter = await get_query_taxon_formatter(
448
+ client,
449
+ query_response,
450
+ lang=ctx.get_inat_user_default("inat_lang"),
451
+ with_url=True,
452
+ )
453
+ response = await self._get_formatted_page(taxon_formatter)
454
+ return self._format_markdown(response)
455
+
456
+ async def add(self, ctx: Context, *args):
457
+ """Add user or place to page"""
458
+ if not (ctx.counts_formatter and ctx.counts_formatter.writable):
459
+ return "Type a command that has writable pages first"
460
+ user_or_place_str = " ".join(args)
461
+ with self.inat_client.set_ctx(ctx) as client:
462
+ add_user = isinstance(ctx.counts_formatter.source.entries[0], UserCount)
463
+ if add_user:
464
+ user_or_place = await match_user(client, user_or_place_str)
465
+ else:
466
+ user_or_place = await match_place(client, user_or_place_str)
467
+ # TODO: update_source with added user or place and (if user) new
468
+ # total and output updated page (advancing to next page if needed)
469
+ formatter = ctx.counts_formatter
470
+ source = formatter.source
471
+ query_response = source.query_response
472
+ if add_user:
473
+ count = await get_user_count(client, query_response, user_or_place)
474
+ else:
475
+ count = await get_place_count(client, query_response, user_or_place)
476
+ source.entries.append(count)
477
+ formatted_counts_page = await self._get_formatted_page(formatter)
478
+ if add_user and len(source.entries) > 1:
479
+ total_user_count = await get_user_count_total(
480
+ client, query_response, source.entries
481
+ )
482
+ formatted_total = format_obs_spp_count(total_user_count, query_response)
483
+ formatted_counts_page += f"\n{formatted_total}"
484
+ return self._format_markdown(formatted_counts_page)
401
485
 
402
486
  async def obs(self, ctx: Context, *args):
487
+ """Show observation"""
403
488
  query = self._parse(" ".join(args))
404
489
 
405
490
  with self.inat_client.set_ctx(ctx) as client:
406
- query_response = await prepare_query(client, self.dronefly_config, query)
491
+ query_response = await prepare_query(client, query)
407
492
  _check_obs_query_fields(query_response)
408
493
  if query_response.taxon:
409
494
  query_response.taxon = await client.taxa.populate(query_response.taxon)
@@ -437,27 +522,24 @@ class Commands:
437
522
  )
438
523
  response = await self._get_formatted_page(formatter)
439
524
 
440
- return response
525
+ return self._format_markdown(response)
441
526
 
442
- async def user(self, ctx: Context, user_id: str):
527
+ async def user(self, ctx: Context, user_str: str):
528
+ """Show user"""
443
529
  with self.inat_client.set_ctx(ctx) as client:
444
- user = None
445
530
  try:
446
- user = await anext(aiter(client.users.from_ids(user_id)), None)
447
- except HTTPError as err:
448
- if err.response.status_code == 404:
449
- pass
450
- if not user:
451
- raise LookupError("User not found.")
452
-
531
+ user = await match_user(client, user_str)
532
+ except ArgumentError as err:
533
+ return str(err)
453
534
  return self._format_markdown(UserFormatter(user).format())
454
535
 
455
536
  async def user_add(self, ctx: Context, user_abbrev: str, user_id: str):
537
+ """Add user to user table"""
456
538
  if user_abbrev != "me":
457
539
  raise ArgumentError(
458
540
  "Only `user add me <user-id>` is supported at this time."
459
541
  )
460
- user_config = self.dronefly_config.user(ctx.author.id)
542
+ user_config = await self.dronefly_config.user(ctx.author.id)
461
543
  configured_user_id = None
462
544
  if user_config:
463
545
  configured_user_id = user_config.get("inat_user_id")
@@ -0,0 +1 @@
1
+ from dronefly.core.controllers.inat.user_controller import UserController # noqa: F401
@@ -0,0 +1,33 @@
1
+ from typing import Iterable
2
+
3
+ from pyinaturalist.constants import MultiIntOrStr
4
+ from pyinaturalist.controllers import UserController as pyiNatUserController
5
+ from pyinaturalist.converters import ensure_list
6
+ from pyinaturalist.models import User
7
+ from pyinaturalist.v1 import get_user_by_id
8
+
9
+ from ...paginator import Paginator, IDPaginator
10
+
11
+
12
+ class UserController(pyiNatUserController):
13
+ def from_ids(self, user_ids: MultiIntOrStr, **params) -> Paginator[User]:
14
+ """Return our paginator with async_one instead of pyiNat's"""
15
+ return self.client.paginate(
16
+ get_user_by_id, User, cls=IDPaginator, ids=ensure_list(user_ids), **params
17
+ )
18
+
19
+ async def from_dronefly_users(
20
+ self, dronefly_users: Iterable, **params
21
+ ) -> Paginator[User]:
22
+ """Get iNat users for list of dronefly users"""
23
+ inat_user_ids = [
24
+ await self.client.ctx.config.user_id(dronefly_user)
25
+ for dronefly_user in dronefly_users
26
+ ]
27
+ return self.client.paginate(
28
+ get_user_by_id,
29
+ User,
30
+ cls=IDPaginator,
31
+ ids=ensure_list(inat_user_ids),
32
+ **params
33
+ )