def generate_growth_dependent_spreadsheet(self, growth_dependent_results): s = xlwt.Workbook() s = self.__generate_sheet_sensibility_analysis(s, growth_dependent_results) sObject = Spreadsheet() sObject.set_workbook(s) return sObject
def main() -> None: """Builds sheets and spreadsheet objects, creates and writes mmr peaks to spreadsheet. """ # Creates sheet service and attaches them to the two spreadsheets. sheets_service: Optional[Sheets] = Sheets("creds.json") leaderboard_spreadsheet: Spreadsheet = Spreadsheet(LEADERBOARD_ID, sheets_service) peak_leaderboard_spreadsheet: Spreadsheet = Spreadsheet( PEAK_LEADERBOARD_ID, sheets_service) # Gets all players from the spreadsheet leaderboard. Keeping all players separated by their county. all_leaderboard_data: List[ Dict] = leaderboard_spreadsheet.get_ranges_values( ["England", "Scotland", "Wales", "Northern Ireland", "Other"], value_render_option="FORMULA", major_dimension="COLUMNS")["valueRanges"] all_leaderboard_data: List[List[List[Union[int, str]]]] = [ data["values"] for data in all_leaderboard_data ] all_players = parse_leaderboard_data(all_leaderboard_data) # Collects each player's peak mmr, then writes this data to the new spreadsheet. # Casts to correct type (don't know why it infers 'str' instead of actual type. country_leaderboards = get_country_leaderboards(all_players) country_leaderboards = cast(List[Dict[str, List[Tuple[str, str, int]]]], country_leaderboards) write_all_leaderboards(peak_leaderboard_spreadsheet, country_leaderboards, "England", "Scotland", "Wales", "Northern Ireland", "Other")
def form(): """ Renders the results page. While the program is running, if a user submits/enters a dropdown menu selection, then enters the submission. This function activates and sends the info stored in the 'posts' variable to the ResultsPage.html. :return: """ # Gets from the HTML if request.method == 'POST': query = request.form(__html_query) else: query = request.args.get(__html_query) error = 'There doesn\'t exist a \'' + __html_query + '\' form in ' + __RESULT_HTML assert query is not None, error sheet = Spreadsheet() posts = sheet.convertToDict(sheet[query]) if len(posts) > 0: query = [item for item in sheet[__python_query] if item != ''] pair = list(zip(sheet.textLength(query, 50), query)) return render_template("ResultsPage.html", posts=posts, pair=pair) else: return render_template(__RESULT_HTML)
def make_spreadsheet(rows): sheet = Spreadsheet() for row in rows: sheet_row = Row() sheet.add_row(sheet_row) for entry in row: sheet_row.append(Cell(entry)) return sheet
def main(client): old_workbook = Spreadsheet('old_workbook', False, source_wb) new_workbook = Spreadsheet('ZReport', True) #set this to the column you want read (the one with LIDs) sourceLIDs = old_workbook.read('F') #query requires LIDs as a string starting and ending with quotes, e.g.: #'(555555, 555556, 555557)' sourceLIDs = tuple(sourceLIDs) sourceLIDs = str(sourceLIDs) # Initialize DFP service. line_item_service = client.GetService('LineItemService', version='v201702') # More info on customizing your query in the links at top query = ('WHERE id IN ' + sourceLIDs) # Create a statement to select line items. statement = dfp.FilterStatement(query) while True: response = line_item_service.getLineItemsByStatement( statement.ToStatement()) if 'results' in response: for line_item in response['results']: # for more tuple value options, see LineItemInfo.txt token = (line_item['id'], line_item['name'], line_item['status'], line_item['isMissingCreatives']) new_workbook.append(token) statement.offset += dfp.SUGGESTED_PAGE_LIMIT else: break new_workbook.save() print('\nNumber of results found: %s' % response['totalResultSetSize'])
def run_sensibility_analysis(self, model_path, print_f, arg1, arg2, objective=None): warnings.warn( "run_sensibility_analysis() is deprecated, use instead:\n" + " results = facadeUtils.compute_growth_dependent_chokepoints(...) \n" + " xlwt_workbook = facadeUtils.generate_growth_dependent_spreadsheet(result)", DeprecationWarning ) results_growth_dependent = self.compute_growth_dependent_chokepoints(model_path, print_f, arg1, arg2, objective) s = xlwt.Workbook() s = self.__generate_sheet_sensibility_analysis(s, results_growth_dependent) sObject = Spreadsheet() sObject.set_workbook(s) return sObject
def return_LID_sets(): #Initialize workbooks old_workbook = Spreadsheet('old_workbook', False, source_wb) #new_workbook = Spreadsheet('LICAResults', True) wbdata = old_workbook.read() #dict pairs of oldLIDs and newLIDs. For matching values in createLICAs LIDSets = [] for row in wbdata: try: oldval = int(row[0]) newval = int(row[2]) LIDSets.append((oldval, newval)) except: continue print("Here is list LIDSets:") print(LIDSets) return LIDSets
def home(): """ Renders the homepage. While the program is running, if a user enters 'localhost:5000/' into their web browser, they'll be rerouted to the homepage: Homepage.html :return: """ sheet = Spreadsheet() # removes duplicates and empty responses query = [item for item in set(sheet[__python_query]) if item != ''] # TODO: remove this when final, it is only for displaying purposes. query += ['Encouragement'] + ['Specific Conditions'] + ['Stage II BC'] # returns a list(tuple) of (truncated text, full text) pair = list(zip(sheet.textLength(query, 50), query)) return render_template(__HOME_HTML, pair=pair)
def __test_function(): """ Raises an error and warns you to have everything installed in the appropriate places. If you fail any, it will output an error message of what could had happened. """ sheet = Spreadsheet() assert len(sheet) > 0, 'Spreadsheet size is 0 on FlaskDriver.py home function.' assert len(sheet[__python_query]) > 0, 'FlaskDriver.py: \'' + __python_query + '\' is not a header in Spreadsheet' assert __RESULT_PATH.exists(), 'You\'r missing or misspelled the ' + __RESULT_HTML + ' in the templates folder.' error = 'You\'r missing the ' + __HOME_HTML + ' in the templates folder. Or you misspelled it.' assert __HOMEPAGE_PATH.exists(), error
def main(): api = RiotApi('RGAPI-1cfcbc31-b14b-48aa-a083-e387b72474f2') spreadsheet = Spreadsheet() summoners = [] for value in Consts.NAMES: summoner = api.get_summoner_by_name(value['name'], value['region']) formattedSummoner = { 'accountId': summoner['accountId'], 'name': value['name'], 'region': value['region'] } summoners.append(formattedSummoner) for value in summoners: print(value) spreadsheet.insertPlayer()
def main(): #update the filepath to the name of your workbook source_wb = getcwd() + "\\SourceFiles\\testsource.xlsx" old_workbook = Spreadsheet('old_workbook', False, source_wb) wb_data = old_workbook.read() dfp = DFPMethods() LIDSets = Helper.return_LID_sets(wb_data) sourceLIDs = Helper.return_source_LIDs(LIDSets) targetLIDs = Helper.return_target_LIDs(LIDSets) target_LID_slots = dfp.getLineSizes(targetLIDs) oldLICAs = dfp.getLICAs(sourceLIDs) trafficked_LIDs = dfp.createLICAs(LIDSets, oldLICAs) print("Here are the failed LIDs, if any:\n") for LID in LIDSets: if LID[1] not in trafficked_LIDs: dfp.failed_lines.append(LID[1]) print(dfp.failed_lines) dfp.activateLineItems(trafficked_LIDs)
def main() -> None: """Builds the sheet service, collects town data, and leaderboards. Then writes them to a new spreadsheet. """ # Creates sheet service and attaches them to the two spreadsheets. sheets_service = Sheets("creds.json") trn_spreadsheet = Spreadsheet(TRN_ID, sheets_service) leaderboard_spreadsheet = Spreadsheet(LEADERBOARD_ID, sheets_service) # Gets all town links from the TRN spreadsheet and parses them to the correct format. all_data = trn_spreadsheet.get_ranges_values( ["England!B2:AY48", "Scotland!B2:AD13", "Wales!B2:Z9", "Northern Ireland!B2:AA6", "Other!B2:AY3"], value_render_option="FORMULA")["valueRanges"] all_data = [ranges["values"] for ranges in all_data] all_town_links = generate_town_links(all_data, 3, 6, 2, 3, 3) country_leaderboards = get_country_leaderboards(all_town_links) # Writes country leaderboards to BRL Counties Leaderboard spreadsheet with # the worksheets with the provided names. write_country_leaderboards(leaderboard_spreadsheet, country_leaderboards, "England", "Scotland", "Wales", "Northern Ireland", "Other")
def search(): query = request.args.get('query', '') error = 'There doesn\'t exist a \'' + __html_query + '\' form in ' + __RESULT_HTML assert query is not None, error tokens = __tokenizer.keep_stop_words(query) # TODO: NEED a TFIDF instance here # posts = getStats(tokens) -> [list of the posts] sheet = Spreadsheet() posts = sheet.convertToDict(sheet[query]) # delete line of code on top of this comment when ready if len(posts) > 0: # remove empties query = [item for item in sheet[__python_query] if item != ''] pair = list(zip(sheet.textLength(query, 50), query)) return render_template("ResultsPage.html", posts=posts, pair=pair) else: return render_template(__RESULT_HTML)
def make_spreadsheet(rows): sheet = Spreadsheet() row_index = -1 for row in rows: row_index += 1 if row_index == 0: sheet.add_title_row(row) else: sheet_row = Row() sheet.add_row(sheet_row) for entry in row: sheet_row.append(Cell(entry)) return sheet
print(USAGE.format(sys.argv[0])) sys.exit(1) # Parse command line arguments. credentialsFileName = sys.argv[1] documentName = sys.argv[2] targetName = sys.argv[3] print("Connecting to Google Sheets API") # scope = ["https://spreadsheets.google.com/feeds"] scope = ["https://www.googleapis.com/auth/drive"] credentials = ServiceAccountCredentials.from_json_keyfile_name( credentialsFileName, scope) client = gspread.authorize(credentials) print("Opening spreadsheet") spreadsheet = Spreadsheet(client) spreadsheet.open(documentName) print("Reading configuration page") cfgPage = spreadsheet.sheet("CFG") cfg = configurationFromPage(cfgPage) print("Reading source page") srcPage = spreadsheet.sheet("SRC") (languages, translations) = parse_page(srcPage, cfg) print("Found languages: '{0}'".format(languages)) print("Reading plural page") plural_page = spreadsheet.sheet("PLURAL") plural_list = parse_plural_page(plural_page, cfg)
def run_summary_model( self, model_path, print_f, arg1, arg2, objective=None, fraction=1.0 ): # verboseprint = print if verbose else lambda *a, **k: None print_f("Reading model...", arg1, arg2) model = CobraMetabolicModel(model_path) if objective is not None: model.set_objective(objective) if self.__processes is not None: model.processes = self.__processes model.save_state("initial") model.save_state("dem") model.save_state("fva") model.save_state("fva_dem") print_f("Generating models...", arg1, arg2) model.find_essential_genes_reactions() print_f("Searching Dead End Metabolites (D.E.M.)...", arg1, arg2) model.find_dem() print_f("Searching chokepoint reactions...", arg1, arg2) model.find_chokepoints(exclude_dead_reactions=True) print_f("Searching essential reactions...", arg1, arg2) model.find_essential_reactions_1() print_f("Searching essential genes...", arg1, arg2) errors_initial = model.find_essential_genes_1() if errors_initial != []: MSG = "Couldn't find essential genes: " + str(errors_initial[0]) print_f(MSG) else: print_f("Searching essential genes reactions...", arg1, arg2) model.find_essential_genes_reactions() model.save_state("initial") print_f("Removing Dead End Metabolites (D.E.M.)...", arg1, arg2) model.remove_dem() print_f("Searching essential reactions...", arg1, arg2) model.find_essential_reactions_1() print_f("Searching new chokepoint reactions...", arg1, arg2) model.find_chokepoints(exclude_dead_reactions=True) if errors_initial == []: print_f("Searching essential genes...", arg1, arg2) errors_dem = model.find_essential_genes_1() if errors_dem == []: print_f("Searching essential genes reactions...", arg1, arg2) model.find_essential_genes_reactions() model.save_state("dem") print_f("Running Flux Variability Analysis...", arg1, arg2) model = CobraMetabolicModel(model_path) if objective is not None: model.set_objective(objective) if self.__processes is not None: model.processes = self.__processes errors_fva = model.fva(update_flux=True, threshold=fraction) if errors_fva != []: MSG = "Couldn't run Flux Variability Analysis: " + str(errors_fva[0]) print_f(MSG, arg1, arg2) else: print_f("Searching Dead End Metabolites (D.E.M.)...", arg1, arg2) model.find_dem() print_f("Searching new chokepoint reactions...", arg1, arg2) model.find_chokepoints(exclude_dead_reactions=True) print_f("Searching essential genes...", arg1, arg2) errors_fva_genes = model.find_essential_genes_1() if errors_fva_genes != []: MSG = "Couldn't find essential genes: " + str(errors_fva_genes[0]) print_f(MSG) else: print_f("Searching essential genes reactions...", arg1, arg2) model.find_essential_genes_reactions() print_f("Searching essential reactions...", arg1, arg2) model.find_essential_reactions_1() model.save_state("fva") print_f("Removing Dead End Metabolites (D.E.M.)...", arg1, arg2) model.remove_dem() print_f("Searching essential reactions...", arg1, arg2) model.find_essential_reactions_1() print_f("Searching new chokepoint reactions...", arg1, arg2) model.find_chokepoints(exclude_dead_reactions=True) if errors_fva_genes == []: print_f("Searching essential genes...", arg1, arg2) model.find_essential_genes_1() print_f("Searching essential genes reactions...", arg1, arg2) model.find_essential_genes_reactions() model.save_state("fva_dem") print_f("Generating spreadsheet...", arg1, arg2) s = Spreadsheet() s.spreadsheet_write_model_info(model.get_state("initial"), "model_info") s.spreadsheet_write_summary( "summary", model.get_state("initial"), model.get_state("dem"), model.get_state("fva"), model.get_state("fva_dem"), ) s.spreadsheet_write_reactions( model.get_state("initial"), "reactions", ordered=True ) s.spreadsheet_write_metabolites( model.get_state("initial"), "metabolites", ordered=True, print_reactions=True, ) s.spreadsheet_write_genes( model.get_state("initial"), "genes", ordered=True, print_reactions=True ) s.spreadsheet_write_reactions( model.get_state("fva"), "reactions_FVA", ordered=True ) s.spreadsheet_write_metabolites( model.get_state("fva"), "metabolites_FVA", ordered=True, print_reactions=True, ) s.spreadsheet_write_reversible_reactions( "reversible reactions", model.get_state("initial"), model.get_state("fva"), ordered=True, ) s.spreadsheet_write_summary_reactions( "chokepoints", model.get_state("initial"), model.get_state("dem"), model.get_state("fva"), model.get_state("fva_dem"), ) s.spreadsheet_write_summary_metabolites( "dead-end", model.get_state("initial"), model.get_state("fva") ) s.spreadsheet_write_chokepoints_genes( "comparison", model.get_state("initial"), model.get_state("dem"), model.get_state("fva"), model.get_state("fva_dem"), ) s.spreadsheet_write_essential_genes_comparison( "essential genes", model.get_state("initial"), model.get_state("dem"), model.get_state("fva"), model.get_state("fva_dem"), ordered=True, ) s.spreadsheet_write_essential_reactions( "essential reactions", model.get_state("initial"), model.get_state("dem"), model.get_state("fva"), model.get_state("fva_dem"), ordered=True, ) return s
class MainWindow(QMainWindow): changePage = Signal(bool) def __init__(self): super().__init__() self.setWindowTitle('Petro-Explorer v1.0') win_icon = QIcon('icons/Logo.ico') self.setWindowIcon(win_icon) self.setStyleSheet('background-color: #363f49;') self.header = Header() self.navigation = Navigation() self.p_top_bar = PetrophysicsTopBar() self.s_top_bar = StatisticsTopBar() self.p_options_1 = PetrophysicsOptions(_mode='KCarman') self.p_options_2 = PetrophysicsOptions(_mode='TCoates') self.p_options_3 = PetrophysicsOptions(_mode='Winland') self.p_options_4 = PetrophysicsOptions(_mode='RQIFZI') self.p_options_5 = PetrophysicsOptions(_mode='Lucia') self.p_options_6 = PetrophysicsOptions(_mode='DParsons') self.s_options_1 = StatisticsOptions(_mode='Regression') self.s_options_2 = StatisticsOptions(_mode='Statistics') self.s_options_3 = StatisticsOptions(_mode='Histogram') self.s_options_4 = StatisticsOptions(_mode='Boxplot') self.sp_controls = SpreadsheetControls() self.plot_controls = PlotControls() self.plot_viewer = PlotViewer() self.spreadsheet = Spreadsheet() self.status_bar = QStatusBar() self.scroll_area_1 = QScrollArea() self.scroll_area_1.setWidget(self.spreadsheet) self.scroll_area_1.setWidgetResizable(True) self.scroll_area_2 = QScrollArea() self.scroll_area_2.setWidget(self.plot_viewer) self.scroll_area_2.setWidgetResizable(True) self.bar_widget = QWidget() self.bar_widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.central_widget = QWidget() self.options_widget = QWidget() self.docking_options = QDockWidget() self.docking_options.setWidget(self.options_widget) self.docking_options.setTitleBarWidget( DockWidgetRibbon(' Opções de cálculo')) self.docking_options2 = QDockWidget() self.docking_options2.setWidget(self.sp_controls) self.docking_options2.setTitleBarWidget( DockWidgetRibbon(' Controles de visualização')) self.setCentralWidget(self.central_widget) self.setStatusBar(self.status_bar) self.addToolBar(self.navigation) self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options) self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options2) self.connections() self.buildLayout() self.centralWidget().setStyleSheet('background-color: #2e3843') self.spreadsheet.setStyleSheet('background-color: white') self.status_bar.setStyleSheet('color: white') def buildLayout(self): stacked_layout_1 = QStackedLayout() # stacked_layout_1.addWidget(QWidget()) stacked_layout_1.addWidget(self.p_top_bar) stacked_layout_1.addWidget(self.s_top_bar) stacked_layout_2 = QStackedLayout() # stacked_layout_2.addWidget(QWidget()) stacked_layout_2.addWidget(self.p_options_1) stacked_layout_2.addWidget(self.p_options_2) stacked_layout_2.addWidget(self.p_options_3) stacked_layout_2.addWidget(self.p_options_4) stacked_layout_2.addWidget(self.p_options_5) stacked_layout_2.addWidget(self.p_options_6) stacked_layout_2.addWidget(self.s_options_1) stacked_layout_2.addWidget(self.s_options_2) stacked_layout_2.addWidget(self.s_options_3) stacked_layout_2.addWidget(self.s_options_4) self.stacked_layout_3 = QStackedLayout() self.stacked_layout_3.addWidget(self.scroll_area_1) self.stacked_layout_3.addWidget(self.scroll_area_2) central_widget_layout = QVBoxLayout() central_widget_layout.addWidget(self.bar_widget) central_widget_layout.addLayout(self.stacked_layout_3) self.central_widget.setLayout(central_widget_layout) self.bar_widget.setLayout(stacked_layout_1) self.options_widget.setLayout(stacked_layout_2) def connections(self): self.navigation.PetroAnalysis.connect( lambda: self.bar_widget.layout().setCurrentIndex(0)) self.navigation.StatsAnalysis.connect( lambda: self.bar_widget.layout().setCurrentIndex(1)) self.navigation.Save.connect(lambda: self.saveDialog()) self.navigation.Import.connect(lambda: self.importDialog()) self.navigation.About.connect(lambda: self.aboutDialog()) self.navigation.Help.connect(lambda: self.helpDialog()) self.navigation.header.HomePage.connect( lambda: self.changePage.emit(True)) self.navigation.ViewSheet.connect(lambda: self.displaySheet()) self.navigation.ViewPlot.connect(lambda: self.displayPltE()) self.navigation.New.connect(lambda: self.spreadsheet.addBlankSheet()) self.p_top_bar.KCarman.connect( lambda: self.options_widget.layout().setCurrentIndex(0)) self.p_top_bar.TCoates.connect( lambda: self.options_widget.layout().setCurrentIndex(1)) self.p_top_bar.Winland.connect( lambda: self.options_widget.layout().setCurrentIndex(2)) self.p_top_bar.DParsons.connect( lambda: self.options_widget.layout().setCurrentIndex(5)) self.p_top_bar.Lucia.connect( lambda: self.options_widget.layout().setCurrentIndex(4)) self.p_top_bar.RF.connect( lambda: self.options_widget.layout().setCurrentIndex(3)) self.s_top_bar.Regr.connect( lambda: self.options_widget.layout().setCurrentIndex(6)) self.s_top_bar.StatDesc.connect( lambda: self.options_widget.layout().setCurrentIndex(7)) self.s_top_bar.Boxplt.connect( lambda: self.options_widget.layout().setCurrentIndex(9)) self.s_top_bar.Hist.connect( lambda: self.options_widget.layout().setCurrentIndex(8)) self.s_options_1.run_button.clicked.connect(self.startRegr) self.s_options_2.run_button.clicked.connect(self.startStat) self.s_options_3.run_button.clicked.connect(self.startHist) self.s_options_4.run_button.clicked.connect(self.startBxpl) self.p_options_1.run.clicked.connect(self.startKCoz) self.p_options_2.run.clicked.connect(self.startTCoa) self.p_options_3.run.clicked.connect(self.startWinl) self.p_options_4.run.clicked.connect(self.startFZIR) self.p_options_5.run.clicked.connect(self.startLuci) self.p_options_6.run.clicked.connect(self.startDyks) self.sp_controls.AddColumn.connect( lambda: self.spreadsheet.addColumn()) self.sp_controls.AddRow.connect(lambda: self.spreadsheet.addRow()) self.sp_controls.DeleteRow.connect( lambda: self.spreadsheet.deleteRow()) self.sp_controls.DeleteColumn.connect( lambda: self.spreadsheet.deleteColumn()) self.plot_controls.run_button.clicked.connect(lambda: self.startPltE()) self.plot_controls.erasePlot.connect( lambda: self.plot_viewer.erasePlot()) self.plot_viewer.feedPlotControls.connect( self.plot_controls.fillFromJson) def startPltE(self): old_json = self.plot_viewer.json_data title = self.plot_controls.modify_title.text() xtype = self.plot_controls.modify_x_axis_type.currentText() ytype = self.plot_controls.modify_y_axis_type.currentText() xlabel = self.plot_controls.modify_x_axis_label.text() ylabel = self.plot_controls.modify_y_axis_label.text() if len(self.plot_controls.modify_lower_x_range.text()) > 0: lxrange = float(self.plot_controls.modify_lower_x_range.text()) else: lxrange = None if len(self.plot_controls.modify_upper_x_range.text()) > 0: uxrange = float(self.plot_controls.modify_upper_x_range.text()) else: uxrange = None if len(self.plot_controls.modify_lower_y_range.text()) > 0: lyrange = float(self.plot_controls.modify_lower_y_range.text()) else: lyrange = None if len(self.plot_controls.modify_upper_y_range.text()) > 0: uyrange = float(self.plot_controls.modify_upper_y_range.text()) else: uyrange = None if len(self.plot_controls.add_x_trace.text()) > 0 and len( self.plot_controls.add_y_trace.text()): trace_type = self.plot_controls.type_of_trace.currentText() x_trace = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.plot_controls. add_x_trace.text( ))] y_trace = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.plot_controls. add_y_trace.text( ))] trace_name = self.plot_controls.trace_name.text() else: trace_type = None x_trace = None y_trace = None trace_name = None io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.loadPltE(io_operations_handler.results)) io_operations_handler.loadParameters(f=pceManifold, _args=[ old_json, title, xtype, ytype, xlabel, ylabel, lxrange, uxrange, lyrange, uyrange, trace_type, x_trace, y_trace, trace_name ]) io_operations_handler.start() def loadPltE(self, results, typ='Regressão'): self.plot_viewer.loadPlot(results[0], results[1], _type=typ) self.displayPltE() def displayPltE(self): self.stacked_layout_3.setCurrentIndex(1) self.docking_options2.setWidget(self.plot_controls) #self.removeDockWidget(self.docking_options3) #self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options2) def loadSheet(self, df): self.spreadsheet.changeModel(data=df, header=list(df.keys())) self.displaySheet() def displaySheet(self): self.stacked_layout_3.setCurrentIndex(0) self.docking_options2.setWidget(self.sp_controls) self.status_bar.clearMessage() #self.removeDockWidget(self.docking_options2) #self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options3) def importDialog(self): func = None file_settings = QFileDialog().getOpenFileName( self, 'Importar Arquivo', filter= "Todos os arquivos (*);; Arquivo de Texto (*.txt);; Arquivo CSV (*.csv);; " "Planilha Excel (*.xlsx)") if ".txt" in file_settings[0]: func = Data.readTXT if ".csv" in file_settings[0]: func = Data.readCSV if ".xlsx" in file_settings[0]: func = Data.readExcel self.status_bar.showMessage('Importando arquivo. Aguarde.') io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.loadSheet(io_operations_handler.results)) io_operations_handler.loadParameters(f=func, _args=[ file_settings[0], ]) io_operations_handler.start() def saveDialog(self): func = None file_settings = QFileDialog().getSaveFileName( self, "Salvar Arquivo", filter="Arquivo de Texto (*.txt);; Arquivo CSV (*.csv);; " "Planilha Excel (*.xlsx)") if ".txt" in file_settings[0]: func = Data.toTXT if ".csv" in file_settings[0]: func = Data.toCSV if ".xlsx" in file_settings[0]: func = Data.toExcel io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.loadParameters( f=func, _args=[self.spreadsheet.retrieveModel(), file_settings[0]]) io_operations_handler.start() def aboutDialog(self): icon = QIcon(r'icons/sobre.png') text = "O Petro-Explorer é um software desenvolvido no Laboratório de Exploração e Produção de Petróleo (" \ "LENEP) da UENF para análises petrofísicas e estatísticas de dados de rocha. " msg = QMessageBox() msg.setWindowTitle('Sobre Petro-Explorer') msg.setWindowIcon(icon) msg.setText(text) msg.exec_() def helpDialog(self): icon = QIcon(r'icons/ajuda.png') text = r"Para utilizar o Petro-Explorer de maneira correta siga os seguintes passos:" \ "\n1 - Clique no botão Novo na barra de navegação, isto irá limpar quaisquer dados de antigas análises.\n" \ "2 - Para começar a sua análise é preciso importar os dados, assim, clique no botão Importar para escolher o seu arquivo. Atente para o fato que somente três tipos de arquivo são suportados (i.e. *.txt, *.csv, *.xlsx). Depois da sua escolha, os dados devem aparecer na planilha do software.\n" \ "3 - Se você desejar realizar uma análise petrofísica, clique no botão de Análise Petrofísica na barra de navegação. Caso queira realizar uma análise estatística, clique no botão de Análise Estatística na barra de navegação.\n" \ "4 - Selecione na barra superior à planilha, a análise que desejas realizar sobre seus dados.\n" \ "5 - No canto direito da janela, selecione os parâmetros de sua análise assim como o destino de seus resultados. Clique no botão 'Começar Análise' para continuar.\n" \ "6 - Analise seus resultados na planilha, e, quando disponível, no gráfico também.\n" \ "7 - Quando terminar, clique no botão Salvar para salvar os resultados de suas análises no disco.\n" \ "8 - Caso queira realizar outra análise, clique no botão \"Novo\" e comece novamente.\n" msg = QMessageBox() msg.setWindowTitle('Ajuda') msg.setWindowIcon(icon) msg.setText(text) msg.exec_() def startRegr(self): xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.s_options_1. payload['x_column'])] ydata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.s_options_1. payload['y_column'])] _type = self.s_options_1.payload['calculate'] dgr = self.s_options_1.degree.value() io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayRegr(self.s_options_1.payload['output_column'], io_operations_handler.results)) io_operations_handler.loadParameters(f=regressionManifold, _args=[xdata, ydata, dgr, _type]) io_operations_handler.start() def startStat(self): xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.s_options_2. payload['x_column'])] mthd = self.s_options_2.payload['calculate'] qtl = self.s_options_2.quartile.value() pctl = self.s_options_2.percentile.value() io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayStat(self.s_options_2.payload['output_column'], io_operations_handler.results)) io_operations_handler.loadParameters(f=statisticsManifold, _args=[xdata, mthd, qtl, pctl]) io_operations_handler.start() def startHist(self): xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.s_options_3. payload['x_column'])] nbins = self.s_options_3.payload['y_column'] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayHist(io_operations_handler.results)) io_operations_handler.loadParameters(f=histogramManifold, _args=[xdata, nbins]) io_operations_handler.start() def startBxpl(self): indexes = [] columns = self.s_options_4.payload['column_range'] for col in columns: indexes.append(self.spreadsheet.model.header_info.index(col)) xdata = self.spreadsheet.model.input_data[:, indexes] box_orientation = self.s_options_4.payload['y_column'] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayBxpl(io_operations_handler.results)) io_operations_handler.loadParameters(f=boxplotManifold, _args=[xdata, box_orientation]) io_operations_handler.start() def startKCoz(self): #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr k = None phi = None svgr = None prp = self.p_options_1.payload['calculate'] if prp == 'Permeabilidade (mD)': phi = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.p_options_1. payload['x_column'])] svgr = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_1. payload['y_column'])] elif prp == 'SVgr (cm-1)': k = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.p_options_1. payload['x_column'])] phi = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.p_options_1. payload['y_column'])] else: k = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.p_options_1. payload['x_column'])] phi = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info. index(self.p_options_1. payload['y_column'])] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayKCoz(io_operations_handler.results)) io_operations_handler.loadParameters(f=kCarmanManifold, _args=[k, phi, svgr, prp]) io_operations_handler.start() def startTCoa(self): #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr prp = self.p_options_2.payload['calculate'] if prp == "Swir (%)": xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_2. payload['x_column'])] ydata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_2. payload['y_column'])] zdata = None else: xdata = None ydata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_2. payload['y_column'])] zdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_2. payload['x_column'])] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayTCoa(io_operations_handler.results)) io_operations_handler.loadParameters(f=tCoatesManifold, _args=[xdata, ydata, zdata, prp]) io_operations_handler.start() def startWinl(self): #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr if self.p_options_3.payload['x_column'] != '': xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_3. payload['x_column'])] else: xdata = [] if self.p_options_3.payload['y_column'] != '': ydata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_3. payload['y_column'])] else: ydata = [] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayWinl(io_operations_handler.results)) io_operations_handler.loadParameters(f=winlandManifold, _args=[xdata, ydata]) io_operations_handler.start() def startFZIR(self): # you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr if self.p_options_4.payload['x_column'] != '': xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_4. payload['x_column'])] else: xdata = None if self.p_options_4.payload['y_column'] != '': ydata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_4. payload['y_column'])] else: ydata = None if self.p_options_4.payload['z_column'] != '': zdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_4. payload['z_column'])] else: zdata = None prp = self.p_options_4.payload['calculate'] un = self.p_options_4.payload['column_range'] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayFZIR(io_operations_handler.results)) io_operations_handler.loadParameters( f=fzManifold, _args=[xdata, ydata, zdata, un, prp]) io_operations_handler.start() def startLuci(self): #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr if self.p_options_5.payload['x_column'] != '': xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_5. payload['x_column'])] else: xdata = [] if self.p_options_5.payload['y_column'] != '': ydata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_5. payload['y_column'])] else: ydata = [] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayLuci(io_operations_handler.results)) io_operations_handler.loadParameters(f=luciaManifold, _args=[xdata, ydata]) io_operations_handler.start() def startDyks(self): #you need to ascertain if x corresponds to Permeability, y to Porosity and z to Swir/Svgr if self.p_options_6.payload['x_column'] != '': xdata = self.spreadsheet.model.input_data[:, self.spreadsheet.model. header_info.index( self.p_options_6. payload['x_column'])] else: xdata = [] prp = self.p_options_6.payload['calculate'] io_operations_handler = HandlerThread() io_operations_handler.messageSent.connect(self.status_bar.showMessage) io_operations_handler.daemon = True io_operations_handler.hasFinished.connect( lambda: self.displayDyks(io_operations_handler.results)) io_operations_handler.loadParameters(f=dParsonsManifold, _args=[xdata, prp]) io_operations_handler.start() def displayKCoz(self, content): content = list(content) content.insert(0, 'Resultados - Kozeny-Carman') self.spreadsheet.addColumn(content) def displayWinl(self, content): self.loadPltE(content[:2]) content[2].insert(0, 'R35 - Winland') content[3].insert(0, 'Ports - Winland') self.spreadsheet.addColumn(content[2]) self.spreadsheet.addColumn(content[3]) def displayTCoa(self, content): content.insert(0, 'Resultados - Timur Coates') self.spreadsheet.addColumn(content) def displayDyks(self, content): content.insert(0, 'Resultados - Dykstra-Parsons') self.spreadsheet.addColumn(content) self.p_options_6.results.setText( 'Atenção! Resultado pode ser diferente do coeficiente calculado através do gráfico de probabilidade. \n' + str(content[0]) + ': ' + str(content[1])) def displayLuci(self, results): self.loadPltE(results[:2]) results[2].insert(0, 'Resultados - RFN/Lucia') self.spreadsheet.addColumn(results[2]) def displayFZIR(self, results): results[0].insert(0, 'Resultados - RQI (μm)') self.spreadsheet.addColumn(results[0]) results[1].insert(0, 'Resultados - PhiZ') self.spreadsheet.addColumn(results[1]) self.loadPltE(results[2:]) def displayRegr(self, display_name, results): self.s_options_1.results.setText(str(results[0])) self.loadPltE(results[-2:]) def displayStat(self, display_name, results): self.s_options_2.results.setText(str(results)) def displayHist(self, results): self.loadPltE(results, 'Histograma') def displayBxpl(self, results): self.loadPltE(results, 'Boxplot')
"Smruti Vidwans comments/ Topics": 'professor_comment' } __author__ = "Mauricio Lomeli" __date__ = "8/15/2019" __copyright__ = "Copyright 2019, KnowNow-Nav" __license__ = "MIT" __version__ = "0.0.0.1" __maintainer__ = "Mauricio Lomeli" __email__ = "*****@*****.**" __status__ = "Prototype" app = Flask(__name__) app.config["DEBUG"] = True sheet = Spreadsheet(DEFAULT_SPREADSHEET, NORM_HEADERS) @app.route("/") @app.route("/home") def home(): """ Renders the homepage. While the program is running, if a user enters 'localhost:5000/' into their web browser, they'll be rerouted to the homepage: Homepage.html :return: """ # removes duplicates and empty responses query = [item for item in set(sheet['query']) if item != ''] # remove this when final, it is only for displaying purposes.
def __init__(self): super().__init__() self.setWindowTitle('Petro-Explorer v1.0') win_icon = QIcon('icons/Logo.ico') self.setWindowIcon(win_icon) self.setStyleSheet('background-color: #363f49;') self.header = Header() self.navigation = Navigation() self.p_top_bar = PetrophysicsTopBar() self.s_top_bar = StatisticsTopBar() self.p_options_1 = PetrophysicsOptions(_mode='KCarman') self.p_options_2 = PetrophysicsOptions(_mode='TCoates') self.p_options_3 = PetrophysicsOptions(_mode='Winland') self.p_options_4 = PetrophysicsOptions(_mode='RQIFZI') self.p_options_5 = PetrophysicsOptions(_mode='Lucia') self.p_options_6 = PetrophysicsOptions(_mode='DParsons') self.s_options_1 = StatisticsOptions(_mode='Regression') self.s_options_2 = StatisticsOptions(_mode='Statistics') self.s_options_3 = StatisticsOptions(_mode='Histogram') self.s_options_4 = StatisticsOptions(_mode='Boxplot') self.sp_controls = SpreadsheetControls() self.plot_controls = PlotControls() self.plot_viewer = PlotViewer() self.spreadsheet = Spreadsheet() self.status_bar = QStatusBar() self.scroll_area_1 = QScrollArea() self.scroll_area_1.setWidget(self.spreadsheet) self.scroll_area_1.setWidgetResizable(True) self.scroll_area_2 = QScrollArea() self.scroll_area_2.setWidget(self.plot_viewer) self.scroll_area_2.setWidgetResizable(True) self.bar_widget = QWidget() self.bar_widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.central_widget = QWidget() self.options_widget = QWidget() self.docking_options = QDockWidget() self.docking_options.setWidget(self.options_widget) self.docking_options.setTitleBarWidget( DockWidgetRibbon(' Opções de cálculo')) self.docking_options2 = QDockWidget() self.docking_options2.setWidget(self.sp_controls) self.docking_options2.setTitleBarWidget( DockWidgetRibbon(' Controles de visualização')) self.setCentralWidget(self.central_widget) self.setStatusBar(self.status_bar) self.addToolBar(self.navigation) self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options) self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.docking_options2) self.connections() self.buildLayout() self.centralWidget().setStyleSheet('background-color: #2e3843') self.spreadsheet.setStyleSheet('background-color: white') self.status_bar.setStyleSheet('color: white')
def __init__(self,widget): super(Note, self).__init__(widget) self.keyLayout = QGridLayout() self.textLayout = QGridLayout() self.keyboardWidget = QWidget(widget) self.keyboardWidget.setGeometry(QRect(self.height*0.05, self.height*0.05, self.width/3, self.height*0.9)) #self.keyboardWidget.setStyleSheet("background-color: #71787a; color: white;") self.keyboardWidget.setLayout(self.keyLayout) self.textWidget = QWidget(widget) self.textWidget.setGeometry(QRect(2*self.height*0.05 + self.width/3, self.height*0.05, 2*self.width/3 - self.height*0.15, self.height*0.9)) #self.textWidget.setStyleSheet("background-color: #71787a;") self.textWidget.setLayout(self.textLayout) #----------BUTTONS-------------- self.buttonGroup = QButtonGroup() self.buttonGroup.setExclusive(True) self.lineGroup = [] btnDim = int(self.keyboardWidget.width()/5) btnSize = QSize(btnDim, btnDim) btnStyle = "background-color: black; font-size:" + str(int(btnDim*0.5)) + "px;" uploadBtnStyle = "background-color: black; font-size:" + str(int(btnDim*0.2)) + "px;" uploadGreenBtnStyle = "background-color: #17fc03; color: black; font-size:" + str(int(btnDim*0.2)) + "px;" self.buttons = [QPushButton(str(i)) for i in range(10)] position = [ [i,j] for i in range(3) for j in range(3)] position.insert(0,[3,1]) for i in range(10): self.buttons[i].setStyleSheet(btnStyle) self.buttons[i].setFixedSize(btnSize) self.keyLayout.addWidget(self.buttons[i], (position[i])[0], (position[i])[1]) self.buttonGroup.addButton(self.buttons[i]) self.cancel = QPushButton("C", self.keyboardWidget) self.cancel.setFixedSize(btnSize) self.cancel.setObjectName("cancel") self.cancel.setStyleSheet(btnStyle) self.keyLayout.addWidget(self.cancel, 3,0) self.cancel.clicked.connect(self.onClickCancel) self.comma = QPushButton(",", self.keyboardWidget) self.comma.setFixedSize(btnSize) self.comma.setObjectName("comma") self.comma.setStyleSheet(btnStyle) self.keyLayout.addWidget(self.comma, 3,2) self.buttonGroup.addButton(self.comma) self.next = QPushButton(QIcon("src/note/next.png"), "",self.keyboardWidget) self.next.setFixedSize(btnSize) self.next.setIconSize(btnSize) self.next.setObjectName("next") self.next.setStyleSheet(btnStyle) self.keyLayout.addWidget(self.next,4,2) self.buttonGroup.addButton(self.next) self.previous = QPushButton(QIcon("src/note/back.png"), "",self.keyboardWidget) self.previous.setFixedSize(btnSize) self.previous.setIconSize(btnSize) self.previous.setObjectName("previous") self.previous.setStyleSheet(btnStyle) self.keyLayout.addWidget(self.previous,4,0) self.buttonGroup.addButton(self.previous) self.upload = QPushButton("UPLOAD", self.keyboardWidget) self.upload.setFixedSize(btnSize) self.upload.setObjectName("upload") self.upload.setStyleSheet(uploadBtnStyle) self.keyLayout.addWidget(self.upload, 4,1) self.upload.clicked.connect(self.onClickUpload) self.buttonGroup.buttonClicked.connect(self.onClickButton) #----------TEXTBOX------------ textWidth = self.textWidget.width()/3 textHeight = textWidth/4 fontSize = str(int(textHeight/1.5)) textStyle = "background-color: black; font-size:" + fontSize + "px;" self.date = QDateEdit(self.textWidget) self.date.setObjectName("date") self.date.setStyleSheet(textStyle) self.date.setDate(QDateTime.currentDateTime().date()) self.textLayout.addWidget(self.date, 0,0) #self.lineGroup.append(self.date) self.fuel = QLineEdit(self.textWidget) self.fuel.setFixedSize(textWidth,textHeight) self.fuel.setStyleSheet(textStyle) self.textLayout.addWidget(self.fuel, 1,0) self.lineGroup.append(self.fuel) self.cost = QLineEdit(self.textWidget) self.cost.setFixedSize(textWidth,textHeight) self.cost.setStyleSheet(textStyle) self.textLayout.addWidget(self.cost, 2,0) self.lineGroup.append(self.cost) self.kilometers = QLineEdit(self.textWidget) self.kilometers.setFixedSize(textWidth,textHeight) self.kilometers.setStyleSheet(textStyle) self.textLayout.addWidget(self.kilometers, 3,0) self.lineGroup.append(self.kilometers) #----------LABEL------------- labelStyle = "color: black; font-size:" +str(int(self.keyboardWidget.width()/12))+ "px;" self.dateLabel = QLabel(self.textWidget) self.dateLabel.setText("DATE") self.dateLabel.setStyleSheet(labelStyle) self.textLayout.addWidget(self.dateLabel,0,1) self.fuelLabel = QLabel(self.textWidget) self.fuelLabel.setText("FUEL") self.fuelLabel.setStyleSheet(labelStyle) self.textLayout.addWidget(self.fuelLabel, 1,1) self.costLabel = QLabel(self.textWidget) self.costLabel.setText("COST") self.costLabel.setStyleSheet(labelStyle) self.textLayout.addWidget(self.costLabel, 2,1) self.kilometersLabel = QLabel(self.textWidget) self.kilometersLabel.setText("KILOMETERS") self.kilometersLabel.setStyleSheet(labelStyle) self.textLayout.addWidget(self.kilometersLabel,3,1) self.elementList.append(self.keyboardWidget) self.elementList.append(self.textWidget) self.index = 0 self.lineGroup[self.index].setFocus() self.show() try: self.spreadSheet = Spreadsheet() except httplib2.ServerNotFoundError: print("errore")
def write_all_leaderboards(spreadsheet: Spreadsheet, country_leaderboards: List[Dict[str, List[Tuple[str, str, int]]]], *args: str) -> None: """Writes all country leaderboards to the selected spreadsheet Parameters ---------- spreadsheet The spreadsheet to write the leaderboards to country_leaderboards The leaderboards to write to the spreadsheets args The names of the sheets that will have leaderboards written to them """ def rowcol_to_a1(row: int, col: int) -> str: """Converts row col cell format into the A1 Google Sheets cell format. Parameters ---------- row Integer representing the row of a cell. col Integer representing the column of a cell. Returns ------- label The A1 representation of the row/col number representation of a cell. """ row = int(row) col = int(col) div = col column_label = '' while div: (div, mod) = divmod(div, 26) if mod == 0: mod = 26 div -= 1 column_label = chr(mod + 64) + column_label label = '%s%s' % (column_label, row) return label all_value_ranges = [] for i in range(len(args)): sheet_name = args[i] start_col = 1 # Creates value range objects. Including formatting hyperlinks to player profiles. # Each county is 3 columns wide. for counties in sorted(country_leaderboards[i]): data = [["Rank", counties, "3's Peak MMR"]] rank = 1 for player in country_leaderboards[i][counties]: data.append([ rank, '=HYPERLINK("{}", "{}")'.format(player[1], player[0]), player[2] ]) rank += 1 range_str = "{}!{}:{}".format(sheet_name, rowcol_to_a1(1, start_col), rowcol_to_a1(rank, start_col + 2)) value_range = {"range": range_str, "values": data} all_value_ranges.append(value_range) start_col += 4 # Casts args which is Tuple[str, ...] to expected List[str] # No runtime cost, just for ide type checking system args = cast(List[str], args) spreadsheet.clear_ranges_values(args) spreadsheet.update_ranges_values(all_value_ranges) spreadsheet.autosize_all_columns()
if (len(sys.argv) < 4): print(USAGE.format(sys.argv[0])) sys.exit(1) # Parse command line arguments. credentialsFileName = sys.argv[1] documentName = sys.argv[2] targetName = sys.argv[3] print("Connecting to Google Sheets API") scope = ["https://spreadsheets.google.com/feeds"] credentials = ServiceAccountCredentials.from_json_keyfile_name( credentialsFileName, scope) client = gspread.authorize(credentials) print("Opening spreadsheet") spreadsheet = Spreadsheet(client) spreadsheet.open(documentName) print("Reading configuration page") cfgPage = spreadsheet.sheet("CFG") cfg = configurationFromPage(cfgPage) print("Reading source page") srcPage = spreadsheet.sheet("SRC") (languages, translations) = parsePage(srcPage, cfg) print("Found languages: '{0}'".format(languages)) if (targetName == "android"): androidGenerateLocalizationFiles(translations, languages) elif (targetName == "ios"):