Пример #1
0
def search_strongs_dictionary_table(query, field):
    # initialize tagpy table object
    tbl = table(Class='data')
    # add head row columns
    tbl.addHeadRow(h.tr(h.th('Lemma'), h.th('Word'), h.th('Transliteration'), h.th('Translation'), h.th('Isopsephy')))
    # make search. if field is isopsephy, force search item to int type
    rows = find(int(query) if field == 'isopsephy' else re.compile(query, re.IGNORECASE), field)
    for i, item in rows.iterrows():
        tbl.addBodyRow(h.tr(h.td(item.lemma), h.td(item.word), h.td(item.transliteration), h.td(item.translation), h.td(item.isopsephy)))
    return tbl
Пример #2
0
def search_strongs_dictionary_table(query, field):
    # initialize tagpy table object
    tbl = table(Class='data')
    # add head row columns
    tbl.addHeadRow(
        h.tr(h.th('Lemma'), h.th('Word'), h.th('Transliteration'),
             h.th('Translation'), h.th('Isopsephy')))
    # make search. if field is isopsephy, force search item to int type
    rows = find(
        int(query) if field == 'isopsephy' else re.compile(
            query, re.IGNORECASE), field)
    for i, item in rows.iterrows():
        tbl.addBodyRow(
            h.tr(h.td(item.lemma), h.td(item.word), h.td(item.transliteration),
                 h.td(item.translation), h.td(item.isopsephy)))
    return tbl
Пример #3
0
def char_table(text, modulo=9):
    # initialize html table
    tbl = table(Class="char-table")
    # add caption / table title
    tbl.addCaption(text)
    # add data rows
    tr1 = h.tr()  # greek letters
    tr2 = h.tr()  # roman letters
    tr3 = h.tr()  # isopsephy number
    tr4 = h.tr()  # summary
    i = 0
    text = unicode(text, encoding="utf-8")
    for word in text.split():
        if i > 0:
            # add empty cells for word separation
            tr1 += h.th(" ")
            tr1 += h.th(" ")
            tr2 += h.td()
            tr2 += h.td(Class="empty-cell")
            tr3 += h.td()
            tr3 += h.td(Class="empty-cell")
            tr4 += h.td()
            tr4 += h.td()
        num = unicode_isopsephy(word)
        tr4 += h.td("%s %s" % (num, h.sub(digital_root(num))),
                    colspan=len(word))
        i = i + 1
        # add each letter on own cell
        for letter in word:
            tr1 += h.th(letter.encode('utf-8'))
            tr2 += h.td(to_roman(letter.encode('utf-8')))
            tr3 += h.td(unicode_isopsephy(letter))
    # add rows to table
    tbl.addHeadRow(tr1)
    tbl.addBodyRow(tr2)
    tbl.addBodyRow(tr3)
    tbl.addFootRow(tr4)
    # add summary footer for table
    num = unicode_isopsephy(text)
    tbl.addFootRow(
        h.tr(
            h.td("%s %s" %
                 (num, h.sub(digital_sum(num), " / ", digital_root(
                     num, modulo))),
                 colspan=len(text) + len(text.split()),
                 style="border-top: solid 1px #ddd")))
    return tbl
Пример #4
0
 def char_table(self, text, modulo=9):
     # initialize html table
     tbl = table(Class="char-table")
     # add caption / table title
     tbl.addCaption(text)
     # add data rows
     tr1 = h.tr()  # script letters
     tr2 = h.tr()  # roman letters
     tr3 = h.tr()  # value
     tr4 = h.tr()  # summary
     i = 0
     for word in text.split():
         if i > 0:
             # add empty cells for word separation
             tr1 += h.th(" ")
             tr1 += h.th(" ")
             tr2 += h.td()
             tr2 += h.td(Class="empty-cell")
             tr3 += h.td()
             tr3 += h.td(Class="empty-cell")
             tr4 += h.td()
             tr4 += h.td()
         num = self.unicode_value(word)
         tr4 += h.td("%s %s" % (num, h.sub(digital_root(num))),
                     colspan=len(word))
         i = i + 1
         # add each letter on own cell
         for letter in word:
             tr1 += h.th(letter)
             tr2 += h.td(self.convert(letter))
             tr3 += h.td(self.unicode_value(letter))
     # add rows to table
     tbl.addHeadRow(tr1)
     tbl.addBodyRow(tr2)
     tbl.addBodyRow(tr3)
     tbl.addFootRow(tr4)
     # add summary footer for table
     num = self.unicode_value(text)
     tbl.addFootRow(
         h.tr(
             h.td("%s %s" % (num,
                             h.sub(digital_sum(num), " / ",
                                   digital_root(num, modulo))),
                  colspan=len(text) + len(text.split()),
                  style="border-top: solid 1px #ddd")))
     return tbl
Пример #5
0
def char_table(text, modulo = 9):
    # initialize html table
    tbl = table(Class="char-table")
    # add caption / table title
    tbl.addCaption(text)
    # add data rows
    tr1 = h.tr() # hebrew letters
    tr2 = h.tr() # roman letters
    tr3 = h.tr() # gematria number
    tr4 = h.tr() # summary
    i = 0
    text = unicode(text, encoding="utf-8")
    for word in text.split():
        if i > 0:
            # add empty cells for word separation
            tr1 += h.th(" ")
            tr1 += h.th(" ")
            tr2 += h.td()
            tr2 += h.td(Class="empty-cell")
            tr3 += h.td()
            tr3 += h.td(Class="empty-cell")
            tr4 += h.td()
            tr4 += h.td()
        num = unicode_gematria(word)
        tr4 += h.td("%s %s" % (num, h.sub(digital_root(num))), colspan=len(word))
        i = i+1
        # add each letter on own cell
        for letter in word:
            tr1 += h.th(letter.encode('utf-8'))
            tr2 += h.td(to_roman(letter.encode('utf-8')))
            tr3 += h.td(unicode_gematria(letter))
    # add rows to table
    tbl.addHeadRow(tr1)
    tbl.addBodyRow(tr2)
    tbl.addBodyRow(tr3)
    tbl.addFootRow(tr4)
    # add summary footer for table
    num = unicode_gematria(text)
    tbl.addFootRow(h.tr(h.td("%s %s" % (num, h.sub(digital_sum(num), " / ", digital_root(num, modulo))), 
                             colspan=len(text)+len(text.split()), 
                             style="border-top: solid 1px #ddd")))
    return tbl
Пример #6
0
 def char_table(self, text, modulo = 9):
     # initialize html table
     tbl = table(Class="char-table")
     # add caption / table title
     tbl.addCaption(text)
     # add data rows
     tr1 = h.tr() # script letters
     tr2 = h.tr() # roman letters
     tr3 = h.tr() # value
     tr4 = h.tr() # summary
     i = 0
     for word in text.split():
         if i > 0:
             # add empty cells for word separation
             tr1 += h.th(" ")
             tr1 += h.th(" ")
             tr2 += h.td()
             tr2 += h.td(Class="empty-cell")
             tr3 += h.td()
             tr3 += h.td(Class="empty-cell")
             tr4 += h.td()
             tr4 += h.td()
         num = self.unicode_value(word)
         tr4 += h.td("%s %s" % (num, h.sub(digital_root(num))), colspan=len(word))
         i = i+1
         # add each letter on own cell
         for letter in word:
             tr1 += h.th(letter)
             tr2 += h.td(self.convert(letter))
             tr3 += h.td(self.unicode_value(letter))
     # add rows to table
     tbl.addHeadRow(tr1)
     tbl.addBodyRow(tr2)
     tbl.addBodyRow(tr3)
     tbl.addFootRow(tr4)
     # add summary footer for table
     num = self.unicode_value(text)
     tbl.addFootRow(h.tr(h.td("%s %s" % (num, h.sub(digital_sum(num), " / ", digital_root(num, modulo))),
                              colspan=len(text)+len(text.split()),
                              style="border-top: solid 1px #ddd")))
     return tbl
Пример #7
0
    def runtests(self, line=None, cell=None, filename='<input>'):
        """
        The %runtests magic searches your IPython namespace for functions
        with names that begin with 'test_'. It will attempt to run these
        functions (calling them with no arguments), and report whether they
        pass, fail (raise an AssertionError), or error (raise any other
        kind of error).

        For tests that fail or error %runtests will show the exception raised
        but not the traceback, so write informative messages!
        """

        import collections
        import time

        ip = get_ipython()

        tests = {}

        # collect tests, only find functions that start with 'test'
        for k, v in ip.user_ns.items():
            if k.startswith('test') and isinstance(
                    v, collections.Callable) and ((not line) or
                                                  (k not in tests_run)):
                tests[k] = v
                tests_run[k] = True

        # initialize table object
        tbl = table(CLASS='data')
        tbl.addColGroup(h.col(), h.col())
        tbl.addCaption('Collected {} tests.\n'.format(len(tests)))
        tbl.addHeadRow(h.tr(h.th('Test function name'), h.th('Status')))

        # run tests
        ok = 0
        fail = {}
        error = {}

        t1 = time.time()

        for name, func in tests.items():
            try:
                func()
            except AssertionError as e:
                msg = 'failed'
                fail[name] = e
            except Exception as e:
                msg = 'error'
                error[name] = e
            else:
                msg = 'successful'
                ok += 1
            tbl.addBodyRow(h.tr(h.td(name), h.td(msg), Class=msg))

        t2 = time.time()

        # collect info on any failures
        if fail:
            tbl.addBodyRows(h.tr(h.th("Failed", span=2)))
            trs = []
            for name, e in fail.items():
                trs.append(h.tr(h.td(name), h.td(repr(e))))
            tbl.addBodyRows(*trs, CLASS='failures')

        # collect info on any errors
        if error:
            tbl.addBodyRows(h.tr(h.th("Errors", span=2)))
            trs = []
            for name, e in error.items():
                trs.append(h.tr(h.td(name), h.td(repr(e))))
            tbl.addBodyRows(*trs, CLASS='errors')

        # summary and timer of the tests
        tbl.addFootRow(
            h.tr(h.td('Successful', Class="right"), h.td('{}'.format(ok))))
        tbl.addFootRow(
            h.tr(h.td('Failed', Class="right"), h.td('{}'.format(len(fail)))))
        tbl.addFootRow(
            h.tr(h.td('Errors', Class="right"), h.td('{}'.format(len(error)))))
        tbl.addFootRow(
            h.tr(h.td("Execution", Class="right"),
                 h.td('{:.4g} seconds'.format(t2 - t1))))

        # return html table string
        return HTML(str(tbl))
Пример #8
0
def runaway(line):
    """
    The %runaway magic searches your IPython namespace for functions
    with names that begin with 'test'. It will attempt to run these
    functions (calling them with no arguments), and report whether they
    pass, fail (raise an AssertionError), or error (raise any other
    kind of error).

    For tests that fail or error %runaway will show the exception raised
    but not the traceback, so write informative messages!

    """
    import collections
    import time

    ip = get_ipython()

    tests = {}

    # collect tests, only find functions that start with 'test'
    for k, v in ip.user_ns.items():
        if k.startswith('test') and isinstance(v, collections.Callable):
            tests[k] = v

    # initialize table object
    tbl = table(CLASS='data')
    tbl.addColGroup(h.col(), h.col())
    tbl.addCaption('Collected {} tests.\n'.format(len(tests)))
    tbl.addHeadRow(h.tr(h.th('Test function name'), h.th('Status')))

    # run tests
    ok = 0
    fail = {}
    error = {}

    t1 = time.time()

    for name, func in tests.items():
        try:
            func()
        except AssertionError as e:
            msg = 'failed'
            fail[name] = e
        except Exception as e:
            msg = 'error'
            error[name] = e
        else:
            msg = 'successful'
            ok += 1
        tbl.addBodyRow(h.tr(h.td(name), h.td(msg), Class=msg))

    t2 = time.time()

    # collect info on any failures
    if fail:
        tbl.addBodyRows(h.tr(h.th("Failed", span=2)))
        trs = []
        for name, e in fail.items():
            trs.append(h.tr(h.td(name), h.td(repr(e))))
        tbl.addBodyRows(*trs, CLASS='failures')

    # collect info on any errors
    if error:
        tbl.addBodyRows(h.tr(h.th("Errors", span=2)))
        trs = []
        for name, e in error.items():
            trs.append(h.tr(h.td(name), h.td(repr(e))))
        tbl.addBodyRows(*trs, CLASS='errors')

    # summary and timer of the tests
    tbl.addFootRow(h.tr(h.td('Successful', Class="right"), h.td('{}'.format(ok))))
    tbl.addFootRow(h.tr(h.td('Failed',     Class="right"), h.td('{}'.format(len(fail)))))
    tbl.addFootRow(h.tr(h.td('Errors',     Class="right"), h.td('{}'.format(len(error)))))
    tbl.addFootRow(h.tr(h.td("Execution",  Class="right"), h.td('{:.4g} seconds'.format(t2 - t1))))

    # return html table string
    return HTML(str(tbl))