def create_main(self, parent, cur): """ Create main function | Structure: | Main | | Declares | | Returns | | Params | | <code block> Args: parent (Funcs): Reference to parent node cur (int): position where main function is identified Returns: int: position where main function ends See also: :py:func:`matlab2cpp.tree.functions.main` """ assert isinstance(parent, mc.collection.Funcs) return functions.main(self, parent, cur)
def create_main(self, parent, cur): """ Create main function | Structure: | Main | | Declares | | Returns | | Params | | <code block> Args: parent (Funcs): Reference to parent node cur (int): position where main function is identified Returns: int: position where main function ends See also: :py:func:`matlab2cpp.tree.functions.main` """ assert isinstance(parent, mc.collection.Funcs) return functions.main(self, parent, cur)
Librairies requises (à installer via pip dans un virtualenv de préférence) lxml psycopg2 requests SPARQLWrapper xmltodict ''' try: conn = psycopg2.connect(SQLALCHEMY_DATABASE_URI) except Exception as e: print("Connexion à la base impossible") try: cur = conn.cursor() # sql = """SELECT DISTINCT cd_ref # FROM taxonomie.bib_noms # LEFT OUTER JOIN taxonomie.t_medias USING(cd_ref) # WHERE id_media IS NULL # """ sql = """SELECT cd_ref from taxonomie.bib_noms LIMIT 10""" # sql = """SELECT cd_ref from atlas.vm_taxons_plus_observes LIMIT 100""" cur.execute(sql) rows = cur.fetchall() except Exception as e: print("Problème lors de la récupération de la liste des cd_ref") main(conn, rows, False, False) conn.close()
#Constantes type de média et id_type média # Images WD_MEDIA_PROP = 'P18' TAXHUB_MEDIA_ID_TYPE = '2' # Audios # WD_MEDIA_PROP='P51' # TAXHUB_MEDIA_ID_TYPE='5' try: conn = psycopg2.connect(SQLALCHEMY_DATABASE_URI) except Exception as e: print("Connexion à la base impossible") try: cur = conn.cursor() # sql = """SELECT DISTINCT cd_ref # FROM taxonomie.bib_noms # LEFT OUTER JOIN taxonomie.t_medias USING(cd_ref) # WHERE id_media IS NULL # """ sql = """SELECT cd_ref from taxonomie.bib_noms LIMIT 10""" # sql = """SELECT cd_ref from atlas.vm_taxons_plus_observes LIMIT 100""" cur.execute(sql) rows = cur.fetchall() except Exception as e: print("Problème lors de la récupération de la liste des cd_ref") main(conn, rows, WD_MEDIA_PROP, TAXHUB_MEDIA_ID_TYPE, False, False) conn.close()
import time #logging.basicConfig(level=logging.INFO) api_id = int(os.environ.get("APP_ID")) api_hash = str(os.environ.get("API_HASH")) api_session = str(os.environ.get("SESSION")) try: api_session = api_session.strip('][').split(', ') except: api_session = [api_session] try: cw_ids = str(os.environ.get("CW_IDS")) cw_ids = ast.literal_eval(cw_ids) if len(cw_ids) == 1: cw_ids += [cw_ids[0] for i in range(len(api_session) - len(cw_ids))] else: cw_ids += [{} for i in range(len(api_session) - len(cw_ids))] except: cw_ids = [{} for i in api_session] if isinstance(api_session, list): cuentas = [ main(api_id, api_hash, str(api_session[i]), cw_ids[i]) for i in range(len(api_session)) ] else: cuenta = main(api_id, api_hash, api_session, cw_ids) print(cuenta)
import os from functions import main from dotenv import load_dotenv load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') if not TOKEN: print("Discord token is not set, please set it in your .env file") else: main(TOKEN)
import functions functions.main()
from functions import validator, area_tool, perimeter_tool, main true = True history = [] area_perimeter = ["area", "perimeter"] while history != "end": history = main(history)
def test_main(self): self.assertEqual(functions.main(), None)
# By: Marcos Gil from functions import main, mean, trimmedMean, median # Importing the functions I created in my functions file main( ) # Calling my main function that I created in functions that initializes the program
def test_unpaid_request(self): self.request.get_json()['financial_status'] = "unpaid" result = functions.main(self.request) self.assertEqual(result.response[0].decode(), "Can't handle unpaid calls")
# Lancer le scripte : python3 run.py < in.txt > out.txt # Imports from time import time #import pyximport #pyximport.install() import functions # Reads number of test cases t = int(input()) # Writes in out.txt for k in range(1, t + 1): # n = int(input()) # n, m = [int(s) for s in input().split(" ")] # v = [int(s) for s in input().split(" ")] # m = [[int(s) for s in input().split(" ")] for _ in range(n)] R, C = [int(s) for s in input().split(" ")] grid = [] for i in range(R): grid.append([int(s) for s in input()]) #print(grid) time1 = time() print("Case #{}: {}".format(k, functions.main(grid, R, C))) print(time() - time1)
from selenium import webdriver except ImportError: subprocess.call([sys.executable, '-m', 'pip', 'install', selenium]) from functions import main download_path = os.getcwd() try: options = webdriver.ChromeOptions() options.headless = True prefs = {'download.default_directory': download_path} options.add_experimental_option('prefs', prefs) options.add_experimental_option('excludeSwitches', ['enable-logging']) driver = webdriver.Chrome(options=options, service_log_path='nul') except: options = webdriver.FirefoxOptions() options.headless = True options.set_preference("browser.download.folderList", 2) options.set_preference("browser.download.manager.showWhenStarting", False) options.set_preference("browser.download.dir", download_path) options.set_preference('devtools.jsonview.enabled', False) driver = webdriver.Firefox(options=options, service_log_path='nul') if __name__ == '__main__': main(driver) driver.close() driver.quit() os.system('pause')
from station import Station from station_elements import Way, Train from functions import main try: ways = [Way(12, '12'), Way(10, '12')] trains = [Train(10, '123q', '2000', '1016')] station = Station(ways) except TypeError: raise TypeError('Отсутсвуют позиционные аргументы') main(trains, station)
def createList(self): msg = QMessageBox() dataFile = self.openFileEntry.text() if len(dataFile.strip()) == 0: msg.setIcon(QMessageBox.Critical) msg.setText(f'Source file entry is empty!') msg.setWindowTitle('Failed') msg.setDetailedText('Enter a valid file name and try again.') msg.exec_() return elif not os.path.exists(dataFile): msg.setIcon(QMessageBox.Critical) msg.setText(f'{dataFile} does not exist!') msg.setWindowTitle('Failed') msg.setDetailedText('Enter a valid file name and try again.') msg.exec_() return groupFile = self.saveFileEntry.text() if len(groupFile.strip()) == 0: msg.setIcon(QMessageBox.Critical) msg.setText('Target file entry is empty!') msg.setWindowTitle('Failed') msg.setDetailedText('Enter a valid file name and try again.') msg.exec_() return groupSizeRaw = self.sizeOfGroupEntry.text() if not groupSizeRaw.isnumeric(): msg.setIcon(QMessageBox.Critical) msg.setText('Group size must be a number!') msg.setWindowTitle('Failed') msg.setDetailedText('Enter a valid number and try again.') msg.exec_() return groupSize = int(groupSizeRaw) allowLess = self.allowLessInGroupOpt.isChecked() hasHeader = self.hasHeader.isChecked() startRow = 0 if hasHeader: startRow = 1 # Do the work ok = fns.main(dataFile, groupFile, groupSize, allowLess, start=startRow) if not ok: msg.setIcon(QMessageBox.Critical) msg.setText('Operation failed!') msg.setWindowTitle('Failed') msg.setDetailedText('Reason: Group size grater than input size.') msg.exec_() return fname = os.path.split(groupFile) now = datetime.datetime.now() msg.setIcon(QMessageBox.Information) msg.setText(f'{fname[1]} was created') msg.setWindowTitle('Success') msg.setDetailedText(f'Operation completed at {now.strftime("%Y-%m-%d %H:%M:%S")} \n\nRead from {dataFile} \n\nWrite to {groupFile}') msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msg.exec_()
from functions import main main()
"""This script demonstrates how to work with system path variables through Python""" import os import sys import functions # Print all the environmental variables variables = os.getenv("PATH").split(";") print(variables) # Appending the file path to the function to the evironmental variables sys.path.append("G:\Dropbox\Github\PyBook\\functions.py") functions.main()
help="API Protocol, default: http", default="http", ) parser.add_argument( "-a", "--address", help="Node API IP/Hostname, default: 127.0.0.1", default="127.0.0.1", ) parser.add_argument( "-o", "--port", help="Node API Port, default: 3413", default="3413", ) parser.add_argument( "-t", "--threads", help="Number of threads, default: 10", default=2, ) args = parser.parse_args() main( get_latest_block(f"{args.protocol}://{args.address}:" f"{args.port}/v2/owner"), f"{args.protocol}://{args.address}:" f"{args.port}/v2/foreign", int(args.threads), )
from keras.models import load_model import functions model = load_model('face-rec_Google.h5') functions.main(model)
#Resticciones: Elaborar una aplicación de línea de comandos en Python que sirva cuyo propósito sea mantener un # diccionario de palabras del slang panameño (xopa, mopri, otras). Las palabras y su significado deben ser almacenadas # dentro de una base de datos SQLite. Las opciones dentro del programa deben incluir como mínimo: # a) Agregar nueva palabra, b) Editar palabra existente, c) Eliminar palabra existente, # d) Ver listado de palabras, e) Buscar significado de palabra, f) Salir from functions import add,delete,edit,display,get_def,control,main if __name__=="__main__": main(opcion=True)
# -*- coding: utf-8 -*- import functions # 屏幕分辨率(根据手机修改) x, y = 1920, 1080 #使用说明 #刷金币进入冒险模式,选择魔女的回忆,进入有闯关的按钮的界面,运行脚本。 # 各步骤等待间隔 #step_wait[0]为加载时间,不同手机加载速度不同 #step_wait[1]为战斗时间 #step_wait[2]为结算时间 #小米6的适配参数为[10,20,3] wait_times = [10, 22, 3] # 刷金币次数 #刷满4200金币需要222次 #直接回车默认刷满 #虚拟机adb初始化 #functions.VT_init() functions.main(wait_times, x, y)
#!/usr/bin/env python """ lien http://www.java2s.com/Tutorial/Python/0360__Tkinker/Drawtext.htm http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_text-method http://apprendre-python.com/page-tkinter-interface-graphique-python-tutoriel http://www.java2s.com/Tutorial/Python/0360__Tkinker/Scrolledcanvas.htm http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm http://stackoverflow.com/questions/22838255/tkinter-canvas-resizing-automatically """ #Importation des bibliotheques necessaires import os import functions from tkinter import * if __name__ == '__main__': menu = functions.main()
Librairies requises (à installer via pip dans un virtualenv de préférence) lxml psycopg2 requests SPARQLWrapper xmltodict ''' try: conn = psycopg2.connect(SQLALCHEMY_DATABASE_URI) except Exception as e: print("Connexion à la base impossible") try: cur = conn.cursor() # sql = """SELECT DISTINCT cd_ref # FROM taxonomie.bib_noms # LEFT OUTER JOIN taxonomie.t_medias USING(cd_ref) # WHERE id_media IS NULL # """ sql = """SELECT cd_ref from taxonomie.bib_noms LIMIT 10""" # sql = """SELECT cd_ref from atlas.vm_taxons_plus_observes LIMIT 100""" cur.execute(sql) rows = cur.fetchall() except Exception as e: print("Problème lors de la récupération de la liste des cd_ref") main(conn, rows, False, False) conn.close()