Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

hola. necesito descargar desde python esta carpeta…

  1. User
  2. Assistant

    Puedes usar la librería gitpython de python para descarga la carpeta de GitHub. Primero necesitas instalar la librería:

    pip install gitpython
    

    Luego puedes usar este código para descargar la carpeta:

    import os
    import git
    
    repo_url = 'https://github.com/cbellom/UNViewer.git'
    folder_path = 'UNViewer/Assets/Fonts/Fuente Ancizar 4.0'
    
    if not os.path.exists(folder_path):
        # Clone the repository if the folder doesn't exist
        git.Repo.clone_from(repo_url, 'UNViewer')
    else:
        # Pull the latest changes from the repository
        repo = git.Repo('UNViewer')
        repo.remotes.origin.pull()
    
    # Move the desired folder to the desired location
    os.rename('UNViewer/Assets/Fonts/Fuente Ancizar 4.0', 'Fuente Ancizar 4.0')
    

    Este código clonará el repositorio en la carpeta UNViewer y luego moverá la carpeta deseada a una nueva carpeta llamada Fuente Ancizar 4.0. Si la carpeta ya existe, el código simplemente actualizará el repositorio existente en la carpeta UNViewer.

  3. User

    puedo descargar la carpeta a "C:\Cosas"

  4. Assistant

    Sí, puedes cambiar la ruta de destino a "C:\Cosas" en el código. Aquí está el código actualizado:

    import os
    import git
    
    repo_url = 'https://github.com/cbellom/UNViewer.git'
    folder_path = 'UNViewer/Assets/Fonts/Fuente Ancizar 4.0'
    destination_path = 'C:/Cosas/Fuente Ancizar 4.0'
    
    if not os.path.exists(folder_path):
        # Clone the repository if the folder doesn't exist
        git.Repo.clone_from(repo_url, 'UNViewer')
    else:
        # Pull the latest changes from the repository
        repo = git.Repo('UNViewer')
        repo.remotes.origin.pull()
    
    # Move the desired folder to the desired location
    if not os.path.exists(destination_path):
        os.mkdir(destination_path)
    os.rename(folder_path, destination_path)
    

    Este código descargará el repositorio en la carpeta UNViewer, luego moverá la carpeta deseada a la carpeta C:/Cosas/Fuente Ancizar 4.0. Si la carpeta no existe, se creará automáticamente.