wols 0.1.0__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.
wols/__init__.py ADDED
@@ -0,0 +1,61 @@
1
+ """WOLS - WeMush Open Labeling Standard.
2
+
3
+ Python implementation of the WOLS v1.1.0 specification for specimen tracking.
4
+
5
+ Example:
6
+ >>> from wols import create_specimen, SpecimenType, to_json
7
+ >>> specimen = create_specimen(
8
+ ... type=SpecimenType.SUBSTRATE,
9
+ ... species="Pleurotus ostreatus",
10
+ ... )
11
+ >>> print(to_json(specimen, indent=2))
12
+ """
13
+
14
+ from wols.constants import (
15
+ DEFAULT_HTTPS_BASE_URL,
16
+ DEFAULT_URL_SCHEME,
17
+ WOLS_CONTEXT,
18
+ WOLS_VERSION,
19
+ UrlScheme,
20
+ )
21
+ from wols.core.create import create_specimen
22
+ from wols.core.parse import parse_compact_url, parse_specimen
23
+ from wols.core.serialize import to_compact_url, to_json
24
+ from wols.core.validate import validate_specimen
25
+ from wols.exceptions import (
26
+ WolsEncryptionError,
27
+ WolsError,
28
+ WolsParseError,
29
+ WolsValidationError,
30
+ )
31
+ from wols.models.enums import GrowthStage, SpecimenType
32
+ from wols.models.specimen import Specimen, SpecimenRef, Strain
33
+ from wols.models.validation import ValidationError, ValidationResult
34
+
35
+ __version__ = "0.1.0"
36
+
37
+ __all__ = [
38
+ "DEFAULT_HTTPS_BASE_URL",
39
+ "DEFAULT_URL_SCHEME",
40
+ "WOLS_CONTEXT",
41
+ "WOLS_VERSION",
42
+ "GrowthStage",
43
+ "Specimen",
44
+ "SpecimenRef",
45
+ "SpecimenType",
46
+ "Strain",
47
+ "UrlScheme",
48
+ "ValidationError",
49
+ "ValidationResult",
50
+ "WolsEncryptionError",
51
+ "WolsError",
52
+ "WolsParseError",
53
+ "WolsValidationError",
54
+ "__version__",
55
+ "create_specimen",
56
+ "parse_compact_url",
57
+ "parse_specimen",
58
+ "to_compact_url",
59
+ "to_json",
60
+ "validate_specimen",
61
+ ]
wols/cli/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ """WOLS command-line interface.
2
+
3
+ Optional module - requires: pip install wols[cli]
4
+ """
5
+
6
+ from wols.cli.app import app
7
+
8
+ __all__ = ["app"]
wols/cli/app.py ADDED
@@ -0,0 +1,521 @@
1
+ """WOLS CLI application."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import logging
7
+ import sys
8
+ from pathlib import Path
9
+ from typing import Annotated
10
+
11
+ import typer
12
+ from rich.console import Console
13
+
14
+ from wols import (
15
+ DEFAULT_HTTPS_BASE_URL,
16
+ UrlScheme,
17
+ __version__,
18
+ create_specimen,
19
+ parse_specimen,
20
+ to_json,
21
+ validate_specimen,
22
+ )
23
+ from wols.models.enums import GrowthStage, SpecimenType
24
+
25
+ logger = logging.getLogger(__name__)
26
+
27
+ app = typer.Typer(
28
+ name="wols",
29
+ help="WOLS - WeMush Open Labeling Standard CLI",
30
+ no_args_is_help=True,
31
+ )
32
+
33
+ console = Console()
34
+ err_console = Console(stderr=True)
35
+
36
+
37
+ def version_callback(value: bool) -> None:
38
+ """Show version and exit."""
39
+ if value:
40
+ console.print(f"wols version {__version__}")
41
+ raise typer.Exit()
42
+
43
+
44
+ @app.callback()
45
+ def main(
46
+ version: Annotated[
47
+ bool | None,
48
+ typer.Option(
49
+ "--version",
50
+ "-v",
51
+ callback=version_callback,
52
+ is_eager=True,
53
+ help="Show version and exit",
54
+ ),
55
+ ] = None,
56
+ ) -> None:
57
+ """WOLS - WeMush Open Labeling Standard CLI."""
58
+ logger.debug("Version: %s", version)
59
+
60
+
61
+ @app.command()
62
+ def create(
63
+ species: Annotated[
64
+ str, typer.Option("--species", "-s", help="Scientific species name")
65
+ ],
66
+ type_: Annotated[
67
+ str,
68
+ typer.Option(
69
+ "--type",
70
+ "-t",
71
+ help="Specimen type (CULTURE, SPAWN, SUBSTRATE, FRUITING, HARVEST)",
72
+ ),
73
+ ],
74
+ strain: Annotated[str | None, typer.Option("--strain", help="Strain name")] = None,
75
+ stage: Annotated[
76
+ str | None,
77
+ typer.Option(
78
+ "--stage",
79
+ help="Growth stage (INOCULATION, COLONIZATION, FRUITING, HARVEST)",
80
+ ),
81
+ ] = None,
82
+ batch: Annotated[
83
+ str | None, typer.Option("--batch", help="Batch identifier")
84
+ ] = None,
85
+ organization: Annotated[
86
+ str | None, typer.Option("--organization", help="Organization name")
87
+ ] = None,
88
+ creator: Annotated[
89
+ str | None, typer.Option("--creator", help="Creator identifier")
90
+ ] = None,
91
+ custom: Annotated[
92
+ str | None, typer.Option("--custom", help="Custom fields as JSON string")
93
+ ] = None,
94
+ output: Annotated[
95
+ Path | None, typer.Option("--output", "-o", help="Write output to file")
96
+ ] = None,
97
+ json_output: Annotated[
98
+ bool,
99
+ typer.Option("--json", "-j", help="Output as JSON (default: human-readable)"),
100
+ ] = False,
101
+ ) -> None:
102
+ """Create a new specimen label."""
103
+ try:
104
+ # Parse custom fields if provided
105
+ custom_fields = None
106
+ if custom:
107
+ try:
108
+ custom_fields = json.loads(custom)
109
+ except json.JSONDecodeError as e:
110
+ err_console.print(
111
+ "[red]Error: INVALID_JSON - "
112
+ f"Failed to parse custom fields: {e}[/red]"
113
+ )
114
+ raise typer.Exit(2)
115
+
116
+ # Validate type
117
+ try:
118
+ specimen_type = SpecimenType(type_.upper())
119
+ except ValueError as exc:
120
+ valid = ", ".join(t.value for t in SpecimenType)
121
+ err_console.print(
122
+ f"[red]Error: INVALID_TYPE - '{type_}'"
123
+ " is not a valid specimen type[/red]"
124
+ )
125
+ err_console.print(f"Valid types: {valid}")
126
+ raise typer.Exit(2) from exc
127
+
128
+ # Validate stage if provided
129
+ growth_stage = None
130
+ if stage:
131
+ try:
132
+ growth_stage = GrowthStage(stage.upper())
133
+ except ValueError as exc:
134
+ valid = ", ".join(s.value for s in GrowthStage)
135
+ err_console.print(
136
+ f"[red]Error: INVALID_STAGE - '{stage}'"
137
+ " is not a valid growth stage[/red]"
138
+ )
139
+ err_console.print(f"Valid stages: {valid}")
140
+ raise typer.Exit(2) from exc
141
+
142
+ # Create specimen
143
+ specimen = create_specimen(
144
+ input_type=specimen_type,
145
+ species=species,
146
+ strain=strain,
147
+ stage=growth_stage,
148
+ batch=batch,
149
+ organization=organization,
150
+ creator=creator,
151
+ custom=custom_fields,
152
+ )
153
+
154
+ # Generate output
155
+ if json_output or output:
156
+ json_str = to_json(specimen, indent=2)
157
+ if output:
158
+ output.write_text(json_str)
159
+ console.print(f"[green]Specimen saved to {output}[/green]")
160
+ else:
161
+ console.print(json_str)
162
+ else:
163
+ # Human-readable output
164
+ console.print("\n[bold]Specimen Created[/bold]")
165
+ console.print("=" * 40)
166
+ console.print(f"[cyan]ID:[/cyan] {specimen.id}")
167
+ console.print(f"[cyan]Version:[/cyan] {specimen.version}")
168
+ console.print(f"[cyan]Type:[/cyan] {specimen.type.value}")
169
+ console.print(f"[cyan]Species:[/cyan] {specimen.species}")
170
+ if specimen.strain:
171
+ console.print(f"[cyan]Strain:[/cyan] {specimen.strain.name}")
172
+ if specimen.stage:
173
+ console.print(f"[cyan]Stage:[/cyan] {specimen.stage.value}")
174
+ if specimen.created:
175
+ console.print(f"[cyan]Created:[/cyan] {specimen.created.isoformat()}")
176
+ except typer.Exit:
177
+ raise
178
+ except Exception as e:
179
+ err_console.print(f"[red]Error: {e}[/red]")
180
+ raise typer.Exit(1)
181
+
182
+
183
+ @app.command()
184
+ def validate(
185
+ input_file: Annotated[
186
+ Path | None,
187
+ typer.Argument(help="Specimen JSON file or - for stdin"),
188
+ ] = None,
189
+ input_opt: Annotated[
190
+ Path | None, typer.Option("--input", "-i", help="Read specimen from file")
191
+ ] = None,
192
+ strict: Annotated[
193
+ bool, typer.Option("--strict", help="Treat unknown fields as errors")
194
+ ] = False,
195
+ json_output: Annotated[
196
+ bool, typer.Option("--json", "-j", help="Output validation result as JSON")
197
+ ] = False,
198
+ ) -> None:
199
+ """Validate specimen JSON against WOLS v1.1.0 schema."""
200
+ # Determine input source
201
+ file_path = input_file or input_opt
202
+
203
+ try:
204
+ if file_path is None or str(file_path) == "-":
205
+ # Read from stdin
206
+ json_str = sys.stdin.read()
207
+ else:
208
+ if not file_path.exists():
209
+ err_console.print(
210
+ "[red]Error: FILE_NOT_FOUND - Could not read file"
211
+ f" '{file_path}'[/red]"
212
+ )
213
+ raise typer.Exit(2)
214
+ json_str = file_path.read_text()
215
+
216
+ # Parse specimen
217
+ try:
218
+ specimen = parse_specimen(json_str)
219
+ except Exception as e:
220
+ if json_output:
221
+ error_result = {
222
+ "valid": False,
223
+ "errors": [
224
+ {
225
+ "path": "",
226
+ "code": "PARSE_ERROR",
227
+ "message": str(e),
228
+ }
229
+ ],
230
+ "warnings": [],
231
+ }
232
+ console.print(json.dumps(error_result, indent=2))
233
+ else:
234
+ console.print("[red]Validation: FAILED[/red]\n")
235
+ console.print(f"[red]Parse Error: {e}[/red]")
236
+ raise typer.Exit(1)
237
+
238
+ # Validate specimen
239
+ result = validate_specimen(specimen, strict=strict)
240
+
241
+ if json_output:
242
+ output = {
243
+ "valid": result.valid,
244
+ "errors": [
245
+ {"path": e.path, "code": e.code, "message": e.message}
246
+ for e in result.errors
247
+ ],
248
+ "warnings": [
249
+ {"path": w.path, "code": w.code, "message": w.message}
250
+ for w in result.warnings
251
+ ],
252
+ }
253
+ console.print(json.dumps(output, indent=2))
254
+ else:
255
+ if result.valid:
256
+ console.print("[green]Validation: PASSED[/green]")
257
+ console.print(f"Specimen ID: {specimen.id}")
258
+ console.print(f"Version: {specimen.version}")
259
+ else:
260
+ console.print("[red]Validation: FAILED[/red]\n")
261
+ console.print("[bold]Errors:[/bold]")
262
+ for error in result.errors:
263
+ console.print(f" - {error.path}: [{error.code}] {error.message}")
264
+
265
+ if result.warnings:
266
+ console.print("\n[bold]Warnings:[/bold]")
267
+ for warning in result.warnings:
268
+ console.print(
269
+ f" - {warning.path}: [{warning.code}] {warning.message}"
270
+ )
271
+
272
+ if not result.valid:
273
+ raise typer.Exit(1)
274
+
275
+ except typer.Exit:
276
+ raise
277
+ except Exception as e:
278
+ err_console.print(f"[red]Error: {e}[/red]")
279
+ raise typer.Exit(1)
280
+
281
+
282
+ @app.command()
283
+ def qr(
284
+ input_file: Annotated[
285
+ Path, typer.Argument(help="Specimen JSON file or - for stdin")
286
+ ],
287
+ output: Annotated[Path, typer.Option("--output", "-o", help="Output file path")],
288
+ format_: Annotated[
289
+ str, typer.Option("--format", "-f", help="Output format: png, svg, base64")
290
+ ] = "png",
291
+ encoding: Annotated[
292
+ str, typer.Option("--encoding", help="QR encoding: embedded, compact")
293
+ ] = "embedded",
294
+ size: Annotated[int, typer.Option("--size", help="Image size in pixels")] = 300,
295
+ error_correction: Annotated[
296
+ str,
297
+ typer.Option("--error-correction", help="Error correction level: L, M, Q, H"),
298
+ ] = "M",
299
+ scheme: Annotated[
300
+ str,
301
+ typer.Option(
302
+ "--scheme",
303
+ help="URL scheme for compact encoding: "
304
+ "web+wemush (PWA, default), wemush (native), https (web)",
305
+ ),
306
+ ] = "web+wemush",
307
+ base_url: Annotated[
308
+ str | None,
309
+ typer.Option(
310
+ "--base-url",
311
+ help=f"Base URL for https scheme (default: {DEFAULT_HTTPS_BASE_URL})",
312
+ ),
313
+ ] = None,
314
+ ) -> None:
315
+ """Generate QR code from specimen JSON."""
316
+ try:
317
+ from wols.qr import generate_qr_base64, generate_qr_png, generate_qr_svg
318
+ except ImportError as imp_exc:
319
+ err_console.print(
320
+ "[red]Error: MODULE_NOT_INSTALLED - QR module not installed[/red]"
321
+ )
322
+ err_console.print("Install with: pip install wols\\[qr]")
323
+ raise typer.Exit(2) from imp_exc
324
+
325
+ try:
326
+ # Read input
327
+ if str(input_file) == "-":
328
+ json_str = sys.stdin.read()
329
+ else:
330
+ if not input_file.exists():
331
+ err_console.print(
332
+ f"[red]Error: FILE_NOT_FOUND - Could not read file"
333
+ f" '{input_file}'[/red]"
334
+ )
335
+ raise typer.Exit(2)
336
+ json_str = input_file.read_text()
337
+
338
+ # Parse specimen
339
+ specimen = parse_specimen(json_str)
340
+
341
+ # Validate format and encoding
342
+ format_lower = format_.lower()
343
+ if format_lower not in ("png", "svg", "base64"):
344
+ err_console.print(
345
+ f"[red]Error: INVALID_FORMAT - '{format_}' is not a valid format[/red]"
346
+ )
347
+ err_console.print("Valid formats: png, svg, base64")
348
+ raise typer.Exit(2)
349
+
350
+ encoding_lower = encoding.lower()
351
+ if encoding_lower not in ("embedded", "compact"):
352
+ err_console.print(
353
+ f"[red]Error: INVALID_ENCODING - '{encoding}' is"
354
+ " not a valid encoding[/red]"
355
+ )
356
+ err_console.print("Valid encodings: embedded, compact")
357
+ raise typer.Exit(2)
358
+
359
+ ec = error_correction.upper()
360
+ if ec not in ("L", "M", "Q", "H"):
361
+ err_console.print(
362
+ f"[red]Error: INVALID_ERROR_CORRECTION -"
363
+ f" '{error_correction}' is not valid[/red]"
364
+ )
365
+ err_console.print("Valid levels: L, M, Q, H")
366
+ raise typer.Exit(2)
367
+
368
+ # Validate URL scheme
369
+ try:
370
+ url_scheme = UrlScheme(scheme)
371
+ except ValueError:
372
+ valid_schemes = ", ".join(s.value for s in UrlScheme)
373
+ err_console.print(
374
+ f"[red]Error: INVALID_SCHEME - '{scheme}' is"
375
+ " not a valid URL scheme[/red]"
376
+ )
377
+ err_console.print(f"Valid schemes: {valid_schemes}")
378
+ raise typer.Exit(2)
379
+
380
+ # Generate QR code
381
+ if format_lower == "png":
382
+ png_data = generate_qr_png(
383
+ specimen,
384
+ format_type=encoding_lower, # type: ignore[arg-type]
385
+ size=size,
386
+ error_correction=ec, # type: ignore[arg-type]
387
+ scheme=url_scheme,
388
+ base_url=base_url,
389
+ )
390
+ output.write_bytes(png_data)
391
+ elif format_lower == "svg":
392
+ svg_data = generate_qr_svg(
393
+ specimen,
394
+ format_type=encoding_lower, # type: ignore[arg-type]
395
+ error_correction=ec, # type: ignore[arg-type]
396
+ scheme=url_scheme,
397
+ base_url=base_url,
398
+ )
399
+ output.write_text(svg_data)
400
+ else: # base64
401
+ b64_data = generate_qr_base64(
402
+ specimen,
403
+ format_type=encoding_lower, # type: ignore[arg-type]
404
+ size=size,
405
+ error_correction=ec, # type: ignore[arg-type]
406
+ scheme=url_scheme,
407
+ base_url=base_url,
408
+ )
409
+ console.print(b64_data)
410
+ return
411
+
412
+ # Success output
413
+ console.print("\n[bold]QR Code Generated[/bold]")
414
+ console.print("=" * 40)
415
+ console.print(f"[cyan]Output:[/cyan] {output}")
416
+ console.print(f"[cyan]Format:[/cyan] {format_.upper()} ({size}x{size})")
417
+ console.print(f"[cyan]Encoding:[/cyan] {encoding_lower}")
418
+ if encoding_lower == "compact":
419
+ console.print(f"[cyan]Scheme:[/cyan] {url_scheme.value}")
420
+ file_size = output.stat().st_size
421
+ console.print(f"[cyan]Size:[/cyan] {file_size:,} bytes")
422
+
423
+ except typer.Exit:
424
+ raise
425
+ except Exception as e:
426
+ err_console.print(f"[red]Error: {e}[/red]")
427
+ raise typer.Exit(1)
428
+
429
+
430
+ @app.command()
431
+ def scan(
432
+ image: Annotated[
433
+ Path,
434
+ typer.Argument(help="QR code image file (PNG, JPEG)"),
435
+ ],
436
+ output: Annotated[
437
+ Path | None,
438
+ typer.Option("--output", "-o", help="Write specimen to file"),
439
+ ] = None,
440
+ json_output: Annotated[
441
+ bool,
442
+ typer.Option("--json", "-j", help="Output as JSON"),
443
+ ] = False,
444
+ ) -> None:
445
+ """Scan QR code image to extract specimen data."""
446
+ try:
447
+ from wols.qr import scan_qr
448
+ except ImportError as imp_exc:
449
+ err_console.print(
450
+ "[red]Error: MODULE_NOT_INSTALLED - QR scan module not installed[/red]"
451
+ )
452
+ err_console.print("Install with: pip install wols\\[qr]")
453
+ raise typer.Exit(2) from imp_exc
454
+
455
+ try:
456
+ if not image.exists():
457
+ err_console.print(
458
+ f"[red]Error: FILE_NOT_FOUND - Could not read file '{image}'[/red]"
459
+ )
460
+ raise typer.Exit(2)
461
+
462
+ # Scan QR code
463
+ from wols.models.specimen import Specimen
464
+
465
+ result = scan_qr(image)
466
+
467
+ if isinstance(result, Specimen):
468
+ # Full specimen
469
+ if json_output or output:
470
+ json_str = to_json(result, indent=2)
471
+ if output:
472
+ output.write_text(json_str)
473
+ console.print(f"[green]Specimen saved to {output}[/green]")
474
+ else:
475
+ console.print(json_str)
476
+ else:
477
+ console.print("\n[bold]Specimen Found[/bold]")
478
+ console.print("=" * 40)
479
+ console.print(f"[cyan]ID:[/cyan] {result.id}")
480
+ console.print(f"[cyan]Version:[/cyan] {result.version}")
481
+ console.print(f"[cyan]Type:[/cyan] {result.type.value}")
482
+ console.print(f"[cyan]Species:[/cyan] {result.species}")
483
+ if result.strain:
484
+ console.print(f"[cyan]Strain:[/cyan] {result.strain.name}")
485
+ else:
486
+ # SpecimenRef (compact URL)
487
+ if json_output:
488
+ output_data = {
489
+ "id": result.id,
490
+ "species_code": result.species_code,
491
+ "stage": result.stage.value if result.stage else None,
492
+ "params": result.params,
493
+ }
494
+ console.print(json.dumps(output_data, indent=2))
495
+ else:
496
+ console.print("\n[bold]Specimen Reference Found[/bold]")
497
+ console.print("=" * 40)
498
+ console.print(f"[cyan]ID:[/cyan] {result.id}")
499
+ if result.species_code:
500
+ console.print(f"[cyan]Species Code:[/cyan] {result.species_code}")
501
+ if result.stage:
502
+ console.print(f"[cyan]Stage:[/cyan] {result.stage.value}")
503
+ console.print(
504
+ "\n[dim]Note: Compact URL contains limited data."
505
+ " Use full embedded format for complete"
506
+ " specimen info.[/dim]"
507
+ )
508
+ except typer.Exit:
509
+ raise
510
+ except Exception as e:
511
+ err_console.print(f"[red]Error: {e}[/red]")
512
+ raise typer.Exit(1)
513
+
514
+
515
+ def main_cli() -> None:
516
+ """Entry point for the CLI."""
517
+ app()
518
+
519
+
520
+ if __name__ == "__main__":
521
+ main_cli()
wols/constants.py ADDED
@@ -0,0 +1,88 @@
1
+ """WOLS constants and configuration values.
2
+
3
+ Contains species codes, stage codes, and JSON-LD context definitions.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from enum import Enum
9
+ from typing import Literal
10
+
11
+ # WOLS specification version
12
+ WOLS_VERSION = "1.1.0"
13
+
14
+ # JSON-LD context URL
15
+ WOLS_CONTEXT = "https://wemush.com/wols/v1"
16
+
17
+ # ID prefix for specimen identifiers
18
+ ID_PREFIX = "wemush"
19
+
20
+
21
+ class UrlScheme(str, Enum):
22
+ """URL scheme options for compact URLs.
23
+
24
+ Attributes:
25
+ WEMUSH: Native app scheme (wemush://) - for native mobile apps.
26
+ WEB_WEMUSH: PWA-compatible scheme (web+wemush://) - for Progressive Web Apps.
27
+ HTTPS: Universal web scheme - works everywhere, requires backend.
28
+ """
29
+
30
+ WEMUSH = "wemush"
31
+ WEB_WEMUSH = "web+wemush"
32
+ HTTPS = "https"
33
+
34
+
35
+ # Type alias for URL scheme literals
36
+ UrlSchemeLiteral = Literal["wemush", "web+wemush", "https"]
37
+
38
+ # Default URL scheme
39
+ DEFAULT_URL_SCHEME: UrlScheme = UrlScheme.WEB_WEMUSH
40
+
41
+ # Default base URL for HTTPS scheme (can be overridden)
42
+ DEFAULT_HTTPS_BASE_URL = "https://wemush.com/s"
43
+
44
+ # All valid URL schemes for parsing (we accept any of these)
45
+ VALID_URL_SCHEMES = frozenset({"wemush", "web+wemush", "https"})
46
+
47
+ # Species codes for compact URL format
48
+ # Maps 2-letter codes to full scientific names
49
+ SPECIES_CODES: dict[str, str] = {
50
+ "PO": "Pleurotus ostreatus",
51
+ "PE": "Pleurotus eryngii",
52
+ "PC": "Pleurotus citrinopileatus",
53
+ "PP": "Pleurotus pulmonarius",
54
+ "GL": "Ganoderma lucidum",
55
+ "GA": "Ganoderma applanatum",
56
+ "LE": "Lentinula edodes",
57
+ "HE": "Hericium erinaceus",
58
+ "HC": "Hericium coralloides",
59
+ "FL": "Flammulina velutipes",
60
+ "AB": "Agaricus bisporus",
61
+ "AA": "Agaricus arvensis",
62
+ "PS": "Psilocybe cubensis",
63
+ "CA": "Cordyceps militaris",
64
+ "TA": "Trametes versicolor",
65
+ "GF": "Grifola frondosa",
66
+ "LP": "Laetiporus sulphureus",
67
+ "CM": "Cyclocybe aegerita",
68
+ "ST": "Stropharia rugosoannulata",
69
+ "PH": "Pholiota nameko",
70
+ "HY": "Hypsizygus tessellatus",
71
+ "CO": "Coprinus comatus",
72
+ "AM": "Armillaria mellea",
73
+ "MO": "Morchella esculenta",
74
+ }
75
+
76
+ # Reverse mapping: scientific name to code
77
+ SPECIES_NAMES: dict[str, str] = {v: k for k, v in SPECIES_CODES.items()}
78
+
79
+ # Stage codes for compact URL format
80
+ STAGE_CODES: dict[str, str] = {
81
+ "INO": "INOCULATION",
82
+ "COL": "COLONIZATION",
83
+ "FRU": "FRUITING",
84
+ "HAR": "HARVEST",
85
+ }
86
+
87
+ # Reverse mapping: stage name to code
88
+ STAGE_NAMES: dict[str, str] = {v: k for k, v in STAGE_CODES.items()}
wols/core/__init__.py ADDED
@@ -0,0 +1,18 @@
1
+ """WOLS core functionality.
2
+
3
+ Contains create, parse, validate, and serialize functions.
4
+ """
5
+
6
+ from wols.core.create import create_specimen
7
+ from wols.core.parse import parse_compact_url, parse_specimen
8
+ from wols.core.serialize import to_compact_url, to_json
9
+ from wols.core.validate import validate_specimen
10
+
11
+ __all__ = [
12
+ "create_specimen",
13
+ "parse_compact_url",
14
+ "parse_specimen",
15
+ "to_compact_url",
16
+ "to_json",
17
+ "validate_specimen",
18
+ ]