(github_url: str)
| 139 | |
| 140 | |
| 141 | def fetch_github_profile(github_url: str) -> Optional[GitHubProfile]: |
| 142 | try: |
| 143 | username = extract_github_username(github_url) |
| 144 | logger.info(f"{username}") |
| 145 | if not username: |
| 146 | print(f"Could not extract username from: {github_url}") |
| 147 | return None |
| 148 | |
| 149 | api_url = f"https://api.github.com/users/{username}" |
| 150 | |
| 151 | status_code, data = _fetch_github_api(api_url) |
| 152 | |
| 153 | if status_code == 200: |
| 154 | profile = GitHubProfile( |
| 155 | username=username, |
| 156 | name=data.get("name"), |
| 157 | bio=data.get("bio"), |
| 158 | location=data.get("location"), |
| 159 | company=data.get("company"), |
| 160 | public_repos=data.get("public_repos"), |
| 161 | followers=data.get("followers"), |
| 162 | following=data.get("following"), |
| 163 | created_at=data.get("created_at"), |
| 164 | updated_at=data.get("updated_at"), |
| 165 | avatar_url=data.get("avatar_url"), |
| 166 | blog=data.get("blog"), |
| 167 | twitter_username=data.get("twitter_username"), |
| 168 | hireable=data.get("hireable"), |
| 169 | ) |
| 170 | |
| 171 | return profile |
| 172 | elif status_code == 404: |
| 173 | print(f"GitHub user not found: {username}") |
| 174 | return None |
| 175 | else: |
| 176 | print(f"GitHub API error: {status_code} - {data}") |
| 177 | return None |
| 178 | |
| 179 | except requests.exceptions.RequestException as e: |
| 180 | print(f"Error fetching GitHub profile: {e}") |
| 181 | return None |
| 182 | except Exception as e: |
| 183 | print(f"Unexpected error fetching GitHub profile: {e}") |
| 184 | return None |
| 185 | |
| 186 | |
| 187 | def fetch_contributions_count(owner: str, contributors_data): |
no test coverage detected