Skip to content

Commit

Permalink
CONTENT_TYPE_TO_EXTENSIONS constant in helpers module
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Mar 19, 2024
1 parent f4c3306 commit c4833f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## [Unreleased]
### Added
- `CONTENT_TYPE_TO_EXTENSIONS` constant in `helpers` module, by @HardNorth

## [5.5.5]
### Added
Expand Down
29 changes: 20 additions & 9 deletions reportportal_client/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import time
import uuid
from platform import machine, processor, system
from types import MappingProxyType
from typing import Optional, Any, List, Dict, Callable, Tuple, Union, TypeVar, Generic

from reportportal_client.core.rp_file import RPFile
Expand All @@ -32,6 +33,25 @@
TRUNCATE_REPLACEMENT: str = '...'
BYTES_TO_READ_FOR_DETECTION = 128

CONTENT_TYPE_TO_EXTENSIONS = MappingProxyType({
'application/pdf': 'pdf',
'application/zip': 'zip',
'application/java-archive': 'jar',
'image/jpeg': 'jpg',
'image/png': 'png',
'image/gif': 'gif',
'image/bmp': 'bmp',
'image/vnd.microsoft.icon': 'ico',
'image/webp': 'webp',
'audio/mpeg': 'mp3',
'audio/wav': 'wav',
'video/mpeg': 'mpeg',
'video/avi': 'avi',
'video/webm': 'webm',
'text/plain': 'txt',
'application/octet-stream': 'bin'
})


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


TYPICAL_MULTIPART_BOUNDARY: str = '--972dbca3abacfd01fb4aea0571532b52'

TYPICAL_JSON_PART_HEADER: str = TYPICAL_MULTIPART_BOUNDARY + '''\r
Content-Disposition: form-data; name="json_request_part"\r
Content-Type: application/json\r
\r
'''

TYPICAL_FILE_PART_HEADER: str = TYPICAL_MULTIPART_BOUNDARY + '''\r
Content-Disposition: form-data; name="file"; filename="{0}"\r
Content-Type: {1}\r
\r
'''

TYPICAL_JSON_PART_HEADER_LENGTH: int = len(TYPICAL_JSON_PART_HEADER)

TYPICAL_MULTIPART_FOOTER: str = '\r\n' + TYPICAL_MULTIPART_BOUNDARY + '--'

TYPICAL_MULTIPART_FOOTER_LENGTH: int = len(TYPICAL_MULTIPART_FOOTER)

TYPICAL_JSON_ARRAY: str = '[]'

TYPICAL_JSON_ARRAY_LENGTH: int = len(TYPICAL_JSON_ARRAY)

TYPICAL_JSON_ARRAY_ELEMENT: str = ','

TYPICAL_JSON_ARRAY_ELEMENT_LENGTH: int = len(TYPICAL_JSON_ARRAY_ELEMENT)


Expand Down

0 comments on commit c4833f3

Please sign in to comment.