API Reference
Core Classes
MiiDatabase
mii.database.MiiDatabase
Reads and manages Miis from a database file
Source code in src/mii/database.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
__getitem__(index)
__init__(file_path, mii_type)
Initialize MiiDatabase by reading from a database file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path
|
Path to the database file |
required |
mii_type
|
MiiType
|
Type of Mii database (determines offset, size, etc.) |
required |
Raises:
| Type | Description |
|---|---|
MiiDatabaseError
|
If file doesn't exist or can't be read |
Examples:
>>> from pathlib import Path
>>> from mii import MiiDatabase, MiiType
>>> database = MiiDatabase(Path("RFL_DB.dat"), MiiType.WII_PLAZA)
>>> print(len(database))
Source code in src/mii/database.py
__iter__()
__len__()
export_all(output_dir, prefix=None)
Export all Miis from this database to individual files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path
|
Directory where Mii files should be written |
required |
prefix
|
Optional[str]
|
Optional prefix for filenames. If None, uses mii_type.PREFIX |
None
|
Returns:
| Type | Description |
|---|---|
List[Path]
|
List of Path objects for the exported files |
Examples:
>>> database = MiiDatabase(Path("RFL_DB.dat"), MiiType.WII_PLAZA)
>>> exported = database.export_all(Path("./miis"))
>>> print(f"Exported {len(exported)} Miis")
Source code in src/mii/database.py
filter(predicate)
Filter Miis by a predicate function
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
Callable[[Mii], bool]
|
Function that takes a Mii and returns True to include it |
required |
Returns:
| Type | Description |
|---|---|
List[Mii]
|
List of Miis that match the predicate |
Examples:
>>> database = MiiDatabase(Path("RFL_DB.dat"), MiiType.WII_PLAZA)
>>> red_miis = database.filter(lambda m: m.favorite_color == "Red")
>>> named_miis = database.filter(lambda m: m.name and m.name != "Unnamed")
Source code in src/mii/database.py
get_all()
get_by_name(name)
Get the first Mii with a matching name (case-insensitive)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name to search for |
required |
Returns:
| Type | Description |
|---|---|
Optional[Mii]
|
Mii with matching name, or None if not found |
Examples:
>>> database = MiiDatabase(Path("RFL_DB.dat"), MiiType.WII_PLAZA)
>>> mii = database.get_by_name("My Mii")
>>> if mii:
... print(mii.creator_name)
Source code in src/mii/database.py
get_favorites()
Get all favorite Miis
Returns:
| Type | Description |
|---|---|
List[Mii]
|
List of Miis marked as favorites |
Examples:
>>> database = MiiDatabase(Path("RFL_DB.dat"), MiiType.WII_PLAZA)
>>> favorites = database.get_favorites()
>>> print(f"Found {len(favorites)} favorite Miis")
Source code in src/mii/database.py
options: show_root_heading: true show_root_toc_entry: true show_source: true
Mii
mii.models.Mii
dataclass
Represents a single Mii with all its data
Source code in src/mii/models.py
9 10 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
is_wii_mii
property
Determine if this Mii is from Wii (True) or 3DS/WiiU (False)
export(path)
Write this Mii to a file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path where the Mii file should be written |
required |
Examples:
Source code in src/mii/models.py
get_birthday_string()
Get formatted birthday string
Returns:
| Type | Description |
|---|---|
str
|
Formatted birthday string (e.g., "1/15") or "Not set" |
Examples:
Source code in src/mii/models.py
get_creation_datetime()
Get creation datetime for this Mii
Returns:
| Type | Description |
|---|---|
datetime
|
Datetime object representing when the Mii was created |
Examples:
>>> mii = database[0]
>>> creation_time = mii.get_creation_datetime()
>>> print(creation_time.strftime("%Y-%m-%d %H:%M:%S"))
Source code in src/mii/models.py
get_creation_seconds()
Extract timestamp seconds from Mii data
Source code in src/mii/models.py
get_gender_string()
Get formatted gender string
Returns:
| Type | Description |
|---|---|
str
|
"Female" or "Male" |
Examples:
get_mii_id_hex()
Get Mii ID as uppercase hex string
Returns:
| Type | Description |
|---|---|
str
|
Mii ID as uppercase hexadecimal string |
Examples:
Source code in src/mii/models.py
options: show_root_heading: true show_root_toc_entry: true show_source: true
MiiParser
mii.parser.MiiParser
Parses raw Mii bytes into Mii dataclass instances
Source code in src/mii/parser.py
6 7 8 9 10 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
parse(data, padding=0)
classmethod
Parse raw Mii bytes into a Mii dataclass instance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
Raw Mii bytes |
required |
padding
|
int
|
Number of padding bytes to append when writing to disk |
0
|
Returns:
| Type | Description |
|---|---|
Mii
|
Mii dataclass instance |
Examples:
>>> with open("WII_PL00000.mii", "rb") as f:
... mii_data = f.read()
>>> mii = MiiParser.parse(mii_data)
>>> print(mii.name)
Source code in src/mii/parser.py
options: show_root_heading: true show_root_toc_entry: true show_source: true
MiiType
mii.types.MiiType
Bases: Enum
Enum describing different Mii database types with their configurations
Examples:
>>> from pathlib import Path
>>> from mii import MiiDatabase, MiiType
>>> # Load Wii Plaza database
>>> database = MiiDatabase(Path("RFL_DB.dat"), MiiType.WII_PLAZA)
>>> # Access type properties
>>> print(MiiType.WII_PLAZA.SOURCE)
>>> print(MiiType.WII_PLAZA.display_name)
Source code in src/mii/types.py
display_name
property
Return a human-readable name for the Mii type
options: show_root_heading: true show_root_toc_entry: true show_source: true
Exceptions
MiiDatabaseError
mii.database.MiiDatabaseError
options: show_root_heading: true show_root_toc_entry: true show_source: true