[Blends-commit] [Git][blends-team/website][master] Download metadata files

Andreas Tille gitlab at salsa.debian.org
Mon Mar 12 20:10:37 UTC 2018


Andreas Tille pushed to branch master at Debian Blends Team / website


Commits:
a644bca3 by Andreas Tille at 2018-03-12T20:15:41+01:00
Download metadata files

- - - - -


1 changed file:

- misc/machine_readable/fetch-machine-readable_salsa.py


Changes:

=====================================
misc/machine_readable/fetch-machine-readable_salsa.py
=====================================
--- a/misc/machine_readable/fetch-machine-readable_salsa.py
+++ b/misc/machine_readable/fetch-machine-readable_salsa.py
@@ -3,6 +3,7 @@
 import gitlab
 import os
 import shutil
+import base64
 
 BLENDSGROUPS=[ 'Debian 3D Printing Team'
              , 'Debian Accessibility Team'
@@ -21,9 +22,19 @@ BLENDSGROUPS=[ 'Debian 3D Printing Team'
              , 'Debichem'
              ]
 
+
 # just start with one team
 BLENDSGROUPS=[ 'Debian Med' ]
 
+debianmetadata = [ 'changelog',
+                   'control',
+                   'copyright',
+                   'README.Debian'
+                 ]
+upstreammetadata = [ 'edam',
+                     'metadata'
+                   ]
+
 TDNAME='machine-readable'
 MACHINEREADABLEARCHIVE='/srv/blends.debian.org/www/_'+TDNAME+'/'+TDNAME+'.tar.xz'
 READMEDEBIANARCHIVE='/srv/blends.debian.org/www/_'+TDNAME+'/README.Debian.tar.xz'
@@ -41,6 +52,16 @@ def get_blends_groups():
             blends_groups.append(group)
     return blends_groups
 
+def output_metadata(subdir, metadata):
+    items = project.repository_tree(path=subdir)
+    for item in items:
+        if item['name'] in metadata:
+            file_info = project.repository_blob(item['id'])
+            content = base64.b64decode(file_info['content'])
+            with open(os.path.join(namedir,name+'.'+item['name']), 'wb') as out:
+                out.write(content)
+            out.close()
+
 # SALSA_TOKEN=os.environ['SALSA_TOKEN']
 
 gl = gitlab.Gitlab("https://salsa.debian.org") # , private_token=SALSA_TOKEN) # anonymous access is fine
@@ -49,8 +70,12 @@ blends_groups = get_blends_groups()
 for group in blends_groups:
     print(group.attributes['name'], group.attributes['id'], group.attributes['path']) # , group.attributes['description'], group.attributes['full_name'])
     gpath = group.attributes['path']
-    projects = group.projects.list(all=True, order_by='name', sort='asc')
-    for project in projects:
+    #projects = group.projects.list(all=True, order_by='name', sort='asc')
+    #projects = group.projects.all(order_by='name', sort='asc')
+    # DEBUG : only few projects to be faster
+    projects = group.projects.list(page=1, per_page=10, order_by='name', sort='asc')
+    for pr in projects:
+        project = gl.projects.get(pr.attributes['id']) # without this extra get repository_tree() fails
         name = project.attributes['name']
         namedir = os.path.join(TARGETDIR, name[0])
         if not os.path.exists(namedir):
@@ -59,8 +84,6 @@ for group in blends_groups:
             out.write("Vcs-Browser: git at salsa.debian.org:%s/%s\n" % (gpath, name))
             out.write("Vcs-Git: git at salsa.debian.org:%s/%s.git\n" % (gpath, name))
         out.close()
-
-#for project in git.getall(git.getprojects):
-#    print(project['name'], project['path_with_namespace'], project['id'])
-    # getrawfile(project['id'], 'master', 'debian/changelog')
-    # getfile(project['id'], 'debian/changelog', 'master')
\ No newline at end of file
+        # print(project)
+        output_metadata('debian', debianmetadata)
+        output_metadata('debian/upstream', upstreammetadata)



View it on GitLab: https://salsa.debian.org/blends-team/website/commit/a644bca3593707b5902edb0c99299f7e68dc20e4

---
View it on GitLab: https://salsa.debian.org/blends-team/website/commit/a644bca3593707b5902edb0c99299f7e68dc20e4
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/blends-commit/attachments/20180312/05c3c159/attachment-0001.html>


More information about the Blends-commit mailing list