<jupyter_start><jupyter_text>Change visibility status of projects<jupyter_code>#!pip install PyGithub
from github import Github 
import sys
import datetime
import pandas as pd
import numpy as np
import random
from collections import Counter
# Load personal access token
with open("/Users/jzk870/Documents/NumericalMethods - Harddisk/token/git_access_token.txt", mode = "r") as file:
    token = file.read()

year = "2022"    
class_name = "projects-" + year<jupyter_output><empty_output><jupyter_text>Load all repositories in this year's class room<jupyter_code># a. Access github through access token. This one has been destroyed by Github for safety reasons.
gh = Github(token)
org = gh.get_organization('NumEconCopenhagen')
all_repos = org.get_repos()

# b. Locate all repositories in current class
current_class = [repo.name for repo in all_repos if class_name in repo.name]
# See this years' repos
for r in current_class:
    print(r.removeprefix(class_name+"-"))<jupyter_output><empty_output><jupyter_text>Set visibility of all repositories<jupyter_code># c. Use edit command and privat property to set visibility
is_private = False

# Set privacy status
for repo in all_repos:
    if repo.name not in current_class:
        continue
        
    # Update status    
    repo.edit(private = is_private)
#test = org.get_repo('projects-2022-crashtest')
#test.edit(private=True)<jupyter_output><empty_output><jupyter_text>Check out visibility<jupyter_code># d. Detect status of all repositories
for repo in all_repos:
    if repo.name not in current_class:
        continue
        
    if repo.private:
        s = "private"
    else: 
        s = "public "
    
    print(s + ": " + repo.name.removeprefix(class_name+"-"))<jupyter_output>public : crashtest
public : git-good
public : team-1
public : 2h2h
public : team-2
public : scandies
public : learning-c
public : anacondainstallers
public : teamhackerhannah
public : gigachad-grape-valley
public : team-abc
public : team-4-4-2
public : group-cobra
public : sprit-af
public : 2-brown-1-white
public : rasmus-markus
public : team-eyu
public : simon-nick
public : ppap
public : sadek-som-statsminister
public : group-aj
public : teamp-up
public : studentsbreadsarerated
public : fc-fredericia
public : rsi-team
public : team-123
public : team-wmutfmu
public : 21
public : lost_in_optimization
public : cil-wil-og-sof
public : msm
public : my_anaconda_don-t
public : slet_mig_senere
public : team-team
public : alberte-og-eva
public : amanda-oliver
public : rebekka-og-alex
public : team-freelvlau
public : cc_bc-_og-_bo
public : amo
public : lads
public : team-hjn
public : gustav-og-daniel
public : three-horses
public : mads-rasmus-kristian
public : anna-thomas-oscar
public : paulaem[...]
{'fraction_non_alphanumeric': 0.0927947598253275, 'fraction_numerical': 0.009097525473071324, 'mean_word_length': 4.317214700193424, 'pattern_counts': {'":': 1, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '503683', 'license': 'MIT', 'n_tokens_mistral': 971, 'n_tokens_neox': 922, 'n_words': 258, 'path': 'projects/Change visibility of repos.ipynb', 'repo_name': 'NumEconCopenhagen/lectures-2022', 'size': '2748'}