def join(values, encoding=None): # {{{1 """Joins a list into a config value.""" if not encoding: encoding = ENCODING strbuf = StringIO() writer = csv.writer(strbuf, dialect=ConfigDialect) writer.writerow(encode(values, encoding)) return decode(strbuf.getvalue().strip(), encoding)
def tag_message(tag, message): message = white(encode(condense(message), encoding=ENCODING)) return bold(' '.join([tag, message]))
def split(value, encoding=None): # {{{1 """Splits config value into a list.""" if not encoding: encoding = ENCODING reader = csv.reader([encode(value, encoding)], dialect=ConfigDialect) return [v.strip().decode(encoding) for v in tuple(reader)[0]]
def encode(self, value): return encode(value, self.encoding)