<commit_before>#                                                            _
# Simple chris ds app demo
#
# (c) 2016 Fetal-Neonatal Neuroimaging & Developmental Science Center
#                   Boston Children's Hospital
#
#              http://childrenshospital.org/FNNDSC/
#                        <EMAIL>
#



import os, sys, shutil

# import the Chris app superclass
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
from base import ChrisApp


class SimpleDSApp(ChrisApp):
    '''
    Add prefix given by the --prefix option to the name of each input file.
    '''
    AUTHORS         = 'FNNDSC (<EMAIL>)'
    SELFPATH        = os.path.dirname(__file__)
    SELFEXEC        = os.path.basename(__file__)
    TITLE           = 'Simple chris ds app'
    CATEGORY        = ''
    TYPE            = 'ds'
    DESCRIPTION     = 'A simple chris ds app demo'
    DOCUMENTATION   = 'http://wiki'
    LICENSE         = 'Opensource (MIT)'
    VERSION         = '0.1'

    def define_parameters(self):
        self.add_parameter('--prefix', action='store', dest='prefix', type=str,
                          optional=False, help='prefix for file names')

    def run(self, options):
        for (dirpath, dirnames, filenames) in os.walk(options.inputdir):
            output_path =  os.path.join(options.outputdir,
                                        dirpath.replace(options.inputdir, ""))
            for dirname in dirnames:
                os.makedirs(os.path.join(output_path, dirnames))
            for name in filenames:
                new_name = options.prefix + name
                shutil.copy(os.path.join(dirpath, name), os.path.join(output_path, new_name))
            


# ENTRYPOINT
if __name__ == "__main__":
    app = SimpleDSApp()
    app.launch()<commit_msg>Minor refactoring.<commit_after>#                                                            _
# Simple chris ds app demo
#
# (c) 2016 Fetal-Neonatal Neuroimaging & Developmental Science Center
#                   Boston Children's Hospital
#
#              http://childrenshospital.org/FNNDSC/
#                        <EMAIL>
#



import os, sys, shutil

# import the Chris app superclass
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
from base import ChrisApp


class SimpleDSApp(ChrisApp):
    '''
    Add prefix given by the --prefix option to the name of each input file.
    '''
    AUTHORS         = 'FNNDSC (<EMAIL>)'
    SELFPATH        = os.path.dirname(__file__)
    SELFEXEC        = os.path.basename(__file__)
    TITLE           = 'Simple chris ds app'
    CATEGORY        = ''
    TYPE            = 'ds'
    DESCRIPTION     = 'A simple chris ds app demo'
    DOCUMENTATION   = 'http://wiki'
    LICENSE         = 'Opensource (MIT)'
    VERSION         = '0.1'

    def define_parameters(self):
        self.add_parameter('--prefix', action='store', dest='prefix', type=str,
                          optional=False, help='prefix for file names')

    def run(self, options):
        for (dirpath, dirnames, filenames) in os.walk(options.inputdir):
            output_path =  os.path.join(options.outputdir,
                                        dirpath.replace(options.inputdir, ""))
            for dirname in dirnames:
                os.makedirs(os.path.join(output_path, dirnames))
            for name in filenames:
                new_name    = options.prefix + name
                str_outpath = os.path.join(output_path, new_name)
                print('Creating new file... %s' % str_outpath)
                shutil.copy(os.path.join(dirpath, name), str_outpath)
            


# ENTRYPOINT
if __name__ == "__main__":
    app = SimpleDSApp()
    app.launch()
{'fraction_non_alphanumeric': 0.10804224207961008, 'fraction_numerical': 0.003249390739236393, 'mean_word_length': 1.7649700598802396, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '253552', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1042, 'n_words': 255}