..::ചുമ്മാ കാണുക ... ഇതുവരെ ഉള്ള എല്ലാ ഫോട്ടോകളും ഉണ്ട് ::..

Thursday, January 1, 2009

..:: vsFileEdit ::..

ഒരു python സ്ക്രിപ്റ്റ്

#/////////////////////////////////////////////////////////////////////////////////////////////////
#// Script Name : vsFileEdit.py //
#// //
#// Script Type : Remove Visual Studio Projects from the startup page //
#// //
#// Author : Kurian O S(Sandhu) //
#// //
#// Date : 01/01/2009 //
#// //
#/////////////////////////////////////////////////////////////////////////////////////////////////

#module imports

import os
import _winreg as wreg
import wx

#class starting here
class ClsVsRemove(wx.Frame):
'''This module is based on Visual Studio 2008 if you want to use 2005 or other versions please change
the 9.0 to like 8.0 or like that'''

#main global vars
myCurSlect=""
putCurI=0
parentUILay={'frameLay':None}
regVsHoldLoc = wreg.OpenKey(wreg.HKEY_CURRENT_USER,r"Software\Microsoft\VisualStudio\9.0\ProjectMRUList",0, wreg.KEY_ALL_ACCESS)
#main int for wx layout
def __init__(self):
'''Here we are creating the main WX layout for the window
To Display the reg values from visual studio'''

self.parentUILay['frameLay']=wx.Frame.__init__(self, id=wx.ID_ANY, name='', parent=None,pos=wx.Point(358, 184),style=wx.CLOSE_BOX|wx.SYSTEM_MENU | wx.CAPTION | wx.CLIP_CHILDREN, title=u'..:: VS File Remover ::..')
self.SetClientSize(wx.Size(291, 250))
self.listbox = wx.ListBox(self, wx.ID_ANY, choices=[],style=wx.LB_SINGLE,size=wx.Size(650,200))
self.removeBut = wx.Button(self, wx.ID_ANY, "Remove Selected")
self.removeAllBut = wx.Button(self, wx.ID_ANY, "Remove All")
sizer = wx.GridBagSizer(vgap=5, hgap=5)
sizer.Add(self.listbox, pos=(0, 0),span=(6, 2),flag=wx.ALL|wx.EXPAND, border=5)
sizer.Add(self.removeBut, pos=(7, 1), flag=wx.ALL, border=5)
sizer.Add(self.removeAllBut, pos=(7, 0), flag=wx.ALL, border=5)
self.SetSizer(sizer)
self.listbox.Bind(wx.EVT_LISTBOX, self.listSlection)
self.removeBut.Bind(wx.EVT_BUTTON, self.removeThisTag)
self.removeAllBut.Bind(wx.EVT_BUTTON, self.removeAllRegKey)
self.Fit()
self.regLoadHere()

#Registry value eading function
def regLoadHere(self):
'''Here we are reading the Registry values and appening to the window
from WX ....'''

for self.putCurI in range(1024):
try:
n,v,t = wreg.EnumValue(self.regVsHoldLoc,self.putCurI)
self.listbox.Append(n+" " +v)
except EnvironmentError:
break

#transfering selection to a global var
def listSlection(self,event):
self.myCurSlect=""
self.myCurSlect=self.listbox.GetStringSelection()
self.myCurSlect=self.myCurSlect+" %s"%+self.listbox.GetSelection()

#main function for remove a single selection
def removeThisTag(self,event):
'''This module will remove only the selected value from the visual studio
And iof the selection is wrong it will through error '''

getValuHr=self.myCurSlect.split(" ")
if getValuHr[0] == "":
raise EnvironmentError, 'Select a File Which you want to remove !!!'
else:
try:
wreg.DeleteValue(self.regVsHoldLoc, getValuHr[0])
dlg = wx.MessageDialog(self, 'Selected File Information is Removed !!!'+getValuHr[1],'Info !!!',wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
for getVal in range(int(getValuHr[3])+1 , self.putCurI):
newContVal=getVal+1
oldKeyVal='File%s'%+newContVal
neKeyName='File%s'%getVal
getOldKeyVal=wreg.QueryValueEx(self.regVsHoldLoc, oldKeyVal)
wreg.DeleteValue(self.regVsHoldLoc, oldKeyVal)
wreg.SetValueEx(self.regVsHoldLoc,neKeyName,0,wreg.REG_EXPAND_SZ,getOldKeyVal[0])
self.Destroy()
ClsVsRemove().Show()
app.MainLoop()
except EnvironmentError, e:
raise EnvironmentError, e

#remove all function call here
def removeAllRegKey(self,event):
'''This module will remove all the values under tha maain key from visual studio'''
dlg = wx.MessageDialog(self, 'All File information for the startup will be removed !!!\nDo You Want to do this ???','Info !!!',style=wx.YES|wx.NO|wx.CANCEL | wx.ICON_INFORMATION)
if dlg.ShowModal()==wx.ID_YES:
dlg.Destroy()
for getVal in range(0 , self.putCurI):
newContVal=getVal+1
oldKeyVal='File%s'%+newContVal
getOldKeyVal=wreg.QueryValueEx(self.regVsHoldLoc, oldKeyVal)
wreg.DeleteValue(self.regVsHoldLoc, oldKeyVal)
dlgConf = wx.MessageDialog(self, 'All File information removed From Startup','Info !!!',style=wx.OK | wx.ICON_INFORMATION)
dlgConf.ShowModal()
dlgConf.Destroy()
self.Destroy()
ClsVsRemove().Show()
app.MainLoop()
else:
print "Exited without any changes !!!"

#starting wx apps with the reg value reader
if __name__ == '__main__':
app = wx.App(0)
ClsVsRemove().Show()
app.MainLoop()

0 comments:

::..ഇപ്പൊ ഇത്രേം പേരു ഇവിടെ ഉണ്ട്..::

..:: സഹിക്കുന്നവര്‍ ::..

..:: സഹിച്ചവര്‍ ::..

..:: കുറെ നല്ല പാട്ടുകള്‍ ::..

..:: കോപ്പിറൈറ്റ് ::..

അടിച്ചോണ്ട് പോയിട്ട് ലാസ്റ്റ് പാര ആയാല്‍ എന്നെ ഒന്നും പറയരുത്

TOP