-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create script to automatically update #12
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
1 parent
64afce5
commit 69a54dd
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"GVAR", | ||
"Koromiko", | ||
"listbox", | ||
"pygithub", | ||
"QEFUNC", | ||
"QEGVAR", | ||
"QFUNC", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |