View difference between Paste ID: hFhZjdCu and XyAjSk9q
SHOW: | | - or go back to the newest paste.
1
import es
2
import os
3-
import path
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-
class DownloadPath(path.path):
13+
14
    basepath = str(es.ServerVar('eventscripts_gamedir'))
15
    
16
    def __init__(self, other):
17
        self.other = other
18-
        path.path.__init__(self, os.path.join(DownloadPath.basepath, other))
18+
19
        
20
    def __str__(self):
21
        return os.path.join(DownloadPath.basepath, self)
22
        
23
    def addDownload(self):
24-
            es.stringtable('downloadables', str(f[0]).split(DownloadPath.basepath + os.sep)[1])
24+
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()