dronefly-core 0.3.9.dev0__py3-none-any.whl → 0.3.9.dev2__py3-none-any.whl
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.
- dronefly/core/clients/inat.py +23 -2
- dronefly/core/commands/__init__.py +256 -21
- dronefly/core/constants.py +24 -0
- dronefly/core/formatters/__init__.py +1 -0
- dronefly/core/formatters/generic.py +275 -98
- dronefly/core/menus/__init__.py +3 -0
- dronefly/core/menus/menu.py +13 -0
- dronefly/core/menus/source.py +348 -0
- dronefly/core/menus/taxon_list.py +31 -0
- dronefly/core/models/__init__.py +3 -0
- dronefly/core/models/config.py +34 -0
- dronefly/core/parsers/constants.py +18 -4
- dronefly/core/parsers/natural.py +9 -1
- dronefly/core/parsers/unixlike.py +5 -0
- dronefly/core/query/__init__.py +1 -1
- dronefly/core/query/query.py +34 -5
- {dronefly_core-0.3.9.dev0.dist-info → dronefly_core-0.3.9.dev2.dist-info}/LICENSE +8 -0
- {dronefly_core-0.3.9.dev0.dist-info → dronefly_core-0.3.9.dev2.dist-info}/METADATA +4 -5
- dronefly_core-0.3.9.dev2.dist-info/RECORD +28 -0
- dronefly_core-0.3.9.dev0.dist-info/RECORD +0 -23
- {dronefly_core-0.3.9.dev0.dist-info → dronefly_core-0.3.9.dev2.dist-info}/WHEEL +0 -0
dronefly/core/clients/inat.py
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
"""Module to access iNaturalist API."""
|
|
2
2
|
from contextlib import contextmanager
|
|
3
3
|
from inspect import signature
|
|
4
|
+
import os
|
|
4
5
|
from typing import Optional
|
|
5
6
|
|
|
6
|
-
from pyinaturalist import
|
|
7
|
+
from pyinaturalist import (
|
|
8
|
+
ClientSession,
|
|
9
|
+
FileLockSQLiteBucket,
|
|
10
|
+
iNatClient as pyiNatClient,
|
|
11
|
+
)
|
|
7
12
|
from pyinaturalist.constants import RequestParams
|
|
8
13
|
|
|
9
|
-
from ..constants import INAT_DEFAULTS
|
|
14
|
+
from ..constants import INAT_DEFAULTS, USER_DATA_PATH
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
class iNatClient(pyiNatClient):
|
|
13
18
|
"""iNat client based on pyinaturalist."""
|
|
14
19
|
|
|
20
|
+
def __init__(self, *args, **kwargs):
|
|
21
|
+
ratelimit_path = os.path.join(USER_DATA_PATH, "ratelimit.db")
|
|
22
|
+
lock_path = os.path.join(USER_DATA_PATH, "ratelimit.lock")
|
|
23
|
+
cache_file = os.path.join(USER_DATA_PATH, "api_requests.db")
|
|
24
|
+
session = ClientSession(
|
|
25
|
+
bucket_class=FileLockSQLiteBucket,
|
|
26
|
+
cache_file=cache_file,
|
|
27
|
+
ratelimit_path=ratelimit_path,
|
|
28
|
+
lock_path=lock_path,
|
|
29
|
+
)
|
|
30
|
+
_kwargs = {
|
|
31
|
+
"session": session,
|
|
32
|
+
**kwargs,
|
|
33
|
+
}
|
|
34
|
+
super().__init__(*args, **_kwargs)
|
|
35
|
+
|
|
15
36
|
def add_client_settings(
|
|
16
37
|
self,
|
|
17
38
|
request_function,
|
|
@@ -3,19 +3,31 @@ import re
|
|
|
3
3
|
from typing import Union
|
|
4
4
|
|
|
5
5
|
from attrs import define
|
|
6
|
+
from requests import HTTPError
|
|
6
7
|
from rich.markdown import Markdown
|
|
7
8
|
|
|
8
9
|
from ..clients.inat import iNatClient
|
|
9
|
-
from ..constants import
|
|
10
|
+
from ..constants import (
|
|
11
|
+
CONFIG_PATH,
|
|
12
|
+
INAT_DEFAULTS,
|
|
13
|
+
INAT_USER_DEFAULT_PARAMS,
|
|
14
|
+
RANK_EQUIVALENTS,
|
|
15
|
+
RANKS_FOR_LEVEL,
|
|
16
|
+
RANK_KEYWORDS,
|
|
17
|
+
RANK_LEVELS,
|
|
18
|
+
)
|
|
10
19
|
|
|
11
20
|
from ..parsers import NaturalParser
|
|
12
21
|
from ..formatters.generic import (
|
|
13
22
|
BaseFormatter,
|
|
14
|
-
|
|
23
|
+
TaxonListFormatter,
|
|
15
24
|
ListFormatter,
|
|
16
25
|
ObservationFormatter,
|
|
17
26
|
TaxonFormatter,
|
|
27
|
+
UserFormatter,
|
|
28
|
+
p,
|
|
18
29
|
)
|
|
30
|
+
from ..models.config import Config
|
|
19
31
|
from ..models.user import User
|
|
20
32
|
from ..query.query import get_base_query_args, QueryResponse
|
|
21
33
|
|
|
@@ -61,11 +73,10 @@ class Context:
|
|
|
61
73
|
"""Return iNat API default for user param default, if any, otherwise global default."""
|
|
62
74
|
if inat_param not in INAT_USER_DEFAULT_PARAMS:
|
|
63
75
|
return None
|
|
76
|
+
default = None
|
|
64
77
|
if self.author:
|
|
65
|
-
default = getattr(self.author, inat_param, None)
|
|
66
|
-
|
|
67
|
-
)
|
|
68
|
-
else:
|
|
78
|
+
default = getattr(self.author, inat_param, None)
|
|
79
|
+
if not default:
|
|
69
80
|
default = INAT_DEFAULTS.get(inat_param)
|
|
70
81
|
return default
|
|
71
82
|
|
|
@@ -94,11 +105,19 @@ class Commands:
|
|
|
94
105
|
inat_client: iNatClient = iNatClient()
|
|
95
106
|
parser: NaturalParser = NaturalParser()
|
|
96
107
|
format: Format = Format.discord_markdown
|
|
108
|
+
config: Config = Config()
|
|
97
109
|
|
|
98
110
|
def _parse(self, query_str):
|
|
99
111
|
return self.parser.parse(query_str)
|
|
100
112
|
|
|
101
|
-
def _get_formatted_page(
|
|
113
|
+
def _get_formatted_page(
|
|
114
|
+
self,
|
|
115
|
+
formatter,
|
|
116
|
+
page: int = 0,
|
|
117
|
+
selected: int = 0,
|
|
118
|
+
header: str = None,
|
|
119
|
+
footer: str = None,
|
|
120
|
+
):
|
|
102
121
|
if getattr(formatter, "format_page", None):
|
|
103
122
|
markdown_text = formatter.format_page(page, selected)
|
|
104
123
|
last_page = formatter.last_page()
|
|
@@ -108,9 +127,14 @@ class Commands:
|
|
|
108
127
|
)
|
|
109
128
|
else:
|
|
110
129
|
markdown_text = formatter.format()
|
|
130
|
+
if header or footer:
|
|
131
|
+
markdown_text = "\n\n".join(
|
|
132
|
+
[item for item in (header, markdown_text, footer) if item is not None]
|
|
133
|
+
)
|
|
111
134
|
return self._format_markdown(markdown_text)
|
|
112
135
|
|
|
113
136
|
def _format_markdown(self, markdown_text: str):
|
|
137
|
+
"""Format Rich vs. Discord markdown."""
|
|
114
138
|
if self.format == Format.rich:
|
|
115
139
|
# Richify the markdown:
|
|
116
140
|
# - In Discord markdown, all newlines are rendered as line breaks
|
|
@@ -136,12 +160,34 @@ class Commands:
|
|
|
136
160
|
response = markdown_text
|
|
137
161
|
return response
|
|
138
162
|
|
|
163
|
+
def _simple_format_markdown(self, markdown_text: str):
|
|
164
|
+
"""Simplified formatter for Rich vs. Discord markdown.
|
|
165
|
+
|
|
166
|
+
Discord vs. Rich linebreak rendering is harder than we thought, e.g.
|
|
167
|
+
`_format_markdown()` doesn't give correct results with point-form
|
|
168
|
+
or numbered lists. If special handling of newlines isn't needed, then
|
|
169
|
+
use this helper instead.
|
|
170
|
+
"""
|
|
171
|
+
if self.format == Format.rich:
|
|
172
|
+
# Richify the markdown
|
|
173
|
+
response = Markdown(markdown_text)
|
|
174
|
+
else:
|
|
175
|
+
# Return the literal markdown for Discord to render
|
|
176
|
+
response = markdown_text
|
|
177
|
+
return response
|
|
178
|
+
|
|
139
179
|
def life(self, ctx: Context, *args):
|
|
140
180
|
_args = " ".join(args) or "by me"
|
|
141
181
|
query = self._parse(_args)
|
|
142
182
|
per_rank = query.per or "main"
|
|
143
|
-
if per_rank not in [*RANK_KEYWORDS, "leaf", "main", "any"]:
|
|
183
|
+
if per_rank not in [*RANK_KEYWORDS, "leaf", "child", "main", "any"]:
|
|
144
184
|
return "Specify `per <rank-or-keyword>`"
|
|
185
|
+
sort_by = query.sort_by or None
|
|
186
|
+
if sort_by not in [None, "obs", "name"]:
|
|
187
|
+
return "Specify `sort by obs` or `sort by name` (default)"
|
|
188
|
+
order = query.order or None
|
|
189
|
+
if order not in [None, "asc", "desc"]:
|
|
190
|
+
return "Specify `order asc` or `order desc`"
|
|
145
191
|
|
|
146
192
|
query_args = get_base_query_args(query)
|
|
147
193
|
with self.inat_client.set_ctx(ctx) as client:
|
|
@@ -180,13 +226,16 @@ class Commands:
|
|
|
180
226
|
|
|
181
227
|
per_page = ctx.per_page
|
|
182
228
|
with_index = self.format == Format.rich
|
|
183
|
-
|
|
184
|
-
|
|
229
|
+
taxon_list = life_list.data
|
|
230
|
+
formatter = TaxonListFormatter(
|
|
231
|
+
taxon_list,
|
|
185
232
|
per_rank,
|
|
186
233
|
query_response,
|
|
187
234
|
with_indent=True,
|
|
188
235
|
per_page=per_page,
|
|
189
236
|
with_index=with_index,
|
|
237
|
+
sort_by=sort_by,
|
|
238
|
+
order=order,
|
|
190
239
|
)
|
|
191
240
|
ctx.page_formatter = formatter
|
|
192
241
|
ctx.page = 0
|
|
@@ -198,6 +247,120 @@ class Commands:
|
|
|
198
247
|
formatter.pages[0]["header"] = title
|
|
199
248
|
return self._get_formatted_page(formatter, 0, 0)
|
|
200
249
|
|
|
250
|
+
def taxon_list(self, ctx: Context, *args):
|
|
251
|
+
query = self._parse(" ".join(args))
|
|
252
|
+
per_rank = query.per or "child"
|
|
253
|
+
if per_rank not in [*RANK_KEYWORDS, "child"]:
|
|
254
|
+
return "Specify `per <rank>` or `per child` (default)"
|
|
255
|
+
_per_rank = per_rank
|
|
256
|
+
rank_level = None
|
|
257
|
+
sort_by = query.sort_by or None
|
|
258
|
+
if sort_by not in [None, "obs", "name"]:
|
|
259
|
+
return "Specify `sort by obs` or `sort by name` (default)"
|
|
260
|
+
order = query.order or None
|
|
261
|
+
if order not in [None, "asc", "desc"]:
|
|
262
|
+
return "Specify `order asc` or `order desc`"
|
|
263
|
+
|
|
264
|
+
query_args = get_base_query_args(query)
|
|
265
|
+
taxon = None
|
|
266
|
+
taxon_list = []
|
|
267
|
+
short_description = ""
|
|
268
|
+
msg = None
|
|
269
|
+
with self.inat_client.set_ctx(ctx) as client:
|
|
270
|
+
# Handle a useful subset of query args in a simplistic way for now
|
|
271
|
+
# (i.e. no config table lookup yet) to model full query in bot
|
|
272
|
+
if query and query.main and query.main.terms:
|
|
273
|
+
main_query_str = " ".join(query.main.terms)
|
|
274
|
+
taxon = client.taxa.autocomplete(q=main_query_str).one()
|
|
275
|
+
if taxon:
|
|
276
|
+
taxon = client.taxa.populate(taxon)
|
|
277
|
+
query_args["taxon"] = taxon
|
|
278
|
+
query_response = QueryResponse(**query_args)
|
|
279
|
+
taxon = query_response.taxon
|
|
280
|
+
if not taxon:
|
|
281
|
+
return f"No taxon {query_response.obs_query_description()}"
|
|
282
|
+
|
|
283
|
+
_taxon_list = [
|
|
284
|
+
taxon,
|
|
285
|
+
*[_taxon for _taxon in taxon.children if _taxon.is_active],
|
|
286
|
+
]
|
|
287
|
+
if per_rank == "child":
|
|
288
|
+
short_description = "Children"
|
|
289
|
+
taxon_list = _taxon_list
|
|
290
|
+
else:
|
|
291
|
+
_per_rank = RANK_EQUIVALENTS.get(per_rank) or per_rank
|
|
292
|
+
rank_level = RANK_LEVELS[_per_rank]
|
|
293
|
+
if rank_level >= taxon.rank_level:
|
|
294
|
+
return self._format_markdown(
|
|
295
|
+
"\N{WARNING SIGN} "
|
|
296
|
+
f"**The rank `{per_rank}` is not lower than "
|
|
297
|
+
"the taxon rank: `{taxon.rank}`.**"
|
|
298
|
+
)
|
|
299
|
+
short_description = p.plural(_per_rank).capitalize()
|
|
300
|
+
_children = [
|
|
301
|
+
child for child in _taxon_list if child.rank_level == rank_level
|
|
302
|
+
]
|
|
303
|
+
_without_rank_ids = [
|
|
304
|
+
child.id for child in _taxon_list if child not in _children
|
|
305
|
+
]
|
|
306
|
+
if len(_without_rank_ids) > 0:
|
|
307
|
+
# One chance at retrieving the remaining children, i.e. if the
|
|
308
|
+
# remainder (direct children - those at the specified rank level)
|
|
309
|
+
# don't constitute a single page of results, then show children
|
|
310
|
+
# instead.
|
|
311
|
+
_descendants = client.taxa.search(
|
|
312
|
+
taxon_id=_without_rank_ids,
|
|
313
|
+
rank_level=rank_level,
|
|
314
|
+
is_active=True,
|
|
315
|
+
per_page=500,
|
|
316
|
+
)
|
|
317
|
+
# The choice of 2500 as our limit is arbitrary:
|
|
318
|
+
# - will take 5 more API calls to satisfy
|
|
319
|
+
# - encompasses the largest genera (e.g. Astragalus)
|
|
320
|
+
# - meant to limit unreasonable sized queries so they don't make
|
|
321
|
+
# excessive API demands
|
|
322
|
+
# - TODO: switch to using a local DB built from full taxonomy dump
|
|
323
|
+
# so we can lift this restriction
|
|
324
|
+
if _descendants.count() > 2500:
|
|
325
|
+
short_description = "Children"
|
|
326
|
+
msg = (
|
|
327
|
+
f"\N{WARNING SIGN} **Too many {p.plural(_per_rank)}. "
|
|
328
|
+
"Listing children instead:**"
|
|
329
|
+
)
|
|
330
|
+
_per_rank = "child"
|
|
331
|
+
taxon_list = _taxon_list
|
|
332
|
+
else:
|
|
333
|
+
taxon_list = [*_children, *_descendants.all()]
|
|
334
|
+
else:
|
|
335
|
+
taxon_list = _children
|
|
336
|
+
# List all ranks at the same level, not just the specified rank
|
|
337
|
+
if _per_rank != "child":
|
|
338
|
+
_per_rank = RANKS_FOR_LEVEL[rank_level]
|
|
339
|
+
|
|
340
|
+
per_page = ctx.per_page
|
|
341
|
+
with_index = self.format == Format.rich
|
|
342
|
+
formatter = TaxonListFormatter(
|
|
343
|
+
taxon_list,
|
|
344
|
+
per_rank=_per_rank,
|
|
345
|
+
query_response=query_response,
|
|
346
|
+
with_indent=True,
|
|
347
|
+
per_page=per_page,
|
|
348
|
+
with_index=with_index,
|
|
349
|
+
sort_by=sort_by,
|
|
350
|
+
order=order,
|
|
351
|
+
short_description=short_description,
|
|
352
|
+
)
|
|
353
|
+
ctx.page_formatter = formatter
|
|
354
|
+
ctx.page = 0
|
|
355
|
+
ctx.selected = 0
|
|
356
|
+
title = formatter.format_title()
|
|
357
|
+
first_page = formatter.get_first_page() or ""
|
|
358
|
+
if first_page:
|
|
359
|
+
# TODO: Provide a method in the formatter to set the title:
|
|
360
|
+
formatter.pages[0]["header"] = title
|
|
361
|
+
page = self._get_formatted_page(formatter, 0, 0, header=msg)
|
|
362
|
+
return page
|
|
363
|
+
|
|
201
364
|
def next(self, ctx: Context):
|
|
202
365
|
if not ctx.page_formatter:
|
|
203
366
|
return "Type a command that has pages first"
|
|
@@ -243,18 +406,28 @@ class Commands:
|
|
|
243
406
|
return self._get_formatted_page(ctx.page_formatter, ctx.page, ctx.selected)
|
|
244
407
|
|
|
245
408
|
def taxon(self, ctx: Context, *args):
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
409
|
+
taxon = None
|
|
410
|
+
if len(args) == 0 or args[0] == "sel":
|
|
411
|
+
formatter = ctx.page_formatter
|
|
412
|
+
if formatter and getattr(formatter, "get_page_of_taxa", None):
|
|
413
|
+
page = formatter.get_page_of_taxa(ctx.page)
|
|
414
|
+
with self.inat_client.set_ctx(ctx) as client:
|
|
415
|
+
taxon = client.taxa.populate(page[ctx.selected])
|
|
416
|
+
else:
|
|
417
|
+
return "Select a taxon first"
|
|
418
|
+
else:
|
|
419
|
+
query = self._parse(" ".join(args))
|
|
420
|
+
# TODO: Handle all query clauses, not just main.terms
|
|
421
|
+
# TODO: Doesn't do any ranking or filtering of results
|
|
422
|
+
if not query.main or not query.main.terms:
|
|
423
|
+
return "Not a taxon"
|
|
252
424
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
425
|
+
with self.inat_client.set_ctx(ctx) as client:
|
|
426
|
+
main_query_str = " ".join(query.main.terms)
|
|
427
|
+
taxon = client.taxa.autocomplete(q=main_query_str).one()
|
|
428
|
+
if not taxon:
|
|
429
|
+
return "Nothing found"
|
|
430
|
+
taxon = client.taxa.populate(taxon)
|
|
258
431
|
|
|
259
432
|
formatter = TaxonFormatter(
|
|
260
433
|
taxon,
|
|
@@ -305,3 +478,65 @@ class Commands:
|
|
|
305
478
|
response = self._get_formatted_page(formatter)
|
|
306
479
|
|
|
307
480
|
return response
|
|
481
|
+
|
|
482
|
+
def user(self, ctx: Context, user_id: str):
|
|
483
|
+
with self.inat_client.set_ctx(ctx) as client:
|
|
484
|
+
user = None
|
|
485
|
+
try:
|
|
486
|
+
user = client.users(user_id)
|
|
487
|
+
except HTTPError as err:
|
|
488
|
+
if err.response.status_code == 404:
|
|
489
|
+
pass
|
|
490
|
+
if not user:
|
|
491
|
+
return "User not found."
|
|
492
|
+
|
|
493
|
+
return self._format_markdown(UserFormatter(user).format())
|
|
494
|
+
|
|
495
|
+
def user_add(self, ctx: Context, user_abbrev: str, user_id: str):
|
|
496
|
+
if user_abbrev != "me":
|
|
497
|
+
return "Only `user add me <user-id>` is supported at this time."
|
|
498
|
+
user_config = self.config.user(ctx.author.id)
|
|
499
|
+
configured_user_id = None
|
|
500
|
+
if user_config:
|
|
501
|
+
configured_user_id = user_config.get("inat_user_id")
|
|
502
|
+
|
|
503
|
+
with self.inat_client.set_ctx(ctx) as client:
|
|
504
|
+
user = None
|
|
505
|
+
try:
|
|
506
|
+
user = client.users(user_id)
|
|
507
|
+
except HTTPError as err:
|
|
508
|
+
if err.response.status_code == 404:
|
|
509
|
+
pass
|
|
510
|
+
if not user:
|
|
511
|
+
return "User not found."
|
|
512
|
+
|
|
513
|
+
response = ""
|
|
514
|
+
redefining = False
|
|
515
|
+
if configured_user_id:
|
|
516
|
+
if configured_user_id == user.id:
|
|
517
|
+
return "User already added."
|
|
518
|
+
configured_user = None
|
|
519
|
+
try:
|
|
520
|
+
configured_user = client.users(configured_user_id)
|
|
521
|
+
except HTTPError as err:
|
|
522
|
+
if err.response.status_code == 404:
|
|
523
|
+
pass
|
|
524
|
+
if configured_user:
|
|
525
|
+
configured_user_str = UserFormatter(configured_user).format()
|
|
526
|
+
else:
|
|
527
|
+
configured_user_str = f"User id not found: {configured_user_id}"
|
|
528
|
+
redefining = True
|
|
529
|
+
response += (
|
|
530
|
+
f"- Already defined as another user: {configured_user_str}\n"
|
|
531
|
+
)
|
|
532
|
+
response += "- To change to the specified user:\n"
|
|
533
|
+
|
|
534
|
+
response += f"1. Confirm this is you: {UserFormatter(user).format()}\n"
|
|
535
|
+
add_or_mod = "modify" if redefining else "add"
|
|
536
|
+
response += f"2. Edit `{CONFIG_PATH}` and {add_or_mod}:\n"
|
|
537
|
+
response += (
|
|
538
|
+
f"```toml\n[users.{ctx.author.id}]\ninat_user_id = {user.id}\n```\n"
|
|
539
|
+
)
|
|
540
|
+
response += "3. Restart dronefly-cli."
|
|
541
|
+
|
|
542
|
+
return self._simple_format_markdown(response)
|
dronefly/core/constants.py
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
from platformdirs import user_data_dir
|
|
2
|
+
import os
|
|
3
|
+
|
|
1
4
|
from pyinaturalist.constants import COMMON_RANKS, RANK_EQUIVALENTS, RANK_LEVELS
|
|
2
5
|
|
|
6
|
+
|
|
7
|
+
USER_DATA_PATH = os.path.join(user_data_dir(), "dronefly-core")
|
|
8
|
+
CONFIG_PATH = os.path.join(USER_DATA_PATH, "config.toml")
|
|
9
|
+
|
|
10
|
+
|
|
3
11
|
# Map Dronefly User param names to iNat API param names:
|
|
4
12
|
INAT_USER_DEFAULT_PARAMS = {
|
|
5
13
|
"inat_place_id": "preferred_place_id",
|
|
@@ -13,5 +21,21 @@ INAT_DEFAULTS = {**INAT_USER_DEFAULTS, "all_names": True}
|
|
|
13
21
|
PLANTAE_ID = 47126
|
|
14
22
|
TRACHEOPHYTA_ID = 211194
|
|
15
23
|
RANK_KEYWORDS = tuple(RANK_LEVELS.keys()) + tuple(RANK_EQUIVALENTS.keys())
|
|
24
|
+
RANK_LEVEL_NAMES = {}
|
|
25
|
+
# For levels with multiple ranks, name the level after the most broadly used
|
|
26
|
+
# rank at that level:
|
|
27
|
+
RANK_LEVEL_TO_NAME = {
|
|
28
|
+
5: "subspecies",
|
|
29
|
+
10: "species",
|
|
30
|
+
20: "genus",
|
|
31
|
+
}
|
|
32
|
+
RANKS_FOR_LEVEL = {}
|
|
33
|
+
for (rank, level) in RANK_LEVELS.items():
|
|
34
|
+
RANK_LEVEL_NAMES[level] = RANK_LEVEL_TO_NAME.get(level) or rank
|
|
35
|
+
if level not in RANKS_FOR_LEVEL:
|
|
36
|
+
RANKS_FOR_LEVEL[level] = [rank]
|
|
37
|
+
else:
|
|
38
|
+
RANKS_FOR_LEVEL[level].append(rank)
|
|
39
|
+
|
|
16
40
|
TAXON_PRIMARY_RANKS = COMMON_RANKS
|
|
17
41
|
TRINOMIAL_ABBR = {"variety": "var.", "subspecies": "ssp.", "form": "f."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .generic import * # noqa: F401,F403
|