Skip to content

Commit

Permalink
fix nsgportal, change nav_order, allow update specific plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dungscout96 committed Jul 18, 2024
1 parent 69dbd49 commit c5367ba
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
19 changes: 13 additions & 6 deletions code/plugins/reformat_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def append_to_file(filepath, filename, parent, output_file):
with open(output_file, 'w') as out:
out.write(text)

def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
def reformat_plugin_dir(plugin_input_dir, plugin_name, order, plugin_type='wiki'):
# plugins_output_dir = '/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins'
plugin_output_dir = os.path.join('/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins', plugin_name)
if not os.path.exists(plugin_output_dir):
Expand All @@ -58,8 +58,11 @@ def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
parent: Plugins
categories: plugins
has_children: true
nav_order: {order}
---
'''.format(plugin_name=plugin_name)
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/{plugin_name}).
'''.format(plugin_name=plugin_name, order=order)
text = append_text + text
with open(index_file, 'w') as out:
out.write(text)
Expand All @@ -77,21 +80,25 @@ def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
title: {plugin_name}
long_title: {plugin_name}
parent: Plugins
nav_order: {order}
---
'''.format(plugin_name=plugin_name)
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/{plugin_name}).
'''.format(plugin_name=plugin_name, order=order)
text = append_text + text
with open(index_file, 'w') as out:
out.write(text)

# main
def main():
if len(sys.argv) != 4:
print('Usage: python test.py <plugin_dir_path> <plugin_name> <plugin_type>')
if len(sys.argv) != 5:
print('Usage: python test.py <plugin_dir_path> <plugin_name> <plugin_type> <nav_order>')
sys.exit(1)
dirpath = sys.argv[1]
plugin_name = sys.argv[2]
plugin_type = sys.argv[3]
reformat_plugin_dir(dirpath, plugin_name, plugin_type)
order = sys.argv[4]
reformat_plugin_dir(dirpath, plugin_name, order, plugin_type)

if __name__ == "__main__":
main()
31 changes: 22 additions & 9 deletions code/plugins/update_plugins.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os
import subprocess
import sys

def run_command(command):
result = subprocess.run(command, shell=True, capture_output=False, text=True)
if result.returncode != 0:
print(f"Command failed: {command}\nError: {result.stderr}")
return result

def update_repo(repo, script, plugin_type='readme'):
def update_repo(repo, order, plugin_type='readme'):
print(f"Updating {repo}...")
current_dir = os.getcwd()
repo_path = os.path.join(current_dir, 'github', repo)
Expand All @@ -22,16 +23,28 @@ def update_repo(repo, script, plugin_type='readme'):
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')

os.chdir(current_dir)
run_command(f'python {script} {repo_path} {repo} {plugin_type}')
script = 'reformat_plugin.py'
command = f'python {script} {repo_path} {repo} {plugin_type} {order}'
run_command(command)

if __name__ == "__main__":
# if 'github' not in current directory, create it
if not os.path.exists('github'):
os.makedirs('github')

# wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
# for plugin in wiki_plugins:
# update_repo(plugin, "reformat_plugin.py", 'wiki')
readme_plugins = ['ARfitStudio'] #, 'roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
for plugin in readme_plugins:
update_repo(plugin, "reformat_plugin.py", "readme")
if len(sys.argv) == 0:
order = 1
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
for plugin in wiki_plugins:
update_repo(plugin, order, 'wiki')
order += 1
readme_plugins = ['ARfitStudio', 'roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
for plugin in readme_plugins:
update_repo(plugin, order, "readme")
order += 1
elif len(sys.argv) == 3:
plugin_name = sys.argv[1]
plugin_type = sys.argv[2]
update_repo(plugin_name, 1, plugin_type)
else:
print('Usage: python update_plugins.py <plugin_name> <plugin_type>')
sys.exit(1)
16 changes: 0 additions & 16 deletions code/plugins/update_plugins.sh

This file was deleted.

0 comments on commit c5367ba

Please sign in to comment.