ambassador.py (1079B)
1 import sys, os 2 3 from subprocess import call 4 5 def stagit(config): 6 config['output_dir'] = config.get("output_dir", "html/") 7 8 config['repo_dir'] = config.get("repo_dir", "src/") 9 10 repos = [] 11 12 for repo in os.listdir(config['repo_dir']): 13 repo_path = os.path.join( config['repo_dir'], repo ) 14 output_path = os.path.join( config['output_dir'], repo ) 15 16 if not os.path.exists(output_path): 17 os.mkdir(output_path) 18 19 path = os.getcwd() 20 21 os.chdir( output_path ) 22 23 try: 24 os.symlink( 25 os.path.join(config['output_dir'], "favicon.png"), 26 os.path.join(output_path, "favicon.png")) 27 except: pass 28 29 try: 30 os.symlink( 31 os.path.join(config['output_dir'], "logo.png"), 32 os.path.join(output_path, "logo.png")) 33 except: pass 34 35 try: 36 os.symlink( 37 os.path.join(config['output_dir'], "style.css"), 38 os.path.join(output_path, "style.css")) 39 except: pass 40 41 call(["stagit", repo_path]) 42 43 os.chdir(path) 44 45 repos.append(repo_path) 46 47 48 os.chdir(config['output_dir']) 49 50 f = open("index.html", "w") 51 52 call(["stagit-index"] + repos, stdout=f) 53 54 55 56