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:
59
venv/lib/python3.12/site-packages/pygments/lexers/tlb.py
Normal file
59
venv/lib/python3.12/site-packages/pygments/lexers/tlb.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""
|
||||
pygments.lexers.tlb
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Lexers for TL-b.
|
||||
|
||||
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from pygments.lexer import RegexLexer, include, words
|
||||
from pygments.token import Operator, Name, \
|
||||
Number, Whitespace, Punctuation, Comment
|
||||
|
||||
__all__ = ['TlbLexer']
|
||||
|
||||
|
||||
class TlbLexer(RegexLexer):
|
||||
"""
|
||||
For TL-b source code.
|
||||
"""
|
||||
|
||||
name = 'Tl-b'
|
||||
aliases = ['tlb']
|
||||
filenames = ['*.tlb']
|
||||
url = 'https://docs.ton.org/#/overviews/TL-B'
|
||||
version_added = ''
|
||||
|
||||
tokens = {
|
||||
'root': [
|
||||
(r'\s+', Whitespace),
|
||||
|
||||
include('comments'),
|
||||
|
||||
(r'[0-9]+', Number),
|
||||
(words((
|
||||
'+', '-', '*', '=', '?', '~', '.',
|
||||
'^', '==', '<', '>', '<=', '>=', '!='
|
||||
)), Operator),
|
||||
(words(('##', '#<', '#<=')), Name.Tag),
|
||||
(r'#[0-9a-f]*_?', Name.Tag),
|
||||
(r'\$[01]*_?', Name.Tag),
|
||||
|
||||
(r'[a-zA-Z_][0-9a-zA-Z_]*', Name),
|
||||
|
||||
(r'[;():\[\]{}]', Punctuation)
|
||||
],
|
||||
|
||||
'comments': [
|
||||
(r'//.*', Comment.Singleline),
|
||||
(r'/\*', Comment.Multiline, 'comment'),
|
||||
],
|
||||
'comment': [
|
||||
(r'[^/*]+', Comment.Multiline),
|
||||
(r'/\*', Comment.Multiline, '#push'),
|
||||
(r'\*/', Comment.Multiline, '#pop'),
|
||||
(r'[*/]', Comment.Multiline),
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user