INNER CODE UNIT · Python

get_github_user_full_name

DataDog/KubeHound · scripts/enrich-third-party-licences.py:14

def get_github_user_full_name(username):
  request = Request(f'https://api.github.com/users/{username}', headers={
    'Authorization': f'Bearer {GITHUB_API_TOKEN}'
  })
  with urlopen(request) as response:
    if response.status != 200:
      raise RuntimeError(f'Failed to get user info for user {username} from the GitHub API')
    parsed_response = json.loads(response.read())
    name = parsed_response.get('name')
    if name is None:
      name = username # fallback to the username
      
    return name
    
for row in licences:
  module, url, license = row.split(',')
  if url.startswith("https://github.com/"):
    username = url.split('/')[3]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…