def fetch(self, country_id):
        fetch_state = False
        scope = ['https://spreadsheets.google.com/feeds']
        credentials = ServiceAccountCredentials.from_json_keyfile_name(
            'client-secret.json', scope)
        sh = gspread.authorize(credentials).open_by_key(
            '1SjJG2RzITf8qAmYDU9RFnWVaMP9912y8KfbuJe8th-c')

        country_id = str(country_id)
        for ws_count, worksheet in enumerate(sh.worksheets()):
            # TODO write State By Country Here

            state_district = seeds.get_state_name(worksheet.title)
            state_name = "{0}/{1}".format(state_district[0], state_district[1])
            state_id = str(uuid.uuid4().hex)
            state = State(id=state_id,
                          object_id=state_id,
                          country_id=str(country_id),
                          name_mm_uni=str(state_name),
                          name_mm_zawgyi=Rabbit.uni2zg(state_name))
            cal_day_list = worksheet.col_values(1)
            hij_day_list = worksheet.col_values(2)
            sehri_time_list = worksheet.col_values(3)
            iftari_time_list = worksheet.col_values(4)

            db_session.add(state)
            db_session.commit()
            for i, (cal_day, hij_day, seh_time, iftar_time) in enumerate(
                    zip(cal_day_list, hij_day_list, sehri_time_list,
                        iftari_time_list)):
                if i is not 0:
                    article_id = str(uuid.uuid4().hex)
                    article = Day(
                        id=article_id,
                        object_id=article_id,
                        country_id=str(country_id),
                        state_id=str(state.object_id),
                        day=i,
                        day_mm=str(seeds.get_mm_num(i)),
                        sehri_time=str(seh_time + " am"),
                        sehri_time_desc="Sehri",
                        calendar_day=str(cal_day),
                        hijari_day=str(hij_day),
                        sehri_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါချည်ချိန်"),
                        sehri_time_desc_mm_uni="ဝါချည်ချိန်",
                        iftari_time=str(iftar_time + " pm"),
                        dua_mm_uni=Rabbit.zg2uni(seeds.daily_dua(i)["dua_mm"]),
                        dua_mm_zawgyi=Rabbit.uni2zg(
                            seeds.daily_dua(i)["dua_mm"]),
                        dua_ar=seeds.daily_dua(i)["dua_ar"],
                        dua_en=seeds.daily_dua(i)["dua_en"],
                        iftari_time_desc="Iftari",
                        iftari_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါဖြေချိန်"),
                        iftari_time_desc_mm_uni="ဝါဖြေချိန်")

                    db_session.add(article)
                    db_session.commit()
                    fetch_state = True

        return fetch_state
Exemple #2
0
    def test_uni2zg(self):
        print("converting Unicode to Zawgyi")
        converted = Rabbit.uni2zg(u"မင်္ဂလာပါ")
        self.assertEqual(converted, u"မဂၤလာပါ")

        converted = Rabbit.uni2zg(u"ပြင်သစ်ဘာသာကီးဘုတ်")
        self.assertEqual(converted, u"ျပင္သစ္ဘာသာကီးဘုတ္")
Exemple #3
0
    def fetch(self, country_id):

        fname = join(dirname(dirname(abspath(__file__))), 'ramdhan-api/data',
                     'ramadan_timetable_sheet.xlsx')
        work_book = xlrd.open_workbook(fname)

        country_id = str(country_id)
        for ws_count, worksheet in enumerate(work_book.sheet_names()):
            # TODO write State By Country Here

            state_district = seeds.get_state_name(worksheet)
            state_name = "{0}/{1}".format(state_district[0], state_district[1])
            state_id = str(uuid.uuid4().hex)
            state = State(id=state_id,
                          object_id=state_id,
                          country_id=str(country_id),
                          name_mm_uni=str(state_name),
                          name_mm_zawgyi=Rabbit.uni2zg(state_name))
            sheet = work_book.sheet_by_index(ws_count)
            cal_day_list = sheet.col_values(0)
            hij_day_list = sheet.col_values(1)
            sehri_time_list = sheet.col_values(2)
            iftari_time_list = sheet.col_values(3)

            db_session.add(state)
            db_session.commit()
            for i, (cal_day, hij_day, seh_time, iftar_time) in enumerate(
                    zip(cal_day_list, hij_day_list, sehri_time_list,
                        iftari_time_list)):
                if i is not 0:
                    article_id = str(uuid.uuid4().hex)
                    article = Day(
                        id=article_id,
                        object_id=article_id,
                        country_id=str(country_id),
                        state_id=str(state.object_id),
                        day=i,
                        day_mm=str(seeds.get_mm_num(i)),
                        sehri_time=str(str(seh_time).strip() + " am"),
                        sehri_time_desc="Sehri",
                        calendar_day=str(date[i - 1]),
                        hijari_day=str(hij_day).strip(),
                        sehri_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါချည်ချိန်"),
                        sehri_time_desc_mm_uni="ဝါချည်ချိန်",
                        iftari_time=str(str(iftar_time).strip() + " pm"),
                        dua_mm_uni=Rabbit.zg2uni(seeds.daily_dua(i)["dua_mm"]),
                        dua_mm_zawgyi=Rabbit.uni2zg(
                            seeds.daily_dua(i)["dua_mm"]),
                        dua_ar=seeds.daily_dua(i)["dua_ar"],
                        dua_en=seeds.daily_dua(i)["dua_en"],
                        iftari_time_desc="Iftari",
                        iftari_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါဖြေချိန်"),
                        iftari_time_desc_mm_uni="ဝါဖြေချိန်")

                    db_session.add(article)
                    db_session.commit()
                    fetch_state = True

        return fetch_state
    def _generate_shops(self, shops, is_zawgyi):
        is_zawgyi = str2bool(is_zawgyi)

        return [{
            "title":
            Rabbit.uni2zg(
                str(shop.get("name_uni")) + str(shop.get("description")))
            if is_zawgyi else str(shop.get("name_uni")) +
            str(shop.get("description")),
            "image_url":
            "http://source.unsplash.com/NEqPK_bF3HQ",
            "subtitle":
            Rabbit.uni2zg(
                str(shop.get("region_name")) + "တွင်ရှိပါသည်။ " +
                str(shop.get("description")))
            if is_zawgyi else shop.get("region_name") + "တွင်ရှိပါသည်။ " +
            shop.get("description"),
            "default_action": {
                "type":
                "web_url",
                "url":
                "https://ramadan-bazzar-web.web.app/shop/{0}/{1}".format(
                    shop.get("id"), is_zawgyi),
                "webview_height_ratio":
                "compact",
            },
            "buttons": [{
                "type":
                "web_url",
                "url":
                "https://ramadan-bazzar-web.web.app/shop/{0}/{1}".format(
                    shop.get("id"), is_zawgyi),
                "title":
                Rabbit.uni2zg("Menu ကြည့်မယ်")
                if is_zawgyi else "Menu ကြည့်မယ်",
            }, {
                "type":
                "postback",
                "title":
                Rabbit.uni2zg("ဆိုင်တွေထပ်ကြည့်မယ်")
                if is_zawgyi else "ဆိုင်တွေထပ်ကြည့်မယ်",
                "payload":
                self.NEXT_SHOPS
            }, {
                "type":
                "postback",
                "title":
                Rabbit.uni2zg("မကြည့်တော့ဘူး")
                if is_zawgyi else "မကြည့်တော့ဘူး",
                "payload":
                self.EXIT_SHOPS
            }]
        } for shop in shops]
Exemple #5
0
    def test_api(self):
        scope = ['https://spreadsheets.google.com/feeds']
        credentials = ServiceAccountCredentials.from_json_keyfile_name(
            'client-secret.json', scope)
        sh = gspread.authorize(credentials).open_by_key(
            '1SjJG2RzITf8qAmYDU9RFnWVaMP9912y8KfbuJe8th-c')
        work_sheets = sh.worksheets()

        assert len(work_sheets) == 14

        country_id = str(uuid.uuid4().hex)
        for ws_count, worksheet in enumerate(sh.worksheets()):
            # TODO write State By Country Here
            state_name = MockConfig().getStateName(worksheet.title)
            state_id = str(uuid.uuid4().hex)
            state = State(id=state_id,
                          object_id=state_id,
                          country_id=str(country_id),
                          name_mm_uni=str(state_name),
                          name_mm_zawgyi=Rabbit.uni2zg(state_name))
            cal_day_list = worksheet.col_values(1)
            hij_day_list = worksheet.col_values(2)
            sehri_time_list = worksheet.col_values(3)
            iftari_time_list = worksheet.col_values(4)

            for i, (cal_day, hij_day, seh_time, iftar_time) in enumerate(
                    zip(cal_day_list, hij_day_list, sehri_time_list,
                        iftari_time_list)):
                if i is not 0:
                    article_id = str(uuid.uuid4().hex)
                    article = Day(
                        id=article_id,
                        object_id=article_id,
                        country_id=str(country_id),
                        state_id=str(state.object_id),
                        day=i,
                        day_mm=str(MockConfig().get_mm_num(i)),
                        sehri_time=str(seh_time) + " am",
                        sehri_time_desc="Sehri",
                        sehri_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါချည်ချိန်"),
                        sehri_time_desc_mm_uni="ဝါချည်ချိန်",
                        iftari_time=str(iftar_time) + " pm",
                        dua_mm_uni=MockConfig().daily_dua(i)["dua_mm"],
                        dua_mm_zawgyi=Rabbit.uni2zg(
                            MockConfig().daily_dua(i)["dua_mm"]),
                        dua_ar=MockConfig().daily_dua(i)["dua_ar"],
                        dua_en=MockConfig().daily_dua(i)["dua_en"],
                        iftari_time_desc="Iftari",
                        iftari_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါဖြေချိန်"),
                        iftari_time_desc_mm_uni="ဝါဖြေချိန်")
 def __init__(self, sender_id, bot):
     self.sender_id = sender_id
     self.bot = bot
     self.MSG_INITIAL_GREETING = Rabbit.uni2zg(
         "အစ်စလာမို့ အာလိုင်းကွန်း (Assalamualaikum)" \
         "Ramadan Bazaar Myanmar မှကြိုဆိုပါတယ်ခင်ဗျာ။ ပထမဦးစွာ အောက်မှာမြင်ရတဲ့ Font လေးရွေးပေးပါအုံး။")
     self.ZAW_GYI_PAYLOAD = "ZAW_GYI_PAYLOAD"
     self.UNICODE_PAYLOAD = "UNICODE_PAYLOAD"
 def _after_shop_selection_exit(self, is_zawgyi):
     is_zawgyi = str2bool(is_zawgyi)
     return [{
         "content_type":
         "text",
         "title":
         Rabbit.uni2zg("ဆိုင်တွေကိုကြည့်မယ်")
         if is_zawgyi else "ဆိုင်တွေကိုကြည့်မယ်",
         "image_url":
         "https://raw.githubusercontent.com/r-phyan-kwee-tech/ramadan-bazaar-mm/master/icons/ic_fork_knife.png",
         "payload":
         self.BROWSE_SHOPS
     }, {
         "content_type": "text",
         "title": Rabbit.uni2zg("အနီးနားမှာရှာမယ်")
         if is_zawgyi else "အနီးနားမှာရှာမယ်",
         "image_url":
         "https://raw.githubusercontent.com/r-phyan-kwee-tech/ramadan-bazaar-mm/master/icons/ic_location.png",
         "payload": self.SELECT_LOCATION_PAYLOAD
     }, {
         "content_type":
         "text",
         "title":
         Rabbit.uni2zg("ကျွန်တော်တို့အကြောင်း")
         if is_zawgyi else "ကျွန်တော်တို့အကြောင်း",
         "image_url":
         "https://raw.githubusercontent.com/r-phyan-kwee-tech/ramadan-bazaar-mm/master/icons/ic_info.png",
         "payload":
         self.ABOUT_US_PAYLOAD
     }, {
         "content_type": "text",
         "title": Rabbit.uni2zg("ဖောင့်ပြန်ရွေးရန်")
         if is_zawgyi else "ဖောင့်ပြန်ရွေးရန်",
         "image_url":
         "https://raw.githubusercontent.com/winhtaikaung/mm-exchange-rate-check-bot/master/icon_image/ic_unicode.png",
         "payload": self.FONT_SELECTION_PAYLOAD
     }, {
         "content_type": "text",
         "title":
         Rabbit.uni2zg("အကူအညီယူမည်။") if is_zawgyi else "အကူအညီယူမည်။",
         "image_url":
         "https://raw.githubusercontent.com/r-phyan-kwee-tech/ramadan-bazaar-mm/master/icons/ic_bouy_help.png",
         "payload": self.HELP
     }]
Exemple #8
0
    def test_mm_num_gen(self):
        all_day = db_session.query(
            Day).filter(Day.id!=None).all()

        for i,r_day in enumerate(all_day):
            print(i)
            print(r_day.day)
            r_day.sehri_time_desc="Sehri"
            r_day.sehri_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါချည်ချိန်")
            r_day.sehri_time_desc_mm_uni="ဝါချည်ချိန်"
            from seeds import daily_dua
            r_day.dua_mm_uni=Rabbit.zg2uni(str(daily_dua(r_day.day)["dua_mm"]))
            r_day.dua_mm_zawgyi=daily_dua(r_day.day)["dua_mm"]
            r_day.dua_ar=daily_dua(r_day.day)["dua_ar"]
            r_day.dua_en=daily_dua(r_day.day)["dua_en"]
            r_day.iftari_time_desc="Iftari"
            r_day.iftari_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါဖြေချိန်")
            r_day.iftari_time_desc_mm_uni="ဝါဖြေချိန်"
            db_session.commit()
        print(all_day)
 def _font_selection_payload(self):
     return [{
         "content_type": "text",
         "title": Rabbit.uni2zg("မြန်မာစာ"),
         "image_url":
         "https://raw.githubusercontent.com/winhtaikaung/mm-exchange-rate-check-bot/master/icon_image/ic_zawgyi.png",
         "payload": self.ZAW_GYI_PAYLOAD
     }, {
         "content_type": "text",
         "title": "မြန်မာစာ",
         "image_url":
         "https://raw.githubusercontent.com/winhtaikaung/mm-exchange-rate-check-bot/master/icon_image/ic_unicode.png",
         "payload": self.UNICODE_PAYLOAD
     }]
Exemple #10
0
    def convert(self):
        """ To handle the convert button press event """
        zg_input = self.root.ids.zawgyi_text
        uni_input = self.root.ids.unicode_text

        mode = "u" if uni_input.text != "" else "z"
        # If Unicode text input is entered then, convert it to Zawgyi

        if mode == "u":
            result = Rabbit.uni2zg(uni_input.text)
            zg_input.text = result
        elif mode == "z":
            result = Rabbit.zg2uni(zg_input.text)
            uni_input.text = result
 def test_uni2zg(self):
     print("converting Unicode to Zawgyi")
     converted = Rabbit.uni2zg(u"မင်္ဂလာပါ")
     self.assertEqual(converted, u"မဂၤလာပါ")
Exemple #12
0
def gen_seeds():
    import uuid
    from database import db_session
    from manage import Country, State, Day

    source_arr = [{
        "base_url": "http://androidweekly.net/issues/",
        "name": "Myanmar",
        "tag": "android"
    }]
    state_arr = [
        "ရန်ကုန်တိုင်း", "မန္တလေးတိုင်း", "ဧရာဝတီတိုင်း", "မကွေးတိုင်း",
        "စစ်ကိုင်းတိုင်း", "တင်္နသာရီတိုင်း", "ပဲခူးတိုင်း", "ကချင်ပြည်နယ်",
        "ချင်းပြည်နယ်", "ရခိုင်ပြည်နယ်", "ရှမ်းပြည်နယ်", "ကယားပြည်နယ်",
        "ကရင်ပြည်နယ်", "မွန်ပြည်နယ်"
    ]
    for s in source_arr:
        print("Generating Country.......\n\n\n")
        country_id = str(uuid.uuid4().hex)

        country = Country(id=country_id,
                          object_id=country_id,
                          name=str(s["name"]))
        db_session.add(country)
        db_session.commit()

        if os.environ["ENV"] != 'production':
            for state in state_arr:
                print("Generating State.........\n\n")
                issue_id = str(uuid.uuid4().hex)
                issue = State(id=issue_id,
                              object_id=issue_id,
                              country_id=str(country.object_id),
                              name_mm_uni=str(state),
                              name_mm_zawgyi=Rabbit.uni2zg(state))
                db_session.add(issue)
                db_session.commit()

                for art in range(1, 31):
                    print("Generating Days.......\n")
                    article_id = str(uuid.uuid4().hex)
                    article = Day(
                        id=article_id,
                        object_id=article_id,
                        country_id=str(country.object_id),
                        state_id=str(issue.object_id),
                        day=art,
                        day_mm=str(get_mm_num(art)),
                        sehri_time="4:3" + str(art) + " am",
                        sehri_time_desc="Sehri",
                        sehri_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါချည်ချိန်"),
                        sehri_time_desc_mm_uni="ဝါချည်ချိန်",
                        iftari_time="7:3" + str(art) + " pm",
                        dua_mm_uni=Rabbit.zg2uni(str(
                            daily_dua(art)["dua_mm"])),
                        dua_mm_zawgyi=daily_dua(art)["dua_mm"],
                        dua_ar=daily_dua(art)["dua_ar"],
                        dua_en=daily_dua(art)["dua_en"],
                        iftari_time_desc="Iftari",
                        iftari_time_desc_mm_zawgyi=Rabbit.uni2zg("ဝါဖြေချိန်"),
                        iftari_time_desc_mm_uni="ဝါဖြေချိန်")
                    db_session.add(article)
                    db_session.commit()
Exemple #13
0
# -*- coding: utf-8 -*-

from kivy.app import App
from kivy.lang import Builder
from kivy.config import Config

from rabbit import Rabbit
"""
Rabbit.uni2zg("မင်္ဂလာပါ")  # returns zg strings "မဂၤလာပါ"

Rabbit.zg2uni("မဂၤလာပါ")   # returns unicode strings "မင်္ဂလာပါ
"""

class UZConverter(App):
    def build(self):
        Config.set('graphics', 'width', '300')
        Config.set('graphics', 'height', '200')

        self.title = "Unicode to Zawgyi Converter"
        self.root = Builder.load_file("gui.kv")
        return self.root

    def convert(self):
        """ To handle the convert button press event """
        zg_input = self.root.ids.zawgyi_text
        uni_input = self.root.ids.unicode_text

        mode = "u" if uni_input.text != "" else "z"
        # If Unicode text input is entered then, convert it to Zawgyi

        if mode == "u":
Exemple #14
0
 def test_uni2zg(self):
     print("converting Unicode to Zawgyi")
     converted = Rabbit.uni2zg(u"မင်္ဂလာပါ")
     self.assertEqual(converted, u"မဂၤလာပါ")