Skip to content

Instantly share code, notes, and snippets.

@oeway
Created May 17, 2019 08:44
Show Gist options
  • Select an option

  • Save oeway/f8dddda6532d91902c9fb881a8684d39 to your computer and use it in GitHub Desktop.

Select an option

Save oeway/f8dddda6532d91902c9fb881a8684d39 to your computer and use it in GitHub Desktop.
<docs lang="markdown">
[TODO: write documentation for this plugin.]
</docs>
<config lang="json">
{
"name": "CreateFolder",
"type": "native-python",
"version": "0.1.0",
"description": "[TODO: describe this plugin with one sentence.]",
"tags": [],
"ui": "",
"cover": "",
"inputs": null,
"outputs": null,
"flags": [],
"icon": "extension",
"api_version": "0.1.5",
"env": "",
"requirements": [],
"dependencies": []
}
</config>
<script lang="python">
from imjoy import api
import asyncio
import os
import shutil
class ImJoyPlugin():
def setup(self):
api.log('initialized')
async def run(self, ctx):
retObj = await api.showFileDialog({'engine': api.ENGINE_URL, 'title': 'creating folder'})
name = await api.prompt(f'What is the folder name you want to create?')
newpath = os.path.join(retObj.path, name)
if not os.path.exists(newpath):
os.makedirs(newpath)
api.alert('folder created!')
else:
api.alert('folder already exists.')
api.export(ImJoyPlugin())
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment