Example #1
0
 def save(self, file_descriptor):
     for st_id in self.stations:
         station = self.get_json(st_id)
         if station == None:
             continue
         meta = {'index': {'_index': name_index, '_type': 'station', '_id': station['id']}}
         util.save_json_to_file(file_descriptor, meta, station)
Example #2
0
 def form_file(self, file_descriptor):
     for st_id in self.stations:
         station_tn = self.get_json(st_id)
         if station_tn == None:
             continue
         complex_id = station_tn['id']
         meta = {'index': {'_index': conf.get('name-index'), '_type': 'station', '_id': complex_id}}
         util.save_json_to_file(file_descriptor, meta, station_tn)
Example #3
0
 def save(self, file_descriptor):
     for mr_id in self.marshes:
         if self.check_in_area(mr_id) and not self.is_aeroexspress(mr_id):
             if len(self.marshes[mr_id]['stations']) > 1:
                 route = self.get_json_route(mr_id)
                 meta = {'index': {'_index': name_index, '_type': 'route', '_id': route['id']}}
                 util.save_json_to_file(file_descriptor, meta, route)
             else:
                 logger.info(u'На маршруте %s %s id=%d, менее 2 остановок', self.marshes[mr_id]['name'], self.marshes[mr_id]['direction'], mr_id)
Example #4
0
 def form_route(self, mr_id, direction, file_descriptor):
     route = self.create_route(mr_id, direction)
     complex_id = route['id']
     meta = {
         'index': {
             '_index': conf.get('name-index'),
             '_type': 'route',
             '_id': complex_id
         }
     }
     util.save_json_to_file(file_descriptor, meta, route)
Example #5
0
 def form_file(self, file_descriptor):
     for st_id in self.stations:
         station_tn = self.get_json(st_id)
         if station_tn == None:
             continue
         complex_id = station_tn['id']
         meta = {
             'index': {
                 '_index': conf.get('name-index'),
                 '_type': 'station',
                 '_id': complex_id
             }
         }
         util.save_json_to_file(file_descriptor, meta, station_tn)
Example #6
0
 def form_route(self, mr_id, direction, file_descriptor):
     route = self.create_route(mr_id, direction)
     complex_id = route['id']
     meta = {'index': {'_index': conf.get('name-index'), '_type': 'route', '_id': complex_id}}
     util.save_json_to_file(file_descriptor, meta, route)
Example #7
0
def main():
    with codecs.open(args.name_file[0], "w", encoding='utf-8') as file_descriptor:
        for hit in args.documents_source:
            meta = {'index': {'_index': hit['_index'], '_type': hit['_type'], '_id': hit['_id']}}
            body = hit['_source']
            util.save_json_to_file(file_descriptor, meta, body)
Example #8
0
def save_cards(cards):
    util.save_json_to_file(cards, 'trello_cards.json')
Example #9
0
def add_flight(flight):
    flights = get_flights()
    flights.append(flight)
    util.save_json_to_file(flights, 'flight_details.json', True)
Example #10
0
def add_error(error):
    errors = get_errors()
    errors.append(error)
    util.save_json_to_file(errors, 'errors.json', True)