~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/win32/ostools.py

  • Committer: Joe Julian
  • Date: 2010-01-10 02:25:31 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: joe@julianfamily.org-20100110022531-wqk61rsagz8xsiga
Added MANIFEST.in to allow bdist_rpm to have all the required include files and tools. bdist_rpm will still fail to build correctly on some distributions due to a disttools bug http://bugs.python.org/issue644744

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import shutil
22
22
import sys
23
23
 
 
24
def makedir(dirname):
 
25
    if not os.path.exists(dirname):
 
26
        os.makedirs(dirname)
 
27
    if not os.path.isdir(dirname):
 
28
        print "Error: Destination is not a directory", dirname
 
29
        return 2
 
30
    return 0
24
31
 
25
32
def main(argv=None):
26
33
    if argv is None:
41
48
            return 1
42
49
 
43
50
        todir = argv.pop()
44
 
        if not os.path.exists(todir):
45
 
            os.makedirs(todir)
46
 
        if not os.path.isdir(todir):
47
 
            print "Error: Destination is not a directory"
48
 
            return 2
 
51
        retcode = makedir(todir)
 
52
        if retcode:
 
53
            return retcode
49
54
 
50
55
        files = []
51
56
        for possible_glob in argv:
64
69
            return 1
65
70
 
66
71
        todir = argv.pop()
67
 
        if not os.path.exists(todir):
68
 
            os.makedirs(todir)
69
 
        if not os.path.isdir(todir):
70
 
            print "Error: Destination is not a directory"
71
 
            return 2
 
72
        retcode = makedir(todir)
 
73
        if retcode:
 
74
            return retcode
72
75
 
73
76
        files = []
74
77
        for possible_glob in argv:
78
81
            relative_path = src
79
82
            dest = os.path.join(todir, relative_path)
80
83
            dest_dir = os.path.dirname(dest)
81
 
            if not os.path.isdir(dest_dir):
82
 
                os.makedirs(dest_dir)
 
84
            retcode = makedir(dest_dir)
 
85
            if retcode:
 
86
                return retcode
83
87
            shutil.copy(src, dest)
84
88
            print "Copied:", src, "=>", dest
85
89
 
106
110
 
107
111
        return 0
108
112
 
 
113
    if cmd == "basename":
 
114
        if len(argv) == 0:
 
115
            print "Usage:  ostools.py basename [PATH | URL]"
 
116
            return 1
 
117
 
 
118
        for path in argv:
 
119
            print os.path.basename(path)
 
120
        return 0
 
121
 
 
122
    if cmd == 'makedir':
 
123
        if len(argv) == 0:
 
124
            print "Usage:  ostools.py makedir DIR"
 
125
            return 1
 
126
 
 
127
        retcode = makedir(argv.pop())
 
128
        if retcode:
 
129
            return retcode
 
130
        return 0
 
131
 
109
132
    print "Usage error"
110
133
    print __doc__
111
134
    return 1