def get_objects_to_upload()

in pantri/scripts/lib/pantri.py [0:0]


    def get_objects_to_upload(self, objects):
        """
        get_objects_to_upload(self, objects)

        Given a list of object paths, return a dictionary containing meatdata of
        file or files withi a directory.
        """
        expanded_objects = []
        objects_metadata = {}

        # Loop though objects to build list of all files to upload
        for obj in objects:
            # Use objects full path when building list of objects
            obj = utils.unix_path(os.path.abspath(obj))

            # Only upload objects within "shelves" directory
            if not obj.startswith((self.git_path)):
                self.logger.error(
                    "Object %s is not within %s " % (obj, self.paths["shelves"])
                )
                # TODO create exit functions and update all call sites
                sys.exit(1)

            # TODO create function to return list of files.
            # Build list of objects
            if os.path.isfile(obj):
                expanded_objects.append(obj)
            elif os.path.isdir(obj):
                for (root, _dirs, files) in os.walk(obj):
                    for f in files:
                        obj = os.path.join(root, f)
                        expanded_objects.append(obj)
            else:
                self.logger.warn("Local file '%s' not found" % obj)

            # Process list of object to calcuate file size, modified time and hash
        objects_metadata = self.process_objects(expanded_objects)
        return objects_metadata