sftp_utils.py
def put_dir_approved_list(self, source, target, approved):
        """
        Uploads the contents of the list to the target path. The
            target directory needs to exists. All subdirectories in source are
            created under target.
        """
        # Replace forward slash in case of Windows
        approved = [i.replace("\\", "/") for i in approved]

        for item in os.listdir(source):
            full_path = os.path.join(source, item)
            full_path = full_path.replace("\\", "/")
            full_path = full_path[2:] if full_path.startswith("./") else full_path
            # aa/bb/cc.dd
            pass
            if os.path.isfile(full_path) and full_path in approved:
                join = os.path.join(source, item).replace("\\", "/")
                self.put(join, f"{target}/{item}")
            elif not os.path.isfile(full_path):
                self.mkdir(f"{target}/{item}", ignore_existing=True)
                self.put_dir_approved_list(full_path, f"{target}/{item}", approved)
            else:
                pass
                # print("This means file isn't approved")
                # TODO clean up empty dirs later? lol

        Uploads the contents of the list to the target path. The
            target directory needs to exists. All subdirectories in source are
            created under target.
        
Uploads the contents of the list to the target path. The
target directory needs to exists. All subdirectories in source are
created under target.
Uploads the contents of the list to the target path . The target directory needs to exists . All subdirectories in source are created under target .
def put_dir_approved_list(self, source, target, approved):
        approved = [i.replace("\\", "/") for i in approved]
        for item in os.listdir(source):
            full_path = os.path.join(source, item)
            full_path = full_path.replace("\\", "/")
            full_path = full_path[2:] if full_path.startswith("./") else full_path
            pass
            if os.path.isfile(full_path) and full_path in approved:
                join = os.path.join(source, item).replace("\\", "/")
                self.put(join, f"{target}/{item}")
            elif not os.path.isfile(full_path):
                self.mkdir(f"{target}/{item}", ignore_existing=True)
                self.put_dir_approved_list(full_path, f"{target}/{item}", approved)
            else:
                pass
def put_dir_approved_list ( self , source , target , approved ) : approved = [ i . replace ( "\\" , "/" ) for i in approved ] for item in os . listdir ( source ) : full_path = os . path . join ( source , item ) full_path = full_path . replace ( "\\" , "/" ) full_path = full_path [ 2 : ] if full_path . startswith ( "./" ) else full_path pass if os . path . isfile ( full_path ) and full_path in approved : join = os . path . join ( source , item ) . replace ( "\\" , "/" ) self . put ( join , f"{target}/{item}" ) elif not os . path . isfile ( full_path ) : self . mkdir ( f"{target}/{item}" , ignore_existing = True ) self . put_dir_approved_list ( full_path , f"{target}/{item}" , approved ) else : pass
Uploads the contents of the list to the target path.
Uploads the contents of the list to the target path .
"""
        Uploads the contents of the list to the target path. The
            target directory needs to exists. All subdirectories in source are
            created under target.
        """ # Replace forward slash in case of Windows # aa/bb/cc.dd # print("This means file isn't approved") # TODO clean up empty dirs later? lol
self
source
target
approved