o
    QDi                     @  st   d dl mZ d dlmZmZmZ d dlmZ ddlm	Z	 ddl
mZ ddlmZ er0dd	lmZ G d
d de	ZdS )    )annotations)TYPE_CHECKINGAnyOptional)urlparse   )Plugin   )GithubAdapterGithubControl)Controlc                   @  s0   e Zd ZdZdddddddZddddZdS )GithubPluginzPlugin for GithubNF)controlbasepath	packagifysourcer   r   Optional[Control]r   Optional[str]r   boolc                C  s   |r	t |ts	dS |du rt |trt|dS t |tsdS t|}|jddd }|jdko<t|dko<t|dk}|rX|pCt }|d |_	t|dkrT|d |_
t|S dS )u}  Checks if the source is meant to access a Github Data portal, and returns the adapter if applicable

        The source is expected to be in one of the formats :

        - https://github.com/user_or_org
        - https://github.com/user_or_org/repo

        Alternatively, user and/or repo information can be provided in the
        GithubControl, with an empty source.

        N)r   /r	   z
github.com   r   )
isinstancer   r
   strr   pathsplitnetloclenuserrepo)selfr   r   r   r   
parsed_urlsplited_urlhas_expected_format r$   [/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/portals/github/plugin.pycreate_adapter   s(   







zGithubPlugin.create_adaptertypec                 C  s   |dkrt S d S )Ngithubr   )r    r'   r$   r$   r%   select_control_classC   s   z!GithubPlugin.select_control_class)r   r   r   r   r   r   r   r   )N)r'   r   )__name__
__module____qualname____doc__r&   r)   r$   r$   r$   r%   r      s    0r   N)
__future__r   typingr   r   r   urllib.parser   systemr   adapterr
   r   r   dialectr   r   r$   r$   r$   r%   <module>   s    