arg='[%s](%s)' % (f['filename'], md_path),
                  subtitle='Copy Markdown Link to Clipboard',
                  valid=True,
                  icon_path='icons/link.png',
                  icon_type='image')
        wf.addModsToItem()
        # Mod for ALT - Export to Evernote
        wf.addMod(key='alt',
                  arg=f['path'],
                  subtitle='Export Note to Evernote',
                  valid=True,
                  icon_path='icons/evernote.png',
                  icon_type='image')
        wf.addModsToItem()
        # Mod for FN - open in Marked 2
        wf.addMod(key='fn',
                  arg=f['path'],
                  subtitle='Open Preview in Marked 2',
                  valid=True,
                  icon_path='icons/marked.png',
                  icon_type='image')
        wf.addModsToItem()
        wf.addItem()

    i = wf.getItems(response_type="dict")['items']
    if len(i) == 0:
        wf.setItem(title="Nothing found...", subtitle="Try again", valid=False)
        wf.addItem()

    wf.write()
Esempio n. 2
0
else:
    sorted_file_list = md_search.getFilesListSorted()
# Write search results into WF object
for f in sorted_file_list:
    c_date = Tools.getDateStr(f['ctime'])
    m_date = Tools.getDateStr(f['mtime'])
    wf.setItem(
        title=f['title'],
        subtitle=
        u"Created: {0}, Modified: {1} ({2} \u2192 Actions, {3} \u2192 Quicklook)"
        .format(c_date, m_date, u'\u2318', u'\u21E7'),
        type='file',
        arg=f['path'])
    # Mod for CMD - new action menu
    wf.addMod(key="cmd",
              arg="{0}>{1}".format(f['path'], query),
              subtitle="Enter Actions Menu for the Note...",
              icon_path="icons/action.png",
              icon_type="image")
    wf.addModsToItem()
    wf.addItem()

if len(wf.getItems(response_type="dict")['items']) == 0:
    wf.setItem(
        title="Nothing found...",
        subtitle="Do you want to create a new note with title \"{0}\"?".format(
            query),
        arg=query)
    wf.addItem()
wf.write()
    it = sorted(get_dirs(ws_home))
else:
    it = sorted(get_files(ws_home))

wf = Items()
if p_path:
    wf.setItem(title='Back', arg=p_path)
    wf.setIcon(m_path='back.png', m_type='image')
    wf.addItem()
if len(it) > 0:
    for i in it:
        if (query == str() or query.lower() in PurePath(i).stem.lower()
            ) and not (os.path.basename(i).startswith('.')):
            ic = 'folder.png' if os.path.isdir(i) else 'workspace.png'
            sub = 'Folder' if os.path.isdir(i) else "Workspace in VSCode"
            title = os.path.basename(i).replace('.code-workspace', '')
            wf.setItem(title=title,
                       subtitle=u'\u23CE to open {0}'.format(sub),
                       arg=i)
            wf.setIcon(m_path=ic, m_type='image')
            wf.addItem()
    if len(wf.getItems(response_type='dict').get('items')) == 0:
        wf.setItem(title="Search does not match a workspace",
                   subtitle="...try again",
                   valid=False)
        wf.addItem()
else:
    wf.setItem(title="No Workspace files or Folders found", valid=False)
    wf.addItem()
wf.write()