From 774a2dacf813441b59bba01fdca15e30d2b9b0e2 Mon Sep 17 00:00:00 2001 From: Aaron Frase Date: Mon, 25 Jul 2016 15:33:10 -0400 Subject: [PATCH 1/2] Optimized imports --- pokecli.py | 15 ++++++------- pokemongo_bot/__init__.py | 21 +++++++++---------- .../cell_workers/evolve_all_worker.py | 7 ++++--- .../cell_workers/pokemon_catch_worker.py | 5 +++-- .../cell_workers/seen_fort_worker.py | 10 ++++----- pokemongo_bot/polyline_stepper.py | 10 +++++---- .../polyline_walker/polyline_tester.py | 5 ++++- .../polyline_walker/polyline_walker.py | 10 +++++---- pokemongo_bot/spiral_navigator.py | 18 +++------------- pokemongo_bot/step_walker.py | 5 ++--- 10 files changed, 49 insertions(+), 57 deletions(-) diff --git a/pokecli.py b/pokecli.py index 7ead36fa70..9a22a9f819 100755 --- a/pokecli.py +++ b/pokecli.py @@ -25,20 +25,17 @@ Author: tjado """ -import os -import re -import json import argparse -import time +import codecs +import json +import logging +import os import ssl import sys -import codecs from getpass import getpass -import logging -import requests -from pokemongo_bot import logger + from pokemongo_bot import PokemonGoBot -from pokemongo_bot.cell_workers.utils import print_green, print_yellow, print_red +from pokemongo_bot import logger if sys.version_info >= (2, 7, 9): ssl._create_default_https_context = ssl._create_unverified_context diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 0fc6014205..a64c5ea1d4 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -1,24 +1,23 @@ # -*- coding: utf-8 -*- -import logging -import googlemaps +import datetime import json +import logging import random -import threading -import time -import datetime -import sys -import logger import re +import sys +import time + +from geopy.geocoders import GoogleV3 from pgoapi import PGoApi -from pgoapi.utilities import f2i, h2f +from pgoapi.utilities import f2i + +import logger from cell_workers import PokemonCatchWorker, SeenFortWorker, MoveToFortWorker, InitialTransferWorker, EvolveAllWorker from cell_workers.utils import distance, get_cellid, encode from human_behaviour import sleep -from spiral_navigator import SpiralNavigator -from geopy.geocoders import GoogleV3 -from math import radians, sqrt, sin, cos, atan2 from item_list import Item +from spiral_navigator import SpiralNavigator class PokemonGoBot(object): diff --git a/pokemongo_bot/cell_workers/evolve_all_worker.py b/pokemongo_bot/cell_workers/evolve_all_worker.py index 9c46dc7555..c3e40a2629 100644 --- a/pokemongo_bot/cell_workers/evolve_all_worker.py +++ b/pokemongo_bot/cell_workers/evolve_all_worker.py @@ -1,8 +1,9 @@ -from utils import distance, format_dist -from pokemongo_bot.human_behaviour import sleep -from pokemongo_bot import logger from sets import Set +from pokemongo_bot import logger +from pokemongo_bot.human_behaviour import sleep + + class EvolveAllWorker(object): def __init__(self, bot): self.api = bot.api diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py index f31f99211d..ec5fc753d2 100644 --- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py +++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py @@ -2,9 +2,10 @@ import time from sets import Set -from utils import distance -from pokemongo_bot.human_behaviour import sleep + from pokemongo_bot import logger +from pokemongo_bot.human_behaviour import sleep + class PokemonCatchWorker(object): BAG_FULL = 'bag_full' diff --git a/pokemongo_bot/cell_workers/seen_fort_worker.py b/pokemongo_bot/cell_workers/seen_fort_worker.py index 673098d8d4..c5709ad511 100644 --- a/pokemongo_bot/cell_workers/seen_fort_worker.py +++ b/pokemongo_bot/cell_workers/seen_fort_worker.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -import json import time -from math import radians, sqrt, sin, cos, atan2 -from pgoapi.utilities import f2i, h2f -from utils import print_green, print_yellow, print_red, format_time -from pokemongo_bot.human_behaviour import sleep + +from pgoapi.utilities import f2i + from pokemongo_bot import logger +from pokemongo_bot.human_behaviour import sleep +from utils import format_time class SeenFortWorker(object): diff --git a/pokemongo_bot/polyline_stepper.py b/pokemongo_bot/polyline_stepper.py index fa91e51969..1ac25dd9a4 100644 --- a/pokemongo_bot/polyline_stepper.py +++ b/pokemongo_bot/polyline_stepper.py @@ -1,11 +1,13 @@ # -*- coding: utf-8 -*- -from polyline_walker import PolylineWalker -from stepper import Stepper from math import ceil -from human_behaviour import sleep -from cell_workers.utils import i2f + +from stepper import Stepper import logger +from cell_workers.utils import i2f +from human_behaviour import sleep +from polyline_walker import PolylineWalker + class PolylineStepper(Stepper): diff --git a/pokemongo_bot/polyline_walker/polyline_tester.py b/pokemongo_bot/polyline_walker/polyline_tester.py index fdf547fdd6..a8d0554e16 100644 --- a/pokemongo_bot/polyline_walker/polyline_tester.py +++ b/pokemongo_bot/polyline_walker/polyline_tester.py @@ -1,8 +1,11 @@ import time +from math import ceil + import haversine import polyline -from math import ceil + from polyline_walker import PolylineWalker + a = PolylineWalker('Poststrasse+20,Zug,CH', 'Guggiweg+7,Zug,CH', 100) print('Walking polyline: ', a.polyline) print('Encoded level: ','B'*len(a.points)) diff --git a/pokemongo_bot/polyline_walker/polyline_walker.py b/pokemongo_bot/polyline_walker/polyline_walker.py index ed82f311dd..2c5be3daaa 100644 --- a/pokemongo_bot/polyline_walker/polyline_walker.py +++ b/pokemongo_bot/polyline_walker/polyline_walker.py @@ -1,10 +1,12 @@ -import requests -import polyline -import haversine import time -from itertools import chain +from itertools import chain from math import ceil +import haversine +import polyline +import requests + + class PolylineWalker(object): def __init__(self, origin, destination, speed): diff --git a/pokemongo_bot/spiral_navigator.py b/pokemongo_bot/spiral_navigator.py index 661160dd08..770d609ee9 100644 --- a/pokemongo_bot/spiral_navigator.py +++ b/pokemongo_bot/spiral_navigator.py @@ -1,20 +1,8 @@ # -*- coding: utf-8 -*- - -import os -import json -import time -import pprint - -from math import ceil -from s2sphere import CellId, LatLng -from google.protobuf.internal import encoder - -from human_behaviour import sleep, random_lat_long_delta -from cell_workers.utils import distance, i2f, format_time, format_dist -from step_walker import StepWalker - -from pgoapi.utilities import f2i, h2f import logger +from cell_workers.utils import distance, i2f, format_dist +from human_behaviour import sleep +from step_walker import StepWalker class SpiralNavigator(object): diff --git a/pokemongo_bot/step_walker.py b/pokemongo_bot/step_walker.py index bba6d1e789..23e723b77c 100644 --- a/pokemongo_bot/step_walker.py +++ b/pokemongo_bot/step_walker.py @@ -1,8 +1,7 @@ -import logger +from math import sqrt -from cell_workers.utils import distance, i2f, format_time, format_dist +from cell_workers.utils import distance, i2f from human_behaviour import random_lat_long_delta, sleep -from math import ceil, sqrt class StepWalker(object): From 35efffa09271a9153bd0506dd34023fca358cb40 Mon Sep 17 00:00:00 2001 From: Aaron Frase Date: Mon, 25 Jul 2016 15:33:52 -0400 Subject: [PATCH 2/2] Replaced tabs with spaces to fix inconsistent indentation. --- pokemongo_bot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index a64c5ea1d4..8a864e37b3 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -183,7 +183,7 @@ def work_on_cell(self, cell, position): forts = [fort for fort in cell['forts'] if 'latitude' in fort and 'type' in fort] - gyms = [gym for gym in cell['forts'] if 'gym_points' in gym] + gyms = [gym for gym in cell['forts'] if 'gym_points' in gym] # Sort all by distance from current pos- eventually this should # build graph & A* it