home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import win32con
- import string
- import traceback
- import win32com.client as win32com
- import win32com.client.gencache as win32com
- import pythoncom
- import time
- import os
- constants = win32com.client.constants
- win32com.client.gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 0, 5, 0)
- error = 'vssutil error'
-
- def GetSS():
- ss = win32com.client.Dispatch('SourceSafe')
- ss.Open(pythoncom.Missing, pythoncom.Missing, pythoncom.Missing)
- return ss
-
-
- def test(projectName):
- ss = GetSS()
- project = ss.VSSItem(projectName)
- for item in project.GetVersions(constants.VSSFLAG_RECURSYES):
- print item.VSSItem.Name, item.VersionNumber, item.Action
-
-
-
- def SubstituteInString(inString, evalEnv):
- substChar = '$'
- fields = string.split(inString, substChar)
- newFields = []
- for i in range(len(fields)):
- didSubst = 0
- strVal = fields[i]
- if i % 2 != 0:
-
- try:
- strVal = eval(strVal, evalEnv[0], evalEnv[1])
- newFields.append(strVal)
- didSubst = 1
- traceback.print_exc()
- print 'Could not substitute', strVal
-
-
- if not didSubst:
- newFields.append(strVal)
- continue
-
- return string.join(map(str, newFields), '')
-
-
- def SubstituteInFile(inName, outName, evalEnv):
- inFile = open(inName, 'r')
-
- try:
- outFile = open(outName, 'w')
-
- try:
- while None:
- line = inFile.read()
- if not line:
- break
-
- outFile.close()
- finally:
- inFile.close()
-
- return None
-
-
-
- def VssLog(project, linePrefix = '', noLabels = 5, maxItems = 150):
- lines = []
- num = 0
- labelNum = 0
- for i in project.GetVersions(constants.VSSFLAG_RECURSYES):
- num = num + 1
- if num > maxItems:
- break
-
- commentDesc = itemDesc = ''
- if i.Action[:5] == 'Added':
- continue
-
- if len(i.Label):
- labelNum = labelNum + 1
- itemDesc = i.Action
- else:
- itemDesc = i.VSSItem.Name
- if str(itemDesc[-4:]) == '.dsp':
- continue
-
- if i.Comment:
- commentDesc = '\n%s\t%s' % (linePrefix, i.Comment)
-
- lines.append('%s%s\t%s%s' % (linePrefix, time.asctime(time.localtime(int(i.Date))), itemDesc, commentDesc))
- if labelNum > noLabels:
- break
- continue
-
- return string.join(lines, '\n')
-
-
- def SubstituteVSSInFile(projectName, inName, outName):
- import win32api
- if win32api.GetFullPathName(inName) == win32api.GetFullPathName(outName):
- raise RuntimeError, 'The input and output filenames can not be the same'
- win32api.GetFullPathName(inName) == win32api.GetFullPathName(outName)
- sourceSafe = GetSS()
- project = sourceSafe.VSSItem(projectName)
- label = None
- for version in project.Versions:
- if version.Label:
- break
- continue
- else:
- print 'Couldnt find a label in the sourcesafe project!'
- return None
- vss_label = None.Label
- vss_date = time.asctime(time.localtime(int(version.Date)))
- now = time.asctime(time.localtime(time.time()))
- SubstituteInFile(inName, outName, (locals(), globals()))
-
-
- def CountCheckouts(item):
- num = 0
- if item.Type == constants.VSSITEM_PROJECT:
- for sub in item.Items:
- num = num + CountCheckouts(sub)
-
- elif item.IsCheckedOut:
- num = num + 1
-
- return num
-
-
- def GetLastBuildNo(project):
- i = GetSS().VSSItem(project)
- lab = None
- for version in i.Versions:
- lab = str(version.Label)
- if lab:
- return lab
-
-
-
- def MakeNewBuildNo(project, buildDesc = None, auto = 0, bRebrand = 0):
- if buildDesc is None:
- buildDesc = 'Created by Python'
-
- ss = GetSS()
- i = ss.VSSItem(project)
- num = CountCheckouts(i)
- if num > 0:
- msg = 'This project has %d items checked out\r\n\r\nDo you still want to continue?' % num
- import win32ui
- if win32ui.MessageBox(msg, project, win32con.MB_YESNO) != win32con.IDYES:
- return None
-
- oldBuild = buildNo = GetLastBuildNo(project)
- if buildNo is None:
- buildNo = '1'
- oldBuild = '<None>'
- else:
-
- try:
- buildNo = string.atoi(buildNo)
- if not bRebrand:
- buildNo = buildNo + 1
-
- buildNo = str(buildNo)
- except ValueError:
- raise error, 'The previous label could not be incremented: %s' % oldBuild
-
- if not auto:
- dialog = dialog
- import pywin.mfc
- buildNo = dialog.GetSimpleInput('Enter new build number', buildNo, '%s - Prev: %s' % (project, oldBuild))
- if buildNo is None:
- return None
-
- i.Label(buildNo, 'Build %s: %s' % (buildNo, buildDesc))
- if auto:
- print 'Branded project %s with label %s' % (project, buildNo)
-
- return buildNo
-
- if __name__ == '__main__':
- tp = '\\Python\\Python Win32 Extensions'
- SubstituteVSSInFile(tp, 'd:\\src\\pythonex\\win32\\win32.txt', 'd:\\temp\\win32.txt')
-
-