123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- /**
- * @license
- * Visual Blocks Language
- *
- * Copyright 2012 Google Inc.
- * https://developers.google.com/blockly/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- /**
- * @fileoverview Generating Python for CORGIS big data blocks.
- * @author acbart@vt.edu (Austin Cory Bart)
- */
- 'use strict';
- goog.provide('Blockly.Python.corgis');
- goog.require('Blockly.Python');
- /*
- * Weather Data
- */
- Blockly.Python['weather_temperature_get'] = function(block) {
- Blockly.Python.definitions_['get_temperatures'] = "__temperatures = [{'Min Temp': 32, 'Max Temp': 46, 'Avg Temp': 39}, {'Min Temp': 31, 'Max Temp': 47, 'Avg Temp': 39}, {'Min Temp': 41, 'Max Temp': 51, 'Avg Temp': 46}, {'Min Temp': 38, 'Max Temp': 52, 'Avg Temp': 45}, {'Min Temp': 29, 'Max Temp': 38, 'Avg Temp': 34}, {'Min Temp': 31, 'Max Temp': 44, 'Avg Temp': 38}, {'Min Temp': 24, 'Max Temp': 36, 'Avg Temp': 30}, {'Min Temp': 9, 'Max Temp': 32, 'Avg Temp': 22}, {'Min Temp': 31, 'Max Temp': 36, 'Avg Temp': 34}, {'Min Temp': 33, 'Max Temp': 43, 'Avg Temp': 38}, {'Min Temp': 23, 'Max Temp': 39, 'Avg Temp': 31}, {'Min Temp': 4, 'Max Temp': 30, 'Avg Temp': 14}, {'Min Temp': 19, 'Max Temp': 34, 'Avg Temp': 27}, {'Min Temp': 35, 'Max Temp': 42, 'Avg Temp': 39}, {'Min Temp': 37, 'Max Temp': 42, 'Avg Temp': 40}, {'Min Temp': 31, 'Max Temp': 40, 'Avg Temp': 36}, {'Min Temp': 30, 'Max Temp': 37, 'Avg Temp': 34}, {'Min Temp': 33, 'Max Temp': 41, 'Avg Temp': 37}, {'Min Temp': 35, 'Max Temp': 42, 'Avg Temp': 39}, {'Min Temp': 36, 'Max Temp': 42, 'Avg Temp': 40}, {'Min Temp': 20, 'Max Temp': 33, 'Avg Temp': 27}, {'Min Temp': 20, 'Max Temp': 39, 'Avg Temp': 30}, {'Min Temp': 25, 'Max Temp': 32, 'Avg Temp': 29}, {'Min Temp': -9, 'Max Temp': 8, 'Avg Temp': 0}, {'Min Temp': 32, 'Max Temp': 42, 'Avg Temp': 37}, {'Min Temp': 60, 'Max Temp': 60, 'Avg Temp': 60}, {'Min Temp': 60, 'Max Temp': 60, 'Avg Temp': 60}, {'Min Temp': 60, 'Max Temp': 60, 'Avg Temp': 60}, {'Min Temp': 39, 'Max Temp': 46, 'Avg Temp': 43}, {'Min Temp': 33, 'Max Temp': 42, 'Avg Temp': 38}, {'Min Temp': 29, 'Max Temp': 35, 'Avg Temp': 32}, {'Min Temp': 23, 'Max Temp': 39, 'Avg Temp': 32}, {'Min Temp': 13, 'Max Temp': 29, 'Avg Temp': 21}, {'Min Temp': 2, 'Max Temp': 9, 'Avg Temp': 6}, {'Min Temp': 32, 'Max Temp': 40, 'Avg Temp': 36}, {'Min Temp': 24, 'Max Temp': 57, 'Avg Temp': 41}, {'Min Temp': 25, 'Max Temp': 54, 'Avg Temp': 40}, {'Min Temp': 45, 'Max Temp': 69, 'Avg Temp': 58}, {'Min Temp': 43, 'Max Temp': 69, 'Avg Temp': 56}, {'Min Temp': 15, 'Max Temp': 42, 'Avg Temp': 29}, {'Min Temp': 27, 'Max Temp': 51, 'Avg Temp': 39}, {'Min Temp': 27, 'Max Temp': 48, 'Avg Temp': 38}, {'Min Temp': 34, 'Max Temp': 49, 'Avg Temp': 42}, {'Min Temp': 33, 'Max Temp': 60, 'Avg Temp': 47}, {'Min Temp': 12, 'Max Temp': 42, 'Avg Temp': 27}, {'Min Temp': 21, 'Max Temp': 49, 'Avg Temp': 35}, {'Min Temp': 37, 'Max Temp': 51, 'Avg Temp': 44}, {'Min Temp': 33, 'Max Temp': 53, 'Avg Temp': 44}, {'Min Temp': 36, 'Max Temp': 55, 'Avg Temp': 46}, {'Min Temp': 41, 'Max Temp': 53, 'Avg Temp': 47}, {'Min Temp': 43, 'Max Temp': 65, 'Avg Temp': 54}, {'Min Temp': 45, 'Max Temp': 63, 'Avg Temp': 55}, {'Min Temp': 36, 'Max Temp': 50, 'Avg Temp': 44}, {'Min Temp': 38, 'Max Temp': 51, 'Avg Temp': 45}, {'Min Temp': 34, 'Max Temp': 52, 'Avg Temp': 44}, {'Min Temp': 41, 'Max Temp': 57, 'Avg Temp': 49}, {'Min Temp': 45, 'Max Temp': 64, 'Avg Temp': 55}, {'Min Temp': 41, 'Max Temp': 51, 'Avg Temp': 46}, {'Min Temp': 33, 'Max Temp': 44, 'Avg Temp': 39}, {'Min Temp': 39, 'Max Temp': 62, 'Avg Temp': 51}, {'Min Temp': 37, 'Max Temp': 63, 'Avg Temp': 51}, {'Min Temp': 33, 'Max Temp': 51, 'Avg Temp': 42}, {'Min Temp': -5, 'Max Temp': 33, 'Avg Temp': 14}, {'Min Temp': 9, 'Max Temp': 45, 'Avg Temp': 28}, {'Min Temp': -23, 'Max Temp': 3, 'Avg Temp': -10}, {'Min Temp': 12, 'Max Temp': 40, 'Avg Temp': 27}, {'Min Temp': 4, 'Max Temp': 24, 'Avg Temp': 14}, {'Min Temp': 4, 'Max Temp': 47, 'Avg Temp': 26}, {'Min Temp': 32, 'Max Temp': 43, 'Avg Temp': 38}, {'Min Temp': 27, 'Max Temp': 40, 'Avg Temp': 34}, {'Min Temp': 27, 'Max Temp': 46, 'Avg Temp': 37}, {'Min Temp': 27, 'Max Temp': 46, 'Avg Temp': 37}, {'Min Temp': 58, 'Max Temp': 68, 'Avg Temp': 63}, {'Min Temp': 70, 'Max Temp': 82, 'Avg Temp': 76}, {'Min Temp': 51, 'Max Temp': 62, 'Avg Temp': 56}, {'Min Temp': 50, 'Max Temp': 61, 'Avg Temp': 56}, {'Min Temp': 74, 'Max Temp': 82, 'Avg Temp': 79}, {'Min Temp': 70, 'Max Temp': 82, 'Avg Temp': 76}, {'Min Temp': 57, 'Max Temp': 72, 'Avg Temp': 65}, {'Min Temp': 44, 'Max Temp': 52, 'Avg Temp': 48}, {'Min Temp': 48, 'Max Temp': 57, 'Avg Temp': 53}, {'Min Temp': 59, 'Max Temp': 71, 'Avg Temp': 66}, {'Min Temp': 62, 'Max Temp': 74, 'Avg Temp': 69}, {'Min Temp': 67, 'Max Temp': 80, 'Avg Temp': 74}, {'Min Temp': 47, 'Max Temp': 58, 'Avg Temp': 51}, {'Min Temp': 36, 'Max Temp': 54, 'Avg Temp': 45}, {'Min Temp': 36, 'Max Temp': 48, 'Avg Temp': 42}, {'Min Temp': 41, 'Max Temp': 56, 'Avg Temp': 48}, {'Min Temp': 40, 'Max Temp': 53, 'Avg Temp': 47}, {'Min Temp': 49, 'Max Temp': 62, 'Avg Temp': 56}, {'Min Temp': 65, 'Max Temp': 81, 'Avg Temp': 73}, {'Min Temp': 64, 'Max Temp': 81, 'Avg Temp': 73}, {'Min Temp': 60, 'Max Temp': 80, 'Avg Temp': 71}, {'Min Temp': 64, 'Max Temp': 79, 'Avg Temp': 72}, {'Min Temp': 60, 'Max Temp': 79, 'Avg Temp': 70}, {'Min Temp': 7, 'Max Temp': 23, 'Avg Temp': 15}, {'Min Temp': 12, 'Max Temp': 29, 'Avg Temp': 21}, {'Min Temp': -4, 'Max Temp': 21, 'Avg Temp': 8}, {'Min Temp': 20, 'Max Temp': 30, 'Avg Temp': 25}, {'Min Temp': 19, 'Max Temp': 31, 'Avg Temp': 25}]";
- let code = "__temperatures";
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['weather_temperature'] = function(block) {
- Blockly.Python.definitions_['import_weather'] = 'import weather';
- var code = 'weather.get_temperature(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('CITY'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['weather_forecasts'] = function(block) {
- Blockly.Python.definitions_['import_weather'] = 'import weather';
- var code = 'weather.get_forecasts(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('CITY'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['weather_highs_lows'] = function(block) {
- Blockly.Python.definitions_['import_weather'] = 'import weather';
- var code = 'weather.get_highs_lows(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('CITY'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['weather_report'] = function(block) {
- Blockly.Python.definitions_['import_weather'] = 'import weather';
- var code = 'weather.get_report(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('CITY'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['weather_report_forecasts'] = function(block) {
- Blockly.Python.definitions_['import_weather'] = 'import weather';
- var code = 'weather.get_forecasted_reports(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('CITY'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['weather_all_forecasts'] = function(block) {
- Blockly.Python.definitions_['import_weather'] = 'import weather';
- var code = 'weather.get_all_forecasted_temperatures()'
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- /*
- * Stocks Data
- */
- Blockly.Python['stocks_current'] = function(block) {
- Blockly.Python.definitions_['import_stocks'] = 'import stocks';
- var code = 'stocks.get_current(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('TICKER'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['stocks_past'] = function(block) {
- Blockly.Python.definitions_['import_stocks'] = 'import stocks';
- var code = 'stocks.get_past(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('TICKER'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- /*
- * Earthquake Data
- */
- Blockly.Python['earthquake_get'] = function(block) {
- Blockly.Python.definitions_['import_earthquakes'] = 'import earthquakes';
- var code = 'earthquakes.get(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('PROPERTY'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['earthquake_both'] = function(block) {
- Blockly.Python.definitions_['import_earthquakes'] = 'import earthquakes';
- var code = 'earthquakes.get_both()';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['earthquake_all'] = function(block) {
- Blockly.Python.definitions_['import_earthquakes'] = 'import earthquakes';
- var code = 'earthquakes.get_all()';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- /*
- * Crime Data
- */
- Blockly.Python['crime_state'] = function(block) {
- Blockly.Python.definitions_['import_crime'] = 'import crime';
- var code = 'crime.get_' + block.getFieldValue('TYPE') + '_crimes(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('STATE'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['crime_year'] = function(block) {
- Blockly.Python.definitions_['import_crime'] = 'import crime';
- var code = 'crime.get_by_year(';
- var argument0 = Blockly.Python.quote_(block.getFieldValue('YEAR'));
- code += argument0 + ')';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- Blockly.Python['crime_all'] = function(block) {
- Blockly.Python.definitions_['import_crime'] = 'import crime';
- var code = 'crime.get_all()';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
- /*
- * Book Data
- */
- Blockly.Python['books_get'] = function(block) {
- Blockly.Python.definitions_['import_books'] = 'import books';
- var code = 'books.get_all()';
- return [code, Blockly.Python.ORDER_ATOMIC];
- };
|