Skip to content

Commit

Permalink
create script to automatically update #12
Browse files Browse the repository at this point in the history
I've done all the testing I can, but it still might break
I also want to add this to the workflows, waiting for permissions to add a token to the environment variables
  • Loading branch information
SiegeToaster committed Oct 6, 2022
1 parent 64afce5 commit 69a54dd
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"GVAR",
"Koromiko",
"listbox",
"pygithub",
"QEFUNC",
"QEGVAR",
"QFUNC",
Expand Down
64 changes: 64 additions & 0 deletions tools/update_RPT_ToDo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3

import os

from pygithub3 import Github

def get_files():
filePath = os.path.dirname(os.getcwd()) # get root directory
filePath = os.path.join(filePath,'addons')
allFiles = {}
paths = os.listdir(filePath)

for path in paths:
pathFiles = []
fullPath = os.path.join(filePath,path,"functions")
if (not os.path.isdir(fullPath)): continue

# print(fullPath)
for file in os.listdir(fullPath):
if (file.endswith(".sqf") and file.startswith('fnc_')):
pathFiles.append(file[4:-4])

allFiles.update({path: pathFiles})

return allFiles

def formatMessage(files, oldMessage):
index = oldMessage.find('- [')
oldMessage = oldMessage[index:]

oldFunctions = {}
for message in oldMessage.split('\n'):
message = message.split('\r')[0]
index = message.find('] ')
if (index > -1):
isComplete = message.find('[x]') > -1
message = message[index + 2:]
oldFunctions.update({message: isComplete})
# print(oldFunctions)

newMessage = "See the [RPT Logging Macros](https://github.com/Soliders-in-Arms-Arma-3-Group/sia3f/wiki/Development#33-rpt-logging-macros) for information on the available macros."
for module in files:
newMessage += "\n\n**{} module**".format(module)
for function in files.get(module):
isCompleteText = ' '
if (oldFunctions.get(function)):
isCompleteText = 'x'
newMessage += "\n- [{}] {}".format(isCompleteText,function)
newMessage += "\n\n*Auto-generated by tools/update_RPT_ToDo.py*"

return newMessage

def main():
files = get_files()
gh = Github(login_or_token=os.environ("SIA_GITHUB_TOKEN"))

issue = gh.get_repo(488816799).get_issue(12)
currentMessage = issue.body

newMessage = formatMessage(files, currentMessage)
print(newMessage)
issue.edit(issue.title, newMessage)
if __name__ == "__main__":
main()

0 comments on commit 69a54dd

Please sign in to comment.