Skip to content

Commit

Permalink
Marketplace for MLPro extensions #413
Browse files Browse the repository at this point in the history
  • Loading branch information
detlefarend committed Sep 14, 2023
1 parent 4c126a6 commit 33e086c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
9 changes: 9 additions & 0 deletions marketplace/templates/issue_comment
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{admins}:
Dear Ladies and Gentlemen,

thank you for wanting to contribute to the MLPro marketplace with your repository [{repo}]({url}). We subject the extension to a short plausibility check and then release it for the marketplace. We will keep you updated on this in this issue. If you have any questions or comments, please feel free to contact us here at any time in the chat.

If you do not want your repository to be listed in the MLPro Marketplace, please let us know as soon as possible and remove the _mlpro-extension_ topic. If you just want to delay the entry to the marketplace, please also contact us. In this case, we will blacklist your repository until you tell us to whitelist it.

Kind regards,
Your MLPro Team
48 changes: 35 additions & 13 deletions marketplace/update_marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
## -- 2023-09-08 0.0.0 DA Creation
## -- 2023-09-08 0.1.0 DA Basic structure
## -- 2023-09-11 0.2.0 DA Method Marketplace._get_extensions implemented
## -- 2023-09-12 0.3.0 DA Restructuring
## -- 2023-09-12 0.3.0 DA Refactoring
## -- 2023-09-13 0.4.0 DA Issue management implemented
## -- 2023-09-14 0.5.0 DA Issue commenting implemented
## -------------------------------------------------------------------------------------------------

"""
Ver. 0.4.0 (2023-09-13)
Ver. 0.5.0 (2023-09-14)
This standalone module collects meta data of all whitelisted GitHub repositories based on the
template repo /fhswf/MLPro-Extension.
Expand All @@ -30,16 +31,18 @@
## -------------------------------------------------------------------------------------------------
class Marketplace (Log):

C_TYPE = 'Marketplace'
C_NAME = 'MLPro'
C_TYPE = 'Marketplace'
C_NAME = 'MLPro'

C_FNAME_WHITELIST = 'whitelist'
C_FNAME_BLACKLIST = 'blacklist'
C_FNAME_TPL_ISSUE_BODY = 'templates' + os.sep + 'issue_body'
C_FNAME_WHITELIST = 'whitelist'
C_FNAME_BLACKLIST = 'blacklist'
C_FNAME_TPL_ISSUE_BODY = 'templates' + os.sep + 'issue_body'
C_FNAME_TPL_ISSUE_COMMENT = 'templates' + os.sep + 'issue_comment'
C_FNAME_TPL_RTD_EXENSION = 'templates' + os.sep + 'rtd_extension'

C_STATUS_APPROVED = 'Approved'
C_STATUS_DENIED = 'Denied'
C_STATUS_PENDING = 'Pending'
C_STATUS_APPROVED = 'Approved'
C_STATUS_DENIED = 'Denied'
C_STATUS_PENDING = 'Pending'

## -------------------------------------------------------------------------------------------------
def __init__(self, p_token, p_logging=Log.C_LOG_ALL):
Expand Down Expand Up @@ -106,6 +109,10 @@ def _get_extensions(self):
org['repos'] = []
extensions[status][repo.organization.login] = org

repo_admins = []
for collaborator in repo.get_collaborators():
if repo.get_collaborator_permission(collaborator.login) == 'admin': repo_admins.append(collaborator.login)

org['repos'].append( ( repo.full_name,
repo.name,
repo.description,
Expand All @@ -114,7 +121,8 @@ def _get_extensions(self):
latest_release.last_modified,
repo.html_url,
repo.homepage,
repo.topics ) )
repo.topics,
repo_admins ) )


# 4 Outro
Expand All @@ -134,7 +142,21 @@ def _create_issue_body(self, p_extension) -> str:

## -------------------------------------------------------------------------------------------------
def _create_issue_comment(self, p_extension) -> str:
return '@detlefarend Pseudo-comment...'

if len( p_extension[9] ) == 0:
self.log(Log.C_LOG_TYPE_W, 'No administrators determined for repo', p_extension[0] )
return

admin_list = []
for admin in p_extension[9]:
admin_list.append('@' + admin)

admins = ' '.join(admin_list)

with open( sys.path[0] + os.sep + self.C_FNAME_TPL_ISSUE_COMMENT ) as f:
body = f.read().format( vars='variables', admins=admins, repo=p_extension[0], url=p_extension[6] )

return body


## -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -188,7 +210,7 @@ def _create_issue(self, p_extension):
# 2.1 Issue needs to be created
issue = self._mlpro.create_issue( title = issue_title,
labels = [ 'pending-extension'],
assignees = [ 'detlefarend' ], #self._mlpro_admins,
assignees = self._mlpro_admins,
body = self._create_issue_body(p_extension) )

issue.create_comment(self._create_issue_comment(p_extension))
Expand Down

0 comments on commit 33e086c

Please sign in to comment.