This repository has been archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctmod.py
80 lines (70 loc) · 2.34 KB
/
ctmod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
'''
Update a CTMod Addon
'''
__author__ = "Patrick Butler <[email protected]>"
__version__ = "$Revision: 31 $"
__copyright__ = "Copyright 2005,2006 Patrick Butler"
__license__ = "GPL Version 2"
import wowaddon
import re
import os
import urllib
class Plugin(wowaddon.Plugin):
def __init__(self, updater, args):
wowaddon.Plugin.__init__(self, updater, args)
if (args[0] == ""):
raise "Need id"
self.id = args[0].strip();
self.name = self.id
self.type = "CTMod"
def getinfo(self):
if self.timemutex(60):
return
self.out("Checking CTMod:%s version..." % self.id )
try:
data = urllib.urlopen("http://www.ctmod.net/downloads.ct").read()
except IOError, e:
raise wowaddon.DownloadError(e)
rows = re.split("<tr>", data)
version = ""
for r in rows:
match = re.search(r"<b>\s*"+self.id + r"\s*</b>\s*(v[0-9.]+\s*\(\d+\))", r, re.I and re.S)
if match != None:
version = match.group(1)
if(version == ""):
raise wowaddon.ParseError
self.newversion = version
self.link = "http://www.ctmod.net/downloads.ct?a=download&m=" + self.id
self.name = self.id + " " + self.newversion
self.zipfilename = self.id + ".zip"
def help():
return """
You must download each mod separately, and if you download one then you probably need to get CT_MasterMod. The argument may be obtained at http://www.ctmod.net/downloads.ct . Use the name of the mod, paying attention to the capitalization eg. CT_MasterMod, CT_BottomBar, CT_BagMod
"""
def search():
ret = []
try:
data = urllib.urlopen("http://www.ctmod.net/downloads.ct").read()
except IOError:
raise wowaddon.DownloadError
rows = re.split("<tr[^>]*>", data)
for r in rows:
match = re.search(r"<b>\s*([^<]*?)</b>\s*(v[0-9.]+\s*\(\d+\))", r, re.I and re.S)
if match != None:
ret.append(match.group(1) )
if ret == []:
raise wowaddon.ParseError
return ret
def argdesc():
return [ {
'title' : 'CTMod',
'type' : 'func',
'type1' : 'None',
'func' : Plugin.search,
'desc' : 'The following page will allow you to install the CTMods of your choice.\nPlease make sure to install CT_Mastermod with whatever else you install' ,
'desc2' : 'Which CTMod module would you like to install?' } ];
help = staticmethod(help)
search = staticmethod(search)
argdesc = staticmethod(argdesc)
wowaddon.addModType("CTMod", Plugin)