Get vehicle summary.
771396
def get_summary(session):
    """"""
    profile = get_profile(session)
    return {
        'user': {
            'email': profile['userProfile']['eMail'],
            'name': '{} {}'.format(profile['userProfile']['firstName'],
                                   profile['userProfile']['lastName'])
        },
        'vehicles': [
            {
                'vin': vehicle['vin'],
                'year': vehicle['year'],
                'make': vehicle['make'],
                'model': _get_model(vehicle),
                'odometer': vehicle['odometerMileage']
            } for vehicle in profile['vehicles']
        ]
    }
617686
def get_details(exc):
    """"""
    detail = None
    fields = collections.OrderedDict()

    if exc.detail:
        detail = exc.detail

    if exc.fields:
        for k, v in six.iteritems(exc.fields):
            try:
                field_detail = v["detail"]
            except (TypeError, KeyError):
                field_detail = v

            if isinstance(field_detail, (list, tuple)):
                field_detail = " ".join(field_detail)

            if k == "non_field_errors":
                if detail:
                    detail += " " + field_detail
                else:
                    detail = field_detail
                continue

            fields[k] = field_detail

    return detail, fields
768095
def get_report(session, vehicle_index):
    """"""
    vhr = get_vehicle_health_report(session, vehicle_index)
    if 'reportCard' not in vhr:
        raise MoparError("no vhr found")
    return _traverse_report(vhr['reportCard'])
1007254
def _get_model(vehicle):
    """"""
    model = vehicle['model']
    model = model.replace(vehicle['year'], '')
    model = model.replace(vehicle['make'], '')
    return model.strip().split(' ')[0]
211560
def summary(self):
        """"""
        return "== Model %s did not complete test %s due to error '%s'. ==" %\
               (str(self.model), str(self.test), str(self.score))
168865
def summarize(self):
        """"""

        s = str(self.allval())

        return self.parse(s[:2]+ ''.join(['Z']*len(s[2:])))
1136465
async def upcoming(self, details: bool = False) -> list:
        """"""
        endpoint = 'dailystats'
        key = 'DailyStats'
        if details:
            endpoint += '/details'
            key = 'DailyStatsDetails'
        data = await self._request('get', endpoint)
        return data[key]
146717
def get_summary_data(self, sec2d_nt):
        """"""
        grouped = set()
        ungrouped = set()
        sections = set()
        secdflt = self.grprobj.hdrobj.secdflt
        for section_name, nts in sec2d_nt:
            if section_name != secdflt:
                if nts:
                    grouped.update(set(nt.GO for nt in nts))
                    sections.add(section_name)
                else:
                    ungrouped.update(set(nt.GO for nt in nts))
        return {'grouped':grouped, 'ungrouped':ungrouped, 'sections':sections}
1115815
def parse_detail(self, response):
        """"""
        # Product Information (a start)
        product_data = {
            'url': response.url,
            'name': response.css('div.page-title h1::text').extract_first(),
        }

        # Inventory Number
        inventory_number = re.search(
            r'(?P<inv_num>\d+)$',
            response.css('span.product-in::text').extract_first(),
        ).group('inv_num')
        product_data.update({'in': inventory_number})

        # Specifications (arbitrary key:value pairs)
        specs_table = response.css('#tab-specs dl')
        for row in specs_table.css('div.spec-row'):
            keys = row.css('dt::text').extract()
            values = row.css('dd::text').extract()
            product_data.update({
                key: value
                for (key, value) in zip(keys, values)
            })

        self.logger.info(product_data['name'])
        yield product_data
123889
def get_routes(departure, dest, vehicle='vlakbus', time='', date=''):
    """"""

    def _get_leaf_element(table, path):
        """Returns leaf element's text in given path"""
        res = table.xpath(path + '/*[not(*)]')
        if res:
            return res[0].text
        return table.xpath(path + '/text()')[0]

    if time == '':
        time = datetime.datetime.now().strftime('%H:%M')

    if date == '':
        date = datetime.datetime.now().strftime('%d.%m.%Y')

    try:
        req = requests.get(CPSK_URL.format(vehicle),
                           params={'date': date, 'time': time, 'f': departure,
                                   't': dest, 'submit': 'true'})
    except:
        return False

    tree = html.fromstring(req.text)
    html_tables = tree.xpath('//div[@id="main-res-inner"]/table/tbody')
    routes = []

    for table in html_tables:
        drive = Drive()
        datalen = len(table.xpath('./tr'))

        prevdate = ''
        for i in range(1, datalen-1):
            line = Line()
            trf = './tr[' + str(i) + ']'
            trt = './tr[' + str(i+1) + ']'
            line.f = _get_leaf_element(table, trf + '/td[3]')
            line.t = _get_leaf_element(table, trt + '/td[3]')
            line.departure = _get_leaf_element(table, trf + '/td[5]')
            line.arrival = _get_leaf_element(table, trt + '/td[4]')
            line.vehicle = table.xpath(trf + '/td[7]/img[1]')[0] \
                                .get('title').replace('Autobus', 'Bus')
            if line.vehicle == 'Presun':
                line.walk_duration = table.xpath(trf + '/td[7]/text()')[0] \
                    .replace('Presun asi ', '')

            delay = table.xpath(trf + '/td[7]/div[1]/' +
                                'span[@class!="nodelay"]/text()')
            if delay and delay[0] is not u'Aktuálne bez meškania':
                mins = delay[0].replace(u'Aktuálne meškanie ', '') \
                               .replace(u' minúty', '') \
                               .replace(u' minútu', '') \
                               .replace(u' minút', '')

                minstr = 'minutes' if mins is not '1' else 'minute'

                line.delay = ' ({0} {1} delay)'.format(mins, minstr)

            platform = table.xpath(trf + '/td[6]/span[1]/text()')
            platform2 = table.xpath(trf + '/td[6]/table/tr[1]/' +
                                    'td[1]/span[1]/text()')
            if platform:
                line.platform = '[{0}]'.format(platform[0])
            elif platform2:
                line.platform = '[{0}]'.format(platform2[0])

            _date = table.xpath(trf + '/td[2]/text()')[0]
            if _date is not ' ':
                prevdate = _date
            line.date = prevdate

            drive.lines.append(line)

        drive.duration = table.xpath('./tr[' + str(datalen) +
                                     ']/td[3]/p/strong[1]/text()')[0]

        try:
            drive.distance = table.xpath('./tr[' + str(datalen) +
                                         ']/td[3]/p/strong[2]/text()')[0]
        except IndexError:
            drive.distance = 'Distance not known'

        routes.append(drive)

    return routes
525265
def desc(self):
        """"""
        doc = inspect.getdoc(self.controller_class)
        if not doc: doc = ''
        return doc
940629
def prt_summary(self, prt=sys.stdout):
        """"""
        # Grouping summary
        fmtstr = "Grouped: {U:3,} User GOs, using {h:2,} of {H:,} Grouping GOs, for run: {NAME}\n"
        prt.write(fmtstr.format(
            NAME=self.grpname,
            U=len(self.usrgos),
            h=len(self.hdrobj.hdrgos.intersection(self.hdrgo2usrgos.keys())),
            H=self.hdrobj.num_hdrgos()))
164441
def get_summary_str(self, sec2d_nt):
        """"""
        data = self.get_summary_data(sec2d_nt)
        return "{M} GO IDs placed into {N} sections; {U} unplaced GO IDs".format(
            N=len(data['sections']), M=len(data['grouped']), U=len(data['ungrouped']))
253532
def summary(self, prn=None, lfilter=None):
        """"""
        for s, r in self.res:
            if lfilter is not None:
                if not lfilter(s, r):
                    continue
            if prn is None:
                print(self._elt2sum((s, r)))
            else:
                print(prn(s, r))
737665
def summary(svc_name=''):
    '''
    
    '''
    ret = {}
    cmd = 'monit summary'
    res = __salt__['cmd.run'](cmd).splitlines()
    for line in res:
        if 'daemon is not running' in line:
            return dict(monit='daemon is not running', result=False)
        elif not line or svc_name not in line or 'The Monit daemon' in line:
            continue
        else:
            parts = line.split('\'')
            if len(parts) == 3:
                resource, name, status_ = (
                    parts[0].strip(), parts[1], parts[2].strip()
                )
                if svc_name != '' and svc_name != name:
                    continue
                if resource not in ret:
                    ret[resource] = {}
                ret[resource][name] = status_
    return ret
56944
async def info(self):
        """
        {'MasterCapability': 9, 'TransportPort': 3975}
        """
        act = self.service.action("X_GetDeviceInfo")
        res = await act.async_call()
        return res
1350936
def vehicles
      @vehicles ||= begin
        _, json = get_json("/vehicles")
        json.map { |data| Vehicle.new(self, data) }
      end
    end