Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/git/objects/blob.py: 71%

17 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# blob.py 

2# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors 

3# 

4# This module is part of GitPython and is released under 

5# the BSD License: http://www.opensource.org/licenses/bsd-license.php 

6from mimetypes import guess_type 

7from . import base 

8 

9from git.types import Literal 

10 

11__all__ = ("Blob",) 

12 

13 

14class Blob(base.IndexObject): 

15 

16 """A Blob encapsulates a git blob object""" 

17 

18 DEFAULT_MIME_TYPE = "text/plain" 

19 type: Literal["blob"] = "blob" 

20 

21 # valid blob modes 

22 executable_mode = 0o100755 

23 file_mode = 0o100644 

24 link_mode = 0o120000 

25 

26 __slots__ = () 

27 

28 @property 

29 def mime_type(self) -> str: 

30 """ 

31 :return: String describing the mime type of this file (based on the filename) 

32 :note: Defaults to 'text/plain' in case the actual file type is unknown.""" 

33 guesses = None 

34 if self.path: 

35 guesses = guess_type(str(self.path)) 

36 return guesses and guesses[0] or self.DEFAULT_MIME_TYPE