color_tools.export
Export system for filaments and colors.
Provides export functionality to various formats (CSV, JSON) for integration with external tools like AutoForge, HueForge, and other color management systems.
Version 1.0 - Simple hardcoded formats, extensible architecture for future enhancements.
- color_tools.export.list_export_formats(data_type='both')[source]
List available export formats.
- Parameters:
data_type (
str) – Filter by ‘filaments’, ‘colors’, or ‘both’- Return type:
- Returns:
Dictionary mapping format name to description
Example
>>> formats = list_export_formats('filaments') >>> print(formats['autoforge']) AutoForge filament library CSV format
- color_tools.export.generate_filename(data_type, format_name)[source]
Generate timestamped filename for export.
- Parameters:
- Returns:
{type}_{format}_{YYYYMMDD}_{HHMMSS}.{ext}
- Return type:
Filename in format
Example
>>> generate_filename('filaments', 'autoforge') 'filaments_autoforge_20251223_143022.csv'
- color_tools.export.export_filaments_autoforge(filaments, output_path=None)[source]
Export filaments to AutoForge CSV format.
- Format:
Brand,Name,TD,Color,Owned Bambu Lab PLA Basic,Jet Black,0.1,#000000,TRUE
- Parameters:
filaments (
list[FilamentRecord]) – List of FilamentRecord objects to exportoutput_path (
Path|str|None) – Output file path (auto-generated if None)
- Return type:
- Returns:
Path to the exported file
Example
>>> from color_tools.palette import FilamentPalette >>> palette = FilamentPalette.load_default() >>> bambu = [f for f in palette.filaments if f.maker == 'Bambu Lab'] >>> path = export_filaments_autoforge(bambu) >>> print(f"Exported {len(bambu)} filaments to {path}")
- color_tools.export.export_filaments_csv(filaments, output_path=None)[source]
Export filaments to generic CSV format with all fields.
- Parameters:
filaments (
list[FilamentRecord]) – List of FilamentRecord objects to exportoutput_path (
Path|str|None) – Output file path (auto-generated if None)
- Return type:
- Returns:
Path to the exported file
Example
>>> from color_tools.palette import FilamentPalette >>> palette = FilamentPalette.load_default() >>> path = export_filaments_csv(palette.filaments)
- color_tools.export.export_filaments_json(filaments, output_path=None)[source]
Export filaments to JSON format.
- Parameters:
filaments (
list[FilamentRecord]) – List of FilamentRecord objects to exportoutput_path (
Path|str|None) – Output file path (auto-generated if None)
- Return type:
- Returns:
Path to the exported file
Example
>>> from color_tools.palette import FilamentPalette >>> palette = FilamentPalette.load_default() >>> path = export_filaments_json(palette.filaments, 'backup.json')
- color_tools.export.export_colors_csv(colors, output_path=None)[source]
Export colors to generic CSV format with all fields.
- Parameters:
colors (
list[ColorRecord]) – List of ColorRecord objects to exportoutput_path (
Path|str|None) – Output file path (auto-generated if None)
- Return type:
- Returns:
Path to the exported file
Example
>>> from color_tools.palette import Palette >>> palette = Palette.load_default() >>> path = export_colors_csv(palette.colors)
- color_tools.export.export_colors_json(colors, output_path=None)[source]
Export colors to JSON format.
- Parameters:
colors (
list[ColorRecord]) – List of ColorRecord objects to exportoutput_path (
Path|str|None) – Output file path (auto-generated if None)
- Return type:
- Returns:
Path to the exported file
Example
>>> from color_tools.palette import Palette >>> palette = Palette.load_default() >>> path = export_colors_json(palette.colors, 'my_colors.json')
- color_tools.export.export_filaments(filaments, format_name, output_path=None)[source]
Export filaments to specified format.
- Parameters:
- Return type:
- Returns:
Path to the exported file
- Raises:
ValueError – If format is not supported for filaments
Example
>>> from color_tools.palette import FilamentPalette >>> palette = FilamentPalette.load_default() >>> bambu = [f for f in palette.filaments if f.maker == 'Bambu Lab'] >>> path = export_filaments(bambu, 'autoforge')
- color_tools.export.export_colors(colors, format_name, output_path=None)[source]
Export colors to specified format.
- Parameters:
- Return type:
- Returns:
Path to the exported file
- Raises:
ValueError – If format is not supported for colors
Example
>>> from color_tools.palette import Palette >>> palette = Palette.load_default() >>> blues = [c for c in palette.colors if 'blue' in c.name.lower()] >>> path = export_colors(blues, 'json', 'blue_colors.json')