User:WindBOT/CoreSource: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
m (dees pen surr)
mNo edit summary
Line 30: Line 30:
import wikiUpload
import wikiUpload
import feedparser
import feedparser
import steam
# Hax for Python < 2.7
try:
from collections import OrderedDict
except:
from backport_OrderedDict import OrderedDict
import collections
collections.OrderedDict = OrderedDict
try:
import steam
except:
steam = None
from wikiUpload import wikiUploader
from wikiUpload import wikiUploader


Line 201: Line 211:
except:
except:
warning('Couldn\'t update edit count.')
warning('Couldn\'t update edit count.')
# Because SOME LIBRARY will not use singletons, this has to be done at the bot level
# rather than the individual filter level to avoid loading the damn thing twice.
steamGameSchemas = {}
def steamGetGameSchema(game):
global steamGameSchemas
if steam is None:
return None
if game not in steamGameSchemas:
steamGameSchemas[game] = game.item_schema()
return steamGameSchemas[game]
steamGameAssets = {}
def steamGetGameAssets(game):
global steamGameAssets
if steam is None:
return None
if game not in steamGameAssets:
steamGameAssets[game] = game.assets()
return steamGameAssets[game]


def compileRegex(regex, flags=re.IGNORECASE):
def compileRegex(regex, flags=re.IGNORECASE):
Line 586: Line 615:
content = content.replace(s[0], s[1])
content = content.replace(s[0], s[1])
return content
return content
def regReplaceCallBack(sub, match):
def regReplaceCallBack(sub, match):
groupcount = 1
groupcount = 1
Line 995: Line 1,023:
except:
except:
error('Couldn\'t grab page', p)
error('Couldn\'t grab page', p)
coderegex = compileRegex(r'^(?: [^\r\n]*(?:[\r\n]+|$))+', re.MULTILINE)
coderegex = compileRegex(r'^(?: [^\r\n]*(?:[\r\n]+|$))+', re.MULTILINE)
trimcode = compileRegex(r'^ |</?nowiki>', re.MULTILINE)
trimcode = compileRegex(r'^ |</?nowiki>', re.MULTILINE)
for m in coderegex.finditer(code):
for m in coderegex.finditer(code):
try:
try:

Navigation menu