UserPreferences

SocialBookmarkingNotesForRemixClass


  1. social bookmarking
  2. EccoMoin.py
  3. EccoToDelicious

social bookmarking

EccoMoin.py

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
 37 
import EccoTk.EccoPy

def getCurrentEccoItems():

    ea = EccoTk.EccoPy.EccoApp()
    eSel = ea.getSelection()
    if isinstance(eSel,EccoTk.EccoPy.EccoItems) and len(eSel.getItems()):
        return eSel.getItems()
    else:
        return None


def EccoItemsToMoinList(eItems,listType='u',level=0,tab=3):
    """
    create a MoinMoin wiki markup to represent the EccoItems
    """
    if listType == 'u':
        limarker = '*'
    else:
        limarker = '1'
    s = ''
    for eItem in eItems:
        s += (level+1)*tab*' ' + limarker + ' ' + eItem.text + "\n"
        for eSub in eItem.getSubs():
            s += EccoItemsToMoinList([eSub], listType,(level+1),tab)
    return s

if (__name__ == '__main__'):
    e = getCurrentEccoItems()
    if (e):
        markup = EccoItemsToMoinList(e,'u',0,3)
        import win32clipboard
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(markup)
        win32clipboard.CloseClipboard()
        print markup

EccoToDelicious

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
 37 
 38 
 39 
 40 
 41 
 42 
 43 
 44 
"""
walk through the selected ecco tree, looking for
   * [] wiki type references
   * [[][]] wiki type references
   * <a href="">comment</a> references
   * if none of these locations, look at the Net Locations folder
to put into delicious
"""


import EccoUtil, pydelicious
import re

def getRefsForEItem(s):
    # look for [http://URL comment] first
    pats = [r"""\[(https*://\S+)\s+([^\]]+)\]""",r"""<a href=["'](https*://[^"']+)["']>([^>]+)</a>"""]
    refs = []

    for rawstr in pats:
        compile_obj = re.compile(rawstr)
        matchstr = s
        match_objs = compile_obj.finditer(matchstr)
        for m in match_objs:
            refs.append(m.groups())

    return refs


def postEccoToDelicious(eItem):

    refs = getRefsForEItem(eItem.text)
    for ref in refs:
        print ref[0],"|", ref[1]
        a.posts_add(ref[0],ref[1])
    for eSub in eItem.getSubs():
        postEccoToDelicious(eSub)

if (__name__ == '__main__'):
    user = 'rdhyee'
    passwd = 'PASSWORD'
    a = pydelicious.apiNew(user, passwd)
    eItems = EccoUtil.getCurrentEccoItems()
    for eItem in eItems:
        postEccoToDelicious(eItem)