- Create backend/services/image_storage.py with 4 core functions:
- sanitize_filename(): remove unsafe chars, limit to 255 chars, convert to lowercase
- get_unique_filename(): handle collisions with UUID suffix (format: {name}_{uuid8}_{variant}.jpg)
- ensure_image_directories(): create /images/ root and category subdirs on startup
- save_image(): save bytes to /images/{category}/{filename}, returns relative path
- Create comprehensive test suite (22 tests) covering all functionality
- Integrate ensure_image_directories() into FastAPI startup event
- Directory structure: /images/{category}/{filename}
- Collision handling: auto-suffix with UUID if filename exists
- All tests passing, pathlib.Path for safe operations
55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
"""
|
|
pygments.styles.rrt
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
pygments "rrt" theme, based on Zap and Emacs defaults.
|
|
|
|
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
from pygments.style import Style
|
|
from pygments.token import (
|
|
Comment,
|
|
Generic,
|
|
Keyword,
|
|
Name,
|
|
Number,
|
|
Operator,
|
|
String,
|
|
Token,
|
|
)
|
|
|
|
__all__ = ['RrtStyle']
|
|
|
|
|
|
class RrtStyle(Style):
|
|
"""
|
|
Minimalistic "rrt" theme, based on Zap and Emacs defaults.
|
|
"""
|
|
|
|
name = 'rrt'
|
|
|
|
background_color = '#000000'
|
|
highlight_color = '#0000ff'
|
|
|
|
styles = {
|
|
Token: '#dddddd',
|
|
Comment: '#00ff00',
|
|
Generic.Emph: '#ffffff',
|
|
Generic.Heading: '#ffff00',
|
|
Generic.Subheading: '#ffff00',
|
|
Generic.Strong: '#ffffff',
|
|
Name.Entity: '#eedd82',
|
|
Name.Function: '#ffff00',
|
|
Name.Variable: '#eedd82',
|
|
Name.Tag: '#7fffd4',
|
|
Name.Constant: '#7fffd4',
|
|
Keyword: '#ff0000',
|
|
Operator.Word: '#ff0000',
|
|
Comment.Preproc: '#e5e5e5',
|
|
String: '#87ceeb',
|
|
Keyword.Type: '#ee82ee',
|
|
Number: '#ff00ff',
|
|
}
|