parameters: (self)
docstring: Retrieve macros from FreeCAD-macros.git
  
          Emits a signal for each macro in
          https://github.com/FreeCAD/FreeCAD-macros.git
docstring_summary: Retrieve macros from FreeCAD-macros.git
docstring_tokens: Retrieve macros from FreeCAD - macros . git
function: def retrieve_macros_from_git(self):
          """Retrieve macros from FreeCAD-macros.git
  
          Emits a signal for each macro in
          https://github.com/FreeCAD/FreeCAD-macros.git
          """
  
          if not have_git or NOGIT:
              message = translate(
                  "AddonsInstaller",
                  "Failed to execute Git Python command: check installation of GitPython and/or git",
              )
              self.status_message_signal.emit(message)
              FreeCAD.Console.PrintWarning(message + "\n")
              return
  
          try:
              if os.path.exists(self.repo_dir):
                  if not os.path.exists(os.path.join(self.repo_dir, ".git")):
                      utils.repair_git_repo(
                          "https://github.com/FreeCAD/FreeCAD-macros.git", self.repo_dir
                      )
                  gitrepo = git.Git(self.repo_dir)
                  gitrepo.pull()
              else:
                  git.Repo.clone_from(
                      "https://github.com/FreeCAD/FreeCAD-macros.git", self.repo_dir
                  )
          except Exception as e:
              FreeCAD.Console.PrintWarning(
                  translate(
                      "AddonsInstaller", "An error occurred fetching macros from GitHub"
                  )
                  + f":\n{e}\n"
              )
          n_files = 0
          for _, _, filenames in os.walk(self.repo_dir):
              n_files += len(filenames)
          counter = 0
          for dirpath, _, filenames in os.walk(self.repo_dir):
              self.progress_made.emit(counter, n_files)
              counter += 1
              if self.current_thread.isInterruptionRequested():
                  return
              if ".git" in dirpath:
                  continue
              for filename in filenames:
                  if self.current_thread.isInterruptionRequested():
                      return
                  if filename.lower().endswith(".fcmacro"):
                      macro = Macro(filename[:-8])  # Remove ".FCMacro".
                      macro.on_git = True
                      macro.src_filename = os.path.join(dirpath, filename)
                      repo = AddonManagerRepo.from_macro(macro)
                      repo.url = "https://github.com/FreeCAD/FreeCAD-macros.git"
                      utils.update_macro_installation_details(repo)
                      self.add_macro_signal.emit(repo)
function_tokens: def retrieve_macros_from_git ( self ) : if not have_git or NOGIT : message = translate ( "AddonsInstaller" , "Failed to execute Git Python command: check installation of GitPython and/or git" , ) self . status_message_signal . emit ( message ) FreeCAD . Console . PrintWarning ( message + "\n" ) return try : if os . path . exists ( self . repo_dir ) : if not os . path . exists ( os . path . join ( self . repo_dir , ".git" ) ) : utils . repair_git_repo ( "https://github.com/FreeCAD/FreeCAD-macros.git" , self . repo_dir ) gitrepo = git . Git ( self . repo_dir ) gitrepo . pull ( ) else : git . Repo . clone_from ( "https://github.com/FreeCAD/FreeCAD-macros.git" , self . repo_dir ) except Exception as e : FreeCAD . Console . PrintWarning ( translate ( "AddonsInstaller" , "An error occurred fetching macros from GitHub" ) + f":\n{e}\n" ) n_files = 0 for _ , _ , filenames in os . walk ( self . repo_dir ) : n_files += len ( filenames ) counter = 0 for dirpath , _ , filenames in os . walk ( self . repo_dir ) : self . progress_made . emit ( counter , n_files ) counter += 1 if self . current_thread . isInterruptionRequested ( ) : return if ".git" in dirpath : continue for filename in filenames : if self . current_thread . isInterruptionRequested ( ) : return if filename . lower ( ) . endswith ( ".fcmacro" ) : macro = Macro ( filename [ : - 8 ] ) # Remove ".FCMacro". macro . on_git = True macro . src_filename = os . path . join ( dirpath , filename ) repo = AddonManagerRepo . from_macro ( macro ) repo . url = "https://github.com/FreeCAD/FreeCAD-macros.git" utils . update_macro_installation_details ( repo ) self . add_macro_signal . emit ( repo )