Skip to content

Commit

Permalink
use json mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
dungscout96 committed Aug 2, 2024
1 parent a2e48fd commit 89c329a
Show file tree
Hide file tree
Showing 29 changed files with 225 additions and 45 deletions.
17 changes: 17 additions & 0 deletions code/plugins/construct_plugin_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json
ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
naming = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica', 'LIMO']
readme_plugins = list(set(ordering) - set(wiki_plugins))

plugin_json = []
for plugin in ordering:
ptype = 'wiki' if plugin in wiki_plugins else 'readme'
link = f'https://github.com/sccn/{plugin}'
plugin_json.append({'plugin': plugin,
'name': naming[ordering.index(plugin)],
'type': ptype,
'link': link})

with open('plugins.json', 'w') as out:
json.dump(plugin_json, out, indent=2)
164 changes: 164 additions & 0 deletions code/plugins/plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
[
{
"plugin": "ICLabel",
"name": "ICLabel",
"type": "readme",
"link": "https://github.com/sccn/ICLabel"
},
{
"plugin": "dipfit",
"name": "dipfit",
"type": "readme",
"link": "https://github.com/sccn/dipfit"
},
{
"plugin": "EEG-BIDS",
"name": "EEG-BIDS",
"type": "wiki",
"link": "https://github.com/sccn/EEG-BIDS"
},
{
"plugin": "roiconnect",
"name": "roiconnect",
"type": "readme",
"link": "https://github.com/sccn/roiconnect"
},
{
"plugin": "amica",
"name": "amica",
"type": "wiki",
"link": "https://github.com/sccn/amica"
},
{
"plugin": "cleanline",
"name": "cleanline",
"type": "readme",
"link": "https://github.com/sccn/cleanline"
},
{
"plugin": "clean_rawdata",
"name": "clean_rawdata",
"type": "wiki",
"link": "https://github.com/sccn/clean_rawdata"
},
{
"plugin": "SIFT",
"name": "SIFT",
"type": "wiki",
"link": "https://github.com/sccn/SIFT"
},
{
"plugin": "zapline-plus",
"name": "zapline-plus",
"type": "readme",
"link": "https://github.com/sccn/zapline-plus"
},
{
"plugin": "eegstats",
"name": "eegstats",
"type": "readme",
"link": "https://github.com/sccn/eegstats"
},
{
"plugin": "trimOutlier",
"name": "trimOutlier",
"type": "readme",
"link": "https://github.com/sccn/trimOutlier"
},
{
"plugin": "fMRIb",
"name": "fMRIb",
"type": "readme",
"link": "https://github.com/sccn/fMRIb"
},
{
"plugin": "imat",
"name": "imat",
"type": "readme",
"link": "https://github.com/sccn/imat"
},
{
"plugin": "nwbio",
"name": "nwbio",
"type": "readme",
"link": "https://github.com/sccn/nwbio"
},
{
"plugin": "NIMA",
"name": "NIMA",
"type": "readme",
"link": "https://github.com/sccn/NIMA"
},
{
"plugin": "PACT",
"name": "PACT",
"type": "readme",
"link": "https://github.com/sccn/PACT"
},
{
"plugin": "NFT",
"name": "NFT",
"type": "wiki",
"link": "https://github.com/sccn/NFT"
},
{
"plugin": "PACTools",
"name": "PACTools",
"type": "readme",
"link": "https://github.com/sccn/PACTools"
},
{
"plugin": "ARfitStudio",
"name": "ARfitStudio",
"type": "readme",
"link": "https://github.com/sccn/ARfitStudio"
},
{
"plugin": "PowPowCAT",
"name": "PowPowCAT",
"type": "readme",
"link": "https://github.com/sccn/PowPowCAT"
},
{
"plugin": "relica",
"name": "relica",
"type": "readme",
"link": "https://github.com/sccn/relica"
},
{
"plugin": "std_dipoleDensity",
"name": "std_dipoleDensity",
"type": "readme",
"link": "https://github.com/sccn/std_dipoleDensity"
},
{
"plugin": "viewprops",
"name": "viewprops",
"type": "readme",
"link": "https://github.com/sccn/viewprops"
},
{
"plugin": "firfilt",
"name": "firfilt",
"type": "readme",
"link": "https://github.com/sccn/firfilt"
},
{
"plugin": "groupSIFT",
"name": "groupSIFT",
"type": "readme",
"link": "https://github.com/sccn/groupSIFT"
},
{
"plugin": "get_chanlocs",
"name": "get_chanlocs",
"type": "wiki",
"link": "https://github.com/sccn/get_chanlocs"
},
{
"plugin": "nsgportal",
"name": "nsgportal",
"type": "wiki",
"link": "https://github.com/sccn/nsgportal"
}
]
4 changes: 2 additions & 2 deletions code/plugins/reformat_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def reformat_wiki_pages(filepath, filename, parent, output_file, wiki_input_dir=
grand_parent: Plugins
'''.format(filename=filename, parent=parent)

if parent == "nsgportal":
if parent in ["nsgportal", "LIMO"]:
pages = []
# load _Sidebar.md and extract all links from markdown file
with open(os.path.join(wiki_input_dir, '_Sidebar.md')) as f:
lines = f.readlines()
for line in lines:
if line.startswith('*'):
if '(' in line:
# extract text between square brackets
page = line[line.find('(')+1:line.find(')')]
pages.append(page)
Expand Down
37 changes: 18 additions & 19 deletions code/plugins/update_plugins.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os
import subprocess
import sys
import json

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, order, plugin_type='readme'):
def update_repo(repo, order, plugin_type='readme', plugin_link="https://github.com/sccn"):
print(f"Updating {repo}...")
current_dir = os.getcwd()
repo_path = os.path.join(current_dir, 'github', repo)
Expand All @@ -17,15 +18,15 @@ def update_repo(repo, order, plugin_type='readme'):
os.chdir(repo_path)
run_command('git pull')
else:
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')
run_command(f'git clone {plugin_link}.git {repo_path}')

if plugin_type == "wiki":
wiki_repo_path = f"{repo_path}.wiki"
if os.path.exists(wiki_repo_path):
os.chdir(wiki_repo_path)
run_command('git pull')
else:
run_command(f'git clone https://github.com/sccn/{repo}.wiki.git {wiki_repo_path}')
run_command(f'git clone {plugin_link}.wiki.git {wiki_repo_path}')

os.chdir(current_dir)
script = 'reformat_plugin.py'
Expand All @@ -36,28 +37,26 @@ def update_repo(repo, order, plugin_type='readme'):
# if 'github' not in current directory, create it
if not os.path.exists('github'):
os.makedirs('github')
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica']
readme_plugins = ['ARfitStudio', 'roiconnect', 'trimOutlier', 'PACT', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']

if not os.path.exists('plugins.json'):
print('Error: plugins.json not found.')
sys.exit(1)
plugin_info = json.load(open('plugins.json'))
plugins = [plugin['plugin'] for plugin in plugin_info]
# wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica', 'LIMO']
# readme_plugins = ['ARfitStudio', 'roiconnect', 'trimOutlier', 'PACT', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
# ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']

if len(sys.argv) == 1:
order = 1
for plugin in wiki_plugins:
update_repo(plugin, order, 'wiki')
order += 1
for plugin in readme_plugins:
update_repo(plugin, order, "readme")
order += 1
for plugin in plugin_info:
update_repo(plugin['plugin'], plugins.index(plugin['plugin']), plugin['type'], plugin['link'])
elif len(sys.argv) == 2:
plugin_name = sys.argv[1]
if plugin_name not in wiki_plugins and plugin_name not in readme_plugins:
if plugin_name not in plugins:
print(f"Plugin {plugin_name} not found.")
sys.exit(1)

plugin_type = 'wiki' if plugin_name in wiki_plugins else 'readme'
plugin_order = ordering.index(plugin_name) + 1

update_repo(plugin_name, plugin_order, plugin_type)
plugin = plugin_info[plugins.index(plugin_name)]
update_repo(plugin['plugin'], plugins.index(plugin['plugin']), plugin['type'], plugin['link'])
else:
print('Usage: python update_plugins.py <plugin_name>')
sys.exit(1)
Empty file modified code/plugins/update_plugins.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion plugins/ARfitStudio/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: ARfitStudio
long_title: ARfitStudio
parent: Plugins
has_children: true
nav_order: 8
nav_order: 18
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/ARfitStudio).

Expand Down
2 changes: 1 addition & 1 deletion plugins/EEG-BIDS/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: EEG-BIDS
long_title: EEG-BIDS
parent: Plugins
has_children: true
nav_order: 4
nav_order: 2
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/EEG-BIDS).

Expand Down
2 changes: 1 addition & 1 deletion plugins/ICLabel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: ICLabel
long_title: ICLabel
parent: Plugins
has_children: true
nav_order: 14
nav_order: 0
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/ICLabel).

Expand Down
2 changes: 1 addition & 1 deletion plugins/NFT/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: NFT
long_title: NFT
parent: Plugins
has_children: true
nav_order: 3
nav_order: 16
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/NFT).

Expand Down
2 changes: 1 addition & 1 deletion plugins/NIMA/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: NIMA
long_title: NIMA
parent: Plugins
has_children: true
nav_order: 26
nav_order: 14
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/NIMA).

Expand Down
2 changes: 1 addition & 1 deletion plugins/PACT/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: PACT
long_title: PACT
parent: Plugins
has_children: true
nav_order: 11
nav_order: 15
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/PACT).

Expand Down
2 changes: 1 addition & 1 deletion plugins/PACTools/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: PACTools
long_title: PACTools
parent: Plugins
has_children: true
nav_order: 18
nav_order: 17
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/PACTools).

Expand Down
2 changes: 1 addition & 1 deletion plugins/PowPowCAT/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: PowPowCAT
long_title: PowPowCAT
parent: Plugins
has_children: true
nav_order: 17
nav_order: 19
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/PowPowCAT).

Expand Down
2 changes: 1 addition & 1 deletion plugins/SIFT/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: SIFT
long_title: SIFT
parent: Plugins
has_children: true
nav_order: 1
nav_order: 7
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/SIFT).

Expand Down
2 changes: 1 addition & 1 deletion plugins/amica/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: amica
long_title: amica
parent: Plugins
has_children: true
nav_order: 7
nav_order: 4
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/amica).

Expand Down
2 changes: 1 addition & 1 deletion plugins/cleanline/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: cleanline
long_title: cleanline
parent: Plugins
has_children: true
nav_order: 25
nav_order: 5
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/cleanline).

Expand Down
2 changes: 1 addition & 1 deletion plugins/dipfit/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: dipfit
long_title: dipfit
parent: Plugins
has_children: true
nav_order: 15
nav_order: 1
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/dipfit).

Expand Down
2 changes: 1 addition & 1 deletion plugins/eegstats/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: eegstats
long_title: eegstats
parent: Plugins
has_children: true
nav_order: 16
nav_order: 9
---
To view the plugin source code, please visit the plugin's [GitHub repository](https://github.com/sccn/eegstats).

Expand Down
Loading

0 comments on commit 89c329a

Please sign in to comment.