Best Python code snippet using avocado_python
__init__.py
Source: __init__.py
...16 for seq in seq_seq:17 if item in seq:18 return True19 return False20def is_script(string, script, ignore=['Inherited', 'Common', 'Unknown']):21 """Returns: true if all chars in string belong to script.22 Args:23 string: A string to test (may be a single char).24 script: Script long name, as in Unicode UCD's Scripts.txt (viz.).25 ignore: A list of scripts that will always suceed for matching purposes.26 For example, ASCII punctuation is listed as 'Common', so 'A.' will27 match as 'Latin', and 'ã.' will match as 'Hiragana'. See UAX #2428 for details.29 >>> is_script('A', 'Latin')30 True31 >>> is_script('ArtemÃsia', 'Latin')32 True33 >>> is_script('á¼Ïίνθιον ', 'Latin')34 False35 >>> is_script('Let θι = 3', 'Latin', ignore=['Greek', 'Common', 'Inherited', 'Unknown'])36 True37 >>> is_script('ã¯ãã¯ããã¼ã®', 'Hiragana')38 True39 >>> is_script('ã¯ãã¯:ããã¼ã®.', 'Hiragana')40 True41 >>> is_script('ã¯ãã¯:ããã¼ã®.', 'Hiragana', ignore=[])42 False43 """44 if ignore == None: ignore = []45 ignore_ranges = []46 for ignored in ignore:47 ignore_ranges += RANGES[ignored]48 for char in string:49 cp = ord(char)50 if ((not in_any_seq(cp, RANGES[script.capitalize()]))51 and not in_any_seq(cp, ignore_ranges)):52 return False53 return True54def which_scripts(char):55 """Returns: list of scripts that char belongs to....
main.py
Source: main.py
1import sqlite32from constants import OLD_DATABASE, CREATE_QUERIES, MIGRATE_SECOND, MIGRATE_JOIN3from flask import Flask, jsonify4import logging5logging.basicConfig(encoding='utf-8', level=logging.INFO)6app = Flask(__name__)7def get_sqlite_query(query, base=OLD_DATABASE, is_script=False):8 """ЧиÑаем ÑÑаÑÑÑ Ð±Ð°Ð·Ñ Ð´Ð°Ð½Ð½ÑÑ
"""9 with sqlite3.connect(base) as connection:10 cursor = connection.cursor()11 if is_script:12 result = cursor.executescript(query)13 else:14 result = cursor.execute(query)15 return result.fetchall()16def get_all_by_id(id):17 query = f"""18 SELECT * 19 FROM animals_new20 WHERE id == {id}21 """22 raw = get_sqlite_query(query, is_script=False)23 result_dict = {'id': raw[0][0], 'age_upon_outcome': raw[0][1], 'animal_id': raw[0][2],24 'name': raw[0][3], 'id_type': raw[0][4], 'id_breed': raw[0][5],25 'id_color1': raw[0][6], 'id_color2': raw[0][7], 'dateOfBirth': raw[0][8][0:10],26 'id_outcome_subtype': raw[0][9], 'id_outcome_type': raw[0][10], 'outcome_month': raw[0][11],27 'outcome_year': raw[0][12]}28 return result_dict29# Создание новÑÑ
ÑаблиÑ. ÐÑÐ½Ð¾Ð²Ð½Ð°Ñ ÑаблиÑа + допÑ30get_sqlite_query(CREATE_QUERIES, is_script=True)31# Ðаполнение доп. ÑÐ°Ð±Ð»Ð¸Ñ Ð´Ð°Ð½Ð½Ñми32get_sqlite_query(MIGRATE_SECOND, is_script=True)33# Ðаполнение оÑновной ÑаблиÑÑ Ð°Ð¹Ð´Ð¸Ñниками ÑеÑез JOIN34get_sqlite_query(MIGRATE_JOIN, is_script=False)35# print((get_all_by_id(1)))36@app.route('/<id>/')37def get_by_id(id):38 """ Шаг 1. ÐоиÑк по Ð½Ð°Ð·Ð²Ð°Ð½Ð¸Ñ Ñамого Ñвежего """39 logging.info(f'ÐÑем по ID: {id}')40 animal = get_all_by_id(id) # СловаÑÑ Ñ Ð´Ð°Ð½Ð½Ñми по ÐÐÐÐÐУ поÑÑÑ41 logging.info(f'ФÑнкÑÐ¸Ñ Ð¿Ð¾Ð¸Ñка веÑнÑла: {animal}')42 return jsonify(animal)43app.config['JSON_AS_ASCII'] = False44if __name__ == '__main__':...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!