Update index.py

pull/628/head
Mr Chen 7 months ago
parent 8ad9153012
commit e5386ab01c
  1. 16
      plugins/gogs/index.py

@ -173,12 +173,12 @@ def initDreplace():
def getRootUrl(): def getRootUrl():
content = mw.readFile(getConf()) content = mw.readFile(getConf())
rep = r'ROOT_URL\s*=\s*(.*)' rep = r'ROOT_URL\\s*=\\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if tmp: if tmp:
return tmp.groups()[0] return tmp.groups()[0]
rep = r'EXTERNAL_URL\s*=\s*(.*)' rep = r'EXTERNAL_URL\\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if tmp: if tmp:
return tmp.groups()[0] return tmp.groups()[0]
@ -187,7 +187,7 @@ def getRootUrl():
def getSshPort(): def getSshPort():
content = mw.readFile(getConf()) content = mw.readFile(getConf())
rep = r'SSH_PORT\s*=\s*(.*)' rep = r'SSH_PORT\\s*=\\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
return '' return ''
@ -196,7 +196,7 @@ def getSshPort():
def getHttpPort(): def getHttpPort():
content = mw.readFile(getConf()) content = mw.readFile(getConf())
rep = r'HTTP_PORT\s*=\s*(.*)' rep = r'HTTP_PORT\\s*=\\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
return '' return ''
@ -205,7 +205,7 @@ def getHttpPort():
def getRootPath(): def getRootPath():
content = mw.readFile(getConf()) content = mw.readFile(getConf())
rep = r'ROOT\s*=\s*(.*)' rep = r'ROOT\\s*=\\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if not tmp: if not tmp:
return '' return ''
@ -218,10 +218,10 @@ def getDbConfValue():
return {} return {}
content = mw.readFile(conf) content = mw.readFile(conf)
rep_scope = r"\[database\](.*?)\[" rep_scope = r"\\[database\\](.*?)\\["
tmp = re.findall(rep_scope, content, re.S) tmp = re.findall(rep_scope, content, re.S)
rep = r'(\w*)\s*=\s*(.*)' rep = r'(\\w*)\\s*=\\s*(.*)'
tmp = re.findall(rep, tmp[0]) tmp = re.findall(rep, tmp[0])
r = {} r = {}
for x in range(len(tmp)): for x in range(len(tmp)):
@ -448,7 +448,7 @@ def submitGogsConf():
conf = mw.readFile(filename) conf = mw.readFile(filename)
for g in gets: for g in gets:
if g in args: if g in args:
rep = g + '\s*=\s*(.*)' rep = g + '\\s*=\\s*(.*)'
val = g + ' = ' + args[g] val = g + ' = ' + args[g]
conf = re.sub(rep, val, conf) conf = re.sub(rep, val, conf)
mw.writeFile(filename, conf) mw.writeFile(filename, conf)

Loading…
Cancel
Save