README
This commit is contained in:
parent
b4780ef47e
commit
86fc5b3595
4 changed files with 142 additions and 45 deletions
|
@ -2,18 +2,18 @@ import os
|
|||
import json
|
||||
from argparse import ArgumentParser
|
||||
|
||||
# 1. 读取一个参数 plugin_dir
|
||||
# 1. Read plugin_dir
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('plugin_dir')
|
||||
args = parser.parse_args()
|
||||
plugin_dir = args.plugin_dir
|
||||
|
||||
# 2. 读取当前根目录下 plugin.json 的 name 字段
|
||||
# 2. Read name in plugin.json
|
||||
with open('plugin.json', 'r', encoding='utf-8') as f:
|
||||
content = json.load(f)
|
||||
name = content.get('name')
|
||||
|
||||
# ...如果 name 字段为空,报错并退出
|
||||
# ...error if name not found
|
||||
if not name or name == '':
|
||||
print('"name" in plugin.json not found, exit')
|
||||
exit()
|
||||
|
@ -22,11 +22,11 @@ dev_dir = os.path.abspath('dev')
|
|||
if not os.path.exists(dev_dir):
|
||||
os.mkdir(dev_dir)
|
||||
|
||||
# 3. 读取 plugin_dir 下的是否有和 name 字段相同的文件夹
|
||||
# ...如果没有,创建一个软链接到当前根目录下的 dev 文件夹
|
||||
# ...如果有,报错并退出
|
||||
# 3. Create symlink
|
||||
if not os.path.exists(os.path.join(plugin_dir, name)):
|
||||
os.symlink(dev_dir, os.path.join(plugin_dir, name))
|
||||
link = os.path.join(plugin_dir, name)
|
||||
os.symlink(dev_dir, link)
|
||||
print('Symlink created:', link)
|
||||
else:
|
||||
print('Folder already exists, exit')
|
||||
exit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue