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:
43
venv/lib/python3.12/site-packages/pygments/lexers/cplint.py
Normal file
43
venv/lib/python3.12/site-packages/pygments/lexers/cplint.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
pygments.lexers.cplint
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Lexer for the cplint language
|
||||
|
||||
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from pygments.lexer import bygroups, inherit, words
|
||||
from pygments.lexers import PrologLexer
|
||||
from pygments.token import Operator, Keyword, Name, String, Punctuation
|
||||
|
||||
__all__ = ['CplintLexer']
|
||||
|
||||
|
||||
class CplintLexer(PrologLexer):
|
||||
"""
|
||||
Lexer for cplint files, including CP-logic, Logic Programs with Annotated
|
||||
Disjunctions, Distributional Clauses syntax, ProbLog, DTProbLog.
|
||||
"""
|
||||
name = 'cplint'
|
||||
url = 'https://cplint.eu'
|
||||
aliases = ['cplint']
|
||||
filenames = ['*.ecl', '*.prolog', '*.pro', '*.pl', '*.P', '*.lpad', '*.cpl']
|
||||
mimetypes = ['text/x-cplint']
|
||||
version_added = '2.12'
|
||||
|
||||
tokens = {
|
||||
'root': [
|
||||
(r'map_query', Keyword),
|
||||
(words(('gaussian', 'uniform_dens', 'dirichlet', 'gamma', 'beta',
|
||||
'poisson', 'binomial', 'geometric', 'exponential', 'pascal',
|
||||
'multinomial', 'user', 'val', 'uniform', 'discrete',
|
||||
'finite')), Name.Builtin),
|
||||
# annotations of atoms
|
||||
(r'([a-z]+)(:)', bygroups(String.Atom, Punctuation)),
|
||||
(r':(-|=)|::?|~=?|=>', Operator),
|
||||
(r'\?', Name.Builtin),
|
||||
inherit,
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user