Esempio n. 1
0
def getrooms(date, campus):
    if date.find(".") >= 0:
        newdate1 = time.strptime(date, "%d.%m.%Y")
    if date.find("/") >= 0:
        newdate1 = time.strptime(date, "%d/%m/%Y")
    print(campus)
    restfinal = []
    qu = JsonQ("data.json")
    if campus.lower().find("wi") >= 0:
        res = qu.at('room.VCALENDAR.VEVENT').where('LOCATION', 'startswith',
                                                   'WH').get()
        for temp in res:
            dtstart = time.strptime(temp['DTSTART'], "%Y%m%dT%H%M%S")
            dtend = time.strptime(temp['DTEND'], "%Y%m%dT%H%M%S")
            if newdate1 < dtstart or newdate1 > dtend:
                restfinal.append(temp)
        res = restfinal
        return res
    if campus.lower().find("ta") >= 0:
        res = qu.at('room.VCALENDAR.VEVENT').where('LOCATION', 'startswith',
                                                   'TA').get()
        return res
    else:
        res = [{
            'id': 12,
            'title': u'not found',
            'question': u'Es gibt kein frei Raum',
            'type': u'date'
        }]
    return res
Esempio n. 2
0
def getWithRoomNumber():
    if session.get('date').find(".") >= 0:
        newdate1 = time.strptime(session.get('date'), "%d.%m.%Y")
    if session.get('date').find("/") >= 0:
        newdate1 = time.strptime(session.get('date'), "%d/%m/%Y")
    restfinal = []
    qu = JsonQ("data.json")
    if session.get('campus').find("Wi") >= 0:
        res = qu.at('room.VCALENDAR.VEVENT').where('LOCATION', 'startswith', 'WH').where("LOCATION", "endswith", session.get('room_number'))\
            .get()
        for temp in res:
            dtstart = time.strptime(temp['DTSTART'], "%Y%m%dT%H%M%S")
            dtend = time.strptime(temp['DTEND'], "%Y%m%dT%H%M%S")
            if newdate1 < dtstart or newdate1 > dtend:
                restfinal.append(temp)
        res = restfinal
        return res
    if session.get('campus').find("Ta") >= 0:
        res = qu.at('room.VCALENDAR.VEVENT').where('LOCATION', 'startswith', 'TA').where("LOCATION", "endswith", session.get('room_number'))\
                        .get()
        return res
    else:
        res = [{
            'id': 12,
            'title': u'not found',
            'question': u'Es gibt kein frei Raum',
            'type': u'date'
        }]
    return res
Esempio n. 3
0
 def parseResult(self, selectionCategory, searchingPhrase):
     try:
         json = JsonQ('json/flights.json')
         if selectionCategory == 'status':
             result = json.at('flights').where(selectionCategory, '=',
                                               searchingPhrase).get()
         else:
             result = json.at('flights').where_contains(
                 selectionCategory, searchingPhrase).get()
         if not result:
             print("There are no flights from the company: " +
                   selectionCategory)
         else:
             for i in range(0, len(result)):
                 company = result[i]['company'].strip()
                 flightNumber = result[i]['flightNumber'].strip()
                 cameFrom = result[i]['cameFrom'].strip()
                 flightTime = result[i]['flightTime'].strip()
                 finalTime = result[i]['finalTime'].strip()
                 terminalNumber = result[i]['terminalNumber'].strip()
                 status = result[i]['status'].strip()
                 print('Flight number ' + str(i + 1) + ': Company: ' +
                       company + '    Flight Number: ' + flightNumber +
                       '    Flight origin: ' + cameFrom +
                       '    Original landing time: ' + flightTime +
                       '    Updated landing time: ' + finalTime +
                       '    Terminal Number: ' + terminalNumber +
                       '    Flight status: ' + status)
             print("\n")
     except:
         print(
             "There is no flights information at the moment, please try again"
             + "\n")
Esempio n. 4
0
def event_notifier(data, old_notify_time):
    """Triggered for checking notifications
    :@param data: dict/json
    :@param old_notify_time: string
    :@return string
    """
    events = []
    if old_notify_time:
        events = JsonQ(data=data).at(".")\
            .where("created_at", ">", old_notify_time)\
            .sort_by("created_at").get()
    else:
        events.append(data[0])

    if events:
        for event in events:
            event_type = event.get("type")

            new_notify_time = event.get("created_at")
            action = _match(event_type)

            if old_notify_time != new_notify_time and action:

                actor = event.get("actor").get("display_login")
                repo_name = event.get("repo").get("name")

                repo_link = "{}{}".format("https://github.com/", repo_name)
                msg = "{} {} {}".format(actor, action, repo_name)

                if (notify_status == 'y' or notify_status == 'yes'):
                    if actor == github_handle:
                        notify(msg, repo_link)
                else:
                    notify(msg, repo_link)

                old_notify_time = new_notify_time
                sleep(5)

    return old_notify_time
Esempio n. 5
0
"""
Example of at()
"""
from pyjsonq import JsonQ

qe = JsonQ("./data.json").at("users").where("id", "<", 3).get()

print("result", qe)
Esempio n. 6
0
"""
Example of sum()
"""
from pyjsonq import JsonQ

e1 = JsonQ("./data.json").at("users.5.visits").sum("year")

print("result", e1)
Esempio n. 7
0
"""
Example of where()
"""
from pyjsonq import JsonQ

e1 = JsonQ("./data.json").at("users")\
                        .where("id", ">", 3)\
                        .where("location", "=", "Barisal")\
                        .get()

print("result", e1)

e2 = JsonQ("./data.json").at("users")\
                        .where("id", ">", 3)\
                        .where("location", "=", "Barisal")\
                        .get()

print("result", e2)

e3 = JsonQ("./data.json").at("users")\
                        .where("id", ">", 3)\
                        .where("location", "=", "barisal", True)\
                        .get()

print("result", e3)
Esempio n. 8
0
"""
Example of group_by()
"""
from pyjsonq import JsonQ

e1 = JsonQ("./data.json").at("products").group_by("price").get()

print("result", e1)
Esempio n. 9
0
"""
Example of chunk()
"""
from pyjsonq import JsonQ

e1 = JsonQ("./data.json").at("users")\
                        .where("location", "=", "Barisal")\
                        .chunk(2)

print("result", e1)
Esempio n. 10
0
"""
Example of sort_by()
"""
from pyjsonq import JsonQ

e1 = JsonQ("./data.json").at("products").sort_by("id", "desc").get()

print("result", e1)