Permalink
Browse files

use utils.copyfile

  • Loading branch information...
1 parent 244164e commit 3d11ee5e5dc69cfd5fc62bab43461250f037beb5 @epico epico committed Oct 22, 2012
Showing with 11 additions and 10 deletions.
  1. +1 −3 evaluate.py
  2. +2 −3 generate.py
  3. +5 −0 lib/utils.py
  4. +3 −4 tryprune.py
View
@@ -1,7 +1,6 @@
#!/usr/bin/python3
import os
import os.path
-import shutil
import sys
from subprocess import Popen, PIPE
from argparse import ArgumentParser
@@ -148,8 +147,7 @@ def evaluateModel(reportfile):
destfile = os.path.join(libpinyin_dir, 'data', \
config.getFinalModelFileName())
- print('copying from ' + modelfile + ' to ' + destfile)
- shutil.copyfile(modelfile, destfile)
+ utils.copyfile(modelfile, destfile)
print('cleaning')
cleanUpData()
View
@@ -2,7 +2,6 @@
import os
import os.path
import sys
-import shutil
from subprocess import Popen, PIPE
from argparse import ArgumentParser
import utils
@@ -83,9 +82,9 @@ def copyoutInMemoryFile(modelfile):
reportfile = modelfile + config.getReportPostfix()
if os.access(inmemoryfile, os.F_OK):
- shutil.copyfile(inmemoryfile, modelfile)
+ utils.copyfile(inmemoryfile, modelfile)
if os.access(inmemoryreportfile, os.F_OK):
- shutil.copyfile(inmemoryreportfile, reportfile)
+ utils.copyfile(inmemoryreportfile, reportfile)
def cleanupFiles(modelnum):
modeldir = os.path.join(config.getModelDir(), subdir, indexname)
View
@@ -1,6 +1,7 @@
import io
import os
import json
+import shutil
from myconfig import MyConfig
@@ -40,6 +41,10 @@ def get_file_length(infile):
f.close()
return length
+def copyfile(src, dst):
+ print('copying from ' + src + ' to ' + dst)
+ shutil.copyfile(src, dst)
+
#JSON Load/Store
def load_status(infile):
View
@@ -1,7 +1,6 @@
#!/usr/bin/python3
import os
import os.path
-import shutil
import sys
from subprocess import Popen, PIPE
from argparse import ArgumentParser
@@ -200,13 +199,13 @@ def pruneModel(prunedmodel, k, CDF):
if os.access(shmmodel, os.F_OK):
os.unlink(shmmodel)
#copy to memory
- shutil.copyfile(mergedmodel, shmmodel)
+ utils.copyfile(mergedmodel, shmmodel)
pruneModel(shmmodel, args.k, args.CDF)
#copy to filesystem
- shutil.copyfile(shmmodel, prunedmodel)
+ utils.copyfile(shmmodel, prunedmodel)
else:
#backup merged model
- shutil.copyfile(mergedmodel, prunedmodel)
+ utils.copyfile(mergedmodel, prunedmodel)
pruneModel(prunedmodel, args.k, args.CDF)
#validate pruned model

0 comments on commit 3d11ee5

Please sign in to comment.