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