idstore
IDStore
Store for ids. Used to create unique IDs on a page.
Source code in mkreports/md/idstore.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
__init__(start_with=0, used_ids=set())
Initialize the IDStore.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_with |
int
|
First value of the counter. |
0
|
used_ids |
set[str]
|
Set of IDs that have to be avoided as they are otherwise used. |
set()
|
Source code in mkreports/md/idstore.py
20 21 22 23 24 25 26 27 28 29 30 31 |
|
_increment(prefix)
Returns the next value of the counter (and increments).
Source code in mkreports/md/idstore.py
33 34 35 36 37 38 |
|
next_id(prefix)
Returns an id with a counted number at the end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
Prefix to be used for the ID. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
ID as a string. |
Source code in mkreports/md/idstore.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|