def build_vehicle(self, vehicleid, podid, pod_name, model_name): model = VehicleModel() model.name = model_name pod = Pod(podid) pod.name = pod_name vehicle = Vehicle(vehicleid) vehicle.pod = pod vehicle.model = model return vehicle
def get_pod_and_distance_from_html_data(self, pod_info_div): pod_link = pod_info_div.find('a') matches = re.match(r'(?P<name>.*) - (?P<dist>[0-9]+\.?[0-9]*) mile\(s\)', pod_link.text) pod_name = str(matches.group('name')) pod_dist = float(matches.group('dist')) matches = re.match(r'MV\.controls\.results\.show_pod_details\((?P<pod_id>[0-9]+)\)', pod_link['onclick']) pod_id = matches.group('pod_id') pod = Pod(pod_id) pod.name = pod_name return pod, pod_dist
def build_vehicle_from_td_element(self, td): pod_a = td.find('a') pod_url = pod_a['href'] pod_names = pod_a.text url_match = re.match(r'my_fleet\.php\?mv_action=show&_r=\d+&pk=(?P<pod_id>\d+)', pod_url) podid = url_match.group('pod_id') vehicle_model, pod_name = \ self.decode_vehicle_name_info_from_element(pod_a) pod = Pod(podid) pod.url = pod_url pod.name = pod_name model = VehicleModel() model.name = vehicle_model vehicle = Vehicle(None) vehicle.model = model vehicle.pod = pod return vehicle