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

21 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-22 16:02 -0400

1""" 

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

3 

4METADATA: 

5 

6File: metadata.py 

7 Project: paperap 

8Created: 2025-03-18 

9 Version: 0.0.9 

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 

24import pydantic 

25 

26from paperap.models.abstract import StandardModel 

27 

28 

29class MetadataElement(pydantic.BaseModel): 

30 """ 

31 Represents metadata for a document in Paperless-NgX. 

32 

33 This is a key-value pair of metadata information. 

34 """ 

35 

36 key: str 

37 value: str 

38 

39 

40class DocumentMetadata(StandardModel): 

41 """ 

42 Represents a Paperless-NgX document's metadata. 

43 

44 Attributes: 

45 original_checksum: The checksum of the original document. 

46 original_size: The size of the original document in bytes. 

47 original_mime_type: The MIME type of the original document. 

48 media_filename: The filename of the media file. 

49 has_archive_version: Whether the document has an archive version. 

50 original_metadata: Metadata of the original document. 

51 archive_checksum: The checksum of the archived document. 

52 archive_media_filename: The filename of the archived media file. 

53 original_filename: The original filename of the document. 

54 lang: The language of the document. 

55 archive_size: The size of the archived document in bytes. 

56 archive_metadata: Metadata of the archived document. 

57 

58 """ 

59 

60 original_checksum: str | None = None 

61 original_size: int | None = None 

62 original_mime_type: str | None = None 

63 media_filename: str | None = None 

64 has_archive_version: bool | None = None 

65 original_metadata: list[MetadataElement] = [] 

66 archive_checksum: str | None = None 

67 archive_media_filename: str | None = None 

68 original_filename: str | None = None 

69 lang: str | None = None 

70 archive_size: int | None = None 

71 archive_metadata: list[MetadataElement] = [] 

72 

73 class Meta(StandardModel.Meta): 

74 read_only_fields = { 

75 "original_checksum", 

76 "original_size", 

77 "original_mime_type", 

78 "media_filename", 

79 "has_archive_version", 

80 "original_metadata", 

81 "archive_checksum", 

82 "archive_media_filename", 

83 "original_filename", 

84 "lang", 

85 "archive_size", 

86 "archive_metadata", 

87 }