cannot create python packages
Hi, i have the following files: current_dir/level1/Called.py current_dir/Caller.py Called.py: --- class Called: def exec1(self): print Hello Caller.py: -- from level1.Called import * c=Called() c.exec1() However it is impossible for Caller.py to find Called.py. I even tried to place the level1 structure inside /usr/lib/pythonX.Y/, whithout success however. Any ideas? Thnx ___ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html -- http://mail.python.org/mailman/listinfo/python-list
find difference in days from YYYYMMDD to YYYYMMDD
Hi, does any body now any such algorith? to find difference in days from MMDD to MMDD? Or just an algorithm, that converts MMDD to seconds since the epoch? Thanks -- http://mail.python.org/mailman/listinfo/python-list
cannot __getitem__ from DB reply list
Hi, i have the following function: def getGNUPlotInputFeaturesVersion(self): s= bugCommits=0 trdocCommits=0 featCommits=0 ct=CommitType() for version in self.releaseVersionsList_: self.execQuery(SELECT msg,prssedDevsFileNum,prssedMakesFileNum,prssedDocsFileNum,prssedGraphsFileNum FROM Commit WHERE \ projVersion=\+version+\;); for tuple in self.dbcursor_.fetchall(): print tuple On the print tuple part, i get: [EMAIL PROTECTED]:~/workspace/SVNLog2DB$ jython 2LaunchQueries.py Connection established to database... Traceback (innermost last): File 2LaunchQueries.py, line 5, in ? File /home/kostas/workspace/SVNLog2DB/QueryExecutor.py, line 80, in getGNUPlotInputFeaturesVersion AttributeError: __getitem__ As far as i have read, this means, that there is a problem getting something from the list, because it might be FOR EXAMPLE , that self.dbcursor_.fetchall() doesn't return a list -i know it does. However, i did a print self.dbcursor_.fetchall() and i got a huge list of tuples... Why can't i iterate the list? Any advice? -- http://mail.python.org/mailman/listinfo/python-list
about __str__
Hi, i have the following class: === class CmterIDCmts: def __init__(self,commiterID,commits): self.commiterID_=long(commiterID) self.commits_=long(commits) def __str__(self): s= s+=+str(self.commiterID_)+:+str(self.commits_)+ return s === and then i create the following 2 objects and list: === a=CmterIDCmts(2,3) b=CmterIDCmts(4,5) print a print b c=[] c.append(a) c.append(b) print c === and this is what i get: === 2:3 4:5 [CmterIDCmts.CmterIDCmts instance at 821045869, CmterIDCmts.CmterIDCmts instance at 1735488308] === The __str__ method of list doesn't seem to call the __str__ method of the objects ie, __str__ is not equicalent to the Java toString() method... Anyway, how can i fix this? Thanks -- http://mail.python.org/mailman/listinfo/python-list
raw string
Hi, i am trying to execute the following query on a DB: qe.execQuery(rSELECT * FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\n' FROM Commiter) However, whether i put the r in the front or not, i always get an error about the \n. What's wrong? -- http://mail.python.org/mailman/listinfo/python-list
trim start and trailing space chars from string
Hi, is there something corresponding to the java String.trim() method, ie trim start and trailing space/tab chars from string? say convert asdf to asdf? Thnx -- http://mail.python.org/mailman/listinfo/python-list
find and remove \ character from string
Hi, i have the following string s and the following code, which doesn't successfully remove the \, but sucessfully removes the \\. s=Sad\\asd\asd newS= for i in s: ... if i!=\\: ... newS=newS+i ... newS 'Sadasd\x07sd' I have also read the following, but i do not understand the ...and the remaining characters have been mapped through the given translation table, which must be a string of length 256. Can some explain? *translate*(table[, deletechars]) Return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. For Unicode objects, the translate() method does not accept the optional deletechars argument. Instead, it returns a copy of the s where all characters have been mapped through the given translation table which must be a mapping of Unicode ordinals to Unicode ordinals, Unicode strings or |None|. Unmapped characters are left untouched. Characters mapped to |None| are deleted. Note, a more flexible approach is to create a custom character mapping codec using the codecs http://docs.python.org/lib/module-codecs.html module (see encodings.cp1251 for an example). -- http://mail.python.org/mailman/listinfo/python-list
cannot declare global vars!
Hi, i had posted earlier for not being able to declare global vars. No i followed the suggestions and created a class, but still the vars do not seem to have a global scope. I have tried pretty much everything. Any advice appreciated... Here: #!/usr/bin/env jython #imports ... class SVNLogs2DBParser: #svnLogging_ #dbTable_ #cmterID_ #projID_ #fileIDNumber_ #Commiter_ #Commit_ #StoredProject_ #ProjectVersion_ #entryList_ def __init__(self,svnLogging_=SVNLogging(SVN_REPOS),dbTable_=DBTablesHandler(),cmterID_=0,projID_=0, fileIDNumber_=0,Commiter_={},Commit_={},StoredProject_={},ProjectVersion_={},entryList_={}): pass #svnLogging_=SVNLogging(SVN_REPOS) #print Connection established to SVN repository... #dbTable_=DBTablesHandler() #cmterID_=0 #projID_=0 #fileIDNumber_=0 #Commiter_={} #Commit_={} #StoredProject_={} #ProjectVersion_={} #entryList_={} #reads all the revision logs (traversing them PIVOT at a time) and #processes each log entry def getLogsLoop(self): while svnLogging_.getCurrentRevisionNumber()!=svnLogging_.getLatestRevisionNumber(): entryList_=svnLogging_.getNextLogs(PIVOT); #print Attempting to go over the HEAD revision... for entry in self.entryList: print processing new SVN entry... processLogEntry(entry) entryList_.clear() #processes each log entry # #entry is of type SVNLogEntry. See SVNKit API #changedPaths is returned as a java.util.HashMap #with key strings (paths) and values SVNLogEntryPath objects #entry.getDates() returns a java.util.Date object def processLogEntry(self, entry): revision = int(entry.getRevision()) commiter = str(entry.getAuthor()) datetime = getTimeStamp(entry.getDate()) message = str(entry.getMessage()) changedPaths = entry.getChangedPaths() #array passed for updating the Commiter DB table Commiter_[0] = cmterID_ Commiter_[1] = commiter dbTable_.updateCommiterTable(Commiter_) #array passed for updating the Commit DB table Commit_[0] = projID_ Commit_[1] = datetime Commit_[2] = cmterID_ Commit_[3] = 0.0 Commit_[4] = #properties fileStats=getFileTypes(changedPaths) Commit_[5] = fileStats[0] Commit_[6] = fileStats[2] Commit_[7] = fileStats[1] Commit_[8] = fileStats[3] Commit_[9] = fileStats[4] dbTable_.updateCommitTable(self.Commit_) ProjectVersion_[0]=projID_ ProjectVersion_[1]=0.0 dbTable_.updateProjectVersionTable(ProjectVersion_) Project[0]=projID_ Project[1]= Project[2]= Project[3]= Project[4]= dbTable_.updateProjectTable(Project_) cmterID_+=1 projID_+=1 ##HELPER##METHODS### ##HELPER##METHODS### -- http://mail.python.org/mailman/listinfo/python-list
UnboundLocalError on global variable
Hi, i have a problem, the source of which is probably the fact, that i have not understood how to declare global variables - I use the Jython compiler, but i think this is a Python issue... First of all, i don not use any classes in this module. The problem is, that i declare and instantiate some vars outside the functions (global ones), but when i use them inside the functions, i get an UnboundLocalError error. Here's the interesting part of the code: == #imports ... #CONSTANTS . ... #connection to DB dbcursor_=db.cursor() #GLOBAL VARS entryList_={} cmterID_=0 //VARIABLE DECLARATION projID_=0 fileIDNumber_=0 Commiter_={} Commit_={} Project_={} ProjectVersion_={} def updateCommiterTable(Commiter): query=INSERT INTO Commiter (pk_cmterID,cmterName) VALUES (+str(Commiter[0])+,\+str(Commiter[1])+\); dbcursor_.execute(query) def updateCommitTable(Commit): query=INSERT INTO Commit (pk_cmitID,cmitTime,fk_cmterID,cmitProperties,cmitComment,cmitCommentLines,fk_projID) VALUES ( \ +str(Commit[0])+,\+str(Commit[1])+\,+str(Commit[2])+,\+str(Commit[3])+\,\+str(Commit[4])+\,+str(Commit[5])+,+str(Commit[6])+); dbcursor_.execute(query) def updateProjectTable(Project): dbcursor_.execute(INSERT INTO Project (pk_projID,projName,projWebsite,projContactPoint,projSrcPath,projMailPath) VALUES ( \ +str(Project[0])+,\+str(Project[1])+\,\+str(Project[2])+\,\+str(Project[3])+\,\+str(Project[4])+\,\+str(Project[5])+\);) def updateProjectVersionTable(ProjectVersion): dbcursor_.execute(INSERT INTO ProjectVersion (pfk_projID,projName,projVersion) VALUES ( \ +str(ProjectVersion[0])+,\+str(ProjectVersion[1])+\,\+str(ProjectVersion[2])+\);); def getLogsLoop(): while svnLogging_.getCurrentRevisionNumber()!=svnLogging_.getLatestRevisionNumber(): try: entryList_=svnLogging_.getNextLogs(PIVOT); except HeadRevisionReachedException: print Attempting to go over the HEAD revision... for entry in entryList_: print processing new SVN entry... processLogEntry(entry) entryList_.clear() def processLogEntry(entry): revision = int(entry.getRevision()) commiter = str(entry.getAuthor()) datetime = getTimeStamp(entry.getDate()) message = str(entry.getMessage()) Commiter_[0] = cmterID_ //HERE's THE PROBLEM Commiter_[1] = commiter updateCommiterTable(Commiter_) Commit_[0] = revision Commit_[1] = datetime Commit_[2] = cmterID_ Commit_[3] = #properties Commit_[4] = message Commit_[5] = getNumberOfLines(message) Commit_[6] = projID_ updateCommitTable(Commit_) ProjectVersion_[0]=projID_ ProjectVersion_[1]= ProjectVersion_[2]= updateProjectVersionTable(ProjectVersion_) Project_[0]=projID_ Project_[1]= Project_[2]= Project_[3]= Project_[4]= Project_[5]= updateProjectTable(Project_) cmterID_+=1 projID_+1 ##HELPER##METHODS### ... ##HELPER##METHODS### getLogsLoop() == And I get: == Traceback (innermost last): File ParseSVN2DB.py, line 182, in ? File ParseSVN2DB.py, line 87, in getLogsLoop File ParseSVN2DB.py, line 100, in processLogEntry UnboundLocalError: local: 'cmterID_' == The things is, that cmterID_ HAS BEEN instantiated... I don't understand. Can somebody please explain? -- http://mail.python.org/mailman/listinfo/python-list