python: add wrap_character alias to wrap_char - refs #1427

This commit is contained in:
Dane Springmeyer 2012-08-21 14:48:10 -07:00
parent d069ce7405
commit 6a0df52b1c
3 changed files with 30 additions and 0 deletions

View file

@ -793,6 +793,18 @@ class _TextSymbolizer(TextSymbolizer,_injector):
self.format.wrap_char = wrap_char
@property
def wrap_character(self):
warnings.warn("'wrap_character' is deprecated, use format.wrap_character",
DeprecationWarning, 2)
return self.format.wrap_character
@wrap_char.setter
def wrap_character(self, wrap_character):
warnings.warn("'wrap_char' is deprecated, use format.wrap_character",
DeprecationWarning, 2)
self.format.wrap_character = wrap_character
@property
def wrap_before(self):

View file

@ -402,6 +402,7 @@ void export_text_placement()
.def_readwrite("line_spacing", &char_properties::line_spacing)
.def_readwrite("text_opacity", &char_properties::text_opacity)
.def_readwrite("wrap_char", &char_properties::wrap_char)
.def_readwrite("wrap_character", &char_properties::wrap_char)
.def_readwrite("wrap_before", &char_properties::wrap_before)
.def_readwrite("fill", &char_properties::fill)
.def_readwrite("halo_fill", &char_properties::halo_fill)
@ -489,6 +490,7 @@ void export_text_placement()
.def_readwrite_convert("line_spacing", &formatting::format_node::line_spacing)
.def_readwrite_convert("text_opacity", &formatting::format_node::text_opacity)
.def_readwrite_convert("wrap_char", &formatting::format_node::wrap_char)
.def_readwrite_convert("wrap_character", &formatting::format_node::wrap_char)
.def_readwrite_convert("wrap_before", &formatting::format_node::wrap_before)
.def_readwrite_convert("text_transform", &formatting::format_node::text_transform)
.def_readwrite_convert("fill", &formatting::format_node::fill)
@ -528,6 +530,7 @@ void export_text_placement()
.def_readwrite("line_spacing", &formatting::expression_format::line_spacing)
.def_readwrite("text_opacity", &formatting::expression_format::text_opacity)
.def_readwrite("wrap_char", &formatting::expression_format::wrap_char)
.def_readwrite("wrap_character", &formatting::expression_format::wrap_char)
.def_readwrite("wrap_before", &formatting::expression_format::wrap_before)
.def_readwrite("fill", &formatting::expression_format::fill)
.def_readwrite("halo_fill", &formatting::expression_format::halo_fill)

View file

@ -34,6 +34,21 @@ def test_line_symbolizer_stroke_reference():
def test_text_symbolizer_init():
s = mapnik.TextSymbolizer()
eq_(s.text_transform, mapnik.text_transform.NONE)
# https://github.com/mapnik/mapnik/issues/1427
eq_(s.wrap_char,ord(' '))
eq_(s.wrap_character,ord(' '))
s.wrap_char = ord('\n')
eq_(s.wrap_char,ord('\n'))
eq_(s.wrap_character,ord('\n'))
eq_(s.format.wrap_character,ord('\n'))
s.wrap_character = ord('\r')
eq_(s.wrap_char,ord('\r'))
eq_(s.wrap_character,ord('\r'))
eq_(s.format.wrap_character,ord('\r'))
s.format.wrap_character = ord(' ')
eq_(s.wrap_char,ord(' '))
eq_(s.wrap_character,ord(' '))
eq_(s.format.wrap_character,ord(' '))
# ShieldSymbolizer initialization
def test_shieldsymbolizer_init():