code
stringlengths
1
1.72M
language
stringclasses
1 value
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 10, 2011 @author: apple ''' import time import cPickle import pymongo import types class MongoModel(object): lasterror = None def __init__(self, db , pk='_id', cache=None , expire=0): self.db = db self.pk = pk self.cache =...
Python
#!/usr/bin/env python # encoding: utf-8 """ config.py Created by AlanYang on 2011-06-04. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ class Config(object): #SERVER_NAME = 'freeasker.com application service' #mongodb config MONGO_HOST = '127.0.0.1' MONGO_PORT = 27017 #redis conf...
Python
#!/usr/bin/env python # encoding: utf-8 """ __init__.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import sys import os def main(): pass if __name__ == '__main__': main()
Python
#!/usr/bin/env python # encoding: utf-8 """ cache.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ from functools import wraps from config import memcacheclients class Cache(object): def __init__(self,contail): if not getattr(contail, 'memcache',None): ...
Python
#!/usr/bin/env python # encoding: utf-8 """ __init__.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import sys import os def main(): pass if __name__ == '__main__': main()
Python
#!/usr/bin/env python # encoding: utf-8 """ cache.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ from functools import wraps from config import memcacheclients class Cache(object): def __init__(self,contail): if not getattr(contail, 'memcache',None): ...
Python
#!/usr/bin/env python # encoding: utf-8 """ test.py Created by AlanYang on 2011-06-17. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import sys import os import types import xapian from multiprocessing import Process from application import app #insert db.set_document(doc) #remove db.delete_document(...
Python
#!/usr/bin/env python # encoding: utf-8 """ usermodel.py Created by AlanYang on 2011-06-04. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import redis import cPickle import hashlib import pymongo from flask import g from mongomodel import MongoModel from application import app from apps.search.searc...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' from flask import Module , render_template, request, session, redirect, url_for,flash import usermodel as model from usermodel import UserModel user = Module(__name__ , name='user') @user.route('/') def index(info=''): if '_i...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' from flask import Module , render_template, request, session, redirect, url_for,flash import usermodel as model from usermodel import UserModel user = Module(__name__ , name='user') @user.route('/') def index(info=''): if '_i...
Python
#!/usr/bin/env python # encoding: utf-8 """ usermodel.py Created by AlanYang on 2011-06-04. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import redis import cPickle import hashlib import pymongo from flask import g from mongomodel import MongoModel from application import app from apps.search.searc...
Python
#!/usr/bin/env python # encoding: utf-8 """ questionmodel.py Created by AlanYang on 2011-06-04. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import os import time import types import hashlib import cPickle import pymongo import memcache from flask import g from mongomodel import MongoModel from appl...
Python
#!/usr/bin/env python # encoding: utf-8 """ questionmodel.py Created by AlanYang on 2011-06-04. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import os import time import types import hashlib import cPickle import pymongo import memcache from flask import g from mongomodel import MongoModel from appl...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' from flask import Module, render_template, request, jsonify , flash , session, redirect, url_for from questionmodel import setquestion, getquestion, searchquestion , getnewestquestions import questionmodel as model from apps.user.u...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' from flask import Module, render_template, request, jsonify , flash , session, redirect, url_for from questionmodel import setquestion, getquestion, searchquestion , getnewestquestions import questionmodel as model from apps.user.u...
Python
#!/usr/bin/env python # encoding: utf-8 """ tagmodel.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import sys import redis import pymongo from flask import g from mongomodel import MongoModel from application import app @app.signal_addtagscore.connect def bumpta...
Python
#!/usr/bin/env python # encoding: utf-8 """ tagmodel.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import sys import redis import pymongo from flask import g from mongomodel import MongoModel from application import app @app.signal_addtagscore.connect def bumpta...
Python
#!/usr/bin/env python # encoding: utf-8 """ __init__.py Created by AlanYang on 2011-06-17. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """
Python
#!/usr/bin/env python # encoding: utf-8 """ views.py Created by AlanYang on 2011-06-23. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ from flask import Module,flash,render_template import tagmodel tag = Module(__name__,name='tag') @tag.route('/') @tag.route('/<int:page>') def index(page=1): ski...
Python
#!/usr/bin/env python # encoding: utf-8 """ views.py Created by AlanYang on 2011-06-23. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ from flask import Module,flash,render_template import tagmodel tag = Module(__name__,name='tag') @tag.route('/') @tag.route('/<int:page>') def index(page=1): ski...
Python
#!/usr/bin/env python # encoding: utf-8 """ __init__.py Created by AlanYang on 2011-06-17. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """
Python
#!/usr/bin/env python # encoding: utf-8 """ __init__.py Created by AlanYang on 2011-06-21. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' from flask import Module,request,render_template,flash,redirect,url_for,session import catalogmodel as model catalog = Module(__name__,name='catalog') @catalog.route('/') def index(): cs = model.get_top_catalo...
Python
#!/usr/bin/env python # encoding: utf-8 """ catalogmodel.py Created by AlanYang on 2011-06-21. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import time,pymongo from flask import g from mongomodel import MongoModel from application import app def add_catalog(catalog): return 'parent' in catalog ...
Python
#!/usr/bin/env python # encoding: utf-8 """ catalogmodel.py Created by AlanYang on 2011-06-21. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import time,pymongo from flask import g from mongomodel import MongoModel from application import app def add_catalog(catalog): return 'parent' in catalog ...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' from flask import Module,request,render_template,flash,redirect,url_for,session import catalogmodel as model catalog = Module(__name__,name='catalog') @catalog.route('/') def index(): cs = model.get_top_catalo...
Python
#!/usr/bin/env python # encoding: utf-8 """ __init__.py Created by AlanYang on 2011-06-21. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 16, 2011 @author: apple ''' import types import cPickle import xapian from mmseg.search import seg_txt_2_dict try: from config import SEARCH_DB_PATH except Exception, e: import sys if sys.platform.startswith('win'): SEARCH_DB_PATH = 'E:\\xa...
Python
#!/usr/bin/env python # encoding: utf-8 """ searchmodel.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import types import redis import cPickle from functools import wraps import searchengine from flask import g from application import app from mongomodel import M...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 16, 2011 @author: apple ''' import types import cPickle import xapian from mmseg.search import seg_txt_2_dict try: from config import SEARCH_DB_PATH except Exception, e: import sys if sys.platform.startswith('win'): SEARCH_DB_PATH = 'E:\\xa...
Python
#!/usr/bin/env python # encoding: utf-8 """ searchmodel.py Created by AlanYang on 2011-06-20. Copyright (c) 2011 __MyCompanyName__. All rights reserved. """ import types import redis import cPickle from functools import wraps import searchengine from flask import g from application import app from mongomodel import M...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple ''' import redis import pymongo from flask import Flask,g from flask.signals import Namespace from flaskext.cache import Cache app = Flask(__name__) app.config.from_object('config.DevelopmentConfig') cache = Cache(app) signals = Name...
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 6, 2011 @author: apple '''
Python
#!/usr/bin/env python # encoding: utf-8 ''' Created on Jun 9, 2011 @author: apple ''' import sys from optparse import OptionParser from application import app if __name__ == '__main__': app.run(host = '0.0.0.0',port=7777,debug=True) sys.exit(0) parser = OptionParser() parser.add_option('-r', '--runtyp...
Python
# Copyright 2008 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
Python
#!/usr/bin/env python # encoding: utf-8 """ url.py @author Andrey Pavlenko """ from django.conf.urls.defaults import * urlpatterns = patterns( '', (r'^$', 'views.index'), (r'^new$', 'views.new'), (r'^edit/(\d+)$', 'views.edit'), )
Python
#!/usr/bin/env python # encoding: utf-8 """ views.py @author Andrey Pavlenko """ import os from google.appengine.api import users from google.appengine.ext import db from google.appengine.ext.db import djangoforms import django from django import http from django import shortcuts from model import Post class PostF...
Python
# Copyright 2008 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
Python
#!/usr/bin/env python # encoding: utf-8 """ model.py @author Andrey Pavlenko """ import datetime from google.appengine.ext import db from google.appengine.api import users class Post(db.Model): ''' Object for blog post and page. ''' author=db.UserProperty(required = True, auto_current_u...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2010 Paulo Jerônimo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
Python
#!/usr/bin/env python #============================================================================== # PyTyle - An on-demand tiling manager # Copyright (C) 2009-2010 Andrew Gallant <andrew@pytyle.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Publ...
Python
#============================================================================== # PyTyle - An on-demand tiling manager # Copyright (C) 2009-2010 Andrew Gallant <andrew@pytyle.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as publishe...
Python
import ptxcb from tile import Tile from container import Container class ManualTile(Tile): def __init__(self, monitor): Tile.__init__(self, monitor) self.root = None self.catchall = None # # Helper methods # def add(self, win): if ( win.tilable() and s...
Python
import ptxcb class Workspace(object): WORKSPACES = {} @staticmethod def add(wsid): Desktop.add(wsid) @staticmethod def iter_all_monitors(): for wsid in Workspace.WORKSPACES: for mon in Workspace.WORKSPACES[wsid].iter_monitors(): yield mon @staticme...
Python
import time import config import ptxcb import state import tilers from command import Command from window import Window from tile import Tile class Dispatcher(object): def __init__(self, event_data): self._event_data = event_data self._stop = False assert 'event' in self._event_data ...
Python
from tile import Tile from container import Container class AutoTile(Tile): def __init__(self, monitor): Tile.__init__(self, monitor) self.store = None self.cycle_index = 0 # # Helper methods # def add(self, win): if ( win.tilable() and self.tiling and ...
Python
import re import config from command import Command from container import Container class Tile(object): queue_tile = set() @staticmethod def dispatch(monitor, command): assert isinstance(command, Command) tiler = monitor.get_tiler() if tiler: if tiler.get_name() == '...
Python
import time import ptxcb import config from command import Command from window import Window from monitor import Monitor from workspace import Workspace from container import Container _ACTIVE = None pointer_grab = False moving = False properties = {} xinerama = ptxcb.connection.xinerama_get_screens() def init(): ...
Python
import math from pt.tile_auto import AutoTile class Vertical(AutoTile): def __init__(self, monitor): AutoTile.__init__(self, monitor) self.hsplit = self.get_option('width_factor') # # Helper methods # def decrement_hsplit(self): self.hsplit -= self.get_option('step_size'...
Python
import math from pt.tile_auto import AutoTile class Center(AutoTile): def __init__(self, monitor): AutoTile.__init__(self, monitor) self.hsplit = self.get_option('width_factor') self.vsplit = self.get_option('height_factor') self.columns = self.get_option('columns') # # H...
Python
from pt.tile_auto import AutoTile class Maximal(AutoTile): def __init__(self, monitor): AutoTile.__init__(self, monitor) # # Commands # def cmd_tile(self): AutoTile.cmd_tile(self) if not self.store.all(): return # Do master last, in case decorations a...
Python
import pt.tile_manual import cascade import center import horizontal import maximal import vertical ManualTile = pt.tile_manual.ManualTile Cascade = cascade.Cascade Center = center.Center Horizontal = horizontal.Horizontal HorizontalRows = horizontal.HorizontalRows Maximal = maximal.Maximal Vertical = vertical.Verti...
Python
import math from pt.tile_auto import AutoTile class Cascade(AutoTile): def __init__(self, monitor): AutoTile.__init__(self, monitor) self.hsplit = self.get_option('width_factor') self.vsplit = self.get_option('height_factor') # # Helper methods # def raise_active(self): ...
Python
import math from pt.tile_auto import AutoTile class Horizontal(AutoTile): def __init__(self, monitor): AutoTile.__init__(self, monitor) self.vsplit = self.get_option('height_factor') # # Helper methods # def decrement_vsplit(self): self.vsplit -= self.get_option('step_si...
Python
class Grid(object): def __init__(self): pass
Python
# Library imports import config import ptxcb import tilers # Class imports from workspace import Workspace class Monitor(object): @staticmethod def add(wsid, xinerama): for mid, screen in enumerate(xinerama): new_mon = Monitor( Workspace.WORKSPACES[wsid], mi...
Python
import time import ptxcb import config from workspace import Workspace class Window(object): WINDOWS = {} @staticmethod def add(wid): if wid not in Window.WINDOWS: if Window.manageable(wid): win = Window(wid) Window.WINDOWS[wid] = win ...
Python
import ptxcb import config from window import BogusWindow class Container(object): idinc = 1 active = None @staticmethod def manage_focus(win): if win and win.container: win.container.borders_activate(win.container.tiler.decor) elif Container.active: Container....
Python
import xcb.xproto import ptxcb import config class Command: _cmds = {} _mods = { 'alt': xcb.xproto.ModMask._1, 'ctrl': xcb.xproto.ModMask.Control, 'shift': xcb.xproto.ModMask.Shift, 'super': xcb.xproto.ModMask._4, 'menu': xcb.xproto.ModMask._3 } def __init__(se...
Python
import ConfigParser import distutils.sysconfig import os import os.path import pwd import re import shutil import sys # This is PyTyle's custom configuration parser. There are two main # goals accomplished with this sub-class: # # 1. It allows retrival of some other types, like lists, booleans, and # lists of certa...
Python
import struct import xcb.xproto, xcb.xcb, xcb.xinerama, xcb.randr conn = None setup = None syms_to_codes = {} codes_to_syms = {} def init(): global conn, setup conn = xcb.xcb.connect() setup = conn.get_setup() init_keymap() def init_keymap(): global setup, syms_to_codes, codes_to_syms q ...
Python
import struct import xcb.xproto import connection from atoms import atoms class Atom: _cache = {} @staticmethod def build_cache(): if Atom._cache: return for atom in atoms: Atom._cache[atom] = connection.get_core().InternAtom( False, ...
Python
atoms = { '_PYTYLE_TYPE': ('ATOM', 32), '_PYTYLE_TYPE_PLACE_HOLDER': ('ATOM', 32), '_PYTYLE_TYPE_BORDER': ('ATOM', 32), 'WM_CLASS': ('STRING', 8), 'WM_HINTS': ('WM_HINTS', 32), 'WM_NAME': ('STRING', 8), 'WM_NORMAL_HINTS': ('WM_SIZE_HINTS', 32), 'WM_PROTOCOLS': ('ATOM', 32), 'WM_STAT...
Python
import xcb.xproto from window import Window from window import XROOT from atom import Atom def dispatch(e): NotifyModes = { 0: 'Normal', 1: 'Grab', 2: 'Ungrab', 3: 'WhileGrabbed' } NotifyDetails = { 0: 'Ancestor', 1: 'Virtual', 2: 'Inferior', 3: 'Nonlinear', 4: 'NonlinearVirtual',...
Python
import struct, traceback, time import xcb.xproto, xcb.xcb import connection from atom import Atom from events import events class Window(object): queue = [] @staticmethod def exec_queue(): for tup in Window.queue: tup[0](*tup[1:]) Window.queue = [] def __init__(self, wid...
Python
import atom import connection import event import keysyms import window Atom = atom.Atom BlankWindow = window.BlankWindow LineWindow = window.LineWindow RootWindow = window.RootWindow Window = window.Window keysyms = keysyms.keysyms atoms = atoms.atoms XROOT = window.XROOT
Python
keysyms = { 'VoidSymbol': 0xffffff, 'BackSpace': 0xff08, 'Tab': 0xff09, 'Linefeed': 0xff0a, 'Clear': 0xff0b, 'Return': 0xff0d, 'Pause': 0xff13, 'Scroll_Lock': 0xff14, 'Sys_Req': 0xff15, 'Escape': 0xff1b, 'Delete': 0xffff, 'Multi_key': 0xff20, 'Codeinput': 0xff37, ...
Python
events = { 'KeyPressEvent': 2, 'KeyReleaseEvent': 3, 'ButtonPressEvent': 4, 'ButtonReleaseEvent': 5, 'MotionNotifyEvent': 6, 'EnterNotifyEvent': 7, 'LeaveNotifyEvent': 8, 'FocusInEvent': 9, 'FocusOutEvent': 10, 'KeymapNotifyEvent': 11, 'ExposeEvent': 12, 'GraphicsExposure...
Python
# -*- coding: utf-8 -*- # # Copyright 2008 Google Inc. All Rights Reserved. # # Licensed under the GNU General Public License, Version 3.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.gnu.org/licenses/gpl.html # # Unless...
Python
#!/usr/bin/python """ HeaderID Extension for Python-Markdown ====================================== Adds ability to set HTML IDs for headers. Basic usage: >>> import markdown >>> text = "# Some Header # {#some_id}" >>> md = markdown.markdown(text, ['headerid']) >>> md u'<h1 id="some_id">Some Hea...
Python
#!/usr/bin/env Python """ Definition List Extension for Python-Markdown ============================================= Added parsing of Definition Lists to Python-Markdown. A simple example: Apple : Pomaceous fruit of plants of the genus Malus in the family Rosaceae. : An american computer co...
Python
#!usr/bin/python """ Meta Data Extension for Python-Markdown ======================================= This extension adds Meta Data handling to markdown. Basic Usage: >>> import markdown >>> text = '''Title: A Test Doc. ... Author: Waylan Limberg ... John Doe ... Blank_Data: ... ....
Python
""" ========================= IMAGE LINKS ================================= Turns paragraphs like <~~~~~~~~~~~~~~~~~~~~~~~~ dir/subdir dir/subdir dir/subdir ~~~~~~~~~~~~~~ dir/subdir dir/subdir dir/subdir ~~~~~~~~~~~~~~~~~~~> Into mini-photo galleries. """ import re, markdown import url_manager IMAGE_LINK = """...
Python
import markdown from markdown import etree DEFAULT_URL = "http://www.freewisdom.org/projects/python-markdown/" DEFAULT_CREATOR = "Yuri Takhteyev" DEFAULT_TITLE = "Markdown in Python" GENERATOR = "http://www.freewisdom.org/projects/python-markdown/markdown2rss" month_map = { "Jan" : "01", "Feb" : "02", ...
Python
#!/usr/bin/env python """ HTML Tidy Extension for Python-Markdown ======================================= Runs [HTML Tidy][] on the output of Python-Markdown using the [uTidylib][] Python wrapper. Both libtidy and uTidylib must be installed on your system. Note than any Tidy [options][] can be passed in as extensio...
Python
""" ========================= FOOTNOTES ================================= This section adds footnote handling to markdown. It can be used as an example for extending python-markdown with relatively complex functionality. While in this case the extension is included inside the module itself, it could just as easily b...
Python
#!/usr/bin/env python ''' WikiLinks Extension for Python-Markdown ====================================== Converts [[WikiLinks]] to relative links. Requires Python-Markdown 2.0+ Basic usage: >>> import markdown >>> text = "Some text with a [[WikiLink]]." >>> html = markdown.markdown(text, ['wikilinks'])...
Python
#!/usr/bin/python """ CodeHilite Extension for Python-Markdown ======================================== Adds code/syntax highlighting to standard Python-Markdown code blocks. Copyright 2006-2008 [Waylan Limberg](http://achinghead.com/). Project website: <http://www.freewisdom.org/project/python-markdown/CodeHilite>...
Python
""" Table of Contents Extension for Python-Markdown * * * (c) 2008 [Jack Miller](http://codezen.org) Dependencies: * [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/) """ import markdown from markdown import etree import re class TocTreeprocessor(markdown.treeprocessors.Treeprocessor): # Iter...
Python
#!/usr/bin/env python """ Fenced Code Extension for Python Markdown ========================================= This extension adds Fenced Code Blocks to Python-Markdown. >>> import markdown >>> text = ''' ... A paragraph before a fenced code block: ... ... ~~~ ... Fenced code block ... ~~...
Python
''' Abbreviation Extension for Python-Markdown ========================================== This extension adds abbreviation handling to Python-Markdown. Simple Usage: >>> import markdown >>> text = """ ... Some text with an ABBR and a REF. Ignore REFERENCE and ref. ... ... *[ABBR]: Abbreviation ...
Python
#!/usr/bin/env python """ Python-Markdown Extra Extension =============================== A compilation of various Python-Markdown extensions that imitates [PHP Markdown Extra](http://michelf.com/projects/php-markdown/extra/). Note that each of the individual extensions still need to be available on your PYTHONPATH. ...
Python
#!/usr/bin/env Python """ Tables Extension for Python-Markdown ==================================== Added parsing of tables to Python-Markdown. A simple example: First Header | Second Header ------------- | ------------- Content Cell | Content Cell Content Cell | Content Cell Copyright 2009 - [Wa...
Python
import markdown import re def isString(s): """ Check if it's string """ return isinstance(s, unicode) or isinstance(s, str) class Processor: def __init__(self, markdown_instance=None): if markdown_instance: self.markdown = markdown_instance class Treeprocessor(Processor): """ ...
Python
""" INLINE PATTERNS ============================================================================= Inline patterns such as *emphasis* are handled by means of auxiliary objects, one per pattern. Pattern objects must be instances of classes that extend markdown.Pattern. Each pattern object uses a single regular express...
Python
""" CORE MARKDOWN BLOCKPARSER ============================================================================= This parser handles basic parsing of Markdown blocks. It doesn't concern itself with inline elements such as **bold** or *italics*, but rather just catches blocks, lists, quotes, etc. The BlockParser is made ...
Python
import markdown class State(list): """ Track the current and nested state of the parser. This utility class is used to track the state of the BlockParser and support multiple levels if nesting. It's just a simple API wrapped around a list. Each time a state is set, that state is appended to the...
Python
# markdown/html4.py # # Add html4 serialization to older versions of Elementree # Taken from ElementTree 1.3 preview with slight modifications # # Copyright (c) 1999-2007 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # # --------------------------------------------------...
Python
""" COMMAND-LINE SPECIFIC STUFF ============================================================================= The rest of the code is specifically for handling the case where Python Markdown is called from the command line. """ import markdown import sys import logging from logging import DEBUG, INFO, WARN, ERROR, CR...
Python
""" POST-PROCESSORS ============================================================================= Markdown also allows post-processors, which are similar to preprocessors in that they need to implement a "run" method. However, they are run after core processing. """ import markdown class Processor: def __init_...
Python
""" PRE-PROCESSORS ============================================================================= Preprocessors work on source text before we start doing anything too complicated. """ import re import markdown HTML_PLACEHOLDER_PREFIX = markdown.STX+"wzxhzdk:" HTML_PLACEHOLDER = HTML_PLACEHOLDER_PREFIX + "%d" + mark...
Python
""" Python Markdown =============== Python Markdown converts Markdown to HTML and can be used as a library or called from the command line. ## Basic usage as a module: import markdown md = Markdown() html = md.convert(your_text_string) ## Basic use from the command line: markdown source.txt > desti...
Python
class OrderedDict(dict): """ A dictionary that keeps its keys in the order in which they're inserted. Copied from Django's SortedDict with some modifications. """ def __new__(cls, *args, **kwargs): instance = super(OrderedDict, cls).__new__(cls, *args, **kwargs) instance.keyOrd...
Python
from markdown import message, CRITICAL import sys ## Import def importETree(): """Import the best implementation of ElementTree, return a module object.""" etree_in_c = None try: # Is it Python 2.5+ with C implemenation of ElementTree installed? import xml.etree.cElementTree as etree_in_c exce...
Python
'''Base classes and helpers for building zone specific tzinfo classes''' from datetime import datetime, timedelta, tzinfo from bisect import bisect_right try: set except NameError: from sets import Set as set import pytz __all__ = [] _timedelta_cache = {} def memorized_timedelta(seconds): '''Create only...
Python