update logo and include projects that have missing pins in the datasheet

This commit is contained in:
Matt Venn
2023-09-11 15:33:06 +02:00
parent b02cc19e78
commit 37c18a964e
3 changed files with 76 additions and 55 deletions
+69 -52
View File
@@ -19,62 +19,79 @@ exit_code = 0
@client.event @client.event
async def on_ready(): async def on_ready():
try: try:
print(f'{client.user} has connected to Discord!') print(f'{client.user} has connected to Discord!')
server = None server = None
for g in client.guilds: for g in client.guilds:
if g.name == TARG: if g.name == TARG:
server = g server = g
break break
if server == None: if server == None:
print(f'Error: Bot is not in a server named {TARG}') print(f'Error: Bot is not in a server named {TARG}')
exit_code = 1 exit_code = 1
await client.close() await client.close()
role = server.get_role(int(ROLE_ID)) role = server.get_role(int(ROLE_ID))
if not role: if not role:
print('Error: requested role does not exist on server!') print('Error: requested role does not exist on server!')
exit_code = 1 exit_code = 1
await client.close() await client.close()
participants = [] participants = []
for project in os.listdir('./projects'): for project in os.listdir('./projects'):
info_file = os.path.join('projects', project, 'info.yaml') info_file = os.path.join('projects', project, 'info.yaml')
if not os.path.exists(info_file): if not os.path.exists(info_file):
print(f'info.yaml does not exist for project {project}. Skipping.') print(f'info.yaml does not exist for project {project}. Skipping.')
else: else:
try: try:
stream = open(info_file, 'r') stream = open(info_file, 'r')
data = yaml.load(stream, Loader=yaml.FullLoader) data = yaml.load(stream, Loader=yaml.FullLoader)
stream.close() stream.close()
dname = data['documentation'] if 'discord' in data['documentation']:
if 'discord' in dname: dname = data['documentation']['discord']
dname = dname['discord'] if len(dname):
parts = dname.split('#') if '#' in dname:
if len(parts) != 2 or len(parts[0]) == 0 or not re.match('^[0-9]{4}$', parts[1]): dname = dname.split('#')[0]
print(f'Invalid format for discord username {dname} in project {project}. Skipping.') # print(f'adding {dname}')
else: participants.append(dname)
participants.append({'name': parts[0], 'discriminator': parts[1]}) else:
else: print(f'Project {project} has no discord username listed. Skipping.')
print(f'Project {project} has no discord username listed. Skipping.') except Exception as ex:
except Exception as ex: print(f'Error parsing info.yaml for project {project}. Skipping.')
print(f'Error parsing info.yaml for project {project}. Skipping.') print(f'Error was: {ex}')
print(f'Error was: {ex}')
for m in server.members:
a = [d for d in participants if d['name'] == m.name and d['discriminator'] == m.discriminator]
if len(a) != 0:
if len([d for d in m.roles if d.id == role.id]) == 0:
print(f'Giving the role to {m.name}#{m.discriminator}')
await m.add_roles(role, reason='Automatic role assignment by GitHub actions pipeline.')
print('All done!')
await client.close() members = []
except Exception as ex: for p in participants:
print('Exception was thrown!') for m in server.members:
print(ex) if m.name == p:
exit_code = 1 members.append(m)
await client.close() break
if m.global_name == p:
members.append(m)
break
else:
print(f'{p} not found in members')
new_role_members = []
for m in members:
if len([d for d in m.roles if d.id == role.id]) == 0:
print(f'Giving the role to {m.name}')
new_role_members.append(m.name)
await m.add_roles(role, reason='Automatic role assignment by GitHub actions pipeline.')
else:
print(f'{m.name} already has role')
print('All done!')
print("gave new role to:")
print('@' + ' @'.join(new_role_members))
await client.close()
except Exception as ex:
print('Exception was thrown!')
print(ex)
exit_code = 1
await client.close()
client.run(TOKEN) client.run(TOKEN)
sys.exit(exit_code) sys.exit(exit_code)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

+4
View File
@@ -97,6 +97,10 @@ class Docs():
else: else:
yaml_data[key] = "" yaml_data[key] = ""
# many people remove unused pins in input / output / bidirectional
for key in ['inputs', 'outputs', 'bidirectional']:
yaml_data[key].extend((8 - len(yaml_data[key])) * ['n/a'])
# now build the doc & print it # now build the doc & print it
try: try:
doc = (doc_template doc = (doc_template