当前位置: 首页>>代码示例>>Python>>正文


Python City.name方法代码示例

本文整理汇总了Python中models.City.name方法的典型用法代码示例。如果您正苦于以下问题:Python City.name方法的具体用法?Python City.name怎么用?Python City.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.City的用法示例。


在下文中一共展示了City.name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_city

# 需要导入模块: from models import City [as 别名]
# 或者: from models.City import name [as 别名]
def run_city(verbose=True, step=10, begin=0, end=0):
    import csv
    filename = os.path.join(settings.BASE_PATH, 'apps', 'world', 'data', 'cities.csv')
    reader = csv.reader(open(filename, 'rb'), delimiter=',', quotechar="'")
    for row in reader:
        c = City()
        c.name = row[4]
        c.capital = bool(int(row[9]))
        c.world_city = bool(int(row[12]))
        c.mega_city = bool(int(row[13]))
        c.point = Point(float(row[22]), float(row[21]))
        #don't save the city if a country can't be found for it
        try:
            c.country = CountryBorder.objects.get(iso3=row[17])
        except :
            continue
        
        try:
            c.state = StateBorder.objects.get(name=row[18])
        except :
            try:
                c.state = StateBorder.objects.get(mpoly__contains=c.point)
            except :
                pass
        c.sqkm = int(row[40])
        topleft = Point(float(row[48]), float(row[55]))
        topright = Point(float(row[51]), float(row[55]))
        bottomleft = Point(float(row[48]), float(row[52]))
        bottomright = Point(float(row[51]), float(row[52]))
        c.mpoly = MultiPolygon(Polygon(LinearRing(topleft, topright, bottomright, bottomleft, topleft)))
        c.save()
        print c.name
开发者ID:dustinmm80,项目名称:zedtrip,代码行数:34,代码来源:load.py

示例2: postCity

# 需要导入模块: from models import City [as 别名]
# 或者: from models.City import name [as 别名]
def postCity():
    try:
        city = City()
        if "name" in request.form: city.name = request.form["name"]
        if "maxLat" in request.form: city.pack = request.form["maxLat"]
        if "maxLon" in request.form: city.pack = request.form["maxLon"]
        if "minLat" in request.form: city.pack = request.form["minLat"]
        if "minLon" in request.form: city.pack = request.form["minLon"]

        db.session.add(city)
        db.session.commit()
        return make_response(jsonify( { 'ok': 'city created' } ), 200)
    except:
        return make_response(jsonify( { 'error': 'Server Error' } ), 500)
开发者ID:iPhoto,项目名称:SmileSpaces,代码行数:16,代码来源:views.py

示例3: create_or_getCity

# 需要导入模块: from models import City [as 别名]
# 或者: from models.City import name [as 别名]
def create_or_getCity(cityName, state, lat,lon):
    try:
        c = City.objects.get(name=cityName)
    except City.DoesNotExist:        
            r = requests.get("http://photon.komoot.de/api/?q={},{}&limit=1&lat={}&lon={}".format(cityName, state.name, lat,lon)).json()
            
            lastCity = City.objects.latest('created_on')
            c = City()
            c.id = lastCity.id +1
            c.name=cityName        
            c.stateID=state.id
            c.lat= r['features'][0]['geometry']['coordinates'][1]
            c.lon= r['features'][0]['geometry']['coordinates'][0]
            c.live="true"
            c.save()
    return c
开发者ID:tejas101,项目名称:airquality,代码行数:18,代码来源:views.py

示例4: seed_cities

# 需要导入模块: from models import City [as 别名]
# 或者: from models.City import name [as 别名]
    def seed_cities(self, number):
        """
        Crée des enregistrements aléatoires dans la table des villes
        :param number: nombre de villes
        :return: void
        """
        for i in range(0, number):
            city = City()
            city.name = self.fake.city()
            city.country = self.fake.country()
            city.is_capital = self.fake.pybool()
            self.city_service.save(city)

        capitals = self.city_service.all_capitals()
        non_capitals = self.city_service.all_non_capitals()

        for city in non_capitals:
            city.capital_id = random.choice(capitals).id
            self.city_service.save(city)
开发者ID:MarvinDurot,项目名称:travel_manager,代码行数:21,代码来源:seeder.py


注:本文中的models.City.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。