<commit_before>#!/usr/bin/env python
#
# Create package with appropriate version number.
#
# Author: <NAME>, <NAME>
#

import os
import getopt
import sys
from numpy import loadtxt
sys.path.append('../scripts')
import sct_utils as sct

#=======================================================================================================================
# usage
#=======================================================================================================================
def usage():
    print 'USAGE: \n' \
        ''+os.path.basename(__file__)+'\n' \
        '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' \
        'Part of the Spinal Cord Toolbox <https://sourceforge.net/projects/spinalcordtoolbox>\n' \
        '\n'\
        'DESCRIPTION\n' \
        '  Create a package of the Spinal Cord Toolbox.\n' \
        '\n' \
        'USAGE\n' \
        '  '+os.path.basename(__file__)+'\n' \
        '\n' \
        'MANDATORY ARGUMENTS\n' \
        '  -s <OS name>      name of the OS {osx,debian}. Default=osx.\n' \
        '\n'\
        'EXAMPLE:\n' \
        '  create_package.py -s debian\n'
    sys.exit(2)

listOS = ['osx','debian']
OSname = listOS[0]
# Check input param
try:
    opts, args = getopt.getopt(sys.argv[1:],'hs:')
except getopt.GetoptError as err:
    print str(err)
    usage()
for opt, arg in opts:
    if opt == '-h':
        usage()
    elif opt in ('-s'):
        OSname = str(arg)

if OSname not in listOS:
    print 'ERROR: OS name should be one of the following: '+'[%s]' % ', '.join(map(str,listOS))
    usage()

# get version
version = str(loadtxt("../version.txt", comments="#", delimiter=",", unpack=False))

# create output folder
folder_sct = '../spinalcordtoolbox_v'+version+'/'
if os.path.exists(folder_sct):
    sct.run('rm -rf '+folder_sct)
sct.run('mkdir '+folder_sct)

# copy folders
sct.run('mkdir '+folder_sct+'spinalcordtoolbox')
sct.run('cp installer.sh '+folder_sct)
sct.run('cp ../README.md '+folder_sct+'spinalcordtoolbox/')
sct.run('cp ../LICENSE '+folder_sct+'spinalcordtoolbox/')
sct.run('cp ../version.txt '+folder_sct+'spinalcordtoolbox/')
sct.run('cp -r ../flirtsch '+folder_sct+'spinalcordtoolbox/')
sct.run('cp -r ../scripts '+folder_sct+'spinalcordtoolbox/')
sct.run('mkdir '+folder_sct+'spinalcordtoolbox/bin')
if OSname == 'osx':
    sct.run('cp -r ../bin/OSX_10.6-7-8/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r OSX_10.6.7.8/ants/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r OSX_10.6.7.8/c3d/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r ../lib '+folder_sct+'spinalcordtoolbox/')
elif OSname == 'debian':
    sct.run('cp -r ../bin/Debian_7.5/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r Debian_7.5/ants/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r Debian_7.5/c3d/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('mkdir '+folder_sct+'spinalcordtoolbox/lib') # not required but we still create lib folder

# copy colormap
sct.run('mkdir '+folder_sct+'spinalcordtoolbox/data/')
sct.run('cp -rf ../data/colormap '+folder_sct+'spinalcordtoolbox/data/')<commit_msg>INST: made input arg mandatory<commit_after>#!/usr/bin/env python
#
# Create package with appropriate version number.
#
# Author: <NAME>, <NAME>
#

import os
import getopt
import sys
from numpy import loadtxt
sys.path.append('../scripts')
import sct_utils as sct

#=======================================================================================================================
# usage
#=======================================================================================================================
def usage():
    print 'USAGE: \n' \
        ''+os.path.basename(__file__)+'\n' \
        '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' \
        'Part of the Spinal Cord Toolbox <https://sourceforge.net/projects/spinalcordtoolbox>\n' \
        '\n'\
        'DESCRIPTION\n' \
        '  Create a package of the Spinal Cord Toolbox.\n' \
        '\n' \
        'USAGE\n' \
        '  '+os.path.basename(__file__)+'\n' \
        '\n' \
        'MANDATORY ARGUMENTS\n' \
        '  -s <OS name>      name of the OS {osx,debian}.\n' \
        '\n'\
        'EXAMPLE:\n' \
        '  create_package.py -s debian\n'
    sys.exit(2)

listOS = ['osx','debian']
OSname = ''
# Check input param
try:
    opts, args = getopt.getopt(sys.argv[1:],'hs:')
except getopt.GetoptError as err:
    print str(err)
    usage()
for opt, arg in opts:
    if opt == '-h':
        usage()
    elif opt in ('-s'):
        OSname = str(arg)

if OSname not in listOS:
    print 'ERROR: OS name should be one of the following: '+'[%s]' % ', '.join(map(str,listOS))
    usage()

# get version
version = str(loadtxt("../version.txt", comments="#", delimiter=",", unpack=False))

# create output folder
folder_sct = '../spinalcordtoolbox_v'+version+'/'
if os.path.exists(folder_sct):
    sct.run('rm -rf '+folder_sct)
sct.run('mkdir '+folder_sct)

# copy folders
sct.run('mkdir '+folder_sct+'spinalcordtoolbox')
sct.run('cp installer.sh '+folder_sct)
sct.run('cp ../README.md '+folder_sct+'spinalcordtoolbox/')
sct.run('cp ../LICENSE '+folder_sct+'spinalcordtoolbox/')
sct.run('cp ../version.txt '+folder_sct+'spinalcordtoolbox/')
sct.run('cp -r ../flirtsch '+folder_sct+'spinalcordtoolbox/')
sct.run('cp -r ../scripts '+folder_sct+'spinalcordtoolbox/')
sct.run('mkdir '+folder_sct+'spinalcordtoolbox/bin')
if OSname == 'osx':
    sct.run('cp -r ../bin/OSX/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r OSX/ants/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r OSX/c3d/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r ../lib '+folder_sct+'spinalcordtoolbox/')
elif OSname == 'debian':
    sct.run('cp -r ../bin/Debian_7.5/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r Debian_7.5/ants/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('cp -r Debian_7.5/c3d/* '+folder_sct+'spinalcordtoolbox/bin/')
    sct.run('mkdir '+folder_sct+'spinalcordtoolbox/lib') # not required but we still create lib folder

# copy colormap
sct.run('mkdir '+folder_sct+'spinalcordtoolbox/data/')
sct.run('cp -rf ../data/colormap '+folder_sct+'spinalcordtoolbox/data/')
{'fraction_non_alphanumeric': 0.2774091627172196, 'fraction_numerical': 0.005687203791469194, 'mean_word_length': 3.76015037593985, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '207733', 'n_tokens_mistral': 2333, 'n_tokens_neox': 2192, 'n_words': 441}