~ubuntu-branches/ubuntu/precise/pybackpack/precise

« back to all changes in this revision

Viewing changes to pybackpack/Copy.py

  • Committer: Bazaar Package Importer
  • Author(s): Andy Price, Andy Price, Piotr Ożarowski, Marco Rodrigues
  • Date: 2007-12-23 15:07:21 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071223150721-16ur0rbpnlppmbz3
Tags: 0.5.4-1
[ Andy Price ]
* New upstream release
* Update debian/docs - TODO file has been removed
* Depend on genisoimage which upstream now uses
* Remove debian/dirs - distutils creates usr/bin
* Fix section in debian/menu to follow menu guidelines

[ Piotr Ożarowski ]
* Homepage field added
* Rename XS-Vcs-* fields to Vcs-* (dpkg supports them now)

[ Marco Rodrigues ]
* Update Standards-Version to 3.7.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import gtk
 
2
import os
 
3
import stat
 
4
from shutil import copy2
 
5
 
 
6
def RecursiveCount(path):
 
7
        count = 1
 
8
        if os.path.isdir(path):
 
9
                for e in os.listdir(path):
 
10
                        count += RecursiveCount(os.path.join(path, e))
 
11
        return count
 
12
 
 
13
def RecursiveSize(path):
 
14
        size = 0
 
15
        for e in os.listdir(path):
 
16
                size += os.path.getsize(os.path.join(path, e))
 
17
                if not os.path.isdir(os.path.join(path, e)):
 
18
                        pass
 
19
                else:
 
20
                        size += RecursiveSize(os.path.join(path, e))
 
21
        return size
 
22
 
 
23
def RecursiveCopy(path, dest, callback=None):
 
24
        for e in os.listdir(path):
 
25
                if callback is not None:
 
26
                        callback(os.path.join(path, e))
 
27
                if not os.path.isdir(os.path.join(path, e)):
 
28
                        copy2(os.path.join(path, e), os.path.join(dest, e))
 
29
                        os.chmod(os.path.join(dest, e), os.stat(os.path.join(path, e)).st_mode|stat.S_IWUSR)
 
30
                else:
 
31
                        os.makedirs(os.path.join(dest, e))
 
32
                        RecursiveCopy(os.path.join(path, e), os.path.join(dest, e), callback)