Inverse operation for `resolve_bot_file_id`.

    The only parameters this method will accept are :tl:`Document` and
    :tl:`Photo`, and it will return a variable-length ``file_id`` string.

    If an invalid parameter is given, it will ``return None``.
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
1358666
function parseModuleId(filepath, transportBase) {
		transportBase = transportBase.replace(/\\/g, "/");
		filepath = filepath.replace(/\\/g, "/");

		var index = filepath.indexOf(transportBase);
		if(transportBase && index > -1) {
			id = filepath.substr(index + transportBase.length).replace(/^\/|\.\w+$/g, "");
		}
		else {
			id = path.basename(filepath).replace(/^\/|\.\w+$/g, "");
		}
		return id;
	}
1072770
def has_file_id(self, repository_fname):
        
        self.con.execute('SELECT 1 FROM archive_files WHERE repositoryFname = %s', (repository_fname,))
        return len(self.con.fetchall()) > 0
552785
def get_file(self,pattern):
        '''
         
        '''
        flag=[fnmatch.fnmatch(l,pattern) for l in self.filelist]
        id=self.fid_list.compress(flag)
        flag = self.fileid == id
        return flag
399493
def image_by_id(self, id):
        
        if not id:
            return None
        return next((image for image in self.images() if image['Id'] == id),
                    None)
853859
def repo_id(self, repo: str) -> str:
        
        if repo.startswith("http"):
            repo_id = re.sub(r"https?://(.www)?", "", repo)
            repo_id = re.sub(r"\.git/?$", "", repo_id)
        else:
            repo_id = repo.replace("file://", "")
            repo_id = re.sub(r"\.git/?$", "", repo_id)
            if repo_id.startswith("~"):
                repo_id = str(Path(repo_id).resolve())

        # replaces everything that isn't alphanumeric, a dot or an underscore
        # to make sure it's a valid folder name and to keep it readable
        # multiple consecutive invalid characters replaced with a single underscore
        repo_id = re.sub(r"[^a-zA-Z0-9._]+", "_", repo_id)

        # and add a hash of the original to make it absolutely unique
        return repo_id + hashlib.sha256(repo.encode("utf-8")).hexdigest()
1050900
def get_file_ids(object):
    """"""
    import MOPdbaccess
    mysql = MOPdbaccess.connect('cfeps','cfhls',dbSystem='MYSQL')
    cfeps=mysql.cursor()
    sql="SELECT file_id FROM measure WHERE provisional LIKE %s"
    cfeps.execute(sql,(object, ))
    file_ids=cfeps.fetchall()

    return (file_ids)
760886
def __get_file(self, file):
        
        file_object = None
        if file['name'] in request.files:
            file_object = request.files[file['name']]
            clean_filename = secure_filename(file_object.filename)
            if clean_filename == '':
                return file_object
            if file_object and self.__allowed_extension(
                    clean_filename, file['extensions']):
                return file_object
        elif file['name'] not in request.files and file['required']:
            return file_object
        return file_object
333068
def _getFileNumber(self, filename):
        
        cur = self._connection.cursor()
        cur.execute('SELECT id FROM files WHERE name = ?', (filename,))
        row = cur.fetchone()
        if row is None:
            return None
        else:
            return row[0]
904066
def _decode_module_id(self, module_id):
        
        name = [''] * 9
        module_id >>= 10
        for i in reversed(range(9)):
            name[i] = self.charset[module_id & 63]
            module_id >>= 6
        return ''.join(name)
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
660726
def get_userid_from_botid(self, botid):
        '''
        '''
        botinfo = self.slack_client.api_call('bots.info', bot=botid)
        if botinfo['ok'] is True:
            return botinfo['bot'].get('user_id')
        else:
            return botid
959665
def get_filename(self, renew=False):
        
        if self._fname is None or renew:
            self._fname = '%s.%s' % (self._id, self._format)
        return self._fname
1129600
def _get_attachment_data(self, id, filename):
        
        uri = '/'.join([self.base_url, self.name, id, 'Attachments', filename])
        return uri, {}, 'get', None, None, False
148002
def image_id_from_registry(image_name):
    """"""
    registry, repository, tag = parse(image_name)
    try:
        token = auth_token(registry, repository).get("token")
        # dockerhub is crazy
        if registry == "index.docker.io":
            registry = "registry-1.docker.io"
        res = requests.head("https://{}/v2/{}/manifests/{}".format(registry, repository, tag), headers={
            "Authorization": "Bearer {}".format(token),
            "Accept": "application/vnd.docker.distribution.manifest.v2+json"
        }, timeout=5)
        res.raise_for_status()
    except requests.RequestException:
        log.error("Received {} when attempting to get digest for {}".format(
            res, image_name))
        return None
    return "@".join([registry+"/"+repository, res.headers["Docker-Content-Digest"]])
63051
def generate_img_id(profile, ext=None, label=None, tmp=False):
    
    if ext and not ext.startswith('.'):
        ext = '.' + ext
    if label:
        label = re.sub(r'[^a-z0-9_\-]', '', label, flags=re.I)
        label = re.sub(r'_+', '_', label)
        label = label[:60]
    return '{profile}:{tmp}{dtstr}_{rand}{label}{ext}'.format(
        profile=profile,
        tmp=(dju_settings.DJU_IMG_UPLOAD_TMP_PREFIX if tmp else ''),
        dtstr=datetime_to_dtstr(),
        rand=get_random_string(4, 'abcdefghijklmnopqrstuvwxyz0123456789'),
        label=(('_' + label) if label else ''),
        ext=(ext or ''),
    )
601617
def modify_filename_id(filename):
    """"""
    split_filename = os.path.splitext(filename)
    id_num_re = re.compile('(\(\d\))')
    id_num = re.findall(id_num_re, split_filename[-2])
    if id_num:
        new_id_num = int(id_num[-1].lstrip('(').rstrip(')')) + 1

        # Reconstruct filename with incremented id and its extension
        filename = ''.join((re.sub(id_num_re, '({0})'.format(new_id_num),
                                   split_filename[-2]), split_filename[-1]))
    else:
        split_filename = os.path.splitext(filename)

        # Reconstruct filename with new id and its extension
        filename = ''.join(('{0} (2)'.format(split_filename[-2]),
                            split_filename[-1]))
    return filename