|
|
@@ -10,6 +10,8 @@ import json
|
|
|
import datetime
|
|
|
import custom_email
|
|
|
from tabulate import tabulate
|
|
|
+from configparser import ConfigParser
|
|
|
+from os import path
|
|
|
|
|
|
### TO DO ###
|
|
|
#
|
|
|
@@ -51,32 +53,46 @@ class Property:
|
|
|
self.acres = acres
|
|
|
self.description = description
|
|
|
self.link = link
|
|
|
-# self.distance_to_work = 0
|
|
|
-# self.time_to_work = 0
|
|
|
-# self.distance_to_school = 0
|
|
|
-# self.time_to_school = 0
|
|
|
|
|
|
+
|
|
|
|
|
|
class Search:
|
|
|
"""Universal Search Criteria"""
|
|
|
|
|
|
- def __init__(self, county: list, lower_price=0, upper_price=500000, \
|
|
|
- lower_acres=5, upper_acres=15, type=['farm','land','home'], lower_sqft='', upper_sqft='', \
|
|
|
- lower_bedrooms='', upper_bedrooms=''):
|
|
|
+# def __init__(self, county: list, lower_price=0, upper_price=500000, \
|
|
|
+# lower_acres=5, upper_acres=15, type=['farm','land','home'], lower_sqft='', upper_sqft='', \
|
|
|
+# lower_bedrooms='', upper_bedrooms=''):
|
|
|
+ def __init__(self):
|
|
|
+ try:
|
|
|
+ config = ConfigParser()
|
|
|
+ if path.exists('../landsearch.conf'):
|
|
|
+ config.read('../landsearch.conf')
|
|
|
+ search_params = config['Search']
|
|
|
+ else:
|
|
|
+ raise FileNotFoundError("Config file $HOME/TopGunSoftware/landsearch.conf not found.")
|
|
|
+ except FileNotFoundError as err:
|
|
|
+ print(err, "Using default search parameters.")
|
|
|
+ except Exception as err:
|
|
|
+ print(err, "Using default search parameters.")
|
|
|
+
|
|
|
self.types=['land', 'farm', 'home', 'house']
|
|
|
- self.county = county
|
|
|
- self.lower_price = lower_price
|
|
|
- self.upper_price = upper_price
|
|
|
- self.lower_acres = lower_acres
|
|
|
- self.upper_acres = upper_acres
|
|
|
- self.type = type ##accept list!
|
|
|
- self.lower_sqft = lower_sqft
|
|
|
- self.upper_sqft = upper_sqft
|
|
|
- self.lower_bedrooms = lower_bedrooms
|
|
|
- self.upper_bedrooms = upper_bedrooms
|
|
|
-
|
|
|
- for property_type in type:
|
|
|
+ self.county = search_params.get('county', ['Gwinnett', 'Hall', 'Jackson', 'Walton', 'Barrow'])
|
|
|
+ self.lower_price = search_params.get('lower_price', 0)
|
|
|
+ self.upper_price = search_params.get('upper_price', 525000)
|
|
|
+ self.lower_acres = search_params.get('lower_acres', 5)
|
|
|
+ self.upper_acres = search_params.get('upper_acres', 15)
|
|
|
+ self.type = search_params.get('type', ['farm', 'house', 'land']) ##accept list!
|
|
|
+ self.lower_sqft = search_params.get('lower_sqft', '')
|
|
|
+ self.upper_sqft = search_params.get('upper_sqft', '')
|
|
|
+ self.lower_bedrooms = search_params.get('lower_bedrooms', '')
|
|
|
+ self.upper_bedrooms = search_params.get('upper_bedrooms', '')
|
|
|
+
|
|
|
+ for property_type in self.type:
|
|
|
assert property_type in self.types, ("Unknown type '" + property_type + "'. Property Type must be of type: " + str(self.types))
|
|
|
+
|
|
|
+## FOR TESTING, PRINT ALL ATTRIBUTES OF SEARCH ##
|
|
|
+ print(vars(self))
|
|
|
+
|
|
|
|
|
|
class ImproperSearchError(Exception):
|
|
|
def __init__ (self, search, message="Improper Search. Must use instance of Search class"):
|
|
|
@@ -217,7 +233,13 @@ class MLSDATA:
|
|
|
See class search for more information.
|
|
|
--> 9/1/20 - takes Search class as argument. All properties are handled by the class <--"""
|
|
|
if isinstance(search, Search):
|
|
|
- if not search.county.capitalize() in self.counties: ### FIX for lower()
|
|
|
+ print(search.county)
|
|
|
+
|
|
|
+##
|
|
|
+# PROGRAM BREAKS HERE
|
|
|
+##
|
|
|
+
|
|
|
+ if not search.county in self.counties: ### FIX for lower()
|
|
|
print("County " + search.county + " not regognized. Exiting")
|
|
|
else:
|
|
|
print("Scanning for results in " + search.county + " using the " + self.mlstype.upper() + " database.")
|
|
|
@@ -376,25 +398,27 @@ The following properties have been found which may be of interest.\n
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
+# gmls = MLSDATA('GMLS')
|
|
|
+# Search()
|
|
|
|
|
|
gmls = MLSDATA('GMLS')
|
|
|
|
|
|
#new_properties = []
|
|
|
|
|
|
for county in ['Walton']: ### FIX
|
|
|
- mysearch = Search(county, type=['farm'], upper_price=400000) ### FIX
|
|
|
+ mysearch = Search() ### FIX
|
|
|
mydata = gmls.getmlsdata(mysearch)
|
|
|
|
|
|
gmls.connectdb()
|
|
|
gmls.dbinsert(mydata)
|
|
|
gmls.closedb()
|
|
|
-
|
|
|
- gmls.email()
|
|
|
-
|
|
|
-print()
|
|
|
-print(str(len(gmls.new_listings)) + " new properties found!")
|
|
|
-print()
|
|
|
-for listing in gmls.new_listings:
|
|
|
- print(listing.MLS, listing.address)
|
|
|
+#
|
|
|
+# gmls.email()
|
|
|
+#
|
|
|
+#print()
|
|
|
+#print(str(len(gmls.new_listings)) + " new properties found!")
|
|
|
+#print()
|
|
|
+#for listing in gmls.new_listings:
|
|
|
+# print(listing.MLS, listing.address)
|
|
|
|
|
|
|