~kevang/mnemosyne-proj/number_keys_show_answer

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/utils.py

  • Committer: Peter.Bienstman at UGent
  • Date: 2014-09-09 19:27:39 UTC
  • Revision ID: peter.bienstman@ugent.be-20140909192739-oierehrdx54813q1
Various cleanups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
            if stat.S_ISFIFO(st.st_mode):
56
56
                raise SpecialFileError("`%s` is a named pipe" % fn)
57
57
 
58
 
    with open(src, 'rb') as fsrc:
59
 
        with open(dst, 'wb') as fdst:
60
 
            copyfileobj(fsrc, fdst)
 
58
    fsrc = None
 
59
    fdst = None
 
60
    try:
 
61
        fsrc = open(src, 'rb')
 
62
        fdst = open(dst, 'wb')
 
63
        copyfileobj(fsrc, fdst)
 
64
    finally:
 
65
        if fdst:
 
66
            fdst.close()
 
67
        if fsrc:
 
68
            fsrc.close()
61
69
 
62
70
def copymode(src, dst):
63
71
    """Copy mode bits from src to dst"""