| •1 |
|
| 2 |
|
| 3 |
from optparse import OptionParser |
| 4 |
from os import makedirs, pardir |
| 5 |
from os.path import abspath, basename, isdir, join |
| 6 |
|
| 7 |
from util import VERSION, createSourcePackage, getRootDirectory |
| 8 |
|
| 9 |
def main(): |
| 10 |
rootDirectory = getRootDirectory() |
| 11 |
|
| 12 |
parser = OptionParser("usage: %prog [options]") |
| 13 |
parser.add_option("-a", "--archive-name", action="store", |
| 14 |
default="midisnoop-%s.tar.gz" % VERSION, |
| 15 |
dest="archiveName", help="The archive file name") |
| 16 |
parser.add_option("-d", "--destination-dir", action="store", |
| 17 |
default=abspath(join(rootDirectory, pardir)), |
| 18 |
dest="destinationDir", |
| 19 |
help="Directory to store the source archive in") |
| 20 |
options, args = parser.parse_args() |
| 21 |
|
| 22 |
if len(args): |
| 23 |
parser.error("incorrect number of required arguments") |
| 24 |
archiveName = options.archiveName |
| 25 |
if basename(archiveName) != archiveName: |
| 26 |
parser.error("'%s': invalid archive name" % archiveName) |
| 27 |
destinationDir = options.destinationDir |
| 28 |
if not isdir(destinationDir): |
| 29 |
makedirs(destinationDir) |
| 30 |
createSourcePackage(join(destinationDir, archiveName)) |
| 31 |
|
| 32 |
if __name__ == "__main__": |
| 33 |
main() |