mirror of
git://git.psyced.org/git/pypsyc
synced 2024-08-15 03:20:04 +00:00
39 lines
1 KiB
Python
39 lines
1 KiB
Python
|
def parsetext(mmp, psyc):
|
||
|
"""string with variables of the form '[_varname]' to be substituted
|
||
|
by the value dictVariables['_varname']"""
|
||
|
pstring = psyc.get_text()
|
||
|
for (varname, value) in mmp.get_state().items():
|
||
|
pstring = pstring.replace('[' + varname + ']', value)
|
||
|
for (varname, value) in psyc.get_state().items():
|
||
|
pstring = pstring.replace('[' + varname + ']', value)
|
||
|
return pstring
|
||
|
|
||
|
def get_host(uni):
|
||
|
import re
|
||
|
|
||
|
m = re.match("^psyc:\/\/(.+)?\/~(.+)?\/?$", uni)
|
||
|
if m: return m.group(1)
|
||
|
|
||
|
m = re.match("^psyc:\/\/([^\/@]+)\@(.+?)\/?$", uni)
|
||
|
if m: return m.group(2)
|
||
|
|
||
|
m = re.match("^psyc:\/\/(.+)?\/\@(.+)?\/?$", uni)
|
||
|
if m: return m.group(1)
|
||
|
|
||
|
m = re.match("^psyc:\/\/(.+)$", uni)
|
||
|
if m: return m.group(1)
|
||
|
|
||
|
def get_place(uni):
|
||
|
import re
|
||
|
m = re.match("^psyc:\/\/(.+)?\/\@(.+)?\/?$", uni)
|
||
|
if m: return m.group(2)
|
||
|
|
||
|
def get_user(uni):
|
||
|
import re
|
||
|
m = re.match("^psyc:\/\/(.+)?\/~(.+)?\/?$", uni)
|
||
|
if m: return m.group(2)
|
||
|
|
||
|
m = re.match("^psyc:\/\/([^\/@]+)\@(.+?)\/?$", uni)
|
||
|
if m: return m.group(1)
|
||
|
|