Coverage for src/paperap/models/document/download/model.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-20 13:17 -0400

1""" 

2---------------------------------------------------------------------------- 

3 

4METADATA: 

5 

6File: download.py 

7 Project: paperap 

8Created: 2025-03-18 

9 Version: 0.0.8 

10Author: Jess Mann 

11Email: jess@jmann.me 

12 Copyright (c) 2025 Jess Mann 

13 

14---------------------------------------------------------------------------- 

15 

16LAST MODIFIED: 

17 

182025-03-18 By Jess Mann 

19 

20""" 

21 

22from __future__ import annotations 

23 

24from enum import Enum 

25from typing import Any, Optional 

26 

27from paperap.const import URLS 

28from paperap.models.abstract import StandardModel 

29 

30 

31class RetrieveFileMode(str, Enum): 

32 """Enum for document file retrieval modes.""" 

33 

34 DOWNLOAD = "download" 

35 PREVIEW = "preview" 

36 THUMBNAIL = "thumbnail" 

37 

38 

39class DownloadedDocument(StandardModel): 

40 """ 

41 Represents a downloaded Paperless-NgX document file. 

42 

43 Attributes: 

44 mode: The retrieval mode (download, preview, thumbnail). 

45 original: Whether to retrieve the original file. 

46 content: The binary content of the file. 

47 content_type: The MIME type of the file. 

48 disposition_filename: The filename from the Content-Disposition header. 

49 disposition_type: The type from the Content-Disposition header. 

50 

51 """ 

52 

53 mode: RetrieveFileMode | None = None 

54 original: bool = False 

55 content: bytes | None = None 

56 content_type: str | None = None 

57 disposition_filename: str | None = None 

58 disposition_type: str | None = None 

59 

60 class Meta(StandardModel.Meta): 

61 read_only_fields = {"content", "content_type", "disposition_filename", "disposition_type"}