Advertisement
Brainsucker

Untitled

May 29th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import es
  2. import os
  3.  
  4. class DownloadHandler:
  5.     downloads = []
  6.    
  7.     @staticmethod
  8.     def downloadAll():
  9.         for d in DownloadHandler.downloads:
  10.             d.addDownload()
  11.  
  12. class DownloadPath(str):
  13.  
  14.     basepath = str(es.ServerVar('eventscripts_gamedir'))
  15.    
  16.     def __init__(self, other):
  17.         self.other = other
  18.         DownloadHandler.downloads.append(self)
  19.        
  20.     def __str__(self):
  21.         return os.path.join(DownloadPath.basepath, self)
  22.        
  23.     def addDownload(self):
  24.         for f in self.files():
  25.             es.stringtable('downloadables', os.path.join(self.other, f))
  26.            
  27.     def getContent(self):
  28.         return os.listdir(str(self))
  29.            
  30.     def files(self):
  31.         return [x for x in self.getContent() if os.path.isfile(os.path.join(str(self), x))]
  32.        
  33.     def dirs(self):
  34.         return [x for x in self.getContent() if os.path.isidr(os.path.join(str(self), x))]
  35.            
  36.            
  37. # Bitte in diesem Bereich alle deine Pfade angeben, die heruntergeladen werden sollen.
  38.  
  39. DownloadPath('maps')
  40. DownloadPath('sound/ordner/und/so/weiter')
  41. # DownloadPath('')
  42.  
  43.  
  44. # Nichts Editieren!
  45.          
  46. def es_map_start(ev):
  47.     DownloadHandler.downloadAll()
  48.    
  49. def load():
  50.     DownloadHandler.downloadAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement