mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 17:56:32 +01:00
Added unittests for utils.py dedent() and list_to_string(). Adjusted list_to_string to correctly handle no endsep.
This commit is contained in:
parent
12c2402dac
commit
11ea572f00
2 changed files with 35 additions and 6 deletions
|
|
@ -110,16 +110,20 @@ def list_to_string(inlist, endsep="and", addquote=False):
|
|||
with addquote and endsep
|
||||
[1,2,3] -> '"1", "2" and "3"'
|
||||
"""
|
||||
if not endsep:
|
||||
endsep = ","
|
||||
else:
|
||||
endsep = " " + endsep
|
||||
if not inlist:
|
||||
return ""
|
||||
if addquote:
|
||||
if len(inlist) == 1:
|
||||
return "\"%s\"" % inlist[0]
|
||||
return ", ".join("\"%s\"" % v for v in inlist[:-1]) + " %s %s" % (endsep, "\"%s\"" % inlist[-1])
|
||||
return ", ".join("\"%s\"" % v for v in inlist[:-1]) + "%s %s" % (endsep, "\"%s\"" % inlist[-1])
|
||||
else:
|
||||
if len(inlist) == 1:
|
||||
return str(inlist[0])
|
||||
return ", ".join(str(v) for v in inlist[:-1]) + " %s %s" % (endsep, inlist[-1])
|
||||
return ", ".join(str(v) for v in inlist[:-1]) + "%s %s" % (endsep, inlist[-1])
|
||||
|
||||
|
||||
def wildcard_to_regexp(instring):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue