Ejemplo n.º 1
0
 def filter(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado siempre será una lista de objetos tipo "PlaceFinder"
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     my_count = response["query"]["count"]
     if my_count > 0:
         if response:
             my_count = response["query"]["count"]
             list_result = []
             my_response = response["query"]["results"]["Result"]
             if type(my_response) is list:
                 for data in response:
                     place = PlaceFinder()
                     place.__Result = data
                     place.__count = my_count
                     list_result.append(place)
             if type(my_response) is dict:
                 place = PlaceFinder()
                 place.__Result = my_response
                 place.__count = my_count
                 list_result.append(place)
             return list_result
     else:
         raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 2
0
    def get(**kwargs):
        """
        Realizamos una consulta a la base de datos de Yahoo para obtener información de geo.concordance.
        Nota:
        Esta función devolverá solamente un objeto.
        Si se encuentran más, entonces la función devuelve el primer resultado de la lista.

        Para obtener más de 1 resultado entonces utilizar la función filter().
        """
        connect = YQLConector()
        query = connect.make_query(YQL_TABLE, **kwargs)
        response = connect.request(query)
        my_count = response["query"]["count"]
        if my_count > 0:
            if response:
                my_response = response["query"]["results"]["concordance"]
                if type(my_response) is dict:  # Si es solo un elemento entonces enviamos de manera directa
                    concordance = Concordance()
                    concordance.__count = my_count
                    concordance.__Result = my_response
                    return concordance
                if type(my_response) is list:
                    msg = 'get function returns more than 1 value, please use "filter"'
                    raise MultipleValueError(msg)
        else:
            return None
Ejemplo n.º 3
0
    def get(**kwargs):
        """
        Realizamos una consulta a la base de datos de Yahoo para obtener información de geo.placefinder.
        Nota:
        Esta función devolverá solamente un objeto.
        Si se encuentran más, entonces la función devuelve el primer resultado de la lista.

        Para obtener más de 1 resultado entonces utilizar la función filter().
        """
        connect = YQLConector()
        query = connect.make_query(YQL_TABLE, **kwargs)
        response = connect.request(query)
        my_count = response["query"]["count"]
        if my_count > 0:
            if response:
                my_count = response["query"]["count"]
                my_response = response["query"]["results"]["Result"]
                if type(my_response) is dict:  # Si es solo un elemento entonces enviamos de manera directa
                    place = PlaceFinder()
                    place.__count = my_count
                    place.__Result = my_response
                    return place
                if type(my_response) is list:
                    msg = 'get function returns more than 1 value, please use "filter"'
                    raise MultipleValueError(msg)
        else:
            raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 4
0
    def get(**kwargs):
        """
        Realizamos una consulta a la base de datos de Yahoo para obtener información de geo.placetypes.
        Nota:
        Esta función devolverá solamente un objeto.
        Si se encuentran más, entonces la función devuelve el primer resultado de la lista.

        Para obtener más de 1 resultado entonces utilizar la función filter().
        """
        connect = YQLConector()
        query = connect.make_query(YQL_TABLE, **kwargs)
        response = connect.request(query)
        my_count = response["query"]["count"]
        if my_count > 0:
            if response:
                my_count = response["query"]["count"]
                my_response = response["query"]["results"]["placeType"]
                if type(my_response) is dict:  # Si es solo un elemento entonces enviamos de manera directa
                    place = PlaceType()
                    place._count = my_count
                    place._Result = my_response
                    place._place_type_name._Result = my_response["placeTypeName"]
                    return place
                if type(my_response) is list:
                    msg = 'get function returns more than 1 value, please use "filter"'
                    raise MultipleValueError(msg)
        else:
            raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 5
0
 def filter(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado siempre será una lista de objetos tipo "Placetypes"
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     my_count = response["query"]["count"]
     if my_count > 0:
         if response:
             my_count = response["query"]["count"]
             list_result = []
             my_response = response["query"]["results"]["placeType"]
             if type(my_response) is list:
                 for data in my_response:
                     place = PlaceType()
                     place._Result = data
                     place._count = my_count
                     place._place_type_name._Result = data["placeTypeName"]
                     list_result.append(place)
             if type(my_response) is dict:
                 place = PlaceType()
                 place._Result = my_response
                 place._count = my_count
                 list_result.append(place)
             return list_result
     else:
         raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 6
0
 def filter(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado siempre será una lista de objetos tipo "Continents"
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     return State.generic_filter(response)
Ejemplo n.º 7
0
 def filter(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado siempre será una lista de objetos tipo "District"
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     return District.generic_filter(response)
Ejemplo n.º 8
0
 def get(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado un solo elemento. Si la consulta retorna más entonces
     se presentará un error de múltiples resultados encontrados.
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     return State.generic_get(response)
Ejemplo n.º 9
0
 def get(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado un solo elemento. Si la consulta retorna más entonces
     se presentará un error de múltiples resultados encontrados.
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     return Continent.generic_get(response)
Ejemplo n.º 10
0
 def get(**kwargs):
     """
     Constructor del objeto Weather, se alimenta inicialmente de un WOEID para obtener información del clima.
     Posteriomente se puede consultar más información del clima utilizando las funciones que contiene.
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     my_count = response["query"]["count"]
     if my_count > 0:
         if response:
             my_count = response["query"]["count"]
             channel = response["query"]["results"]["channel"]
             forecast = Forecast()
             forecast.__count = my_count
             forecast.__Result = channel
             try:
                 forecast.__item._Result = channel["item"]  # LLenamos el objeto tipo item
             except KeyError:
                 pass
             try:
                 forecast.__location._Result = channel["location"]  # Llenamos el objeto tipo location
             except KeyError:
                 pass
             try:
                 forecast.__units._Result = channel["units"]  # Llenamos el objeto tipo location
             except KeyError:
                 pass
             try:
                 forecast.__wind._Result = channel["wind"]  # Llenamos el objeto tipo location
             except KeyError:
                 pass
             try:
                 forecast.__atmosphere._Result = channel["atmosphere"]  # Llenamos el objeto tipo atmosphere
             except KeyError:
                 pass
             try:
                 forecast.__astronomy._Result = channel["astronomy"]  # Llenamos el objeto tipo astronomy
             except KeyError:
                 pass
             try:
                 forecast.__image._Result = channel["image"]  # Llenamos el objeto tipo image
             except KeyError:
                 pass
             try:
                 condition = _Condition()  # Creamos un elemento del tipo Condition
                 condition._Result = channel["item"]["condition"]  # Inicializamos el valor de __Result
                 forecast.__item._condition = condition  # Asignamos el objeto al objeto principal forecast
             except KeyError:
                 pass
             except StandardError:
                 pass
             return forecast
     else:
         raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 11
0
 def get(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado un solo elemento. Si la consulta retorna más entonces
     se presentará un error de múltiples resultados encontrados.
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     if response["query"]["count"] > 0:
         return District.generic_get(response)
     else:
         raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 12
0
 def get(**kwargs):
     """
     Constructor del objeto Weather, se alimenta inicialmente de un WOEID para obtener información del clima.
     Posteriomente se puede consultar más información del clima utilizando las funciones que contiene.
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     my_count = response["query"]["count"]
     if my_count > 0:
         if response:
             my_count = response["query"]["count"]
             channel = response["query"]["results"]["channel"]
             forecast = Forecast()
             forecast.__count = my_count
             forecast.__Result = channel
             try:
                 forecast.__item._Result = channel[
                     "item"]  # LLenamos el objeto tipo item
             except KeyError:
                 pass
             try:
                 forecast.__location._Result = channel[
                     "location"]  # Llenamos el objeto tipo location
             except KeyError:
                 pass
             try:
                 forecast.__units._Result = channel[
                     "units"]  # Llenamos el objeto tipo location
             except KeyError:
                 pass
             try:
                 forecast.__wind._Result = channel[
                     "wind"]  # Llenamos el objeto tipo location
             except KeyError:
                 pass
             try:
                 forecast.__atmosphere._Result = channel[
                     "atmosphere"]  # Llenamos el objeto tipo atmosphere
             except KeyError:
                 pass
             try:
                 forecast.__astronomy._Result = channel[
                     "astronomy"]  # Llenamos el objeto tipo astronomy
             except KeyError:
                 pass
             try:
                 forecast.__image._Result = channel[
                     "image"]  # Llenamos el objeto tipo image
             except KeyError:
                 pass
             try:
                 condition = _Condition(
                 )  # Creamos un elemento del tipo Condition
                 condition._Result = channel["item"][
                     "condition"]  # Inicializamos el valor de __Result
                 forecast.__item._condition = condition  # Asignamos el objeto al objeto principal forecast
             except KeyError:
                 pass
             except StandardError:
                 pass
             return forecast
     else:
         raise Exception(
             "No se encontraron resultados con los criterios especificados")
Ejemplo n.º 13
0
    def get(**kwargs):
        """
        Realizamos una consulta a la base de datos de Yahoo para obtener información de geo.place.
        Nota:
        Esta función devolverá solamente un objeto.
        Si se encuentran más, entonces la función devuelve el primer resultado de la lista.

        Para obtener más de 1 resultado entonces utilizar la función filter().
        """
        connect = YQLConector()
        query = connect.make_query(YQL_TABLE, **kwargs)
        response = connect.request(query)
        my_count = response["query"]["count"]
        if my_count > 0:
            if response:
                my_response = response["query"]["results"]["place"]
                if type(my_response) is dict:  # Si es solo un elemento entonces enviamos de manera directa
                    place = Place()
                    place.__count = my_count
                    place.__Result = my_response
                    try:
                        place.__place_type_name._Result = my_response["placeTypeName"]
                    except KeyError:
                        pass
                    try:
                        place.__country._Result = my_response["country"]
                    except KeyError:
                        pass
                    try:
                        place.__admin1._Result = my_response["admin1"]
                    except KeyError:
                        pass
                    try:
                        place.__admin2._Result = my_response["admin2"]
                    except KeyError:
                        pass
                    try:
                        place.__admin3._Result = my_response["admin3"]
                    except KeyError:
                        pass
                    try:
                        place.__locality1._Result = my_response["locality1"]
                    except KeyError:
                        pass
                    try:
                        place.__locality2._Result = my_response["locality2"]
                    except KeyError:
                        pass
                    try:
                        place.__postal._Result = my_response["postal"]
                    except KeyError:
                        pass
                    try:
                        place.__centroid._Result = my_response["centroid"]
                    except KeyError:
                        pass
                    try:
                        northeast = _NorthEast()
                        northeast._Result = my_response["boundingBox"]["northEast"]
                        place.__bounding_box._north_east = northeast
                    except KeyError:
                        pass
                    try:
                        southwest = _SouthWest()
                        southwest._Result = my_response["boundingBox"]["southWest"]
                        place.__bounding_box._south_west = southwest
                    except KeyError:
                        pass
                    try:
                        place.__timezone._Result = my_response["timezone"]
                    except KeyError:
                        pass
                    return place
                if type(my_response) is list:
                    msg = 'get function returns more than 1 value, please use "filter"'
                    raise MultipleValueError(msg)
        else:
            raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 14
0
 def filter(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado siempre será una lista de objetos tipo "PlaceFinder"
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     my_count = response["query"]["count"]
     if my_count > 0:
         if response:
             list_result = []
             responses = response["query"]["results"]["place"]
             if type(responses) is list:
                 for my_response in responses:
                     place = Place()
                     place.__count = my_count
                     place.__Result = my_response
                     try:
                         place.__place_type_name._Result = my_response["placeTypeName"]
                     except KeyError:
                         pass
                     try:
                         place.__country._Result = my_response["country"]
                     except KeyError:
                         pass
                     try:
                         place.__admin1._Result = my_response["admin1"]
                     except KeyError:
                         pass
                     try:
                         place.__admin2._Result = my_response["admin2"]
                     except KeyError:
                         pass
                     try:
                         place.__admin3._Result = my_response["admin3"]
                     except KeyError:
                         pass
                     try:
                         place.__locality1._Result = my_response["locality1"]
                     except KeyError:
                         pass
                     try:
                         place.__locality2._Result = my_response["locality2"]
                     except KeyError:
                         pass
                     try:
                         place.__postal._Result = my_response["postal"]
                     except KeyError:
                         pass
                     try:
                         place.__centroid._Result = my_response["centroid"]
                     except KeyError:
                         pass
                     try:
                         northeast = _NorthEast()
                         northeast._Result = my_response["boundingBox"]["northEast"]
                         place.__bounding_box._north_east = northeast
                     except KeyError:
                         pass
                     try:
                         southwest = _SouthWest()
                         southwest._Result = my_response["boundingBox"]["southWest"]
                         place.__bounding_box._south_west = southwest
                     except KeyError:
                         pass
                     try:
                         place.__timezone._Result = my_response["timezone"]
                     except KeyError:
                         pass
                     list_result.append(place)
             if type(responses) is dict:
                 place = Place()
                 place.__count = my_count
                 my_response = responses
                 place.__Result = my_response
                 try:
                     place.__place_type_name._Result = my_response["placeTypeName"]
                 except KeyError:
                     pass
                 try:
                     place.__country._Result = my_response["country"]
                 except KeyError:
                     pass
                 try:
                     place.__admin1._Result = my_response["admin1"]
                 except KeyError:
                     pass
                 try:
                     place.__admin2._Result = my_response["admin2"]
                 except KeyError:
                     pass
                 try:
                     place.__admin3._Result = my_response["admin3"]
                 except KeyError:
                     pass
                 try:
                     place.__locality1._Result = my_response["locality1"]
                 except KeyError:
                     pass
                 try:
                     place.__locality2._Result = my_response["locality2"]
                 except KeyError:
                     pass
                 try:
                     place.__postal._Result = my_response["postal"]
                 except KeyError:
                     pass
                 try:
                     place.__centroid._Result = my_response["centroid"]
                 except KeyError:
                     pass
                 try:
                     northeast = _NorthEast()
                     northeast._Result = my_response["boundingBox"]["northEast"]
                     place.__bounding_box._north_east = northeast
                 except KeyError:
                     pass
                 try:
                     southwest = _SouthWest()
                     southwest._Result = my_response["boundingBox"]["southWest"]
                     place.__bounding_box._south_west = southwest
                 except KeyError:
                     pass
                 try:
                     place.__timezone._Result = my_response["timezone"]
                 except KeyError:
                     pass
                 list_result.append(place)
             return list_result
     else:
         raise Exception("No se encontraron resultados con los criterios especificados")
Ejemplo n.º 15
0
    def get(**kwargs):
        """
        Realizamos una consulta a la base de datos de Yahoo para obtener información de geo.place.
        Nota:
        Esta función devolverá solamente un objeto.
        Si se encuentran más, entonces la función devuelve el primer resultado de la lista.

        Para obtener más de 1 resultado entonces utilizar la función filter().
        """
        connect = YQLConector()
        query = connect.make_query(YQL_TABLE, **kwargs)
        response = connect.request(query)
        my_count = response["query"]["count"]
        if my_count > 0:
            if response:
                my_response = response["query"]["results"]["place"]
                if type(
                        my_response
                ) is dict:  # Si es solo un elemento entonces enviamos de manera directa
                    place = Place()
                    place.__count = my_count
                    place.__Result = my_response
                    try:
                        place.__place_type_name._Result = my_response[
                            "placeTypeName"]
                    except KeyError:
                        pass
                    try:
                        place.__country._Result = my_response["country"]
                    except KeyError:
                        pass
                    try:
                        place.__admin1._Result = my_response["admin1"]
                    except KeyError:
                        pass
                    try:
                        place.__admin2._Result = my_response["admin2"]
                    except KeyError:
                        pass
                    try:
                        place.__admin3._Result = my_response["admin3"]
                    except KeyError:
                        pass
                    try:
                        place.__locality1._Result = my_response["locality1"]
                    except KeyError:
                        pass
                    try:
                        place.__locality2._Result = my_response["locality2"]
                    except KeyError:
                        pass
                    try:
                        place.__postal._Result = my_response["postal"]
                    except KeyError:
                        pass
                    try:
                        place.__centroid._Result = my_response["centroid"]
                    except KeyError:
                        pass
                    try:
                        northeast = _NorthEast()
                        northeast._Result = my_response["boundingBox"][
                            "northEast"]
                        place.__bounding_box._north_east = northeast
                    except KeyError:
                        pass
                    try:
                        southwest = _SouthWest()
                        southwest._Result = my_response["boundingBox"][
                            "southWest"]
                        place.__bounding_box._south_west = southwest
                    except KeyError:
                        pass
                    try:
                        place.__timezone._Result = my_response["timezone"]
                    except KeyError:
                        pass
                    return place
                if type(my_response) is list:
                    msg = 'get function returns more than 1 value, please use "filter"'
                    raise MultipleValueError(msg)
        else:
            raise Exception(
                "No se encontraron resultados con los criterios especificados")
Ejemplo n.º 16
0
 def filter(**kwargs):
     """
     Realiza una consulta a la base de datos de Yahoo utilizando YQL.
     El valor retornado siempre será una lista de objetos tipo "PlaceFinder"
     """
     connect = YQLConector()
     query = connect.make_query(YQL_TABLE, **kwargs)
     response = connect.request(query)
     my_count = response["query"]["count"]
     if my_count > 0:
         if response:
             list_result = []
             responses = response["query"]["results"]["place"]
             if type(responses) is list:
                 for my_response in responses:
                     place = Place()
                     place.__count = my_count
                     place.__Result = my_response
                     try:
                         place.__place_type_name._Result = my_response[
                             "placeTypeName"]
                     except KeyError:
                         pass
                     try:
                         place.__country._Result = my_response["country"]
                     except KeyError:
                         pass
                     try:
                         place.__admin1._Result = my_response["admin1"]
                     except KeyError:
                         pass
                     try:
                         place.__admin2._Result = my_response["admin2"]
                     except KeyError:
                         pass
                     try:
                         place.__admin3._Result = my_response["admin3"]
                     except KeyError:
                         pass
                     try:
                         place.__locality1._Result = my_response[
                             "locality1"]
                     except KeyError:
                         pass
                     try:
                         place.__locality2._Result = my_response[
                             "locality2"]
                     except KeyError:
                         pass
                     try:
                         place.__postal._Result = my_response["postal"]
                     except KeyError:
                         pass
                     try:
                         place.__centroid._Result = my_response["centroid"]
                     except KeyError:
                         pass
                     try:
                         northeast = _NorthEast()
                         northeast._Result = my_response["boundingBox"][
                             "northEast"]
                         place.__bounding_box._north_east = northeast
                     except KeyError:
                         pass
                     try:
                         southwest = _SouthWest()
                         southwest._Result = my_response["boundingBox"][
                             "southWest"]
                         place.__bounding_box._south_west = southwest
                     except KeyError:
                         pass
                     try:
                         place.__timezone._Result = my_response["timezone"]
                     except KeyError:
                         pass
                     list_result.append(place)
             if type(responses) is dict:
                 place = Place()
                 place.__count = my_count
                 my_response = responses
                 place.__Result = my_response
                 try:
                     place.__place_type_name._Result = my_response[
                         "placeTypeName"]
                 except KeyError:
                     pass
                 try:
                     place.__country._Result = my_response["country"]
                 except KeyError:
                     pass
                 try:
                     place.__admin1._Result = my_response["admin1"]
                 except KeyError:
                     pass
                 try:
                     place.__admin2._Result = my_response["admin2"]
                 except KeyError:
                     pass
                 try:
                     place.__admin3._Result = my_response["admin3"]
                 except KeyError:
                     pass
                 try:
                     place.__locality1._Result = my_response["locality1"]
                 except KeyError:
                     pass
                 try:
                     place.__locality2._Result = my_response["locality2"]
                 except KeyError:
                     pass
                 try:
                     place.__postal._Result = my_response["postal"]
                 except KeyError:
                     pass
                 try:
                     place.__centroid._Result = my_response["centroid"]
                 except KeyError:
                     pass
                 try:
                     northeast = _NorthEast()
                     northeast._Result = my_response["boundingBox"][
                         "northEast"]
                     place.__bounding_box._north_east = northeast
                 except KeyError:
                     pass
                 try:
                     southwest = _SouthWest()
                     southwest._Result = my_response["boundingBox"][
                         "southWest"]
                     place.__bounding_box._south_west = southwest
                 except KeyError:
                     pass
                 try:
                     place.__timezone._Result = my_response["timezone"]
                 except KeyError:
                     pass
                 list_result.append(place)
             return list_result
     else:
         raise Exception(
             "No se encontraron resultados con los criterios especificados")