Ejemplo n.º 1
0
    def toStr(cls, lang, i, **kwargs):
        i += 1
        daf_num = i / 2
        daf = ""

        if i > daf_num * 2:
            en_daf = "%db" % daf_num
        else:
            en_daf = "%da" % daf_num

        if lang == "en":
            daf = en_daf

        elif lang == "he":
            dotted = kwargs.get("dotted")
            if dotted:
                daf = encode_hebrew_daf(en_daf)
            else:
                punctuation = kwargs.get("punctuation", True)
                if i > daf_num * 2:
                    daf = ("%s " % encode_hebrew_numeral(daf_num, punctuation=punctuation)) + u"\u05D1"
                else:
                    daf = ("%s " % encode_hebrew_numeral(daf_num, punctuation=punctuation)) + u"\u05D0"

        return daf
Ejemplo n.º 2
0
def section_to_daf(section, lang="en"):
    """
    Transforms a section number to its corresponding daf string,
    in English or in Hebrew.
    """
    section += 1
    daf = section / 2

    if lang == "en":
        if section > daf * 2:
            daf = u"{}b".format(daf)
        else:
            daf = u"{}a".format(daf)

    elif lang == "he":
        if section > daf * 2:
            daf = u"{}{}".format(
                sanitize(encode_small_hebrew_numeral(daf), False) if daf < 1200
                else encode_hebrew_numeral(daf, punctuation=False), ':')
        else:
            daf = u"{}{}".format(
                sanitize(encode_small_hebrew_numeral(daf), False) if daf < 1200
                else encode_hebrew_numeral(daf, punctuation=False), '.')

    return daf
Ejemplo n.º 3
0
def daf_yomi(datetime_obj):
    """
    Returns the daf yomi for date
    """
    date_str = datetime_obj.strftime(" %m/ %d/%Y").replace(" 0", "").replace(
        " ", "")
    daf = db.dafyomi.find_one({"date": date_str})
    rf = model.Ref(daf["daf"] + "a")
    name = daf["daf"]
    daf_num = int(daf["daf"].split(" ")[-1])
    daf_num_he = encode_hebrew_numeral(daf_num)
    name_he = u"{} {}".format(rf.he_book(), daf_num_he)

    return {
        'title': {
            'en': 'Daf Yomi',
            'he': u'דף יומי'
        },
        'displayValue': {
            'en': name,
            'he': name_he
        },
        'url': rf.url(),
        'order': 3,
        'category': rf.index.get_primary_category()
    }
Ejemplo n.º 4
0
 def test_encodes_and_decodes_correctly(self):
     for x in range(1, 5000):
         if x in (2000, 3000, 4000, 5000):
             # known ambiguity with single thousands above 1000
             pass
         else:
             assert x == h.decode_hebrew_numeral(h.encode_hebrew_numeral(x))
Ejemplo n.º 5
0
 def test_encodes_and_decodes_correctly(self):
     for x in range(1, 5000):
         if x in (2000, 3000, 4000, 5000):
             # known ambiguity with single thousands above 1000
             pass
         else:
             assert x == h.decode_hebrew_numeral(h.encode_hebrew_numeral(x))
Ejemplo n.º 6
0
    def toStr(lang, i):
        i += 1
        daf = i / 2

        if lang == "en":
            if i > daf * 2:
                daf = "%db" % daf
            else:
                daf = "%da" % daf

        elif lang == "he":
            if i > daf * 2:
                daf = ("%s " % encode_hebrew_numeral(daf)) + u"\u05D1"
            else:
                daf = ("%s " % encode_hebrew_numeral(daf)) + u"\u05D0"

        return daf
Ejemplo n.º 7
0
    def toStr(lang, i):
        i += 1
        daf = i / 2

        if lang == "en":
            if i > daf * 2:
                daf = "%db" % daf
            else:
                daf = "%da" % daf

        elif lang == "he":
            if i > daf * 2:
                daf = ("%s " % encode_hebrew_numeral(daf)) + u"\u05D1"
            else:
                daf = ("%s " % encode_hebrew_numeral(daf)) + u"\u05D0"

        return daf
Ejemplo n.º 8
0
def section_to_daf(section, lang="en"):
    """
    Transforms a section number to its corresponding daf string,
    in English or in Hebrew.
    """
    section += 1
    daf = section / 2

    if lang == "en":
        if section > daf * 2:
            daf = u"{}b".format(daf)
        else:
            daf = u"{}a".format(daf)

    elif lang == "he":
        if section > daf * 2:
            daf = u"{}{}".format(encode_hebrew_numeral(daf, punctuation=False), ':')
        else:
            daf = u"{}{}".format(encode_hebrew_numeral(daf, punctuation=False), '.')

    return daf
Ejemplo n.º 9
0
def section_to_daf(section, lang="en"):
    """
    Transforms a section number to its corresponding daf string,
    in English or in Hebrew.
    """
    section += 1
    daf = section / 2

    if lang == "en":
        if section > daf * 2:
            daf = "%db" % daf
        else:
            daf = "%da" % daf

    elif lang == "he":
        if section > daf * 2:
            daf = ("%s " % encode_hebrew_numeral(daf)) + u"\u05D1"
        else:
            daf = ("%s " % encode_hebrew_numeral(daf)) + u"\u05D0"

    return daf
Ejemplo n.º 10
0
 def toStr(self, lang, i):
     if lang == "en":
         return str(i)
     if lang == "he":
         return encode_hebrew_numeral(i)
Ejemplo n.º 11
0
 def test_can_encode_without_errors(self):
     for x in range(1, 5000):
         _ = h.encode_hebrew_numeral(x)
Ejemplo n.º 12
0
 def test_can_encode_without_errors(self):
     for x in range(1, 5000):
         _ = h.encode_hebrew_numeral(x)
Ejemplo n.º 13
0
 def toStr(self, lang, i):
     if lang == "en":
         return str(i)
     if lang == "he":
         return encode_hebrew_numeral(i)
Ejemplo n.º 14
0
    u"אורות_ארץ_ישראל_פרק" + u"_":
    (u"Orot, Lights from Darkness, Land of Israel", 8, 2),
    u"אורות_המלחמה_פרק" + u"_": (u"Orot, Lights from Darkness, War", 10, 2),
    u"אורות_ישראל_ותחייתו_פרק" + u"_":
    (u"Orot, Lights from Darkness, Israel and its Rebirth", 32, 2),
    u"אורות_התחיה_פרק" + u"_":
    (u"Orot, Lights from Darkness, Lights of Rebirth", 72,
     2),  # 34 - length 4, 12 - length 3, 5 - length 2
}

for url, (node_addr, r, offset) in sections_bases.iteritems():
    print url
    node_data = []
    for i in range(1, r + 1):
        print str(i) + u" "
        full_url = base + url + encode_hebrew_numeral(i, False)
        node_data += [get_single(full_url, offset)]
    j["text"] = node_data
    postText(server, apikey, node_addr, j)

# 1-layered text on numbered sub-pages
sections_bases = {
    u"אורות_ישראל_פרק_ב_פסקה" + u"_":
    (u"Orot, Lights of Israel, The Individual and the Collective", 8, 0),
    u"אורות_ישראל_פרק_ג_פסקה" + u"_":
    (u"Orot, Lights of Israel, Connection to the Collective", 11, 0),
    u"אורות_ישראל_פרק_ד_פסקה" + u"_":
    (u"Orot, Lights of Israel, Love of Israel", 10, 0),
}

for url, (node_addr, r, offset) in sections_bases.iteritems():
Ejemplo n.º 15
0
 def toStr(cls, lang, i, **kwargs):
     if lang == "en":
         return str(i)
     elif lang == "he":
         punctuation = kwargs.get("punctuation", True)
         return encode_hebrew_numeral(i, punctuation=punctuation)

# 2-Layered texts on numbered sub pages
sections_bases = {
    u"אורות_ארץ_ישראל_פרק" + u"_" : (u"Orot, Lights from Darkness, Land of Israel", 8, 2),
    u"אורות_המלחמה_פרק" + u"_" :  (u"Orot, Lights from Darkness, War", 10, 2),
    u"אורות_ישראל_ותחייתו_פרק" + u"_" : (u"Orot, Lights from Darkness, Israel and its Rebirth", 32, 2),
    u"אורות_התחיה_פרק" + u"_" : (u"Orot, Lights from Darkness, Lights of Rebirth", 72, 2), # 34 - length 4, 12 - length 3, 5 - length 2
}

for url, (node_addr, r, offset) in sections_bases.iteritems():
    print url
    node_data = []
    for i in range(1, r + 1):
        print str(i) + u" "
        full_url = base + url + encode_hebrew_numeral(i, False)
        node_data += [get_single(full_url, offset)]
    j["text"] = node_data
    postText(server, apikey, node_addr, j)

# 1-layered text on numbered sub-pages
sections_bases = {
    u"אורות_ישראל_פרק_ב_פסקה" + u"_" : (u"Orot, Lights of Israel, The Individual and the Collective", 8, 0),
    u"אורות_ישראל_פרק_ג_פסקה" + u"_" : (u"Orot, Lights of Israel, Connection to the Collective", 11, 0),
    u"אורות_ישראל_פרק_ד_פסקה" + u"_" : (u"Orot, Lights of Israel, Love of Israel", 10, 0),
}

for url, (node_addr, r, offset) in sections_bases.iteritems():
    print url
    node_data = []
    for i in range(1, r + 1):