コード例 #1
0
ファイル: Location.py プロジェクト: SkinMissle76/wisautprof
class LinkedinLocation:

  def __init__(self):
    self._cdb = CountiesDB()

  def getCounty(self, locationStr):
    l = self._splitLocationString(locationStr)
    if len(l) == 2:
      city, county = l[0], l[1]
      foundCounty1 = self._cdb.getCityCounty(city)
      foundCounty2 = self._cdb.getCountyByName(county)
    elif len(l) == 1:
      cityOrCounty = l[0]
      foundCounty1 = self._cdb.getCityCounty(cityOrCounty)
      foundCounty2 = self._cdb.getCountyByName(cityOrCounty)
    else:
      return None

    if foundCounty1 is not None:
      return foundCounty1
    elif foundCounty2 is not None :
      return foundCounty2
    else:
      return None



  def _splitLocationString(self, locationStr):
    return filter(lambda i : not self._strAreEqual(i, "United Kingdom"),
                  locationStr.split(", "))

  def _strAreEqual(self, a, b):
    return str.lower(str(a)) == str.lower(str(b))
コード例 #2
0
from models.CitiesCountiesDB import CountiesDB


db = CountiesDB()

countyId = 2
county = db.get(str(countyId))
print county["county"]
print county["cities"]
コード例 #3
0
ファイル: Location.py プロジェクト: SkinMissle76/wisautprof
 def __init__(self):
   self._cdb = CountiesDB()
コード例 #4
0
def getAllCountiesToSearch():
  c_db = CountiesDB()
  counties = map(lambda c : c["county"], c_db.getAllCounties())
  return counties
コード例 #5
0
def getAllCitiesToSearch():
  c_db = CountiesDB()
  cities = c_db.getAllCities()

  sortedCities = sorted(cities, key = lambda c : c["city"])
  return sortedCities
コード例 #6
0
from models.CitiesCountiesDB import CountiesDB
from crawlers.WikipediaUkCities import WikipediaUKCities



db = CountiesDB()
wc = WikipediaUKCities()

counties = wc.getCounties()
print "fetched information for", len(counties.keys()), "counties"

for i,c in counties.iteritems():
  db.add(str(i), c)