Export a result.

        :param id: Result ID as an int.
        :param exclude_captures: If bool `True`, don't export capture files
        :rtype: tuple `(io.BytesIO, 'filename')`
541964
def export(self, id, exclude_captures=False): # pylint: disable=invalid-name,redefined-builtin
        
        return self.service.export(self.base, id, params={'exclude_captures': exclude_captures})
338384
def export(request, page_id, export_unpublished=False):
    
    try:
        if export_unpublished:
            root_page = Page.objects.get(id=page_id)
        else:
            root_page = Page.objects.get(id=page_id, live=True)
    except Page.DoesNotExist:
        return JsonResponse({'error': _('page not found')})

    payload = export_pages(root_page, export_unpublished=export_unpublished)

    return JsonResponse(payload)
1264702
def export_process_template(self, id, **kwargs):
        
        route_values = {}
        if id is not None:
            route_values['id'] = self._serialize.url('id', id, 'str')
        route_values['action'] = 'Export'
        response = self._send(http_method='GET',
                              location_id='29e1f38d-9e9c-4358-86a5-cdf9896a5759',
                              version='5.0-preview.1',
                              route_values=route_values,
                              accept_media_type='application/zip')
        if "callback" in kwargs:
            callback = kwargs["callback"]
        else:
            callback = None
        return self._client.stream_download(response, callback=callback)
955279
def get_sds_by_id(self,id):
        
        for sds in self.sds:
            if sds.id == id:
                return sds
        raise KeyError("SDS with that ID not found")
1074763
def list(self, id):
        
        id = self.__unpack_id(id)        
        return self.__api_request('GET', '/api/v1/lists/{0}'.format(id))
118372
def save_id_to_path_mapping(self):
    
    if not self.id_to_path_mapping:
      return
    with open(self.local_id_to_path_mapping_file, 'w') as f:
      writer = csv.writer(f)
      writer.writerow(['id', 'path'])
      for k, v in sorted(iteritems(self.id_to_path_mapping)):
        writer.writerow([k, v])
    cmd = ['gsutil', 'cp', self.local_id_to_path_mapping_file,
           os.path.join(self.target_dir, 'id_to_path_mapping.csv')]
    if subprocess.call(cmd) != 0:
      logging.error('Can\'t copy id_to_path_mapping.csv to target directory')
27689
def GetExportedResult(self,
                        original_result,
                        converter,
                        metadata=None,
                        token=None):
    """"""

    exported_results = list(
        converter.Convert(
            metadata or ExportedMetadata(), original_result, token=token))

    if not exported_results:
      raise ExportError("Got 0 exported result when a single one "
                        "was expected.")

    if len(exported_results) > 1:
      raise ExportError("Got > 1 exported results when a single "
                        "one was expected, seems like a logical bug.")

    return exported_results[0]
614973
def get_experiment_from_id(self, experiment_id):
    

    experiment = self.experiment_id_map.get(experiment_id)

    if experiment:
      return experiment

    self.logger.error('Experiment ID "%s" is not in datafile.' % experiment_id)
    self.error_handler.handle_error(exceptions.InvalidExperimentException(enums.Errors.INVALID_EXPERIMENT_KEY_ERROR))
    return None
780576
def copy_id(self):
        '''
        
        '''
        stdout, stderr, retcode = self._run_cmd(self._copy_id_str_old())
        if salt.defaults.exitcodes.EX_OK != retcode and 'Usage' in stderr:
            stdout, stderr, retcode = self._run_cmd(self._copy_id_str_new())
        return stdout, stderr, retcode
435769
def get_file_by_id(self, file_id):
        
        return self._create_item_response(
            self.data_service.get_file(file_id),
            File
        )
1325559
def container_by_id(self, id):
        
        if not id:
            return None
        return next((container for container in self.containers(all=True)
                     if container['Id'] == id), None)
1021451
def get_status_return_level(self, ids, **kwargs):
        
        convert = kwargs['convert'] if 'convert' in kwargs else self._convert
        srl = []
        for id in ids:
            try:
                srl.extend(self._get_status_return_level((id, ),
                                                         error_handler=None, convert=convert))
            except DxlTimeoutError as e:
                if self.ping(id):
                    srl.append('never' if convert else 0)
                else:
                    if self._error_handler:
                        self._error_handler.handle_timeout(e)
                        return ()
                    else:
                        raise e

        return tuple(srl)
961099
def include_from_file(records, handle):
    
    ids = set(i.strip() for i in handle)

    for record in records:
        if record.id.strip() in ids:
            yield record
1265914
def dump_ifd(self, ifd, ifd_name, tag_dict=EXIF_TAGS, relative=0, stop_tag=DEFAULT_STOP_TAG):
        
        # make sure we can process the entries
        try:
            entries = self.s2n(ifd, 2)
        except TypeError:
            logger.warning("Possibly corrupted IFD: %s" % ifd)
            return

        for i in range(entries):
            # entry is index of start of this IFD in the file
            entry = ifd + 2 + 12 * i
            tag = self.s2n(entry, 2)

            # get tag name early to avoid errors, help debug
            tag_entry = tag_dict.get(tag)
            if tag_entry:
                tag_name = tag_entry[0]
            else:
                tag_name = 'Tag 0x%04X' % tag

            # ignore certain tags for faster processing
            if not (not self.detailed and tag in IGNORE_TAGS):
                field_type = self.s2n(entry + 2, 2)

                # unknown field type
                if not 0 < field_type < len(FIELD_TYPES):
                    if not self.strict:
                        continue
                    else:
                        raise ValueError('Unknown type %d in tag 0x%04X' % (field_type, tag))

                type_length = FIELD_TYPES[field_type][0]
                count = self.s2n(entry + 4, 4)
                # Adjust for tag id/type/count (2+2+4 bytes)
                # Now we point at either the data or the 2nd level offset
                offset = entry + 8

                # If the value fits in 4 bytes, it is inlined, else we
                # need to jump ahead again.
                if count * type_length > 4:
                    # offset is not the value; it's a pointer to the value
                    # if relative we set things up so s2n will seek to the right
                    # place when it adds self.offset.  Note that this 'relative'
                    # is for the Nikon type 3 makernote.  Other cameras may use
                    # other relative offsets, which would have to be computed here
                    # slightly differently.
                    if relative:
                        tmp_offset = self.s2n(offset, 4)
                        offset = tmp_offset + ifd - 8
                        if self.fake_exif:
                            offset += 18
                    else:
                        offset = self.s2n(offset, 4)

                field_offset = offset
                values = None
                if field_type == 2:
                    # special case: null-terminated ASCII string
                    # XXX investigate
                    # sometimes gets too big to fit in int value
                    if count != 0:  # and count < (2**31):  # 2E31 is hardware dependant. --gd
                        file_position = self.offset + offset
                        try:
                            self.file.seek(file_position)
                            values = self.file.read(count)
                            #print(values)
                            # Drop any garbage after a null.
                            values = values.split(b'\x00', 1)[0]
                            if isinstance(values, bytes):
                                try:
                                    values = values.decode("utf-8")
                                except UnicodeDecodeError:
                                    logger.warning("Possibly corrupted field %s in %s IFD", tag_name, ifd_name)
                        except OverflowError:
                            logger.warn('OverflowError at position: %s, length: %s', file_position, count)
                            values = ''
                        except MemoryError:
                            logger.warn('MemoryError at position: %s, length: %s', file_position, count)
                            values = ''
                else:
                    values = []
                    signed = (field_type in [6, 8, 9, 10])

                    # XXX investigate
                    # some entries get too big to handle could be malformed
                    # file or problem with self.s2n
                    if count < 1000:
                        for dummy in range(count):
                            if field_type in (5, 10):
                                # a ratio
                                value = Ratio(self.s2n(offset, 4, signed),
                                              self.s2n(offset + 4, 4, signed))
                            else:
                                value = self.s2n(offset, type_length, signed)
                            values.append(value)
                            offset = offset + type_length
                    # The test above causes problems with tags that are
                    # supposed to have long values! Fix up one important case.
                    elif tag_name in ('MakerNote', makernote.canon.CAMERA_INFO_TAG_NAME):
                        for dummy in range(count):
                            value = self.s2n(offset, type_length, signed)
                            values.append(value)
                            offset = offset + type_length

                # now 'values' is either a string or an array
                if count == 1 and field_type != 2:
                    printable = str(values[0])
                elif count > 50 and len(values) > 20:
                    printable = str(values[0:20])[0:-1] + ", ... ]"
                else:
                    try:
                        printable = str(values)
                    # fix for python2's handling of unicode values
                    except UnicodeEncodeError:
                        printable = unicode(values)

                # compute printable version of values
                if tag_entry:
                    # optional 2nd tag element is present
                    if len(tag_entry) != 1:
                        if callable(tag_entry[1]):
                            # call mapping function
                            printable = tag_entry[1](values)
                        elif type(tag_entry[1]) is tuple:
                            ifd_info = tag_entry[1]
                            try:
                                logger.debug('%s SubIFD at offset %d:', ifd_info[0], values[0])
                                self.dump_ifd(values[0], ifd_info[0], tag_dict=ifd_info[1], stop_tag=stop_tag)
                            except IndexError:
                                logger.warn('No values found for %s SubIFD', ifd_info[0])
                        else:
                            printable = ''
                            for i in values:
                                # use lookup table for this tag
                                printable += tag_entry[1].get(i, repr(i))

                self.tags[ifd_name + ' ' + tag_name] = IfdTag(printable, tag,
                                                              field_type,
                                                              values, field_offset,
                                                              count * type_length)
                try:
                    tag_value = repr(self.tags[ifd_name + ' ' + tag_name])
                # fix for python2's handling of unicode values
                except UnicodeEncodeError:
                    tag_value = unicode(self.tags[ifd_name + ' ' + tag_name])
                logger.debug(' %s: %s', tag_name, tag_value)

            if tag_name == stop_tag:
                break
798370
def remove(self, id):
        
        before_len = len(self.model.db)
        self.model.db = [t for t in self.model.db if t["id"] != id]
        if not self._batch.enable.is_set():
            self.model.save_db()
        return before_len - len(self.model.db)
927077
async def download_media_by_id(self, media_id):
        
        try:
            msg = self.found_media[int(media_id)]
        except (ValueError, KeyError):
            # ValueError when parsing, KeyError when accessing dictionary
            print('Invalid media ID given or message not found!')
            return

        print('Downloading media to usermedia/...')
        os.makedirs('usermedia', exist_ok=True)
        output = await self.download_media(
            msg.media,
            file='usermedia/',
            progress_callback=self.download_progress_callback
        )
        print('Media downloaded to {}!'.format(output))
150948
def extract_metadata(id)
      return {} if metadata_files.blank?
      metadata_file = metadata_files.find { |f| f.id == id }
      metadata_file.extract_metadata if metadata_file
    end