Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pickles!

  • Loading branch information...
commit 3505f3517158941e2b668da4359ecbe5149e7f14 1 parent 0c339fd
@orestis authored
Showing with 19 additions and 3 deletions.
  1. +1 −0  PerfTimer.py
  2. +18 −3 pysmell/idehelper.py
View
1  PerfTimer.py
@@ -17,6 +17,7 @@ def add(self, name):
def report(self, (startName, startTime), (endName, endTime)):
print >> OUT, '%s: from %s to %s: %0.3f' % (self.name, startName, endName,
(endTime - startTime).microseconds / 1000.0)
+ OUT.flush()
def _end(self):
self.add('end')
View
21 pysmell/idehelper.py
@@ -15,6 +15,11 @@
from pysmell.codefinder import findRootPackageList, getImports, getNames, getClassAndParents, analyzeFile, getSafeTree
from pysmell.matchers import MATCHERS
+try:
+ import cPickle as pickle
+except:
+ import pickle
+
def findBase(line, col):
index = col
# col points at the end of the completed string
@@ -38,7 +43,12 @@ def updatePySmellDict(master, partial):
def tryReadPYSMELLDICT(directory, filename, dictToUpdate):
from PerfTimer import PerfTimer
t = PerfTimer('tryRead: ' + directory + ' ' + filename, 2)
- if os.path.exists(os.path.join(directory, filename)):
+ fullPath = os.path.join(directory, filename)
+ pickleFileName = os.path.join(directory, 'pickle_' + filename)
+ if os.path.exists(pickleFileName):
+ t.BeforeLoadPickle
+ d = pickle.load(open(pickleFileName, 'rb'))
+ elif os.path.exists(fullPath):
t.BeforeOpen
tagsFile = open(os.path.join(directory, filename), 'r')
try:
@@ -46,10 +56,15 @@ def tryReadPYSMELLDICT(directory, filename, dictToUpdate):
contents = tagsFile.read()
t.BeforeEval
d = eval(contents)
- t.BeforeUpdate
- updatePySmellDict(dictToUpdate, d)
+ t.BeforePickle
+ pickleFile = open(pickleFileName, 'wb')
+ pickle.dump(d, pickleFile, protocol=pickle.HIGHEST_PROTOCOL)
+ pickleFile.close()
finally:
tagsFile.close()
+ t.BeforeUpdate
+ updatePySmellDict(dictToUpdate, d)
+
t.end
Please sign in to comment.
Something went wrong with that request. Please try again.