/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/win32/ostools.py

  • Committer: John Arbash Meinel
  • Date: 2009-04-21 23:54:16 UTC
  • mto: (4300.1.7 groupcompress_info)
  • mto: This revision was merged to the branch mainline in revision 4301.
  • Revision ID: john@arbash-meinel.com-20090421235416-f0cz6ilf5cufbugi
Fix bug #364900, properly remove the 64kB that was just encoded in the copy.
Also, stop supporting None as a copy length in 'encode_copy_instruction'.
It was only used by the test suite, and it is good to pull that sort of thing out of
production code. (Besides, setting the copy to 64kB has the same effect.)

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
31
24
 
32
25
def main(argv=None):
33
26
    if argv is None:
48
41
            return 1
49
42
 
50
43
        todir = argv.pop()
51
 
        retcode = makedir(todir)
52
 
        if retcode:
53
 
            return retcode
 
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
54
49
 
55
50
        files = []
56
51
        for possible_glob in argv:
69
64
            return 1
70
65
 
71
66
        todir = argv.pop()
72
 
        retcode = makedir(todir)
73
 
        if retcode:
74
 
            return retcode
 
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
75
72
 
76
73
        files = []
77
74
        for possible_glob in argv:
81
78
            relative_path = src
82
79
            dest = os.path.join(todir, relative_path)
83
80
            dest_dir = os.path.dirname(dest)
84
 
            retcode = makedir(dest_dir)
85
 
            if retcode:
86
 
                return retcode
 
81
            if not os.path.isdir(dest_dir):
 
82
                os.makedirs(dest_dir)
87
83
            shutil.copy(src, dest)
88
84
            print "Copied:", src, "=>", dest
89
85
 
110
106
 
111
107
        return 0
112
108
 
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
 
 
132
109
    print "Usage error"
133
110
    print __doc__
134
111
    return 1