Skip to content

Commit c4833f3

Browse files
committed
CONTENT_TYPE_TO_EXTENSIONS constant in helpers module
1 parent f4c3306 commit c4833f3

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Added
5+
- `CONTENT_TYPE_TO_EXTENSIONS` constant in `helpers` module, by @HardNorth
46

57
## [5.5.5]
68
### Added

reportportal_client/helpers.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import time
2323
import uuid
2424
from platform import machine, processor, system
25+
from types import MappingProxyType
2526
from typing import Optional, Any, List, Dict, Callable, Tuple, Union, TypeVar, Generic
2627

2728
from reportportal_client.core.rp_file import RPFile
@@ -32,6 +33,25 @@
3233
TRUNCATE_REPLACEMENT: str = '...'
3334
BYTES_TO_READ_FOR_DETECTION = 128
3435

36+
CONTENT_TYPE_TO_EXTENSIONS = MappingProxyType({
37+
'application/pdf': 'pdf',
38+
'application/zip': 'zip',
39+
'application/java-archive': 'jar',
40+
'image/jpeg': 'jpg',
41+
'image/png': 'png',
42+
'image/gif': 'gif',
43+
'image/bmp': 'bmp',
44+
'image/vnd.microsoft.icon': 'ico',
45+
'image/webp': 'webp',
46+
'audio/mpeg': 'mp3',
47+
'audio/wav': 'wav',
48+
'video/mpeg': 'mpeg',
49+
'video/avi': 'avi',
50+
'video/webm': 'webm',
51+
'text/plain': 'txt',
52+
'application/octet-stream': 'bin'
53+
})
54+
3555

3656
class LifoQueue(Generic[_T]):
3757
"""Primitive thread-safe Last-in-first-out queue implementation."""
@@ -310,31 +330,22 @@ def get_function_params(func: Callable, args: tuple, kwargs: Dict[str, Any]) ->
310330

311331

312332
TYPICAL_MULTIPART_BOUNDARY: str = '--972dbca3abacfd01fb4aea0571532b52'
313-
314333
TYPICAL_JSON_PART_HEADER: str = TYPICAL_MULTIPART_BOUNDARY + '''\r
315334
Content-Disposition: form-data; name="json_request_part"\r
316335
Content-Type: application/json\r
317336
\r
318337
'''
319-
320338
TYPICAL_FILE_PART_HEADER: str = TYPICAL_MULTIPART_BOUNDARY + '''\r
321339
Content-Disposition: form-data; name="file"; filename="{0}"\r
322340
Content-Type: {1}\r
323341
\r
324342
'''
325-
326343
TYPICAL_JSON_PART_HEADER_LENGTH: int = len(TYPICAL_JSON_PART_HEADER)
327-
328344
TYPICAL_MULTIPART_FOOTER: str = '\r\n' + TYPICAL_MULTIPART_BOUNDARY + '--'
329-
330345
TYPICAL_MULTIPART_FOOTER_LENGTH: int = len(TYPICAL_MULTIPART_FOOTER)
331-
332346
TYPICAL_JSON_ARRAY: str = '[]'
333-
334347
TYPICAL_JSON_ARRAY_LENGTH: int = len(TYPICAL_JSON_ARRAY)
335-
336348
TYPICAL_JSON_ARRAY_ELEMENT: str = ','
337-
338349
TYPICAL_JSON_ARRAY_ELEMENT_LENGTH: int = len(TYPICAL_JSON_ARRAY_ELEMENT)
339350

340351

0 commit comments

Comments
 (0)