Last active
December 19, 2015 02:49
-
-
Save bensternthal/5885501 to your computer and use it in GitHub Desktop.
Re-writing a bash script Justin wrote in python.
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
import csv | |
import os | |
from os.path import join, getsize | |
ROOTURL = 'http://www.mozilla.org' | |
ROOTSVN = 'http://viewvc.svn.mozilla.org/vc/projects/mozilla.org/trunk' | |
with open('test.csv', 'wb') as csvfile: | |
csvwriter = csv.writer(csvfile, delimiter=',', | |
quotechar='|', quoting=csv.QUOTE_MINIMAL) | |
csvwriter.writerow(['URL', 'SVN Path', 'File In Dir']) | |
for root, dirs, files in os.walk('/Users/bsternthal/Documents/Dev/mozilla-legacy/mozilla.org', topdown=True): | |
if '.svn' in dirs: | |
dirs.remove('.svn') | |
files_in_current_directory = len(files) | |
filePath, path = root.split("mozilla.org",1) | |
url = ROOTURL + path | |
svn = ROOTSVN + path | |
csvwriter.writerow([url, svn, files_in_current_directory]) |
try:
dirs.remove('.svn')
except ValueError:
pass
shorten files_in_current_directory or just use this directly
comment split -- what am i doing here
string concatination - maybe .join ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make path to svn a var