AddonManager: Provisions to support different git hosting platforms than github
This commit is contained in:
@@ -233,3 +233,58 @@ def restartFreeCAD():
|
||||
if FreeCADGui.getMainWindow().close():
|
||||
QtCore.QProcess.startDetached(QtGui.QApplication.applicationFilePath(),args)
|
||||
|
||||
|
||||
def getzipurl(baseurl):
|
||||
|
||||
"Returns the location of a zip file from a repo, if available"
|
||||
|
||||
url = getserver(baseurl).strip("/")
|
||||
if url.endswith("github.com"):
|
||||
return baseurl+"/archive/master.zip"
|
||||
elif url.endswith("framagit.org"):
|
||||
# https://framagit.org/freecad-france/mooc-workbench/-/archive/master/mooc-workbench-master.zip
|
||||
reponame = baseurl.strip("/").split("/")[-1]
|
||||
return baseurl+"/-/archive/master/"+reponame+"-master.zip"
|
||||
else:
|
||||
print("Debug: addonmanager_utilities.getzipurl: Unknown git host:",url)
|
||||
return None
|
||||
|
||||
|
||||
def getreadmeurl(baseurl):
|
||||
|
||||
"Returns the location of a readme file"
|
||||
|
||||
url = getserver(baseurl).strip("/")
|
||||
if url.endswith("github.com") or url.endswith("framagit.org"):
|
||||
return baseurl+"/blob/master/README.md"
|
||||
else:
|
||||
print("Debug: addonmanager_utilities.getreadmeurl: Unknown git host:",url)
|
||||
return None
|
||||
|
||||
|
||||
def getreadmeregex(baseurl):
|
||||
|
||||
"""Return a regex string that extracts the contents to be displayed in the description
|
||||
panel of the Addon manager, from raw HTML data (the readme's html rendering usually)"""
|
||||
|
||||
url = getserver(baseurl).strip("/")
|
||||
if url.endswith("github.com"):
|
||||
return "<article.*?>(.*?)</article>"
|
||||
elif url.endswith("framagit.org"):
|
||||
return None # the readme content on framagit is generated by javascript so unretrievable by urlopen
|
||||
else:
|
||||
print("Debug: addonmanager_utilities.getreadmeregex: Unknown git host:",url)
|
||||
return None
|
||||
|
||||
|
||||
def getdescregex(baseurl):
|
||||
|
||||
"""Returns a regex string that extracts a WB description to be displayed in the description
|
||||
panel of the Addon manager, if the README could not be found"""
|
||||
|
||||
url = getserver(baseurl).strip("/")
|
||||
if url.endswith("github.com") or url.endswith("framagit.org"):
|
||||
return "<meta property=\"og:description\" content=\"(.*?)\""
|
||||
else:
|
||||
print("Debug: addonmanager_utilities.getdescregex: Unknown git host:",url)
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user