(perm_name)
从permission的codename中拿到appname与权限名
从permission的codename中拿到appname与权限名
从permission的codename中拿到appname与权限名
def match_permission(perm_name):
    """从permission的codename中拿到appname与权限名"""
    str4format = r"(?:{label}[.])?{prefix}(?P<appname>.+?)(?:|(?P<permission>.+))?$"
    pattern = str4format.format(
        label="wechat_django",
        prefix=WECHATPERM_PREFIX
    ).replace("|", "[|]")
    match = re.match(pattern, perm_name)
    if match:
        return match.group("appname"), match.group("permission")
    else:
        return None, None
def match_permission ( perm_name ) : str4format = r"(?:{label}[.])?{prefix}(?P<appname>.+?)(?:|(?P<permission>.+))?$" pattern = str4format . format ( label = "wechat_django" , prefix = WECHATPERM_PREFIX ) . replace ( "|" , "[|]" ) match = re . match ( pattern , perm_name ) if match : return match . group ( "appname" ) , match . group ( "permission" ) else : return None , None