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



import os, sys

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


class SimpleFSApp(ChrisApp):
    """
    Create file out.txt with the directory listing of the directory
    given by the --dir argument.
    """
    AUTHORS         = 'FNNDSC (<EMAIL>)'
    SELFPATH        = os.path.dirname(__file__)
    SELFEXEC        = os.path.basename(__file__)
    TITLE           = 'Simple chris fs app'
    CATEGORY        = ''
    TYPE            = 'fs'
    DESCRIPTION     = 'A simple chris fs app demo'
    DOCUMENTATION   = 'http://wiki'
    LICENSE         = 'Opensource (MIT)'
    VERSION         = '0.1'

    def define_parameters(self):
        self.add_parameter('--dir', action='store', dest='dir', type=str, default='./',
                          optional=True, help='look up directory')

    def run(self, options):
        print(os.system('ls ' + options.dir + '>' + os.path.join(options.outputdir,
                                                                 'out.txt')))


# ENTRYPOINT
if __name__ == "__main__":
    app = SimpleFSApp()
    app.launch()<commit_msg>Change behaviour to "touch" files in 'ls' exec.<commit_after>#                                                            _
# Simple chris fs app demo
#
# (c) 2016 Fetal-Neonatal Neuroimaging & Developmental Science Center
#                   Boston Children's Hospital
#
#              http://childrenshospital.org/FNNDSC/
#                        <EMAIL>
#

import os, sys

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


def touch(path):
    with open(path, 'a'):
        os.utime(path, None)

class SimpleFSApp(ChrisApp):
    """
    Create file out.txt with the directory listing of the directory
    given by the --dir argument.
    """
    AUTHORS         = 'FNNDSC (<EMAIL>)'
    SELFPATH        = os.path.dirname(__file__)
    SELFEXEC        = os.path.basename(__file__)
    TITLE           = 'Simple chris fs app'
    CATEGORY        = ''
    TYPE            = 'fs'
    DESCRIPTION     = 'A simple chris fs app demo'
    DOCUMENTATION   = 'http://wiki'
    LICENSE         = 'Opensource (MIT)'
    VERSION         = '0.1'

    def define_parameters(self):
        self.add_parameter('--dir', action='store', dest='dir', type=str, default='./',
                          optional=True, help='look up directory')

    def run(self, options):
        str_outFile = os.path.join(options.outputdir, 'out.txt')
        print(os.system('ls ' + options.dir + '>' + str_outFile))

        # Create a 'dummy' listing of empty files mirroring the target dir listing
        with open(str_outFile) as f:
            l_ls    = f.readlines()
        print(l_ls)
        l_ls = map(str.strip, l_ls)
        for str_file in l_ls:
            str_fullPath    = os.path.join(options.outputdir, str_file)
            print('touching file... %s' % str_fullPath)
            touch(str_fullPath)


# ENTRYPOINT
if __name__ == "__main__":
    app = SimpleFSApp()
    app.launch()
{'fraction_non_alphanumeric': 0.11749194257251684, 'fraction_numerical': 0.0035159683562847933, 'mean_word_length': 1.826158940397351, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, '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': '2649531', 'n_tokens_mistral': 1039, 'n_tokens_neox': 990, 'n_words': 253}