a method to retrieve route information for file on telegram api

        :param file_id: string with id of file in a message send to bot
        :return: dictionary of response details with route details in [json][result]
3268
def get_route(self, file_id):

        ''' 
        '''

        title = '%s.get_route' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'file_id': file_id,
        }
        for key, value in input_fields.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, str(value))
                self.fields.validate(value, '.%s' % key, object_title)

    # construct key word arguments
        request_kwargs = {
            'url': '%s/getFile' % self.api_endpoint,
            'data': {
                'file_id': file_id
            }
        }

    # send request
        response_details = self._post_request(**request_kwargs)

        return response_details
152509
def file_blob_id(path)
    file_path = Rails.root.join('test/fixtures'.freeze).join(path)
    blob_contents = File.binread file_path

    # This needs to be kept in sync with blob_model.rb.
    Base64.urlsafe_encode64(Digest::SHA256.digest(blob_contents)).inspect
  end
836654
def scan_file(self, this_file, this_filename):
        
        params = {
            'api_key': self.api_key,
            'filename': this_filename
        }
        try:
            files = {'file': (this_file.name, open(this_file.name, 'rb'), 'application/octet-stream')}
        except TypeError as e:
            return dict(error=e.message)

        try:
            response = requests.post(self.base + 'file/upload', files=files, data=params)
        except requests.RequestException as e:
            return dict(error=e.message)

        return _return_response_and_status_code(response)
1022147
def file_view(self, request, field_entry_id):
        
        model = self.fieldentry_model
        field_entry = get_object_or_404(model, id=field_entry_id)
        path = join(fs.location, field_entry.value)
        response = HttpResponse(content_type=guess_type(path)[0])
        f = open(path, "r+b")
        response["Content-Disposition"] = "attachment; filename=%s" % f.name
        response.write(f.read())
        f.close()
        return response
638342
def _get_member_file_data(member_data, id_filename=False):
        
        file_data = {}
        for datafile in member_data['data']:
            if id_filename:
                basename = '{}.{}'.format(datafile['id'], datafile['basename'])
            else:
                basename = datafile['basename']
            if (basename not in file_data or
                    arrow.get(datafile['created']) >
                    arrow.get(file_data[basename]['created'])):
                file_data[basename] = datafile
        return file_data
355921
def retrieve_data(file_paths):

    
    data_dict = {}
    for file_path in file_paths:
        with open(file_path) as fh:
            try:
                content = yaml.load(fh.read())
            except yaml.YAMLError as e:
                raise MiuraException(
                    "Unable to parse yaml at {0}: \n {1}".format(
                        file_path,
                        str(e)
                    ))
            if not isinstance(content, dict):
                raise MiuraException(
                    "{0} is does not translate to a dictionary!".format(file_path)
                )
            data_dict.update(content)
    return data_dict
1217007
def get(self, file_id: str) -> [typing.BinaryIO, str, datetime.datetime]:
        """"""
        raise NotImplementedError("Downloading files for downloading files in FileStore has not been implemented yet.")
938423
def parse_mapping_file(file):
        
        id_map = {}
        if os.path.exists(os.path.join(os.path.dirname(__file__), file)):
            with open(os.path.join(os.path.dirname(__file__), file)) as tsvfile:
                reader = csv.reader(tsvfile, delimiter="\t")
                for row in reader:
                    key = row[0]
                    value = row[1]
                    id_map[key] = value

        return id_map
1057754
def file_list( blockchain_id, config_path=CONFIG_PATH, wallet_keys=None ):
    

    config_dir = os.path.dirname(config_path)
    client_config_path = os.path.join(config_dir, blockstack_client.CONFIG_FILENAME )
    proxy = blockstack_client.get_default_proxy( config_path=client_config_path )

    res = blockstack_client.data_list( blockchain_id, wallet_keys=wallet_keys, proxy=proxy )
    if 'error' in res:
        log.error("Failed to list data: %s" % res['error'])
        return {'error': 'Failed to list data'}

    listing = []

    # find the ones that this app put there 
    for rec in res['listing']:
        if not file_is_fq_data_name( rec['data_id'] ):
            continue
        
        listing.append( rec )

    return {'status': True, 'listing': listing}
62657
def upload_scan(self, application_id, file_path):
        
        return self._request(
            'POST', 'rest/applications/' + str(application_id) + '/upload',
            files={'file': open(file_path, 'rb')}
        )
152343
def parse_file_info(self, file_info):
        

        self.info["playback_time"] = file_info.playback_time
        self.info["match_id"] = file_info.game_info.dota.match_id
        self.info["game_mode"] = file_info.game_info.dota.game_mode
        self.info["game_winner"] = file_info.game_info.dota.game_winner

        for index, player in enumerate(file_info.game_info.dota.player_info):
            p = self.heroes[player.hero_name]
            p.name = player.player_name
            p.index = index
            p.team = 0 if index < 5 else 1

            self.indexed_players[index] = p
            self.info["players"][player.player_name] = p
877316
def send_message(chat_id):
    

    files = request.files

    if files:
        res = send_media(chat_id, request)
    else:
        message = request.form.get('message')
        res = g.driver.chat_send_message(chat_id, message)

    if res:
        return jsonify(res)
    else:
        return False
95374
async def get_file(self):
        
        if hasattr(self, 'file_path'):
            return self
        else:
            return await self.bot.get_file(self.file_id)
274195
def __send_api_file(self, file_name):
        

        file_name = join(self.app.static_folder, file_name)

        with codecs.open(file_name, 'r', 'utf-8') as file:
            data = file.read()

        # replaces the hard coded url by the current url.
        api_project = self.__read_api_project()

        old_url = api_project.get('url')

        # replaces the project's url only if it is present in the file.
        if old_url:
            new_url = request.url_root.strip('/')
            data = data.replace(old_url, new_url)

        # creates a flask response to send
        # the file to the browser

        headers = Headers()
        headers['Content-Length'] = getsize(file_name)

        response = self.app.response_class(data,
                                           mimetype=mimetypes.guess_type(file_name)[0],
                                           headers=headers,
                                           direct_passthrough=True)

        response.last_modified = int(getmtime(file_name))

        return response
545379
def pack_bot_file_id(file):
    
    if isinstance(file, types.MessageMediaDocument):
        file = file.document
    elif isinstance(file, types.MessageMediaPhoto):
        file = file.photo

    if isinstance(file, types.Document):
        file_type = 5
        for attribute in file.attributes:
            if isinstance(attribute, types.DocumentAttributeAudio):
                file_type = 3 if attribute.voice else 9
            elif isinstance(attribute, types.DocumentAttributeVideo):
                file_type = 13 if attribute.round_message else 4
            elif isinstance(attribute, types.DocumentAttributeSticker):
                file_type = 8
            elif isinstance(attribute, types.DocumentAttributeAnimated):
                file_type = 10
            else:
                continue
            break

        return _encode_telegram_base64(_rle_encode(struct.pack(
            '<iiqqb', file_type, file.dc_id, file.id, file.access_hash, 2)))

    elif isinstance(file, types.Photo):
        size = next((x for x in reversed(file.sizes) if isinstance(
            x, (types.PhotoSize, types.PhotoCachedSize))), None)

        if not size:
            return None

        size = size.location
        return _encode_telegram_base64(_rle_encode(struct.pack(
            '<iiqqqqib', 2, file.dc_id, file.id, file.access_hash,
            size.volume_id, 0, size.local_id, 2  # 0 = old `secret`
        )))
    else:
        return None
125610
def download_file(self, file_id, dest):
        
        f = self.getFile(file_id)
        try:
            d = dest if _isfile(dest) else open(dest, 'wb')

            r = api.download((self._token, f['file_path']), preload_content=False)

            while 1:
                data = r.read(self._file_chunk_size)
                if not data:
                    break
                d.write(data)
        finally:
            if not _isfile(dest) and 'd' in locals():
                d.close()

            if 'r' in locals():
                r.release_conn()
132706
def _get_id(self, file_path):
        
        '''  '''
        
        title = '%s._get_id' % self.__class__.__name__
        
    # construct request kwargs
        list_kwargs = {
            'spaces': self.drive_space,
            'fields': 'files(id, parents)'
        }
    
    # determine path segments
        path_segments = file_path.split(os.sep)
        
    # walk down parents to file name
        parent_id = ''
        empty_string = ''
        while path_segments:
            walk_query = "name = '%s'" % path_segments.pop(0)
            if parent_id:
                walk_query += "and '%s' in parents" % parent_id
            list_kwargs['q'] = walk_query
            try:
                response = self.drive.list(**list_kwargs).execute()
            except:
                raise DriveConnectionError(title)
            file_list = response.get('files', [])
            if file_list:
                if path_segments:
                    parent_id = file_list[0].get('id')
                else:
                    file_id = file_list[0].get('id')
                    return file_id, parent_id
            else:
                return empty_string, empty_string