Created
April 8, 2015 15:03
-
-
Save tylerjereddy/defd459f7f0bb34a35ee to your computer and use it in GitHub Desktop.
process_MDA_strings_github_migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Module to assess and adjust URLs / links in MDA project documentation after recent move to github.''' | |
import os | |
import subprocess | |
for dirname, dirnames, filenames in os.walk('/Users/treddy/python_modules/MDAnalysis/MDA_dev/mdanalysis/'): | |
# print path to all filenames. | |
#for filename in filenames: | |
#print os.path.join(dirname, filename) | |
#print all lines from .py files with OLD HOMEPAGE URLs in them: | |
#for filename in filenames: | |
#if filename[-2:] == 'py': | |
#with open(os.path.join(dirname,filename),'r') as python_module: | |
#for line in python_module.readlines(): | |
#if 'http://mdanalysis.googlecode.com' in line: | |
#print filename,':', line | |
#replace old homepage URL with new homepage URL in all .py files in MDA dir structure | |
# for filename in filenames: | |
# if filename[-2:] == 'py': | |
# filepath = os.path.join(dirname,filename) | |
# with open(filepath,'r') as current_file: | |
# list_lines_current_file = current_file.readlines() | |
# list_new_lines = [] | |
# for line in list_lines_current_file: | |
# if 'http://mdanalysis.googlecode.com' in line: | |
# new_line = line.replace('mdanalysis.googlecode.com','www.MDAnalysis.org') | |
# list_new_lines.append(new_line) | |
# else: | |
# list_new_lines.append(line) | |
# with open(filepath,'w') as replacement_file: | |
# replacement_file.writelines(list_new_lines) | |
#print all lines from .py files with ANY URLs in them: | |
#for filename in filenames: | |
#if filename[-2:] == 'py': | |
#with open(os.path.join(dirname,filename),'r') as python_module: | |
#for line in python_module.readlines(): | |
#if 'http' in line: | |
#print filename,':', line | |
#print all lines from .py files with OLD issue URLs in them: | |
#for filename in filenames: | |
#if filename[-2:] == 'py': | |
#path = os.path.join(dirname,filename) | |
#with open(path,'r') as python_module: | |
#for line in python_module.readlines(): | |
#if 'http' in line and 'issue' in line and 'google' in line: | |
#print path,':', line | |
#replace all SIMPLE issue lines with github equivalents: | |
#for filename in filenames: | |
#if filename[-2:] == 'py': | |
#filepath = os.path.join(dirname,filename) | |
#with open(filepath,'r') as current_file: | |
#list_lines_current_file = current_file.readlines() | |
#list_new_lines = [] | |
#for line in list_lines_current_file: | |
#if 'http' in line and 'issue' in line and 'google' in line and 'detail' in line and not '#' in line: | |
#print 'old line:', line | |
#issue_number = line.split('=')[-1] | |
#print 'issue_number:', issue_number | |
#new_line = line.replace('http://code.google.com/p/mdanalysis/issues/detail?id=','https://github.com/MDAnalysis/mdanalysis/issues/') | |
#new_line = new_line.replace('https://code.google.com/p/mdanalysis/issues/detail?id=','https://github.com/MDAnalysis/mdanalysis/issues/') | |
#list_new_lines.append(new_line) | |
#print 'new line:', new_line | |
#else: | |
#list_new_lines.append(line) | |
#with open(filepath,'w') as replacement_file: | |
#replacement_file.writelines(list_new_lines) | |
#print all lines from .py files containing pertinent (OLD) 'wiki' string: | |
#for filename in filenames: | |
#if filename[-2:] == 'py': | |
#path = os.path.join(dirname,filename) | |
#with open(path,'r') as python_module: | |
#for line in python_module.readlines(): | |
#if 'wiki' in line and 'google' in line: | |
#print path,':', line | |
#print all lines from .py files containing ANY URLs (for quick visual check): | |
for filename in filenames: | |
if filename[-2:] == 'py': | |
path = os.path.join(dirname,filename) | |
with open(path,'r') as python_module: | |
for line in python_module.readlines(): | |
if 'http' in line: | |
print filename,':', line | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment