/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: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
 
1
#!/usr/bin/python
2
2
 
3
3
"""Cross-platform os tools: files/directories manipulations
4
4
Usage:
25
25
    if not os.path.exists(dirname):
26
26
        os.makedirs(dirname)
27
27
    if not os.path.isdir(dirname):
28
 
        print("Error: Destination is not a directory", dirname)
 
28
        print "Error: Destination is not a directory", dirname
29
29
        return 2
30
30
    return 0
31
31
 
39
39
    cmd = argv.pop(0)
40
40
 
41
41
    if cmd == 'help':
42
 
        print(__doc__)
 
42
        print __doc__
43
43
        return 0
44
44
 
45
45
    if cmd == 'copytodir':
46
46
        if len(argv) < 2:
47
 
            print("Usage:  ostools.py copytodir FILES... DIR")
 
47
            print "Usage:  ostools.py copytodir FILES... DIR"
48
48
            return 1
49
49
 
50
50
        todir = argv.pop()
59
59
        for src in files:
60
60
            dest = os.path.join(todir, os.path.basename(src))
61
61
            shutil.copy(src, dest)
62
 
            print("Copied:", src, "=>", dest)
 
62
            print "Copied:", src, "=>", dest
63
63
 
64
64
        return 0
65
65
 
66
66
    if cmd == 'copytree':
67
67
        if len(argv) < 2:
68
 
            print("Usage:  ostools.py copytree FILES... DIR")
 
68
            print "Usage:  ostools.py copytree FILES... DIR"
69
69
            return 1
70
70
 
71
71
        todir = argv.pop()
85
85
            if retcode:
86
86
                return retcode
87
87
            shutil.copy(src, dest)
88
 
            print("Copied:", src, "=>", dest)
 
88
            print "Copied:", src, "=>", dest
89
89
 
90
90
        return 0
91
91
 
92
92
    if cmd == 'remove':
93
93
        if len(argv) == 0:
94
 
            print("Usage:  ostools.py remove [FILES...] [DIRS...]")
 
94
            print "Usage:  ostools.py remove [FILES...] [DIRS...]"
95
95
            return 1
96
96
 
97
97
        filesdirs = []
101
101
        for i in filesdirs:
102
102
            if os.path.isdir(i):
103
103
                shutil.rmtree(i)
104
 
                print("Removed:", i)
 
104
                print "Removed:", i
105
105
            elif os.path.isfile(i):
106
106
                os.remove(i)
107
 
                print("Removed:", i)
 
107
                print "Removed:", i
108
108
            else:
109
 
                print("Not found:", i)
 
109
                print "Not found:", i
110
110
 
111
111
        return 0
112
112
 
113
113
    if cmd == "basename":
114
114
        if len(argv) == 0:
115
 
            print("Usage:  ostools.py basename [PATH | URL]")
 
115
            print "Usage:  ostools.py basename [PATH | URL]"
116
116
            return 1
117
117
 
118
118
        for path in argv:
119
 
            print(os.path.basename(path))
 
119
            print os.path.basename(path)
120
120
        return 0
121
121
 
122
122
    if cmd == 'makedir':
123
123
        if len(argv) == 0:
124
 
            print("Usage:  ostools.py makedir DIR")
 
124
            print "Usage:  ostools.py makedir DIR"
125
125
            return 1
126
126
 
127
127
        retcode = makedir(argv.pop())
129
129
            return retcode
130
130
        return 0
131
131
 
132
 
    print("Usage error")
133
 
    print(__doc__)
 
132
    print "Usage error"
 
133
    print __doc__
134
134
    return 1
135
135
 
136
136