示例#1
0
    elif(language=="iPhone"):
        return ".m"
    elif(language=="Windows Registry"):
        return ".reg"
    elif(language=="Bash"):
        return ".sh"
    elif(language=="CSS"):
        return ".css"
    elif(language=="HTML"):
        return ".html"
    elif(language=="Python"):
        return ".py"
    else:
        return ".txt"

snipplr=SnipplrPy()
snipplr.setup("Your API Key")
for snippt in snipplr.list():
    #get file
    #json.dumps(d)
    
        
    result=snipplr.get(snippt['id'])
    if json.dumps(result)!="null":
        file_ext=get_ext(result['language'])

        source=result['source']

        if not os.path.exists("./output"):
            os.makedirs("output")
示例#2
0
        return ".m"
    elif (language == "Windows Registry"):
        return ".reg"
    elif (language == "Bash"):
        return ".sh"
    elif (language == "CSS"):
        return ".css"
    elif (language == "HTML"):
        return ".html"
    elif (language == "Python"):
        return ".py"
    else:
        return ".txt"


snipplr = SnipplrPy()
snipplr.setup("Your API Key")
for snippt in snipplr.list():
    #get file
    #json.dumps(d)

    result = snipplr.get(snippt['id'])
    if json.dumps(result) != "null":
        file_ext = get_ext(result['language'])

        source = result['source']

        if not os.path.exists("./output"):
            os.makedirs("output")

        write_file = open(
示例#3
0
            description = "Scheme: %s" % description

        source = html_unescape(sn.get("source", ""))

        gist_post_console(filename, description, source, True, GHUB_USER, GHUB_PSW)

    except:
        print "ERROR! NOT SAVED"




# main app


c = SnipplrPy()
c.setup(SNIPPLR_ID)

snippets = [x for x in c.list()]

# {'updated': {'timezone': '+10:00 EST', 'datetime': <DateTime '20100517T06:41:47' at 10b9df710>}, 'favorite': False, 'id': '34616', 'private': False, 'title': "'Dictionary Comprehensions'"}
# {'updated': {'timezone': '+10:00 EST', 'datetime': <DateTime '20110828T06:35:36' at 10b9df758>}, 'favorite': False, 'id': '54284', 'private': False, 'title': 'Adding custom django package to WSGI settings'}

for s in snippets:
    sn = c.get(s['id'])
    if sn:
        try:
            print "Snippet --%s--" % sn.get("title", "")
        except:
            print "Snippet --%s--" % str(sn.get("id", ""))
        create_gist_from_snipplr(sn)