feat(phase1): add image storage utilities
- 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
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
pygments.lexers.procfile
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Lexer for Procfile file format.
|
||||
|
||||
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from pygments.lexer import RegexLexer, bygroups
|
||||
from pygments.token import Name, Number, String, Text, Punctuation
|
||||
|
||||
__all__ = ["ProcfileLexer"]
|
||||
|
||||
|
||||
class ProcfileLexer(RegexLexer):
|
||||
"""
|
||||
Lexer for Procfile file format.
|
||||
|
||||
The format is used to run processes on Heroku or is used by Foreman or
|
||||
Honcho tools.
|
||||
"""
|
||||
name = 'Procfile'
|
||||
url = 'https://devcenter.heroku.com/articles/procfile#procfile-format'
|
||||
aliases = ['procfile']
|
||||
filenames = ['Procfile']
|
||||
version_added = '2.10'
|
||||
|
||||
tokens = {
|
||||
'root': [
|
||||
(r'^([a-z]+)(:)', bygroups(Name.Label, Punctuation)),
|
||||
(r'\s+', Text.Whitespace),
|
||||
(r'"[^"]*"', String),
|
||||
(r"'[^']*'", String),
|
||||
(r'[0-9]+', Number.Integer),
|
||||
(r'\$[a-zA-Z_][\w]*', Name.Variable),
|
||||
(r'(\w+)(=)(\w+)', bygroups(Name.Variable, Punctuation, String)),
|
||||
(r'([\w\-\./]+)', Text),
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user