Ejemplo n.º 1
0
def test_cropping():
    entire_screen_pil = Image.open(
        os.path.join(get_dir('tests', 'screenshots'), 'screenshot1.png'))
    top_left_corner = get_table_template_image('default', 'topleft_corner')
    img = cv2.cvtColor(np.array(entire_screen_pil), cv2.COLOR_BGR2RGB)
    count, points, bestfit, minimum_value = find_template_on_screen(
        top_left_corner, img, 0.01)
Ejemplo n.º 2
0
def test_crop_func():
    entire_screen_pil = Image.open(
        os.path.join(get_dir('tests', 'screenshots'), 'screenshot1.png'))
    top_left_corner = get_table_template_image('default', 'topleft_corner')
    cropped = crop_screenshot_with_topleft_corner(entire_screen_pil,
                                                  top_left_corner)
    assert cropped
Ejemplo n.º 3
0
def get_relevant_files():
    """
    Get relevant changed files of current branch vs target branch.

    check_all_files (bool): get all files if true, get changed files since comparison commit

    Filenames are filtered:
       - Files need to be in lint_extensions
       - Files cannot be in the exclude_folders list

    Returns:
        list of str: changed files

    """
    filenames = [
        y for x in os.walk(get_dir('codebase'))
        for y in glob(os.path.join(x[0], '*.py'))
    ]
    if os.name == 'nt':
        filenames = [filename.replace('/', """\\""") for filename in filenames]
    filenames = [filename for filename in filenames if filename]
    filenames = [
        filename for filename in filenames
        if os.path.splitext(filename)[1] in LINT_EXTENSIONS
    ]
    filenames = [os.path.join(CODEBASE, filename) for filename in filenames]
    log.debug(filenames)

    return filenames
Ejemplo n.º 4
0
def test_ocr_pp1():
    mongo = MongoManager()
    table_dict = mongo.get_table(
        "PartyPoker 6 Players Fast Forward $1-$2 NL Hold'em")
    table_scraper = TableScraper(table_dict)
    table_scraper.screenshot = Image.open(
        os.path.join(get_dir('tests', 'screenshots'),
                     '173280759_PreFlop_0.png'))
    table_scraper.crop_from_top_left_corner()

    result = ocr(table_scraper.screenshot, 'total_pot_area',
                 table_scraper.table_dict)
    assert result == 0.09

    result = ocr(table_scraper.screenshot, 'call_value',
                 table_scraper.table_dict)
    assert result == 0.04

    result = ocr(table_scraper.screenshot, 'raise_value',
                 table_scraper.table_dict)
    assert result == 0.1

    result = ocr(table_scraper.screenshot,
                 'player_funds_area',
                 table_scraper.table_dict,
                 player='0')
    assert result == 1.32
Ejemplo n.º 5
0
def test_crop_func():
    entire_screen_pil = Image.open(
        os.path.join(get_dir('tests', 'screenshots'),
                     '173280759_PreFlop_0.png'))
    top_left_corner = get_table_template_image(
        "PartyPoker 6 Players Fast Forward $1-$2 NL Hold'em", 'topleft_corner')
    cropped = crop_screenshot_with_topleft_corner(entire_screen_pil,
                                                  top_left_corner)
    assert cropped
Ejemplo n.º 6
0
def test_cropping():
    entire_screen_pil = Image.open(
        os.path.join(get_dir('tests', 'screenshots'),
                     '173280759_PreFlop_0.png'))
    top_left_corner = get_table_template_image(
        "PartyPoker 6 Players Fast Forward $1-$2 NL Hold'em", 'topleft_corner')
    img = cv2.cvtColor(np.array(entire_screen_pil), cv2.COLOR_BGR2RGB)
    count, points, bestfit, minimum_value = find_template_on_screen(
        top_left_corner, img, 0.01)
Ejemplo n.º 7
0
def test_table_scraper():
    mongo = MongoManager()
    table_dict = mongo.get_table('default')
    table_scraper = TableScraper(table_dict)
    table_scraper.screenshot = Image.open(
        os.path.join(get_dir('tests'), 'screenshot1.png'))
    table_scraper.crop_from_top_left_corner()
    table_scraper.is_my_turn()
    table_scraper.lost_everything()
    table_scraper.get_my_cards()
    table_scraper.get_table_cards()
    table_scraper.get_dealer_position()
    table_scraper.get_players_in_game()
    table_scraper.get_pots()
    table_scraper.get_players_funds()
    table_scraper.get_call_value()
    table_scraper.get_raise_value()
    table_scraper.all_in_call_button()
    table_scraper.has_call_button()
    table_scraper.has_raise_button()
Ejemplo n.º 8
0
def test_table_scraper():
    mongo = MongoManager()
    table_dict = mongo.get_table(
        "PartyPoker 6 Players Fast Forward $1-$2 NL Hold'em")
    table_scraper = TableScraper(table_dict)
    table_scraper.screenshot = Image.open(
        os.path.join(get_dir('tests', 'screenshots'),
                     '173280759_PreFlop_0.png'))
    table_scraper.crop_from_top_left_corner()
    table_scraper.is_my_turn()
    table_scraper.lost_everything()
    table_scraper.get_my_cards2()
    table_scraper.get_table_cards2()
    table_scraper.get_dealer_position2()
    table_scraper.get_players_in_game()
    table_scraper.get_pots()
    table_scraper.get_players_funds()
    table_scraper.get_call_value()
    table_scraper.get_raise_value()
    table_scraper.has_all_in_call_button()
    table_scraper.has_call_button()
    table_scraper.has_raise_button()
Ejemplo n.º 9
0
import os
import sys
from glob import glob

from pydocstyle import Error, check
from pydocstyle.cli import setup_stream_handlers, ReturnCode
from pydocstyle.config import ConfigurationParser, IllegalConfiguration
from pylint import lint
from pylint.reporters.text import TextReporter

from  tools.helper import get_dir

# pylint: disable=anomalous-backslash-in-string,too-few-public-methods,inconsistent-return-statements

log = logging.getLogger(__name__)
CODEBASE = get_dir('codebase')
REPOS = [name for name in os.listdir(CODEBASE) if os.path.isdir(name)]

FOLDERS = [name for name in os.listdir(CODEBASE) if
           os.path.isdir(os.path.join(CODEBASE, name)) and '.' not in name[0] and '_' not in name[0]]

LINT_EXTENSIONS = ['.py']

EXCLUDE_SUBFOLDERS = ['.idea', 'doc', 'mongodb-backup','mongodb-transfer2']

# To ignore specific rules, please disable it in your file or function,
# or (if given broad consensus) ignore it globally by adding an exception to .pylintrc.
# Full list of readable pylint message short-names can be found here:
# https://github.com/janjur/readable-pylint-messages

IGNORE_LIST = ["""\r\n""",  # part of final output