diff --git a/code/plugins/reformat_plugin.py b/code/plugins/reformat_plugin.py index eb68b2a..7985e5f 100644 --- a/code/plugins/reformat_plugin.py +++ b/code/plugins/reformat_plugin.py @@ -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): @@ -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) @@ -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 ') + if len(sys.argv) != 5: + print('Usage: python test.py ') 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() \ No newline at end of file diff --git a/code/plugins/update_plugins.py b/code/plugins/update_plugins.py index c3c9c24..5d166af 100644 --- a/code/plugins/update_plugins.py +++ b/code/plugins/update_plugins.py @@ -1,5 +1,6 @@ import os import subprocess +import sys def run_command(command): result = subprocess.run(command, shell=True, capture_output=False, text=True) @@ -7,7 +8,7 @@ def run_command(command): 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) @@ -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 ') + sys.exit(1) diff --git a/code/plugins/update_plugins.sh b/code/plugins/update_plugins.sh deleted file mode 100644 index 5d61b38..0000000 --- a/code/plugins/update_plugins.sh +++ /dev/null @@ -1,16 +0,0 @@ -current_dir=$(pwd) - -repo="SIFT" -if cd ../../$repo; then git pull; else git clone https://github.com/sccn/$repo.wiki.git ../../$repo; fi -python Wiki_plugin.py ../../$repo $repo -cd $current_dir - -repo="EEG-BIDS" -if cd ../../$repo; then git pull; else git clone https://github.com/sccn/$repo.git ../../$repo; fi -python README_plugin.py ../../$repo $repo -cd $current_dir - -repo="roiconnect" -if cd ../../$repo; then git pull; else git clone https://github.com/sccn/$repo.git ../../$repo; fi -python README_plugin.py ../../$repo $repo -cd $current_dir \ No newline at end of file