3
# Copyright (C) 2012 Yahoo! Inc.
5
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License version 3, as
9
# published by the Free Software Foundation.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
def __init__(self, _merger, opts):
22
self._append = 'append' in opts
24
# On encountering a unicode object to merge value with
25
# we will for now just proxy into the string method to let it handle it.
26
def _on_unicode(self, value, merge_with):
27
return self._on_str(value, merge_with)
29
# On encountering a string object to merge with we will
30
# perform the following action, if appending we will
31
# merge them together, otherwise we will just return value.
32
def _on_str(self, value, merge_with):
36
if isinstance(value, (unicode)):
37
return value + unicode(merge_with)
39
return value + str(merge_with)