Esempio n. 1
0
 def write_line(values, underline=u""):
     strings = [cypher_str(value).splitlines(False) for value in values]
     height = max(map(len, strings)) if strings else 1
     for y in range(height):
         line_text = u""
         underline_text = u""
         for x, _ in enumerate(values):
             try:
                 text = strings[x][y]
             except IndexError:
                 text = u""
             if auto_align and self._fields[x]["numeric"]:
                 text = space + text.rjust(widths[x]) + space
                 u_text = underline * len(text)
             else:
                 text = space + text.ljust(widths[x]) + space
                 u_text = underline * len(text)
             if x > 0:
                 text = separator + text
                 u_text = separator + u_text
             line_text += text
             underline_text += u_text
         if underline:
             line_text += newline + underline_text
         line_text += newline
         print(line_text, end=u"", file=file)
Esempio n. 2
0
 def write_tr(values, tag):
     print(u"<tr>", end="", file=file)
     for i, value in enumerate(values):
         if tag == "th":
             template = u'<{}>{}</{}>'
         elif auto_align and self._fields[i]["numeric"]:
             template = u'<{} style="text-align:right">{}</{}>'
         else:
             template = u'<{} style="text-align:left">{}</{}>'
         print(template.format(tag, html_escape(cypher_str(value)), tag), end="", file=file)
     print(u"</tr>", end="", file=file)
Esempio n. 3
0
 def calc_widths(values, **_):
     strings = [cypher_str(value).splitlines(False) for value in values]
     for i, s in enumerate(strings):
         w = max(map(len, s)) if s else 0
         if w > widths[i]:
             widths[i] = w
Esempio n. 4
0
 def list_parameter_sets(self):
     for data in self.parameter_sets:
         self.console.write(cypher_str(data))
     num_sets = len(self.parameter_sets)
     self.console.write_metadata("({} parameter set{})".format(
         num_sets, "" if num_sets == 1 else "s"))
Esempio n. 5
0
def test_cypher_str_on_bytes():
    assert cypher_str(b"hello, world") == u"hello, world"
Esempio n. 6
0
 def __getattr__(self, key):
     from py2neo.cypher import cypher_str
     return cypher_str(self.__items.get(key, self.__default_value),
                       **self.__kwargs)