Beispiel #1
0
def scripts_serving(file):
    
    target_path = Path(BASE_DIR.joinpath("scripts"), file)

    if target_path.exists() and not target_path.is_dir():

        return send_file(target_path.open(mode="rb"), attachment_filename=target_path.name)

    abort(404)
Beispiel #2
0
 def tree_add(self, path_object: WindowsPath, parentDir, n=0):
     line = self.indentSpace * n
     fixedName = path_object.name.replace("_", " ")
     fixedName = re.sub(r'.md$', '', fixedName)
     fixedName = fixedName.title()
     pathName = re.sub(r'.md$', '', path_object.name)
     if path_object.is_file():
         fileContent = self.fileSign.replace("%s", fixedName) + '\n'
         fileContent = fileContent.replace('%path', parentDir + pathName)
         self.tree += line + fileContent + '\n'
         return False
     elif path_object.is_dir():
         self.tree += line + self.dirSign.replace("%s", fixedName) + '\n'
         return True
 def tree_add(self, path_object: WindowsPath, n=0, last=False):
     if n > 0:
         if last:
             self.tree += '│' + ('    │' * (n - 1)) + '    └────' + path_object.name
         else:
             self.tree += '│' + ('    │' * (n - 1)) + '    ├────' + path_object.name
     else:
         if last:
             self.tree += '└' + ('──' * 2) + path_object.name
         else:
             self.tree += '├' + ('──' * 2) + path_object.name
     if path_object.is_file():
         self.tree += '\n'
         return False
     elif path_object.is_dir():
         self.tree += '/\n'
         return True