Skip to content

Instantly share code, notes, and snippets.

@PJensen
Created July 13, 2009 20:57
Show Gist options
  • Save PJensen/146448 to your computer and use it in GitHub Desktop.
Save PJensen/146448 to your computer and use it in GitHub Desktop.
VSS Remover; incomplete
import os, sys, string
class VSSRemover:
def __init__(self, aStartDir):
self._startDir = aStartDir
self._extensions = ['sln', 'scc', 'vssscc', 'csproj', 'vspscc']
self._slnSCTagOne = "GlobalSection(SourceCodeControl)"
self._slnSCTagTwo = "EndGlobalSection"
self._remSAK = []
self._remSAK.append("<SccProjectName>SAK</SccProjectName>")
self._remSAK.append("<SccLocalPath>SAK</SccLocalPath>")
self._remSAK.append("<SccAuxPath>SAK</SccAuxPath>")
self._remSAK.append("<SccProvider>SAK</SccProvider>")
os.chdir(aStartDir)
def start(self):
self.__dfs(self._startDir)
def __slnAction(self, aPath):
print 'sln'
def __sccAction(self, aPath):
print 'scc'
def __vsssccAction(self, aPath):
print 'vssscc'
def __csprojAction(self, aPath):
print 'csproj'
def __vspsccAction(self, aPath):
print 'vspscc'
def __visit(self, aFullPath, aExt):
actionResult = {'sln':self.__slnAction,
'scc':self.__sccAction,
'vssscc':self.__vsssccAction,
'csproj':self.__csprojAction,
'vspscc':self.__vspsccAction
}[aExt](aFullPath)
def __makeWritable(self, aFileName):
try:
fileAtt = os.stat(aFileName)[0]
if (not fileAtt & stat.S_IWRITE):
os.chmod(aFileName, stat.S_IWRITE)
except:
pass
def __dfs(self, aPath):
os.chdir(aPath)
files = os.listdir('.')
for file in files:
if (os.path.isdir(file)):
self.__dfs(file)
elif (os.path.isfile(file)):
for ext in self._extensions:
try:
if (file.split('.' + ext)[1] == ''):
fullPath = os.path.join(os.getcwd(), file)
self.__visit(fullPath, ext)
except:
pass
print '\t',
os.chdir('..')
a = VSSRemover('c:\softwaredevelopment\pythondev')
a.start()
@PJensen
Copy link
Author

PJensen commented Sep 10, 2010

yuk This sucks.

@PJensen
Copy link
Author

PJensen commented Sep 10, 2010

os.walk(..)

works a whole bunch better than this trash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment