hola. necesito descargar desde python esta carpeta…
- User
hola. necesito descargar desde python esta carpeta https://github.com/cbellom/UNViewer/tree/master/Assets/Fonts/Fuente%20Ancizar%204.0
- Assistant
Puedes usar la librería
gitpythonde python para descarga la carpeta de GitHub. Primero necesitas instalar la librería:pip install gitpythonLuego 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
UNViewery luego moverá la carpeta deseada a una nueva carpeta llamadaFuente Ancizar 4.0. Si la carpeta ya existe, el código simplemente actualizará el repositorio existente en la carpetaUNViewer. - User
puedo descargar la carpeta a "C:\Cosas"
- 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 carpetaC:/Cosas/Fuente Ancizar 4.0. Si la carpeta no existe, se creará automáticamente.