Skip to content
Snippets Groups Projects
Select Git revision
  • e000b3c9b2dbbcd35895e414c4c7c4490c9a84e7
  • master default protected
  • replication_test
  • dev protected
  • 551-init-broker-service-permissions
  • release-1.10 protected
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • release-1.9 protected
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • 485-fixity-checks
  • 530-various-schema-problems-with-subsets
  • release-1.7 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
  • v1.9.2 protected
  • v1.9.2-rc0 protected
  • v1.9.1 protected
41 results

Pipfile

Blame
  • command_line.py 2.27 KiB
    """Command line interface of lifescale utils.
    
    Copyright (C) 2022  Andreas Hellerschmied <heller182@gmx.at>
    """
    
    from lifescale.scripts.ls2csv import ls2csv as ls2csv_main
    import argparse
    import os
    
    
    def is_file(filename):
        """Check, whether the input string is the path to an existing file."""
        if os.path.isfile(filename):
            return filename
        raise argparse.ArgumentTypeError("'{}' is not a valid file.".format(filename))
    
    
    def is_dir(pathname):
        """Check, whether the input string is a valid and existing filepath."""
        if os.path.exists(pathname):
            return pathname
        raise argparse.ArgumentTypeError("'{}' is not a valid directory.".format(pathname))
    
    
    def ls2csv():
        """Command line interface including argument parser for the lifescale2csv converter."""
        parser = argparse.ArgumentParser(prog="ls2csv",
                                         description="Conversion from lifescale xlsm output to csv files",
                                         epilog="The ls2csv converter loads and parses xlsm files created by the lifescale "
                                                "unit. It writes several csv files to the output directory that contain "
                                                "extracted data from the input xlsm file in an easily readable way.",
                                         formatter_class=argparse.ArgumentDefaultsHelpFormatter)
        parser.add_argument("-i", "--input-xlsm", type=is_file, required=True, help="Path and name of the input xlsm file "
                                                                                    "created by "
                                                                                    "lifescale.")
        parser.add_argument("-o", "--out-dir", type=is_dir, required=True, help="Output directory for the CSV files.")
        parser.add_argument("-nv", "--not-verbose", required=False, help="Disable command line status messages.",
                            action='store_true')
        # parser.add_argument("--out-dir", type=is_dir, required=False,
        #                     help="path to output directory", default=OUT_PATH)
        args = parser.parse_args()
        verbose = not args.not_verbose
    
        return ls2csv_main(xlsm_filename=args.input_xlsm, output_dir=args.out_dir, verbose=verbose)
    
    
    if __name__ == '__main__':
        ls2csv()