Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/airflow/sdk/io/stat.py: 54%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

35 statements  

1# Licensed to the Apache Software Foundation (ASF) under one 

2# or more contributor license agreements. See the NOTICE file 

3# distributed with this work for additional information 

4# regarding copyright ownership. The ASF licenses this file 

5# to you under the Apache License, Version 2.0 (the 

6# "License"); you may not use this file except in compliance 

7# with the License. You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, 

12# software distributed under the License is distributed on an 

13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 

14# KIND, either express or implied. See the License for the 

15# specific language governing permissions and limitations 

16# under the License. 

17from __future__ import annotations 

18 

19from stat import S_IFDIR, S_IFLNK, S_IFREG 

20 

21 

22class stat_result(dict): 

23 """ 

24 stat_result: Result from stat, fstat, or lstat. 

25 

26 This object provides a subset of os.stat_result attributes, 

27 for results returned from ObjectStoragePath.stat() 

28 

29 It provides st_dev, st_ino, st_mode, st_nlink, st_uid, st_gid, 

30 st_size and st_mtime if they are available from the underlying 

31 storage. Extended attributes maybe accessed via dict access. 

32 

33 See os.stat for more information. 

34 """ 

35 

36 st_dev = property(lambda self: 0) 

37 """device""" 

38 

39 st_size = property(lambda self: self.get("size", 0)) 

40 """total size, in bytes""" 

41 

42 st_gid = property(lambda self: self.get("gid", 0)) 

43 """group ID of owner""" 

44 

45 st_uid = property(lambda self: self.get("uid", 0)) 

46 """user ID of owner""" 

47 

48 st_ino = property(lambda self: self.get("ino", 0)) 

49 """inode""" 

50 

51 st_nlink = property(lambda self: self.get("nlink", 0)) 

52 """number of hard links""" 

53 

54 @property 

55 def st_mtime(self): 

56 """Time of most recent content modification.""" 

57 if "mtime" in self: 

58 return self.get("mtime") 

59 

60 if "LastModified" in self: 

61 return self.get("LastModified").timestamp() 

62 

63 # per posix.py 

64 return 0 

65 

66 @property 

67 def st_mode(self): 

68 """Protection bits.""" 

69 if "mode" in self: 

70 return self.get("mode") 

71 

72 # per posix.py 

73 mode = 0o0 

74 if self.get("type", "") == "file": 

75 mode = S_IFREG 

76 

77 if self.get("type", "") == "directory": 

78 mode = S_IFDIR 

79 

80 if self.get("isLink", False): 

81 mode = S_IFLNK 

82 

83 return mode