Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1. import sys
  2.  
  3. class File:
  4.     def __init__(self, path):
  5.         self.path = path
  6.         self.contents = []
  7.    
  8.     def add_content(self, *content):
  9.         for item in content:
  10.             self.contents.append(item)
  11.    
  12.     def show(self):
  13.         for item in self.contents:
  14.             print(item)
  15.        
  16.     def rename(self, new_path):
  17.         self.path = new_path
  18.        
  19.     def remove(self):
  20.         self.content = []
  21.         self.path = ""
  22.        
  23.     def size(self):
  24.         size = sum([sys.getsizeof(item) for item in self.contents])
  25.         return size,sys.getsizeof(self.contents),sys.getsizeof(self)
  26.    
  27.     def info(self):
  28.         return self.path, self.contents
  29.        
  30. class MediaFile(File):
  31.     def __init__(self,path,codec,geoloc,duration):
  32.         super().__init__(path)
  33.         self.codec = codec
  34.         self.geoloc = geoloc
  35.         self.duration = duration
  36.        
  37.     def info(self):
  38.         return super().info(),self.codec,self.geoloc,self.duration
  39.    
  40.  
  41. class VideoFile(MediaFile):
  42.     def __init__(self,path,codec,geoloc,duration,dimensions):
  43.         super().__init__(path,codec,geoloc,duration)
  44.         self.dimensions = dimensions
  45.        
  46.     def info(self):
  47.         return vars(self)
  48.    
  49. Video1 = VideoFile("/home/python/vanrossum.mp4","h264",(23.21325,35.34534),487,(1920,1080))
  50.  
  51. Video1.add_content('Hello','world')
  52. print(Video1.info())
  53. print(Video1.size())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement