Merge pull request #6 from evennia/master

Update
This commit is contained in:
delizin 2014-02-01 15:04:23 -08:00
commit 32ae069a0c
4 changed files with 21 additions and 21 deletions

View file

@ -15,6 +15,7 @@ user.
"""
import re
from src.utils import utils
from src.utils.utils import to_str
# ANSI definitions
@ -355,7 +356,7 @@ class ANSIString(unicode):
string to be handled as already decoded. It is important not to double
decode strings, as escapes can only be respected once.
"""
string = args[0]
string = to_str(args[0], force_string=True)
if not isinstance(string, basestring):
string = str(string)
parser = kwargs.get('parser', ANSI_PARSER)

View file

@ -1,7 +1,6 @@
# coding=utf-8
"""
Evform - a way to create advanced ascii forms
Mudform - a way to create advanced ascii forms
This is intended for creating advanced ascii game forms, such as a
large pretty character sheet or info document.
@ -68,11 +67,11 @@ Use as follows:
7: 18,
8: 10,
9: 3})
# create the MudTables
tableA = mudform.MudTable("HP","MV","MP",
# create the EvTables
tableA = mudform.EvTable("HP","MV","MP",
table=[["**"], ["*****"], ["***"]],
border="incols")
tableB = mudform.MudTable("Skill", "Value", "Exp",
tableB = mudform.EvTable("Skill", "Value", "Exp",
table=[["Shooting", "Herbalism", "Smithing"],
[12,14,9],["550/1200", "990/1400", "205/900"]],
border="incols")
@ -102,10 +101,10 @@ This produces the following result:
| |**|* | Herbalism |14 |990/1400 |
| |* | | Smithing |9 |205/900 |
| | |
------------------------------------------------
`----------------------------------------------´
The marked forms have been replaced with Cells of text and with
MudTables. The form can be updated by simply re-applying form.map()
EvTables. The form can be updated by simply re-applying form.map()
with the updated data.
When working with the template ascii file, you can use form.reload()
@ -121,7 +120,7 @@ form will raise an error.
import re
import copy
from src.utils.mudtable import Cell, MudTable
from src.utils.evtable import Cell, EvTable
from src.utils.utils import all_from_module, to_str, to_unicode
# non-valid form-identifying characters (which can thus be
@ -131,7 +130,7 @@ from src.utils.utils import all_from_module, to_str, to_unicode
INVALID_FORMCHARS = r"\s\/\|\\\*\_\-\#\<\>\~\^\:\;\.\,"
class MudForm(object):
class EvForm(object):
"""
This object is instantiated with a text file and parses
it for rectangular form fields. It can then be fed a
@ -151,10 +150,10 @@ class MudForm(object):
"FORM":templatestring}
if this is given, filename is not read.
cells - a dictionary mapping of {id:text}
tables - dictionary mapping of {id:MudTable}
tables - dictionary mapping of {id:EvTable}
other kwargs are fed as options to the Cells and MudTablets
(see mudtablet.Cell and mudtablet.MudTablet for more info).
other kwargs are fed as options to the Cells and EvTables
(see evtablet.Cell and evtable.EvTable for more info).
"""
self.filename = filename
@ -304,7 +303,7 @@ class MudForm(object):
if table:
table.reformat(width=width, height=height, **options)
else:
table = MudTable(width=width, height=height, **options)
table = EvTable(width=width, height=height, **options)
mapping[key] = (iyup, leftix, width, height, table)
return mapping
@ -331,7 +330,7 @@ class MudForm(object):
tables - a dictionary of {identifier:table}
kwargs will be forwarded to tables/cells. See
mudtable.Cell and mudtable.MudTable for info.
evtable.Cell and evtable.EvTable for info.
"""
# clean kwargs (these cannot be overridden)

View file

@ -7,7 +7,7 @@ FORMCHAR = "x"
TABLECHAR = "c"
FORM = """
.------------------------------------------------.
{c.------------------------------------------------.
| |
| Name: xxxxx1xxxxx Player: xxxxxxx2xxxxxxx |
| xxxxxxxxxxx |

View file

@ -1,7 +1,7 @@
# coding=utf-8
"""
Mudtable
EvTable
This is an advanced ASCII table creator. It was inspired
by prettytable but shares no code.
@ -9,7 +9,7 @@ by prettytable but shares no code.
Example usage:
table = MudTable("Heading1", "Heading2", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells")
table = EvTable("Heading1", "Heading2", table=[[1,2,3],[4,5,6],[7,8,9]], border="cells")
table.add_column("This is long data", "This is even longer data")
table.add_row("This is a single row")
print table
@ -78,7 +78,7 @@ def make_iter(obj):
return not hasattr(obj, '__iter__') and [obj] or obj
# Cell class (see further down for the MudTable itself)
# Cell class (see further down for the EvTable itself)
class Cell(object):
"""
@ -446,9 +446,9 @@ class Cell(object):
return "\n".join(self.formatted)
# Main Mudtable class
# Main Evtable class
class MudTable(object):
class EvTable(object):
"""
Table class.