Skip to content

Commit 69dbd49

Browse files
committed
fix images issue
1 parent 726b8a5 commit 69dbd49

File tree

86 files changed

+112
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+112
-129
lines changed

code/plugins/README_plugin.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

code/plugins/Wiki_plugin.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

code/plugins/reformat_plugin.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import os
2+
import sys
3+
import shutil
4+
5+
# open a text file ending with .md and append a paragraph to it
6+
def reformat_plugin(dirpath, plugin_name):
7+
plugins_dir = '/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins'
8+
index_file = os.path.join(plugins_dir, 'index.md')
9+
shutil.copyfile(os.path.join(dirpath, 'README.md'), index_file)
10+
with open(index_file) as f:
11+
text = f.read()
12+
append_text = '''---
13+
layout: default
14+
title: {plugin_name}
15+
long_title: {plugin_name}
16+
parent: Plugins
17+
---
18+
'''.format(plugin_name=plugin_name)
19+
text = append_text + text
20+
with open(index_file, 'w') as out:
21+
out.write(text)
22+
23+
# open a text file ending with .md and append a paragraph to it
24+
# Usage: python test.py <filename>.md
25+
def append_to_file(filepath, filename, parent, output_file):
26+
with open(filepath) as f:
27+
text = f.read()
28+
append_text = '''---
29+
layout: default
30+
title: {filename}
31+
long_title: {filename}
32+
parent: {parent}
33+
grand_parent: Plugins
34+
---
35+
'''.format(filename=filename, parent=parent)
36+
text = append_text + text
37+
with open(output_file, 'w') as out:
38+
out.write(text)
39+
40+
def reformat_plugin_dir(plugin_input_dir, plugin_name, plugin_type='wiki'):
41+
# plugins_output_dir = '/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins'
42+
plugin_output_dir = os.path.join('/Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins', plugin_name)
43+
if not os.path.exists(plugin_output_dir):
44+
os.makedirs(plugin_output_dir)
45+
# copy image directory from input to output dir
46+
if os.path.exists(os.path.join(plugin_input_dir, 'images')):
47+
shutil.copytree(os.path.join(plugin_input_dir, 'images'), os.path.join(plugin_output_dir, 'images'), dirs_exist_ok=True)
48+
49+
index_file = os.path.join(plugin_output_dir, 'index.md')
50+
if plugin_type == 'wiki':
51+
shutil.copyfile(os.path.join(plugin_input_dir, 'Home.md'), index_file)
52+
with open(index_file) as f:
53+
text = f.read()
54+
append_text = '''---
55+
layout: default
56+
title: {plugin_name}
57+
long_title: {plugin_name}
58+
parent: Plugins
59+
categories: plugins
60+
has_children: true
61+
---
62+
'''.format(plugin_name=plugin_name)
63+
text = append_text + text
64+
with open(index_file, 'w') as out:
65+
out.write(text)
66+
67+
for root, dirs, files in os.walk(plugin_input_dir):
68+
for file in files:
69+
if file.endswith('.md') and not file.startswith('index') and not file.startswith('Home'):
70+
append_to_file(os.path.join(plugin_input_dir, file), file.strip('.md'), plugin_name, os.path.join(plugin_output_dir, file))
71+
else:
72+
shutil.copyfile(os.path.join(plugin_input_dir, 'README.md'), index_file)
73+
with open(index_file) as f:
74+
text = f.read()
75+
append_text = '''---
76+
layout: default
77+
title: {plugin_name}
78+
long_title: {plugin_name}
79+
parent: Plugins
80+
---
81+
'''.format(plugin_name=plugin_name)
82+
text = append_text + text
83+
with open(index_file, 'w') as out:
84+
out.write(text)
85+
86+
# main
87+
def main():
88+
if len(sys.argv) != 4:
89+
print('Usage: python test.py <plugin_dir_path> <plugin_name> <plugin_type>')
90+
sys.exit(1)
91+
dirpath = sys.argv[1]
92+
plugin_name = sys.argv[2]
93+
plugin_type = sys.argv[3]
94+
reformat_plugin_dir(dirpath, plugin_name, plugin_type)
95+
96+
if __name__ == "__main__":
97+
main()

code/plugins/update_plugins.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def run_command(command):
77
print(f"Command failed: {command}\nError: {result.stderr}")
88
return result
99

10-
def update_repo(repo, script, type='readme'):
10+
def update_repo(repo, script, plugin_type='readme'):
1111
print(f"Updating {repo}...")
1212
current_dir = os.getcwd()
1313
repo_path = os.path.join(current_dir, 'github', repo)
@@ -16,22 +16,22 @@ def update_repo(repo, script, type='readme'):
1616
os.chdir(repo_path)
1717
run_command('git pull')
1818
else:
19-
if type == "wiki":
19+
if plugin_type == "wiki":
2020
run_command(f'git clone https://github.com/sccn/{repo}.wiki.git {repo_path}')
2121
else:
2222
run_command(f'git clone https://github.com/sccn/{repo}.git {repo_path}')
2323

2424
os.chdir(current_dir)
25-
run_command(f'python {script} {repo_path} {repo}')
25+
run_command(f'python {script} {repo_path} {repo} {plugin_type}')
2626

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

32-
wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
33-
for plugin in wiki_plugins:
34-
update_repo(plugin, "Wiki_plugin.py", 'wiki')
35-
readme_plugins = ['roiconnect', 'EEG-BIDS', 'trimOutlier', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'amica', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline', 'ARfitStudio ', 'NIMA', 'firfilt']
32+
# wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'PACT', 'nsgportal', 'clean_rawdata']
33+
# for plugin in wiki_plugins:
34+
# update_repo(plugin, "reformat_plugin.py", 'wiki')
35+
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']
3636
for plugin in readme_plugins:
37-
update_repo(plugin, "README_plugin.py")
37+
update_repo(plugin, "reformat_plugin.py", "readme")
107 KB

plugins/ARfitStudio/images/Onics.png

111 KB

0 commit comments

Comments
 (0)