{"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"view.py","language":"python","identifier":"get_view_file","parameters":"(handler, params={})","argument_list":"","return_statement":"return {'file': 'notfound.html', 'dirs': template_dirs}","docstring":"Looks for presence of template files with priority given to \n HTTP method (verb) and role.\n Full filenames are ... where\n = lower-case handler name\n = role of current user\n = HTTP verb, e.g. GET or POST\n = html, xml, etc.\n Only and are required.\n Properties 'module_name' and 'handler_name' can be passed in \n params to override the current module\/handler name.\n \n Returns:\n Tuple with first element = template file name and\n second element = template directory path tuple","docstring_summary":"Looks for presence of template files with priority given to \n HTTP method (verb) and role.\n Full filenames are ... where\n = lower-case handler name\n = role of current user\n = HTTP verb, e.g. GET or POST\n = html, xml, etc.\n Only and are required.\n Properties 'module_name' and 'handler_name' can be passed in \n params to override the current module\/handler name.\n \n Returns:\n Tuple with first element = template file name and\n second element = template directory path tuple","docstring_tokens":["Looks","for","presence","of","template","files","with","priority","given","to","HTTP","method","(","verb",")","and","role",".","Full","filenames","are","",".","",".","",".","","where","","=","lower","-","case","handler","name","","=","role","of","current","user","","=","HTTP","verb","e",".","g",".","GET","or","POST","","=","html","xml","etc",".","Only","","and","","are","required",".","Properties","module_name","and","handler_name","can","be","passed","in","params","to","override","the","current","module","\/","handler","name",".","Returns",":","Tuple","with","first","element","=","template","file","name","and","second","element","=","template","directory","path","tuple"],"function":"def get_view_file(handler, params={}):\n \"\"\"\n Looks for presence of template files with priority given to \n HTTP method (verb) and role.\n Full filenames are ... where\n = lower-case handler name\n = role of current user\n = HTTP verb, e.g. GET or POST\n = html, xml, etc.\n Only and are required.\n Properties 'module_name' and 'handler_name' can be passed in \n params to override the current module\/handler name.\n \n Returns:\n Tuple with first element = template file name and\n second element = template directory path tuple\n \"\"\"\n if 'ext' in params:\n desired_ext = params['ext']\n else:\n desired_ext = 'html'\n\n verb = handler.request.method.lower()\n app_name = ''\n module_name = None\n handler_name = None\n cls = handler.__class__\n if (cls.__module__.startswith('handlers.')\n and cls.__name__.endswith('Handler')):\n handler_path = cls.__module__.split('.')\n if len(handler_path) == 3:\n app_name = to_filename(handler_path[1])\n module_name = to_filename(handler_path[-1])\n handler_name = to_filename(cls.__name__.partition('Handler')[0])\n\n if 'app_name' in params:\n app_name = params['app_name']\n if 'module_name' in params:\n module_name = params['module_name']\n if 'handler_name' in params:\n handler_name = params['handler_name']\n\n # Get template directory hierarchy -- Needed if we inherit from templates\n # in directories above us (due to sharing with other templates).\n themes = config.BLOG['theme']\n if isinstance(themes, basestring):\n themes = [themes]\n template_dirs = []\n views_dir = os.path.join(config.APP_ROOT_DIR, 'views')\n for theme in themes:\n root_folder = os.path.join(views_dir, theme)\n if module_name:\n template_dirs += (os.path.join(root_folder, app_name, module_name),)\n if app_name:\n template_dirs += (os.path.join(root_folder, app_name),)\n template_dirs += (root_folder,)\n \n # Now check possible extensions for the given template file.\n if module_name and handler_name:\n entries = templates.get(app_name, {}).get(module_name, {})\n possible_roles = []\n if users.is_current_user_admin():\n possible_roles.append('.admin.')\n if users.get_current_user():\n possible_roles.append('.user.')\n possible_roles.append('.')\n for role in possible_roles:\n filename = ''.join([handler_name, role, verb, '.', desired_ext])\n if filename in entries:\n return {'file': filename, 'dirs': template_dirs}\n for role in possible_roles:\n filename = ''.join([handler_name, role, desired_ext])\n if filename in entries:\n return {'file': filename, 'dirs': template_dirs}\n return {'file': 'notfound.html', 'dirs': template_dirs}","function_tokens":["def","get_view_file","(","handler",",","params","=","{","}",")",":","if","'ext'","in","params",":","desired_ext","=","params","[","'ext'","]","else",":","desired_ext","=","'html'","verb","=","handler",".","request",".","method",".","lower","(",")","app_name","=","''","module_name","=","None","handler_name","=","None","cls","=","handler",".","__class__","if","(","cls",".","__module__",".","startswith","(","'handlers.'",")","and","cls",".","__name__",".","endswith","(","'Handler'",")",")",":","handler_path","=","cls",".","__module__",".","split","(","'.'",")","if","len","(","handler_path",")","==","3",":","app_name","=","to_filename","(","handler_path","[","1","]",")","module_name","=","to_filename","(","handler_path","[","-","1","]",")","handler_name","=","to_filename","(","cls",".","__name__",".","partition","(","'Handler'",")","[","0","]",")","if","'app_name'","in","params",":","app_name","=","params","[","'app_name'","]","if","'module_name'","in","params",":","module_name","=","params","[","'module_name'","]","if","'handler_name'","in","params",":","handler_name","=","params","[","'handler_name'","]","# Get template directory hierarchy -- Needed if we inherit from templates","# in directories above us (due to sharing with other templates).","themes","=","config",".","BLOG","[","'theme'","]","if","isinstance","(","themes",",","basestring",")",":","themes","=","[","themes","]","template_dirs","=","[","]","views_dir","=","os",".","path",".","join","(","config",".","APP_ROOT_DIR",",","'views'",")","for","theme","in","themes",":","root_folder","=","os",".","path",".","join","(","views_dir",",","theme",")","if","module_name",":","template_dirs","+=","(","os",".","path",".","join","(","root_folder",",","app_name",",","module_name",")",",",")","if","app_name",":","template_dirs","+=","(","os",".","path",".","join","(","root_folder",",","app_name",")",",",")","template_dirs","+=","(","root_folder",",",")","# Now check possible extensions for the given template file.","if","module_name","and","handler_name",":","entries","=","templates",".","get","(","app_name",",","{","}",")",".","get","(","module_name",",","{","}",")","possible_roles","=","[","]","if","users",".","is_current_user_admin","(",")",":","possible_roles",".","append","(","'.admin.'",")","if","users",".","get_current_user","(",")",":","possible_roles",".","append","(","'.user.'",")","possible_roles",".","append","(","'.'",")","for","role","in","possible_roles",":","filename","=","''",".","join","(","[","handler_name",",","role",",","verb",",","'.'",",","desired_ext","]",")","if","filename","in","entries",":","return","{","'file'",":","filename",",","'dirs'",":","template_dirs","}","for","role","in","possible_roles",":","filename","=","''",".","join","(","[","handler_name",",","role",",","desired_ext","]",")","if","filename","in","entries",":","return","{","'file'",":","filename",",","'dirs'",":","template_dirs","}","return","{","'file'",":","'notfound.html'",",","'dirs'",":","template_dirs","}"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/view.py#L77-L151"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"view.py","language":"python","identifier":"ViewPage.__init__","parameters":"(self, cache_time=None)","argument_list":"","return_statement":"","docstring":"Each ViewPage has a variable cache timeout","docstring_summary":"Each ViewPage has a variable cache timeout","docstring_tokens":["Each","ViewPage","has","a","variable","cache","timeout"],"function":"def __init__(self, cache_time=None):\n \"\"\"Each ViewPage has a variable cache timeout\"\"\"\n if cache_time == None:\n self.cache_time = config.BLOG['cache_time']\n else:\n self.cache_time = cache_time","function_tokens":["def","__init__","(","self",",","cache_time","=","None",")",":","if","cache_time","==","None",":","self",".","cache_time","=","config",".","BLOG","[","'cache_time'","]","else",":","self",".","cache_time","=","cache_time"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/view.py#L154-L159"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"view.py","language":"python","identifier":"ViewPage.full_render","parameters":"(self, handler, template_info, more_params)","argument_list":"","return_statement":"return template.render(template_info['file'], template_params,\n debug=config.DEBUG, \n template_dirs=template_info['dirs'])","docstring":"Render a dynamic page from scatch.","docstring_summary":"Render a dynamic page from scatch.","docstring_tokens":["Render","a","dynamic","page","from","scatch","."],"function":"def full_render(self, handler, template_info, more_params):\n \"\"\"Render a dynamic page from scatch.\"\"\"\n logging.debug(\"Doing full render using template_file: %s\", template_info['file'])\n url = handler.request.uri\n scheme, netloc, path, query, fragment = urlparse.urlsplit(url)\n\n global NUM_FULL_RENDERS\n if not path in NUM_FULL_RENDERS:\n NUM_FULL_RENDERS[path] = 0\n NUM_FULL_RENDERS[path] += 1 # This lets us see % of cached views\n # in \/admin\/timings (see timings.py)\n tags = Tag.list()\n\n # Define some parameters it'd be nice to have in views by default.\n template_params = {\n \"current_url\": url,\n \"bloog_version\": config.BLOG['bloog_version'],\n \"user\": users.get_current_user(),\n \"user_is_admin\": users.is_current_user_admin(),\n \"login_url\": users.create_login_url(handler.request.uri),\n \"logout_url\": users.create_logout_url(handler.request.uri),\n \"blog\": config.BLOG,\n \"blog_tags\": tags\n }\n template_params.update(config.PAGE)\n template_params.update(more_params)\n return template.render(template_info['file'], template_params,\n debug=config.DEBUG, \n template_dirs=template_info['dirs'])","function_tokens":["def","full_render","(","self",",","handler",",","template_info",",","more_params",")",":","logging",".","debug","(","\"Doing full render using template_file: %s\"",",","template_info","[","'file'","]",")","url","=","handler",".","request",".","uri","scheme",",","netloc",",","path",",","query",",","fragment","=","urlparse",".","urlsplit","(","url",")","global","NUM_FULL_RENDERS","if","not","path","in","NUM_FULL_RENDERS",":","NUM_FULL_RENDERS","[","path","]","=","0","NUM_FULL_RENDERS","[","path","]","+=","1","# This lets us see % of cached views","# in \/admin\/timings (see timings.py)","tags","=","Tag",".","list","(",")","# Define some parameters it'd be nice to have in views by default.","template_params","=","{","\"current_url\"",":","url",",","\"bloog_version\"",":","config",".","BLOG","[","'bloog_version'","]",",","\"user\"",":","users",".","get_current_user","(",")",",","\"user_is_admin\"",":","users",".","is_current_user_admin","(",")",",","\"login_url\"",":","users",".","create_login_url","(","handler",".","request",".","uri",")",",","\"logout_url\"",":","users",".","create_logout_url","(","handler",".","request",".","uri",")",",","\"blog\"",":","config",".","BLOG",",","\"blog_tags\"",":","tags","}","template_params",".","update","(","config",".","PAGE",")","template_params",".","update","(","more_params",")","return","template",".","render","(","template_info","[","'file'","]",",","template_params",",","debug","=","config",".","DEBUG",",","template_dirs","=","template_info","[","'dirs'","]",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/view.py#L161-L189"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"view.py","language":"python","identifier":"ViewPage.render_or_get_cache","parameters":"(self, handler, template_info, template_params={})","argument_list":"","return_statement":"return output","docstring":"Checks if there's a non-stale cached version of this view, \n and if so, return it.","docstring_summary":"Checks if there's a non-stale cached version of this view, \n and if so, return it.","docstring_tokens":["Checks","if","there","s","a","non","-","stale","cached","version","of","this","view","and","if","so","return","it","."],"function":"def render_or_get_cache(self, handler, template_info, template_params={}):\n \"\"\"Checks if there's a non-stale cached version of this view, \n and if so, return it.\"\"\"\n user = users.get_current_user()\n key = handler.request.url\n if self.cache_time and not user:\n # See if there's a cache within time.\n # The cache key suggests a problem with the url <-> function \n # mapping, because a significant advantage of RESTful design \n # is that a distinct url gets you a distinct, cacheable \n # resource. If we have to include states like \"user?\" and \n # \"admin?\", then it suggests these flags should be in url. \n # TODO - Think about the above with respect to caching.\n try:\n data = memcache.get(key)\n except ValueError:\n data = None\n if data is not None:\n return data\n\n output = self.full_render(handler, template_info, template_params)\n if self.cache_time and not user:\n memcache.add(key, output, self.cache_time)\n return output","function_tokens":["def","render_or_get_cache","(","self",",","handler",",","template_info",",","template_params","=","{","}",")",":","user","=","users",".","get_current_user","(",")","key","=","handler",".","request",".","url","if","self",".","cache_time","and","not","user",":","# See if there's a cache within time.","# The cache key suggests a problem with the url <-> function ","# mapping, because a significant advantage of RESTful design ","# is that a distinct url gets you a distinct, cacheable ","# resource. If we have to include states like \"user?\" and ","# \"admin?\", then it suggests these flags should be in url. ","# TODO - Think about the above with respect to caching.","try",":","data","=","memcache",".","get","(","key",")","except","ValueError",":","data","=","None","if","data","is","not","None",":","return","data","output","=","self",".","full_render","(","handler",",","template_info",",","template_params",")","if","self",".","cache_time","and","not","user",":","memcache",".","add","(","key",",","output",",","self",".","cache_time",")","return","output"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/view.py#L191-L214"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"view.py","language":"python","identifier":"ViewPage.render","parameters":"(self, handler, params={})","argument_list":"","return_statement":"","docstring":"Can pass overriding parameters within dict. These parameters can \n include:\n 'ext': 'xml' (or any other format type)","docstring_summary":"Can pass overriding parameters within dict. These parameters can \n include:\n 'ext': 'xml' (or any other format type)","docstring_tokens":["Can","pass","overriding","parameters","within","dict",".","These","parameters","can","include",":","ext",":","xml","(","or","any","other","format","type",")"],"function":"def render(self, handler, params={}):\n \"\"\"\n Can pass overriding parameters within dict. These parameters can \n include:\n 'ext': 'xml' (or any other format type)\n \"\"\"\n template_info = get_view_file(handler, params)\n logging.debug(\"Using template at %s\", template_info['file'])\n output = self.render_or_get_cache(handler, template_info, params)\n handler.response.out.write(output)","function_tokens":["def","render","(","self",",","handler",",","params","=","{","}",")",":","template_info","=","get_view_file","(","handler",",","params",")","logging",".","debug","(","\"Using template at %s\"",",","template_info","[","'file'","]",")","output","=","self",".","render_or_get_cache","(","handler",",","template_info",",","params",")","handler",".","response",".","out",".","write","(","output",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/view.py#L216-L225"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"view.py","language":"python","identifier":"ViewPage.render_query","parameters":"(self, handler, model_name, query, params={},\n num_limit=config.PAGE['articles_per_page'],\n num_offset=0)","argument_list":"","return_statement":"","docstring":"Handles typical rendering of queries into datastore\n with paging.","docstring_summary":"Handles typical rendering of queries into datastore\n with paging.","docstring_tokens":["Handles","typical","rendering","of","queries","into","datastore","with","paging","."],"function":"def render_query(self, handler, model_name, query, params={},\n num_limit=config.PAGE['articles_per_page'],\n num_offset=0):\n \"\"\"\n Handles typical rendering of queries into datastore\n with paging.\n \"\"\"\n limit = string.atoi(handler.request.get(\"limit\") or str(num_limit))\n offset = string.atoi(handler.request.get(\"offset\") or str(num_offset))\n # Trick is to ask for one more than you need to see if 'next' needed.\n models = query.fetch(limit+1, offset)\n render_params = {model_name: models, 'limit': limit}\n if len(models) > limit:\n render_params.update({ 'next_offset': str(offset+limit) })\n models.pop()\n if offset > 0:\n render_params.update({ 'prev_offset': str(offset-limit) })\n render_params.update(params)\n\n self.render(handler, render_params)","function_tokens":["def","render_query","(","self",",","handler",",","model_name",",","query",",","params","=","{","}",",","num_limit","=","config",".","PAGE","[","'articles_per_page'","]",",","num_offset","=","0",")",":","limit","=","string",".","atoi","(","handler",".","request",".","get","(","\"limit\"",")","or","str","(","num_limit",")",")","offset","=","string",".","atoi","(","handler",".","request",".","get","(","\"offset\"",")","or","str","(","num_offset",")",")","# Trick is to ask for one more than you need to see if 'next' needed.","models","=","query",".","fetch","(","limit","+","1",",","offset",")","render_params","=","{","model_name",":","models",",","'limit'",":","limit","}","if","len","(","models",")",">","limit",":","render_params",".","update","(","{","'next_offset'",":","str","(","offset","+","limit",")","}",")","models",".","pop","(",")","if","offset",">","0",":","render_params",".","update","(","{","'prev_offset'",":","str","(","offset","-","limit",")","}",")","render_params",".","update","(","params",")","self",".","render","(","handler",",","render_params",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/view.py#L227-L246"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/authorized.py","language":"python","identifier":"role","parameters":"(role)","argument_list":"","return_statement":"return wrapper","docstring":"A decorator to enforce user roles, currently 'user' (logged in) \n and 'admin'.\n\n To use it, decorate your handler methods like this:\n\n import authorized\n @authorized.role(\"admin\")\n def get(self):\n user = users.GetCurrentUser(self)\n self.response.out.write('Hello, ' + user.nickname())\n\n If this decorator is applied to a GET handler, we check if the \n user is logged in and redirect her to the create_login_url() if not.\n\n For HTTP verbs other than GET, we cannot do redirects to the login \n url because the return redirects are done as GETs (not the original \n HTTP verb for the handler). So if the user is not logged in, we \n return an error.","docstring_summary":"A decorator to enforce user roles, currently 'user' (logged in) \n and 'admin'.","docstring_tokens":["A","decorator","to","enforce","user","roles","currently","user","(","logged","in",")","and","admin","."],"function":"def role(role):\n \"\"\"\n A decorator to enforce user roles, currently 'user' (logged in) \n and 'admin'.\n\n To use it, decorate your handler methods like this:\n\n import authorized\n @authorized.role(\"admin\")\n def get(self):\n user = users.GetCurrentUser(self)\n self.response.out.write('Hello, ' + user.nickname())\n\n If this decorator is applied to a GET handler, we check if the \n user is logged in and redirect her to the create_login_url() if not.\n\n For HTTP verbs other than GET, we cannot do redirects to the login \n url because the return redirects are done as GETs (not the original \n HTTP verb for the handler). So if the user is not logged in, we \n return an error.\n \"\"\"\n def wrapper(handler_method):\n def check_login(self, *args, **kwargs):\n user = users.get_current_user()\n if not user:\n if self.request.method != 'GET':\n logging.debug(\"Not user - aborting\")\n self.error(403)\n else:\n logging.debug(\"User not logged in -- force login\")\n self.redirect(users.create_login_url(self.request.uri))\n elif role == \"user\" or (role == \"admin\" and \n users.is_current_user_admin()):\n logging.debug(\"Role is %s so will allow handler\", role)\n handler_method(self, *args, **kwargs)\n else:\n if self.request.method == 'GET':\n logging.debug(\"Unknown role (%s) on GET\", role)\n self.redirect(\"\/403.html\")\n else:\n logging.debug(\"Unknown role: %s\", role)\n self.error(403) # User didn't meet role. \n # TODO: Give better feedback\/status code.\n return check_login\n return wrapper","function_tokens":["def","role","(","role",")",":","def","wrapper","(","handler_method",")",":","def","check_login","(","self",",","*","args",",","*","*","kwargs",")",":","user","=","users",".","get_current_user","(",")","if","not","user",":","if","self",".","request",".","method","!=","'GET'",":","logging",".","debug","(","\"Not user - aborting\"",")","self",".","error","(","403",")","else",":","logging",".","debug","(","\"User not logged in -- force login\"",")","self",".","redirect","(","users",".","create_login_url","(","self",".","request",".","uri",")",")","elif","role","==","\"user\"","or","(","role","==","\"admin\"","and","users",".","is_current_user_admin","(",")",")",":","logging",".","debug","(","\"Role is %s so will allow handler\"",",","role",")","handler_method","(","self",",","*","args",",","*","*","kwargs",")","else",":","if","self",".","request",".","method","==","'GET'",":","logging",".","debug","(","\"Unknown role (%s) on GET\"",",","role",")","self",".","redirect","(","\"\/403.html\"",")","else",":","logging",".","debug","(","\"Unknown role: %s\"",",","role",")","self",".","error","(","403",")","# User didn't meet role. ","# TODO: Give better feedback\/status code.","return","check_login","return","wrapper"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/authorized.py#L35-L79"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/template.py","language":"python","identifier":"render","parameters":"(template_path, template_dict, debug=False, template_dirs=())","argument_list":"","return_statement":"return t.render(Context(template_dict))","docstring":"Renders the template at the given path with the given dict of values.\n\n Example usage:\n render(\"templates\/index.html\", {\"name\": \"Bret\", \"values\": [1, 2, 3]})\n\n Args:\n template_path: path to a Django template\n template_dict: dictionary of values to apply to the template","docstring_summary":"Renders the template at the given path with the given dict of values.","docstring_tokens":["Renders","the","template","at","the","given","path","with","the","given","dict","of","values","."],"function":"def render(template_path, template_dict, debug=False, template_dirs=()):\n \"\"\"Renders the template at the given path with the given dict of values.\n\n Example usage:\n render(\"templates\/index.html\", {\"name\": \"Bret\", \"values\": [1, 2, 3]})\n\n Args:\n template_path: path to a Django template\n template_dict: dictionary of values to apply to the template\n \"\"\"\n t = load(template_path, debug, template_dirs)\n return t.render(Context(template_dict))","function_tokens":["def","render","(","template_path",",","template_dict",",","debug","=","False",",","template_dirs","=","(",")",")",":","t","=","load","(","template_path",",","debug",",","template_dirs",")","return","t",".","render","(","Context","(","template_dict",")",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/template.py#L71-L82"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/template.py","language":"python","identifier":"load","parameters":"(path, debug=False, template_dirs=())","argument_list":"","return_statement":"return template","docstring":"Loads the Django template from the given path.\n\n It is better to use this function than to construct a Template using the\n class below because Django requires you to load the template with a method\n if you want imports and extends to work in the template.","docstring_summary":"Loads the Django template from the given path.","docstring_tokens":["Loads","the","Django","template","from","the","given","path","."],"function":"def load(path, debug=False, template_dirs=()):\n \"\"\"Loads the Django template from the given path.\n\n It is better to use this function than to construct a Template using the\n class below because Django requires you to load the template with a method\n if you want imports and extends to work in the template.\n \"\"\"\n abspath = os.path.abspath(path)\n\n if not debug:\n template = template_cache.get(abspath, None)\n else:\n template = None\n\n if not template:\n directory, file_name = os.path.split(abspath)\n if directory:\n template_dirs = [directory] + template_dirs\n new_settings = {\n 'TEMPLATE_DIRS': template_dirs,\n 'TEMPLATE_DEBUG': debug,\n 'DEBUG': debug,\n }\n old_settings = _swap_settings(new_settings)\n try:\n template = django.template.loader.get_template(file_name)\n finally:\n _swap_settings(old_settings)\n\n if not debug:\n template_cache[abspath] = template\n\n def wrap_render(context, orig_render=template.render):\n URLNode = django.template.defaulttags.URLNode\n save_urlnode_render = URLNode.render\n old_settings = _swap_settings(new_settings)\n try:\n URLNode.render = _urlnode_render_replacement\n return orig_render(context)\n finally:\n _swap_settings(old_settings)\n URLNode.render = save_urlnode_render\n\n template.render = wrap_render\n\n return template","function_tokens":["def","load","(","path",",","debug","=","False",",","template_dirs","=","(",")",")",":","abspath","=","os",".","path",".","abspath","(","path",")","if","not","debug",":","template","=","template_cache",".","get","(","abspath",",","None",")","else",":","template","=","None","if","not","template",":","directory",",","file_name","=","os",".","path",".","split","(","abspath",")","if","directory",":","template_dirs","=","[","directory","]","+","template_dirs","new_settings","=","{","'TEMPLATE_DIRS'",":","template_dirs",",","'TEMPLATE_DEBUG'",":","debug",",","'DEBUG'",":","debug",",","}","old_settings","=","_swap_settings","(","new_settings",")","try",":","template","=","django",".","template",".","loader",".","get_template","(","file_name",")","finally",":","_swap_settings","(","old_settings",")","if","not","debug",":","template_cache","[","abspath","]","=","template","def","wrap_render","(","context",",","orig_render","=","template",".","render",")",":","URLNode","=","django",".","template",".","defaulttags",".","URLNode","save_urlnode_render","=","URLNode",".","render","old_settings","=","_swap_settings","(","new_settings",")","try",":","URLNode",".","render","=","_urlnode_render_replacement","return","orig_render","(","context",")","finally",":","_swap_settings","(","old_settings",")","URLNode",".","render","=","save_urlnode_render","template",".","render","=","wrap_render","return","template"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/template.py#L86-L131"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/template.py","language":"python","identifier":"_swap_settings","parameters":"(new)","argument_list":"","return_statement":"return old","docstring":"Swap in selected Django settings, returning old settings.\n\n Example:\n save = _swap_settings({'X': 1, 'Y': 2})\n try:\n ...new settings for X and Y are in effect here...\n finally:\n _swap_settings(save)\n\n Args:\n new: A dict containing settings to change; the keys should\n be setting names and the values settings values.\n\n Returns:\n Another dict structured the same was as the argument containing\n the original settings. Original settings that were not set at all\n are returned as None, and will be restored as None by the\n 'finally' clause in the example above. This shouldn't matter; we\n can't delete settings that are given as None, since None is also a\n legitimate value for some settings. Creating a separate flag value\n for 'unset' settings seems overkill as there is no known use case.","docstring_summary":"Swap in selected Django settings, returning old settings.","docstring_tokens":["Swap","in","selected","Django","settings","returning","old","settings","."],"function":"def _swap_settings(new):\n \"\"\"Swap in selected Django settings, returning old settings.\n\n Example:\n save = _swap_settings({'X': 1, 'Y': 2})\n try:\n ...new settings for X and Y are in effect here...\n finally:\n _swap_settings(save)\n\n Args:\n new: A dict containing settings to change; the keys should\n be setting names and the values settings values.\n\n Returns:\n Another dict structured the same was as the argument containing\n the original settings. Original settings that were not set at all\n are returned as None, and will be restored as None by the\n 'finally' clause in the example above. This shouldn't matter; we\n can't delete settings that are given as None, since None is also a\n legitimate value for some settings. Creating a separate flag value\n for 'unset' settings seems overkill as there is no known use case.\n \"\"\"\n settings = django.conf.settings\n old = {}\n for key, value in new.iteritems():\n old[key] = getattr(settings, key, None)\n setattr(settings, key, value)\n return old","function_tokens":["def","_swap_settings","(","new",")",":","settings","=","django",".","conf",".","settings","old","=","{","}","for","key",",","value","in","new",".","iteritems","(",")",":","old","[","key","]","=","getattr","(","settings",",","key",",","None",")","setattr","(","settings",",","key",",","value",")","return","old"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/template.py#L134-L162"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/template.py","language":"python","identifier":"create_template_register","parameters":"()","argument_list":"","return_statement":"return django.template.Library()","docstring":"Used to extend the Django template library with custom filters and tags.\n\n To extend the template library with a custom filter module, create a Python\n module, and create a module-level variable named \"register\", and register\n all custom filters to it as described at\n http:\/\/www.djangoproject.com\/documentation\/templates_python\/\n #extending-the-template-system:\n\n templatefilters.py\n ==================\n register = webapp.template.create_template_register()\n\n def cut(value, arg):\n return value.replace(arg, '')\n register.filter(cut)\n\n Then, register the custom template module with the register_template_module\n function below in your application module:\n\n myapp.py\n ========\n webapp.template.register_template_module('templatefilters')","docstring_summary":"Used to extend the Django template library with custom filters and tags.","docstring_tokens":["Used","to","extend","the","Django","template","library","with","custom","filters","and","tags","."],"function":"def create_template_register():\n \"\"\"Used to extend the Django template library with custom filters and tags.\n\n To extend the template library with a custom filter module, create a Python\n module, and create a module-level variable named \"register\", and register\n all custom filters to it as described at\n http:\/\/www.djangoproject.com\/documentation\/templates_python\/\n #extending-the-template-system:\n\n templatefilters.py\n ==================\n register = webapp.template.create_template_register()\n\n def cut(value, arg):\n return value.replace(arg, '')\n register.filter(cut)\n\n Then, register the custom template module with the register_template_module\n function below in your application module:\n\n myapp.py\n ========\n webapp.template.register_template_module('templatefilters')\n \"\"\"\n return django.template.Library()","function_tokens":["def","create_template_register","(",")",":","return","django",".","template",".","Library","(",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/template.py#L165-L189"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/template.py","language":"python","identifier":"register_template_library","parameters":"(package_name)","argument_list":"","return_statement":"","docstring":"Registers a template extension module to make it usable in templates.\n\n See the documentation for create_template_register for more information.","docstring_summary":"Registers a template extension module to make it usable in templates.","docstring_tokens":["Registers","a","template","extension","module","to","make","it","usable","in","templates","."],"function":"def register_template_library(package_name):\n \"\"\"Registers a template extension module to make it usable in templates.\n\n See the documentation for create_template_register for more information.\"\"\"\n if not django.template.libraries.get(package_name, None):\n django.template.add_to_builtins(package_name)","function_tokens":["def","register_template_library","(","package_name",")",":","if","not","django",".","template",".","libraries",".","get","(","package_name",",","None",")",":","django",".","template",".","add_to_builtins","(","package_name",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/template.py#L192-L197"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/template.py","language":"python","identifier":"_urlnode_render_replacement","parameters":"(self, context)","argument_list":"","return_statement":"","docstring":"Replacement for django's {% url %} block.\n\n This version uses WSGIApplication's url mapping to create urls.\n\n Examples:\n\n \n {% url MyPageHandler implicit_args=False %}\n {% url MyPageHandler \"calendar\" %}\n {% url MyPageHandler \"jsmith\",\"calendar\" %}","docstring_summary":"Replacement for django's {% url %} block.","docstring_tokens":["Replacement","for","django","s","{","%","url","%","}","block","."],"function":"def _urlnode_render_replacement(self, context):\n \"\"\"Replacement for django's {% url %} block.\n\n This version uses WSGIApplication's url mapping to create urls.\n\n Examples:\n\n \n {% url MyPageHandler implicit_args=False %}\n {% url MyPageHandler \"calendar\" %}\n {% url MyPageHandler \"jsmith\",\"calendar\" %}\n \"\"\"\n args = [arg.resolve(context) for arg in self.args]\n try:\n app = webapp.WSGIApplication.active_instance\n handler = app.get_registered_handler_by_name(self.view_name)\n return handler.get_url(implicit_args=True, *args)\n except webapp.NoUrlFoundError:\n return ''","function_tokens":["def","_urlnode_render_replacement","(","self",",","context",")",":","args","=","[","arg",".","resolve","(","context",")","for","arg","in","self",".","args","]","try",":","app","=","webapp",".","WSGIApplication",".","active_instance","handler","=","app",".","get_registered_handler_by_name","(","self",".","view_name",")","return","handler",".","get_url","(","implicit_args","=","True",",","*","args",")","except","webapp",".","NoUrlFoundError",":","return","''"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/template.py#L204-L222"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/codehighlighter.py","language":"python","identifier":"process_html","parameters":"(html)","argument_list":"","return_statement":"return clean_html.decode('utf-8'), list_language_files","docstring":"Processes HTML for embedded code using SyntaxHighlighter\n \n Determines languages used by checking class attribute of pre tags\n with name=\"code\".\n\n Args:\n html: HTML to be processed for embedded code\n\n Returns:\n The modified html and a list of strings giving the embedded\n code languages.","docstring_summary":"Processes HTML for embedded code using SyntaxHighlighter\n \n Determines languages used by checking class attribute of pre tags\n with name=\"code\".","docstring_tokens":["Processes","HTML","for","embedded","code","using","SyntaxHighlighter","Determines","languages","used","by","checking","class","attribute","of","pre","tags","with","name","=","code","."],"function":"def process_html(html):\n \"\"\"Processes HTML for embedded code using SyntaxHighlighter\n \n Determines languages used by checking class attribute of pre tags\n with name=\"code\".\n\n Args:\n html: HTML to be processed for embedded code\n\n Returns:\n The modified html and a list of strings giving the embedded\n code languages.\n \"\"\"\n code_tag = re.compile('\\s*
', \n                          re.MULTILINE)\n    languages = set([])\n    soup = BeautifulSoup(html)\n    clean_html = ''\n    for section in soup.contents:\n        txt = str(section)\n        matchobj = re.match(code_tag, txt)\n        if matchobj:\n            languages.add(matchobj.group(1))\n            clean_html += re.sub(r'
', \"\\n\", txt)\n else:\n clean_html += txt\n \n # Map the language class names to the spelling for javascript files\n list_language_files = [language_jsfiles[lang] for lang in list(languages)]\n return clean_html.decode('utf-8'), list_language_files","function_tokens":["def","process_html","(","html",")",":","code_tag","=","re",".","compile","(","'\\s*
'",",","re",".","MULTILINE",")","languages","=","set","(","[","]",")","soup","=","BeautifulSoup","(","html",")","clean_html","=","''","for","section","in","soup",".","contents",":","txt","=","str","(","section",")","matchobj","=","re",".","match","(","code_tag",",","txt",")","if","matchobj",":","languages",".","add","(","matchobj",".","group","(","1",")",")","clean_html","+=","re",".","sub","(","r'
'",",","\"\\n\"",",","txt",")","else",":","clean_html","+=","txt","# Map the language class names to the spelling for javascript files","list_language_files","=","[","language_jsfiles","[","lang","]","for","lang","in","list","(","languages",")","]","return","clean_html",".","decode","(","'utf-8'",")",",","list_language_files"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/codehighlighter.py#L40-L69"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/sanitizer.py","language":"python","identifier":"sanitize_html","parameters":"(html='

No comment<\/p>', encoding=None,\n allow_tags=[], allow_attributes=[],\n blacklist_tags=[], blacklist_attributes=[],\n trusted_source=False)","argument_list":"","return_statement":"return soup.renderContents().decode('utf-8')","docstring":"Parses HTML and tries to sanitize it using white list.\n \n This method is a mishmash of code from Django snippets\n (http:\/\/www.djangosnippets.org\/snippets\/169) and the\n HTML sanitization of Universal Feed Parser. It explicitly\n looks for valid hrefs to prevent scripts lurking in there.\n Unfortunately, style, either as a tag or attribute, can\n contain malicious script through executable CSS definitions.\n So sanitized HTML cannot be colored or highlighted using styles.\n\n Args:\n html: HTML to be sanitized.\n allow_tags: limit all tags to just this list\n allow_attributes: limit all tags to just this list\n allow_styling: should only be TRUE if you trust source\n\n Returns:\n Sanitized version of html\n\n Raises:\n DangerousHTMLError if the supplied HTML has dangerous elements.","docstring_summary":"Parses HTML and tries to sanitize it using white list.\n \n This method is a mishmash of code from Django snippets\n (http:\/\/www.djangosnippets.org\/snippets\/169) and the\n HTML sanitization of Universal Feed Parser. It explicitly\n looks for valid hrefs to prevent scripts lurking in there.\n Unfortunately, style, either as a tag or attribute, can\n contain malicious script through executable CSS definitions.\n So sanitized HTML cannot be colored or highlighted using styles.","docstring_tokens":["Parses","HTML","and","tries","to","sanitize","it","using","white","list",".","This","method","is","a","mishmash","of","code","from","Django","snippets","(","http",":","\/\/","www",".","djangosnippets",".","org","\/","snippets","\/","169",")","and","the","HTML","sanitization","of","Universal","Feed","Parser",".","It","explicitly","looks","for","valid","hrefs","to","prevent","scripts","lurking","in","there",".","Unfortunately","style","either","as","a","tag","or","attribute","can","contain","malicious","script","through","executable","CSS","definitions",".","So","sanitized","HTML","cannot","be","colored","or","highlighted","using","styles","."],"function":"def sanitize_html(html='

No comment<\/p>', encoding=None,\n allow_tags=[], allow_attributes=[],\n blacklist_tags=[], blacklist_attributes=[],\n trusted_source=False):\n \"\"\"Parses HTML and tries to sanitize it using white list.\n \n This method is a mishmash of code from Django snippets\n (http:\/\/www.djangosnippets.org\/snippets\/169) and the\n HTML sanitization of Universal Feed Parser. It explicitly\n looks for valid hrefs to prevent scripts lurking in there.\n Unfortunately, style, either as a tag or attribute, can\n contain malicious script through executable CSS definitions.\n So sanitized HTML cannot be colored or highlighted using styles.\n\n Args:\n html: HTML to be sanitized.\n allow_tags: limit all tags to just this list\n allow_attributes: limit all tags to just this list\n allow_styling: should only be TRUE if you trust source\n\n Returns:\n Sanitized version of html\n\n Raises:\n DangerousHTMLError if the supplied HTML has dangerous elements.\n \"\"\"\n if not allow_tags:\n allow_tags = acceptable_tags\n if not allow_attributes:\n allow_attributes = acceptable_attributes\n allow_tags = [tag for tag in allow_tags if tag not in blacklist_tags]\n allow_attributes = [tag for tag in allow_attributes \n if tag not in blacklist_tags]\n if trusted_source:\n allow_attributes += attributes_for_trusted_source\n allow_tags += tags_for_trusted_source\n\n if isinstance(html, unicode) and not encoding:\n logging.debug(\"Sanitizing unicode input.\")\n soup = BeautifulSoup(html, \n convertEntities=BeautifulSoup.XHTML_ENTITIES)\n else:\n if not encoding:\n encoding = 'latin-1'\n logging.debug(\"Sanitizing string input, assuming %s\", encoding)\n soup = BeautifulSoup(html.decode(encoding, 'ignore'),\n convertEntities=BeautifulSoup.XHTML_ENTITIES)\n for comment in soup.findAll(\n text = lambda text: isinstance(text, Comment)):\n comment.extract()\n for tag in soup.findAll(True):\n if tag.name not in allow_tags:\n tag.hidden = True\n if tag.name in danger_elements:\n raise DangerousHTMLError(html)\n ok_attrs = []\n for attr, val in tag.attrs:\n if attr == 'href' and not href_matcher.match(val) and not trusted_source:\n continue\n if attr in allow_attributes:\n if attr in js_possible_attributes:\n if javascript_matcher.match(val):\n raise DangerousHTMLError(html)\n ok_attrs += [(attr, val)]\n tag.attrs = ok_attrs\n return soup.renderContents().decode('utf-8')","function_tokens":["def","sanitize_html","(","html","=","'

No comment<\/p>'",",","encoding","=","None",",","allow_tags","=","[","]",",","allow_attributes","=","[","]",",","blacklist_tags","=","[","]",",","blacklist_attributes","=","[","]",",","trusted_source","=","False",")",":","if","not","allow_tags",":","allow_tags","=","acceptable_tags","if","not","allow_attributes",":","allow_attributes","=","acceptable_attributes","allow_tags","=","[","tag","for","tag","in","allow_tags","if","tag","not","in","blacklist_tags","]","allow_attributes","=","[","tag","for","tag","in","allow_attributes","if","tag","not","in","blacklist_tags","]","if","trusted_source",":","allow_attributes","+=","attributes_for_trusted_source","allow_tags","+=","tags_for_trusted_source","if","isinstance","(","html",",","unicode",")","and","not","encoding",":","logging",".","debug","(","\"Sanitizing unicode input.\"",")","soup","=","BeautifulSoup","(","html",",","convertEntities","=","BeautifulSoup",".","XHTML_ENTITIES",")","else",":","if","not","encoding",":","encoding","=","'latin-1'","logging",".","debug","(","\"Sanitizing string input, assuming %s\"",",","encoding",")","soup","=","BeautifulSoup","(","html",".","decode","(","encoding",",","'ignore'",")",",","convertEntities","=","BeautifulSoup",".","XHTML_ENTITIES",")","for","comment","in","soup",".","findAll","(","text","=","lambda","text",":","isinstance","(","text",",","Comment",")",")",":","comment",".","extract","(",")","for","tag","in","soup",".","findAll","(","True",")",":","if","tag",".","name","not","in","allow_tags",":","tag",".","hidden","=","True","if","tag",".","name","in","danger_elements",":","raise","DangerousHTMLError","(","html",")","ok_attrs","=","[","]","for","attr",",","val","in","tag",".","attrs",":","if","attr","==","'href'","and","not","href_matcher",".","match","(","val",")","and","not","trusted_source",":","continue","if","attr","in","allow_attributes",":","if","attr","in","js_possible_attributes",":","if","javascript_matcher",".","match","(","val",")",":","raise","DangerousHTMLError","(","html",")","ok_attrs","+=","[","(","attr",",","val",")","]","tag",".","attrs","=","ok_attrs","return","soup",".","renderContents","(",")",".","decode","(","'utf-8'",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/sanitizer.py#L66-L131"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/sanitizer.py","language":"python","identifier":"chop_up","parameters":"(text, chop_size=5)","argument_list":"","return_statement":"return [text[i*chop_size:min(chars,(i+1)*chop_size)] \n for i in xrange(0, blocks)]","docstring":"Returns a list of smaller chunks of text","docstring_summary":"Returns a list of smaller chunks of text","docstring_tokens":["Returns","a","list","of","smaller","chunks","of","text"],"function":"def chop_up(text, chop_size=5):\n \"Returns a list of smaller chunks of text\"\n chars = len(text)\n blocks = chars \/ chop_size\n if chars % chop_size:\n blocks += 1\n return [text[i*chop_size:min(chars,(i+1)*chop_size)] \n for i in xrange(0, blocks)]","function_tokens":["def","chop_up","(","text",",","chop_size","=","5",")",":","chars","=","len","(","text",")","blocks","=","chars","\/","chop_size","if","chars","%","chop_size",":","blocks","+=","1","return","[","text","[","i","*","chop_size",":","min","(","chars",",","(","i","+","1",")","*","chop_size",")","]","for","i","in","xrange","(","0",",","blocks",")","]"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/sanitizer.py#L133-L140"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"isList","parameters":"(l)","argument_list":"","return_statement":"return hasattr(l, '__iter__') \\\n or (type(l) in (types.ListType, types.TupleType))","docstring":"Convenience method that works with all 2.x versions of Python\n to determine whether or not something is listlike.","docstring_summary":"Convenience method that works with all 2.x versions of Python\n to determine whether or not something is listlike.","docstring_tokens":["Convenience","method","that","works","with","all","2",".","x","versions","of","Python","to","determine","whether","or","not","something","is","listlike","."],"function":"def isList(l):\n \"\"\"Convenience method that works with all 2.x versions of Python\n to determine whether or not something is listlike.\"\"\"\n return hasattr(l, '__iter__') \\\n or (type(l) in (types.ListType, types.TupleType))","function_tokens":["def","isList","(","l",")",":","return","hasattr","(","l",",","'__iter__'",")","or","(","type","(","l",")","in","(","types",".","ListType",",","types",".","TupleType",")",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L946-L950"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"isString","parameters":"(s)","argument_list":"","return_statement":"","docstring":"Convenience method that works with all 2.x versions of Python\n to determine whether or not something is stringlike.","docstring_summary":"Convenience method that works with all 2.x versions of Python\n to determine whether or not something is stringlike.","docstring_tokens":["Convenience","method","that","works","with","all","2",".","x","versions","of","Python","to","determine","whether","or","not","something","is","stringlike","."],"function":"def isString(s):\n \"\"\"Convenience method that works with all 2.x versions of Python\n to determine whether or not something is stringlike.\"\"\"\n try:\n return isinstance(s, unicode) or isinstance(s, basestring)\n except NameError:\n return isinstance(s, str)","function_tokens":["def","isString","(","s",")",":","try",":","return","isinstance","(","s",",","unicode",")","or","isinstance","(","s",",","basestring",")","except","NameError",":","return","isinstance","(","s",",","str",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L952-L958"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"buildTagMap","parameters":"(default, *args)","argument_list":"","return_statement":"return built","docstring":"Turns a list of maps, lists, or scalars into a single map.\n Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and\n NESTING_RESET_TAGS maps out of lists and partial maps.","docstring_summary":"Turns a list of maps, lists, or scalars into a single map.\n Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and\n NESTING_RESET_TAGS maps out of lists and partial maps.","docstring_tokens":["Turns","a","list","of","maps","lists","or","scalars","into","a","single","map",".","Used","to","build","the","SELF_CLOSING_TAGS","NESTABLE_TAGS","and","NESTING_RESET_TAGS","maps","out","of","lists","and","partial","maps","."],"function":"def buildTagMap(default, *args):\n \"\"\"Turns a list of maps, lists, or scalars into a single map.\n Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and\n NESTING_RESET_TAGS maps out of lists and partial maps.\"\"\"\n built = {}\n for portion in args:\n if hasattr(portion, 'items'):\n #It's a map. Merge it.\n for k,v in portion.items():\n built[k] = v\n elif isList(portion):\n #It's a list. Map each item to the default.\n for k in portion:\n built[k] = default\n else:\n #It's a scalar. Map it to the default.\n built[portion] = default\n return built","function_tokens":["def","buildTagMap","(","default",",","*","args",")",":","built","=","{","}","for","portion","in","args",":","if","hasattr","(","portion",",","'items'",")",":","#It's a map. Merge it.","for","k",",","v","in","portion",".","items","(",")",":","built","[","k","]","=","v","elif","isList","(","portion",")",":","#It's a list. Map each item to the default.","for","k","in","portion",":","built","[","k","]","=","default","else",":","#It's a scalar. Map it to the default.","built","[","portion","]","=","default","return","built"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L960-L977"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.setup","parameters":"(self, parent=None, previous=None)","argument_list":"","return_statement":"","docstring":"Sets up the initial relations between this element and\n other elements.","docstring_summary":"Sets up the initial relations between this element and\n other elements.","docstring_tokens":["Sets","up","the","initial","relations","between","this","element","and","other","elements","."],"function":"def setup(self, parent=None, previous=None):\n \"\"\"Sets up the initial relations between this element and\n other elements.\"\"\"\n self.parent = parent\n self.previous = previous\n self.next = None\n self.previousSibling = None\n self.nextSibling = None\n if self.parent and self.parent.contents:\n self.previousSibling = self.parent.contents[-1]\n self.previousSibling.nextSibling = self","function_tokens":["def","setup","(","self",",","parent","=","None",",","previous","=","None",")",":","self",".","parent","=","parent","self",".","previous","=","previous","self",".","next","=","None","self",".","previousSibling","=","None","self",".","nextSibling","=","None","if","self",".","parent","and","self",".","parent",".","contents",":","self",".","previousSibling","=","self",".","parent",".","contents","[","-","1","]","self",".","previousSibling",".","nextSibling","=","self"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L113-L123"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.extract","parameters":"(self)","argument_list":"","return_statement":"return self","docstring":"Destructively rips this element out of the tree.","docstring_summary":"Destructively rips this element out of the tree.","docstring_tokens":["Destructively","rips","this","element","out","of","the","tree","."],"function":"def extract(self):\n \"\"\"Destructively rips this element out of the tree.\"\"\"\n if self.parent:\n try:\n self.parent.contents.remove(self)\n except ValueError:\n pass\n\n #Find the two elements that would be next to each other if\n #this element (and any children) hadn't been parsed. Connect\n #the two.\n lastChild = self._lastRecursiveChild()\n nextElement = lastChild.next\n\n if self.previous:\n self.previous.next = nextElement\n if nextElement:\n nextElement.previous = self.previous\n self.previous = None\n lastChild.next = None\n\n self.parent = None\n if self.previousSibling:\n self.previousSibling.nextSibling = self.nextSibling\n if self.nextSibling:\n self.nextSibling.previousSibling = self.previousSibling\n self.previousSibling = self.nextSibling = None\n return self","function_tokens":["def","extract","(","self",")",":","if","self",".","parent",":","try",":","self",".","parent",".","contents",".","remove","(","self",")","except","ValueError",":","pass","#Find the two elements that would be next to each other if","#this element (and any children) hadn't been parsed. Connect","#the two.","lastChild","=","self",".","_lastRecursiveChild","(",")","nextElement","=","lastChild",".","next","if","self",".","previous",":","self",".","previous",".","next","=","nextElement","if","nextElement",":","nextElement",".","previous","=","self",".","previous","self",".","previous","=","None","lastChild",".","next","=","None","self",".","parent","=","None","if","self",".","previousSibling",":","self",".","previousSibling",".","nextSibling","=","self",".","nextSibling","if","self",".","nextSibling",":","self",".","nextSibling",".","previousSibling","=","self",".","previousSibling","self",".","previousSibling","=","self",".","nextSibling","=","None","return","self"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L139-L166"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement._lastRecursiveChild","parameters":"(self)","argument_list":"","return_statement":"return lastChild","docstring":"Finds the last element beneath this object to be parsed.","docstring_summary":"Finds the last element beneath this object to be parsed.","docstring_tokens":["Finds","the","last","element","beneath","this","object","to","be","parsed","."],"function":"def _lastRecursiveChild(self):\n \"Finds the last element beneath this object to be parsed.\"\n lastChild = self\n while hasattr(lastChild, 'contents') and lastChild.contents:\n lastChild = lastChild.contents[-1]\n return lastChild","function_tokens":["def","_lastRecursiveChild","(","self",")",":","lastChild","=","self","while","hasattr","(","lastChild",",","'contents'",")","and","lastChild",".","contents",":","lastChild","=","lastChild",".","contents","[","-","1","]","return","lastChild"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L168-L173"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.append","parameters":"(self, tag)","argument_list":"","return_statement":"","docstring":"Appends the given tag to the contents of this tag.","docstring_summary":"Appends the given tag to the contents of this tag.","docstring_tokens":["Appends","the","given","tag","to","the","contents","of","this","tag","."],"function":"def append(self, tag):\n \"\"\"Appends the given tag to the contents of this tag.\"\"\"\n self.insert(len(self.contents), tag)","function_tokens":["def","append","(","self",",","tag",")",":","self",".","insert","(","len","(","self",".","contents",")",",","tag",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L235-L237"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findNext","parameters":"(self, name=None, attrs={}, text=None, **kwargs)","argument_list":"","return_statement":"return self._findOne(self.findAllNext, name, attrs, text, **kwargs)","docstring":"Returns the first item that matches the given criteria and\n appears after this Tag in the document.","docstring_summary":"Returns the first item that matches the given criteria and\n appears after this Tag in the document.","docstring_tokens":["Returns","the","first","item","that","matches","the","given","criteria","and","appears","after","this","Tag","in","the","document","."],"function":"def findNext(self, name=None, attrs={}, text=None, **kwargs):\n \"\"\"Returns the first item that matches the given criteria and\n appears after this Tag in the document.\"\"\"\n return self._findOne(self.findAllNext, name, attrs, text, **kwargs)","function_tokens":["def","findNext","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","*","*","kwargs",")",":","return","self",".","_findOne","(","self",".","findAllNext",",","name",",","attrs",",","text",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L239-L242"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findAllNext","parameters":"(self, name=None, attrs={}, text=None, limit=None,\n **kwargs)","argument_list":"","return_statement":"return self._findAll(name, attrs, text, limit, self.nextGenerator,\n **kwargs)","docstring":"Returns all items that match the given criteria and appear\n after this Tag in the document.","docstring_summary":"Returns all items that match the given criteria and appear\n after this Tag in the document.","docstring_tokens":["Returns","all","items","that","match","the","given","criteria","and","appear","after","this","Tag","in","the","document","."],"function":"def findAllNext(self, name=None, attrs={}, text=None, limit=None,\n **kwargs):\n \"\"\"Returns all items that match the given criteria and appear\n after this Tag in the document.\"\"\"\n return self._findAll(name, attrs, text, limit, self.nextGenerator,\n **kwargs)","function_tokens":["def","findAllNext","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","limit","=","None",",","*","*","kwargs",")",":","return","self",".","_findAll","(","name",",","attrs",",","text",",","limit",",","self",".","nextGenerator",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L244-L249"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findNextSibling","parameters":"(self, name=None, attrs={}, text=None, **kwargs)","argument_list":"","return_statement":"return self._findOne(self.findNextSiblings, name, attrs, text,\n **kwargs)","docstring":"Returns the closest sibling to this Tag that matches the\n given criteria and appears after this Tag in the document.","docstring_summary":"Returns the closest sibling to this Tag that matches the\n given criteria and appears after this Tag in the document.","docstring_tokens":["Returns","the","closest","sibling","to","this","Tag","that","matches","the","given","criteria","and","appears","after","this","Tag","in","the","document","."],"function":"def findNextSibling(self, name=None, attrs={}, text=None, **kwargs):\n \"\"\"Returns the closest sibling to this Tag that matches the\n given criteria and appears after this Tag in the document.\"\"\"\n return self._findOne(self.findNextSiblings, name, attrs, text,\n **kwargs)","function_tokens":["def","findNextSibling","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","*","*","kwargs",")",":","return","self",".","_findOne","(","self",".","findNextSiblings",",","name",",","attrs",",","text",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L251-L255"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findNextSiblings","parameters":"(self, name=None, attrs={}, text=None, limit=None,\n **kwargs)","argument_list":"","return_statement":"return self._findAll(name, attrs, text, limit,\n self.nextSiblingGenerator, **kwargs)","docstring":"Returns the siblings of this Tag that match the given\n criteria and appear after this Tag in the document.","docstring_summary":"Returns the siblings of this Tag that match the given\n criteria and appear after this Tag in the document.","docstring_tokens":["Returns","the","siblings","of","this","Tag","that","match","the","given","criteria","and","appear","after","this","Tag","in","the","document","."],"function":"def findNextSiblings(self, name=None, attrs={}, text=None, limit=None,\n **kwargs):\n \"\"\"Returns the siblings of this Tag that match the given\n criteria and appear after this Tag in the document.\"\"\"\n return self._findAll(name, attrs, text, limit,\n self.nextSiblingGenerator, **kwargs)","function_tokens":["def","findNextSiblings","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","limit","=","None",",","*","*","kwargs",")",":","return","self",".","_findAll","(","name",",","attrs",",","text",",","limit",",","self",".","nextSiblingGenerator",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L257-L262"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findPrevious","parameters":"(self, name=None, attrs={}, text=None, **kwargs)","argument_list":"","return_statement":"return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs)","docstring":"Returns the first item that matches the given criteria and\n appears before this Tag in the document.","docstring_summary":"Returns the first item that matches the given criteria and\n appears before this Tag in the document.","docstring_tokens":["Returns","the","first","item","that","matches","the","given","criteria","and","appears","before","this","Tag","in","the","document","."],"function":"def findPrevious(self, name=None, attrs={}, text=None, **kwargs):\n \"\"\"Returns the first item that matches the given criteria and\n appears before this Tag in the document.\"\"\"\n return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs)","function_tokens":["def","findPrevious","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","*","*","kwargs",")",":","return","self",".","_findOne","(","self",".","findAllPrevious",",","name",",","attrs",",","text",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L265-L268"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findAllPrevious","parameters":"(self, name=None, attrs={}, text=None, limit=None,\n **kwargs)","argument_list":"","return_statement":"return self._findAll(name, attrs, text, limit, self.previousGenerator,\n **kwargs)","docstring":"Returns all items that match the given criteria and appear\n before this Tag in the document.","docstring_summary":"Returns all items that match the given criteria and appear\n before this Tag in the document.","docstring_tokens":["Returns","all","items","that","match","the","given","criteria","and","appear","before","this","Tag","in","the","document","."],"function":"def findAllPrevious(self, name=None, attrs={}, text=None, limit=None,\n **kwargs):\n \"\"\"Returns all items that match the given criteria and appear\n before this Tag in the document.\"\"\"\n return self._findAll(name, attrs, text, limit, self.previousGenerator,\n **kwargs)","function_tokens":["def","findAllPrevious","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","limit","=","None",",","*","*","kwargs",")",":","return","self",".","_findAll","(","name",",","attrs",",","text",",","limit",",","self",".","previousGenerator",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L270-L275"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findPreviousSibling","parameters":"(self, name=None, attrs={}, text=None, **kwargs)","argument_list":"","return_statement":"return self._findOne(self.findPreviousSiblings, name, attrs, text,\n **kwargs)","docstring":"Returns the closest sibling to this Tag that matches the\n given criteria and appears before this Tag in the document.","docstring_summary":"Returns the closest sibling to this Tag that matches the\n given criteria and appears before this Tag in the document.","docstring_tokens":["Returns","the","closest","sibling","to","this","Tag","that","matches","the","given","criteria","and","appears","before","this","Tag","in","the","document","."],"function":"def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs):\n \"\"\"Returns the closest sibling to this Tag that matches the\n given criteria and appears before this Tag in the document.\"\"\"\n return self._findOne(self.findPreviousSiblings, name, attrs, text,\n **kwargs)","function_tokens":["def","findPreviousSibling","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","*","*","kwargs",")",":","return","self",".","_findOne","(","self",".","findPreviousSiblings",",","name",",","attrs",",","text",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L278-L282"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findPreviousSiblings","parameters":"(self, name=None, attrs={}, text=None,\n limit=None, **kwargs)","argument_list":"","return_statement":"return self._findAll(name, attrs, text, limit,\n self.previousSiblingGenerator, **kwargs)","docstring":"Returns the siblings of this Tag that match the given\n criteria and appear before this Tag in the document.","docstring_summary":"Returns the siblings of this Tag that match the given\n criteria and appear before this Tag in the document.","docstring_tokens":["Returns","the","siblings","of","this","Tag","that","match","the","given","criteria","and","appear","before","this","Tag","in","the","document","."],"function":"def findPreviousSiblings(self, name=None, attrs={}, text=None,\n limit=None, **kwargs):\n \"\"\"Returns the siblings of this Tag that match the given\n criteria and appear before this Tag in the document.\"\"\"\n return self._findAll(name, attrs, text, limit,\n self.previousSiblingGenerator, **kwargs)","function_tokens":["def","findPreviousSiblings","(","self",",","name","=","None",",","attrs","=","{","}",",","text","=","None",",","limit","=","None",",","*","*","kwargs",")",":","return","self",".","_findAll","(","name",",","attrs",",","text",",","limit",",","self",".","previousSiblingGenerator",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L284-L289"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findParent","parameters":"(self, name=None, attrs={}, **kwargs)","argument_list":"","return_statement":"return r","docstring":"Returns the closest parent of this Tag that matches the given\n criteria.","docstring_summary":"Returns the closest parent of this Tag that matches the given\n criteria.","docstring_tokens":["Returns","the","closest","parent","of","this","Tag","that","matches","the","given","criteria","."],"function":"def findParent(self, name=None, attrs={}, **kwargs):\n \"\"\"Returns the closest parent of this Tag that matches the given\n criteria.\"\"\"\n # NOTE: We can't use _findOne because findParents takes a different\n # set of arguments.\n r = None\n l = self.findParents(name, attrs, 1)\n if l:\n r = l[0]\n return r","function_tokens":["def","findParent","(","self",",","name","=","None",",","attrs","=","{","}",",","*","*","kwargs",")",":","# NOTE: We can't use _findOne because findParents takes a different","# set of arguments.","r","=","None","l","=","self",".","findParents","(","name",",","attrs",",","1",")","if","l",":","r","=","l","[","0","]","return","r"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L292-L301"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.findParents","parameters":"(self, name=None, attrs={}, limit=None, **kwargs)","argument_list":"","return_statement":"return self._findAll(name, attrs, None, limit, self.parentGenerator,\n **kwargs)","docstring":"Returns the parents of this Tag that match the given\n criteria.","docstring_summary":"Returns the parents of this Tag that match the given\n criteria.","docstring_tokens":["Returns","the","parents","of","this","Tag","that","match","the","given","criteria","."],"function":"def findParents(self, name=None, attrs={}, limit=None, **kwargs):\n \"\"\"Returns the parents of this Tag that match the given\n criteria.\"\"\"\n\n return self._findAll(name, attrs, None, limit, self.parentGenerator,\n **kwargs)","function_tokens":["def","findParents","(","self",",","name","=","None",",","attrs","=","{","}",",","limit","=","None",",","*","*","kwargs",")",":","return","self",".","_findAll","(","name",",","attrs",",","None",",","limit",",","self",".","parentGenerator",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L303-L308"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement._findAll","parameters":"(self, name, attrs, text, limit, generator, **kwargs)","argument_list":"","return_statement":"return results","docstring":"Iterates over a generator looking for things that match.","docstring_summary":"Iterates over a generator looking for things that match.","docstring_tokens":["Iterates","over","a","generator","looking","for","things","that","match","."],"function":"def _findAll(self, name, attrs, text, limit, generator, **kwargs):\n \"Iterates over a generator looking for things that match.\"\n\n if isinstance(name, SoupStrainer):\n strainer = name\n else:\n # Build a SoupStrainer\n strainer = SoupStrainer(name, attrs, text, **kwargs)\n results = ResultSet(strainer)\n g = generator()\n while True:\n try:\n i = g.next()\n except StopIteration:\n break\n if i:\n found = strainer.search(i)\n if found:\n results.append(found)\n if limit and len(results) >= limit:\n break\n return results","function_tokens":["def","_findAll","(","self",",","name",",","attrs",",","text",",","limit",",","generator",",","*","*","kwargs",")",":","if","isinstance","(","name",",","SoupStrainer",")",":","strainer","=","name","else",":","# Build a SoupStrainer","strainer","=","SoupStrainer","(","name",",","attrs",",","text",",","*","*","kwargs",")","results","=","ResultSet","(","strainer",")","g","=","generator","(",")","while","True",":","try",":","i","=","g",".","next","(",")","except","StopIteration",":","break","if","i",":","found","=","strainer",".","search","(","i",")","if","found",":","results",".","append","(","found",")","if","limit","and","len","(","results",")",">=","limit",":","break","return","results"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L320-L341"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"PageElement.toEncoding","parameters":"(self, s, encoding=None)","argument_list":"","return_statement":"return s","docstring":"Encodes an object to a string in some encoding, or to Unicode.\n .","docstring_summary":"Encodes an object to a string in some encoding, or to Unicode.\n .","docstring_tokens":["Encodes","an","object","to","a","string","in","some","encoding","or","to","Unicode",".","."],"function":"def toEncoding(self, s, encoding=None):\n \"\"\"Encodes an object to a string in some encoding, or to Unicode.\n .\"\"\"\n if isinstance(s, unicode):\n if encoding:\n s = s.encode(encoding)\n elif isinstance(s, str):\n if encoding:\n s = s.encode(encoding)\n else:\n s = unicode(s)\n else:\n if encoding:\n s = self.toEncoding(str(s), encoding)\n else:\n s = unicode(s)\n return s","function_tokens":["def","toEncoding","(","self",",","s",",","encoding","=","None",")",":","if","isinstance","(","s",",","unicode",")",":","if","encoding",":","s","=","s",".","encode","(","encoding",")","elif","isinstance","(","s",",","str",")",":","if","encoding",":","s","=","s",".","encode","(","encoding",")","else",":","s","=","unicode","(","s",")","else",":","if","encoding",":","s","=","self",".","toEncoding","(","str","(","s",")",",","encoding",")","else",":","s","=","unicode","(","s",")","return","s"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L380-L396"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"NavigableString.__new__","parameters":"(cls, value)","argument_list":"","return_statement":"return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)","docstring":"Create a new NavigableString.\n\n When unpickling a NavigableString, this method is called with\n the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be\n passed in to the superclass's __new__ or the superclass won't know\n how to handle non-ASCII characters.","docstring_summary":"Create a new NavigableString.","docstring_tokens":["Create","a","new","NavigableString","."],"function":"def __new__(cls, value):\n \"\"\"Create a new NavigableString.\n\n When unpickling a NavigableString, this method is called with\n the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be\n passed in to the superclass's __new__ or the superclass won't know\n how to handle non-ASCII characters.\n \"\"\"\n if isinstance(value, unicode):\n return unicode.__new__(cls, value)\n return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)","function_tokens":["def","__new__","(","cls",",","value",")",":","if","isinstance","(","value",",","unicode",")",":","return","unicode",".","__new__","(","cls",",","value",")","return","unicode",".","__new__","(","cls",",","value",",","DEFAULT_OUTPUT_ENCODING",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L400-L410"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"NavigableString.__getattr__","parameters":"(self, attr)","argument_list":"","return_statement":"","docstring":"text.string gives you text. This is for backwards\n compatibility for Navigable*String, but for CData* it lets you\n get the string without the CData wrapper.","docstring_summary":"text.string gives you text. This is for backwards\n compatibility for Navigable*String, but for CData* it lets you\n get the string without the CData wrapper.","docstring_tokens":["text",".","string","gives","you","text",".","This","is","for","backwards","compatibility","for","Navigable","*","String","but","for","CData","*","it","lets","you","get","the","string","without","the","CData","wrapper","."],"function":"def __getattr__(self, attr):\n \"\"\"text.string gives you text. This is for backwards\n compatibility for Navigable*String, but for CData* it lets you\n get the string without the CData wrapper.\"\"\"\n if attr == 'string':\n return self\n else:\n raise AttributeError, \"'%s' object has no attribute '%s'\" % (self.__class__.__name__, attr)","function_tokens":["def","__getattr__","(","self",",","attr",")",":","if","attr","==","'string'",":","return","self","else",":","raise","AttributeError",",","\"'%s' object has no attribute '%s'\"","%","(","self",".","__class__",".","__name__",",","attr",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L415-L422"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag._invert","parameters":"(h)","argument_list":"","return_statement":"return i","docstring":"Cheap function to invert a hash.","docstring_summary":"Cheap function to invert a hash.","docstring_tokens":["Cheap","function","to","invert","a","hash","."],"function":"def _invert(h):\n \"Cheap function to invert a hash.\"\n i = {}\n for k,v in h.items():\n i[v] = k\n return i","function_tokens":["def","_invert","(","h",")",":","i","=","{","}","for","k",",","v","in","h",".","items","(",")",":","i","[","v","]","=","k","return","i"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L457-L462"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag._convertEntities","parameters":"(self, match)","argument_list":"","return_statement":"","docstring":"Used in a call to re.sub to replace HTML, XML, and numeric\n entities with the appropriate Unicode characters. If HTML\n entities are being converted, any unrecognized entities are\n escaped.","docstring_summary":"Used in a call to re.sub to replace HTML, XML, and numeric\n entities with the appropriate Unicode characters. If HTML\n entities are being converted, any unrecognized entities are\n escaped.","docstring_tokens":["Used","in","a","call","to","re",".","sub","to","replace","HTML","XML","and","numeric","entities","with","the","appropriate","Unicode","characters",".","If","HTML","entities","are","being","converted","any","unrecognized","entities","are","escaped","."],"function":"def _convertEntities(self, match):\n \"\"\"Used in a call to re.sub to replace HTML, XML, and numeric\n entities with the appropriate Unicode characters. If HTML\n entities are being converted, any unrecognized entities are\n escaped.\"\"\"\n x = match.group(1)\n if self.convertHTMLEntities and x in name2codepoint:\n return unichr(name2codepoint[x])\n elif x in self.XML_ENTITIES_TO_SPECIAL_CHARS:\n if self.convertXMLEntities:\n return self.XML_ENTITIES_TO_SPECIAL_CHARS[x]\n else:\n return u'&%s;' % x\n elif len(x) > 0 and x[0] == '#':\n # Handle numeric entities\n if len(x) > 1 and x[1] == 'x':\n return unichr(int(x[2:], 16))\n else:\n return unichr(int(x[1:]))\n\n elif self.escapeUnrecognizedEntities:\n return u'&%s;' % x\n else:\n return u'&%s;' % x","function_tokens":["def","_convertEntities","(","self",",","match",")",":","x","=","match",".","group","(","1",")","if","self",".","convertHTMLEntities","and","x","in","name2codepoint",":","return","unichr","(","name2codepoint","[","x","]",")","elif","x","in","self",".","XML_ENTITIES_TO_SPECIAL_CHARS",":","if","self",".","convertXMLEntities",":","return","self",".","XML_ENTITIES_TO_SPECIAL_CHARS","[","x","]","else",":","return","u'&%s;'","%","x","elif","len","(","x",")",">","0","and","x","[","0","]","==","'#'",":","# Handle numeric entities","if","len","(","x",")",">","1","and","x","[","1","]","==","'x'",":","return","unichr","(","int","(","x","[","2",":","]",",","16",")",")","else",":","return","unichr","(","int","(","x","[","1",":","]",")",")","elif","self",".","escapeUnrecognizedEntities",":","return","u'&%s;'","%","x","else",":","return","u'&%s;'","%","x"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L472-L495"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__init__","parameters":"(self, parser, name, attrs=None, parent=None,\n previous=None)","argument_list":"","return_statement":"","docstring":"Basic constructor.","docstring_summary":"Basic constructor.","docstring_tokens":["Basic","constructor","."],"function":"def __init__(self, parser, name, attrs=None, parent=None,\n previous=None):\n \"Basic constructor.\"\n\n # We don't actually store the parser object: that lets extracted\n # chunks be garbage-collected\n self.parserClass = parser.__class__\n self.isSelfClosing = parser.isSelfClosingTag(name)\n self.name = name\n if attrs == None:\n attrs = []\n self.attrs = attrs\n self.contents = []\n self.setup(parent, previous)\n self.hidden = False\n self.containsSubstitutions = False\n self.convertHTMLEntities = parser.convertHTMLEntities\n self.convertXMLEntities = parser.convertXMLEntities\n self.escapeUnrecognizedEntities = parser.escapeUnrecognizedEntities\n\n # Convert any HTML, XML, or numeric entities in the attribute values.\n convert = lambda(k, val): (k,\n re.sub(\"&(#\\d+|#x[0-9a-fA-F]+|\\w+);\",\n self._convertEntities,\n val))\n self.attrs = map(convert, self.attrs)","function_tokens":["def","__init__","(","self",",","parser",",","name",",","attrs","=","None",",","parent","=","None",",","previous","=","None",")",":","# We don't actually store the parser object: that lets extracted","# chunks be garbage-collected","self",".","parserClass","=","parser",".","__class__","self",".","isSelfClosing","=","parser",".","isSelfClosingTag","(","name",")","self",".","name","=","name","if","attrs","==","None",":","attrs","=","[","]","self",".","attrs","=","attrs","self",".","contents","=","[","]","self",".","setup","(","parent",",","previous",")","self",".","hidden","=","False","self",".","containsSubstitutions","=","False","self",".","convertHTMLEntities","=","parser",".","convertHTMLEntities","self",".","convertXMLEntities","=","parser",".","convertXMLEntities","self",".","escapeUnrecognizedEntities","=","parser",".","escapeUnrecognizedEntities","# Convert any HTML, XML, or numeric entities in the attribute values.","convert","=","lambda","(","k",",","val",")",":","(","k",",","re",".","sub","(","\"&(#\\d+|#x[0-9a-fA-F]+|\\w+);\"",",","self",".","_convertEntities",",","val",")",")","self",".","attrs","=","map","(","convert",",","self",".","attrs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L497-L522"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.get","parameters":"(self, key, default=None)","argument_list":"","return_statement":"return self._getAttrMap().get(key, default)","docstring":"Returns the value of the 'key' attribute for the tag, or\n the value given for 'default' if it doesn't have that\n attribute.","docstring_summary":"Returns the value of the 'key' attribute for the tag, or\n the value given for 'default' if it doesn't have that\n attribute.","docstring_tokens":["Returns","the","value","of","the","key","attribute","for","the","tag","or","the","value","given","for","default","if","it","doesn","t","have","that","attribute","."],"function":"def get(self, key, default=None):\n \"\"\"Returns the value of the 'key' attribute for the tag, or\n the value given for 'default' if it doesn't have that\n attribute.\"\"\"\n return self._getAttrMap().get(key, default)","function_tokens":["def","get","(","self",",","key",",","default","=","None",")",":","return","self",".","_getAttrMap","(",")",".","get","(","key",",","default",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L524-L528"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__getitem__","parameters":"(self, key)","argument_list":"","return_statement":"return self._getAttrMap()[key]","docstring":"tag[key] returns the value of the 'key' attribute for the tag,\n and throws an exception if it's not there.","docstring_summary":"tag[key] returns the value of the 'key' attribute for the tag,\n and throws an exception if it's not there.","docstring_tokens":["tag","[","key","]","returns","the","value","of","the","key","attribute","for","the","tag","and","throws","an","exception","if","it","s","not","there","."],"function":"def __getitem__(self, key):\n \"\"\"tag[key] returns the value of the 'key' attribute for the tag,\n and throws an exception if it's not there.\"\"\"\n return self._getAttrMap()[key]","function_tokens":["def","__getitem__","(","self",",","key",")",":","return","self",".","_getAttrMap","(",")","[","key","]"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L533-L536"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__iter__","parameters":"(self)","argument_list":"","return_statement":"return iter(self.contents)","docstring":"Iterating over a tag iterates over its contents.","docstring_summary":"Iterating over a tag iterates over its contents.","docstring_tokens":["Iterating","over","a","tag","iterates","over","its","contents","."],"function":"def __iter__(self):\n \"Iterating over a tag iterates over its contents.\"\n return iter(self.contents)","function_tokens":["def","__iter__","(","self",")",":","return","iter","(","self",".","contents",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L538-L540"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__len__","parameters":"(self)","argument_list":"","return_statement":"return len(self.contents)","docstring":"The length of a tag is the length of its list of contents.","docstring_summary":"The length of a tag is the length of its list of contents.","docstring_tokens":["The","length","of","a","tag","is","the","length","of","its","list","of","contents","."],"function":"def __len__(self):\n \"The length of a tag is the length of its list of contents.\"\n return len(self.contents)","function_tokens":["def","__len__","(","self",")",":","return","len","(","self",".","contents",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L542-L544"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__nonzero__","parameters":"(self)","argument_list":"","return_statement":"return True","docstring":"A tag is non-None even if it has no contents.","docstring_summary":"A tag is non-None even if it has no contents.","docstring_tokens":["A","tag","is","non","-","None","even","if","it","has","no","contents","."],"function":"def __nonzero__(self):\n \"A tag is non-None even if it has no contents.\"\n return True","function_tokens":["def","__nonzero__","(","self",")",":","return","True"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L549-L551"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__setitem__","parameters":"(self, key, value)","argument_list":"","return_statement":"","docstring":"Setting tag[key] sets the value of the 'key' attribute for the\n tag.","docstring_summary":"Setting tag[key] sets the value of the 'key' attribute for the\n tag.","docstring_tokens":["Setting","tag","[","key","]","sets","the","value","of","the","key","attribute","for","the","tag","."],"function":"def __setitem__(self, key, value):\n \"\"\"Setting tag[key] sets the value of the 'key' attribute for the\n tag.\"\"\"\n self._getAttrMap()\n self.attrMap[key] = value\n found = False\n for i in range(0, len(self.attrs)):\n if self.attrs[i][0] == key:\n self.attrs[i] = (key, value)\n found = True\n if not found:\n self.attrs.append((key, value))\n self._getAttrMap()[key] = value","function_tokens":["def","__setitem__","(","self",",","key",",","value",")",":","self",".","_getAttrMap","(",")","self",".","attrMap","[","key","]","=","value","found","=","False","for","i","in","range","(","0",",","len","(","self",".","attrs",")",")",":","if","self",".","attrs","[","i","]","[","0","]","==","key",":","self",".","attrs","[","i","]","=","(","key",",","value",")","found","=","True","if","not","found",":","self",".","attrs",".","append","(","(","key",",","value",")",")","self",".","_getAttrMap","(",")","[","key","]","=","value"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L553-L565"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__delitem__","parameters":"(self, key)","argument_list":"","return_statement":"","docstring":"Deleting tag[key] deletes all 'key' attributes for the tag.","docstring_summary":"Deleting tag[key] deletes all 'key' attributes for the tag.","docstring_tokens":["Deleting","tag","[","key","]","deletes","all","key","attributes","for","the","tag","."],"function":"def __delitem__(self, key):\n \"Deleting tag[key] deletes all 'key' attributes for the tag.\"\n for item in self.attrs:\n if item[0] == key:\n self.attrs.remove(item)\n #We don't break because bad HTML can define the same\n #attribute multiple times.\n self._getAttrMap()\n if self.attrMap.has_key(key):\n del self.attrMap[key]","function_tokens":["def","__delitem__","(","self",",","key",")",":","for","item","in","self",".","attrs",":","if","item","[","0","]","==","key",":","self",".","attrs",".","remove","(","item",")","#We don't break because bad HTML can define the same","#attribute multiple times.","self",".","_getAttrMap","(",")","if","self",".","attrMap",".","has_key","(","key",")",":","del","self",".","attrMap","[","key","]"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L567-L576"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__call__","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"return apply(self.findAll, args, kwargs)","docstring":"Calling a tag like a function is the same as calling its\n findAll() method. Eg. tag('a') returns a list of all the A tags\n found within this tag.","docstring_summary":"Calling a tag like a function is the same as calling its\n findAll() method. Eg. tag('a') returns a list of all the A tags\n found within this tag.","docstring_tokens":["Calling","a","tag","like","a","function","is","the","same","as","calling","its","findAll","()","method",".","Eg",".","tag","(","a",")","returns","a","list","of","all","the","A","tags","found","within","this","tag","."],"function":"def __call__(self, *args, **kwargs):\n \"\"\"Calling a tag like a function is the same as calling its\n findAll() method. Eg. tag('a') returns a list of all the A tags\n found within this tag.\"\"\"\n return apply(self.findAll, args, kwargs)","function_tokens":["def","__call__","(","self",",","*","args",",","*","*","kwargs",")",":","return","apply","(","self",".","findAll",",","args",",","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L578-L582"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__eq__","parameters":"(self, other)","argument_list":"","return_statement":"return True","docstring":"Returns true iff this tag has the same name, the same attributes,\n and the same contents (recursively) as the given tag.\n\n NOTE: right now this will return false if two tags have the\n same attributes in a different order. Should this be fixed?","docstring_summary":"Returns true iff this tag has the same name, the same attributes,\n and the same contents (recursively) as the given tag.","docstring_tokens":["Returns","true","iff","this","tag","has","the","same","name","the","same","attributes","and","the","same","contents","(","recursively",")","as","the","given","tag","."],"function":"def __eq__(self, other):\n \"\"\"Returns true iff this tag has the same name, the same attributes,\n and the same contents (recursively) as the given tag.\n\n NOTE: right now this will return false if two tags have the\n same attributes in a different order. Should this be fixed?\"\"\"\n if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other):\n return False\n for i in range(0, len(self.contents)):\n if self.contents[i] != other.contents[i]:\n return False\n return True","function_tokens":["def","__eq__","(","self",",","other",")",":","if","not","hasattr","(","other",",","'name'",")","or","not","hasattr","(","other",",","'attrs'",")","or","not","hasattr","(","other",",","'contents'",")","or","self",".","name","!=","other",".","name","or","self",".","attrs","!=","other",".","attrs","or","len","(","self",")","!=","len","(","other",")",":","return","False","for","i","in","range","(","0",",","len","(","self",".","contents",")",")",":","if","self",".","contents","[","i","]","!=","other",".","contents","[","i","]",":","return","False","return","True"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L592-L603"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__ne__","parameters":"(self, other)","argument_list":"","return_statement":"return not self == other","docstring":"Returns true iff this tag is not identical to the other tag,\n as defined in __eq__.","docstring_summary":"Returns true iff this tag is not identical to the other tag,\n as defined in __eq__.","docstring_tokens":["Returns","true","iff","this","tag","is","not","identical","to","the","other","tag","as","defined","in","__eq__","."],"function":"def __ne__(self, other):\n \"\"\"Returns true iff this tag is not identical to the other tag,\n as defined in __eq__.\"\"\"\n return not self == other","function_tokens":["def","__ne__","(","self",",","other",")",":","return","not","self","==","other"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L605-L608"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__repr__","parameters":"(self, encoding=DEFAULT_OUTPUT_ENCODING)","argument_list":"","return_statement":"return self.__str__(encoding)","docstring":"Renders this tag as a string.","docstring_summary":"Renders this tag as a string.","docstring_tokens":["Renders","this","tag","as","a","string","."],"function":"def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING):\n \"\"\"Renders this tag as a string.\"\"\"\n return self.__str__(encoding)","function_tokens":["def","__repr__","(","self",",","encoding","=","DEFAULT_OUTPUT_ENCODING",")",":","return","self",".","__str__","(","encoding",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L610-L612"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag._sub_entity","parameters":"(self, x)","argument_list":"","return_statement":"return \"&\" + self.XML_SPECIAL_CHARS_TO_ENTITIES[x.group(0)[0]] + \";\"","docstring":"Used with a regular expression to substitute the\n appropriate XML entity for an XML special character.","docstring_summary":"Used with a regular expression to substitute the\n appropriate XML entity for an XML special character.","docstring_tokens":["Used","with","a","regular","expression","to","substitute","the","appropriate","XML","entity","for","an","XML","special","character","."],"function":"def _sub_entity(self, x):\n \"\"\"Used with a regular expression to substitute the\n appropriate XML entity for an XML special character.\"\"\"\n return \"&\" + self.XML_SPECIAL_CHARS_TO_ENTITIES[x.group(0)[0]] + \";\"","function_tokens":["def","_sub_entity","(","self",",","x",")",":","return","\"&\"","+","self",".","XML_SPECIAL_CHARS_TO_ENTITIES","[","x",".","group","(","0",")","[","0","]","]","+","\";\""],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L621-L624"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.__str__","parameters":"(self, encoding=DEFAULT_OUTPUT_ENCODING,\n prettyPrint=False, indentLevel=0)","argument_list":"","return_statement":"return s","docstring":"Returns a string or Unicode representation of this tag and\n its contents. To get Unicode, pass None for encoding.\n\n NOTE: since Python's HTML parser consumes whitespace, this\n method is not certain to reproduce the whitespace present in\n the original string.","docstring_summary":"Returns a string or Unicode representation of this tag and\n its contents. To get Unicode, pass None for encoding.","docstring_tokens":["Returns","a","string","or","Unicode","representation","of","this","tag","and","its","contents",".","To","get","Unicode","pass","None","for","encoding","."],"function":"def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING,\n prettyPrint=False, indentLevel=0):\n \"\"\"Returns a string or Unicode representation of this tag and\n its contents. To get Unicode, pass None for encoding.\n\n NOTE: since Python's HTML parser consumes whitespace, this\n method is not certain to reproduce the whitespace present in\n the original string.\"\"\"\n\n encodedName = self.toEncoding(self.name, encoding)\n\n attrs = []\n if self.attrs:\n for key, val in self.attrs:\n fmt = '%s=\"%s\"'\n if isString(val):\n if self.containsSubstitutions and '%SOUP-ENCODING%' in val:\n val = self.substituteEncoding(val, encoding)\n\n # The attribute value either:\n #\n # * Contains no embedded double quotes or single quotes.\n # No problem: we enclose it in double quotes.\n # * Contains embedded single quotes. No problem:\n # double quotes work here too.\n # * Contains embedded double quotes. No problem:\n # we enclose it in single quotes.\n # * Embeds both single _and_ double quotes. This\n # can't happen naturally, but it can happen if\n # you modify an attribute value after parsing\n # the document. Now we have a bit of a\n # problem. We solve it by enclosing the\n # attribute in single quotes, and escaping any\n # embedded single quotes to XML entities.\n if '\"' in val:\n fmt = \"%s='%s'\"\n if \"'\" in val:\n # TODO: replace with apos when\n # appropriate.\n val = val.replace(\"'\", \"&squot;\")\n\n # Now we're okay w\/r\/t quotes. But the attribute\n # value might also contain angle brackets, or\n # ampersands that aren't part of entities. We need\n # to escape those to XML entities too.\n val = self.BARE_AMPERSAND_OR_BRACKET.sub(self._sub_entity, val)\n\n attrs.append(fmt % (self.toEncoding(key, encoding),\n self.toEncoding(val, encoding)))\n close = ''\n closeTag = ''\n if self.isSelfClosing:\n close = ' \/'\n else:\n closeTag = '<\/%s>' % encodedName\n\n indentTag, indentContents = 0, 0\n if prettyPrint:\n indentTag = indentLevel\n space = (' ' * (indentTag-1))\n indentContents = indentTag + 1\n contents = self.renderContents(encoding, prettyPrint, indentContents)\n if self.hidden:\n s = contents\n else:\n s = []\n attributeString = ''\n if attrs:\n attributeString = ' ' + ' '.join(attrs)\n if prettyPrint:\n s.append(space)\n s.append('<%s%s%s>' % (encodedName, attributeString, close))\n if prettyPrint:\n s.append(\"\\n\")\n s.append(contents)\n if prettyPrint and contents and contents[-1] != \"\\n\":\n s.append(\"\\n\")\n if prettyPrint and closeTag:\n s.append(space)\n s.append(closeTag)\n if prettyPrint and closeTag and self.nextSibling:\n s.append(\"\\n\")\n s = ''.join(s)\n return s","function_tokens":["def","__str__","(","self",",","encoding","=","DEFAULT_OUTPUT_ENCODING",",","prettyPrint","=","False",",","indentLevel","=","0",")",":","encodedName","=","self",".","toEncoding","(","self",".","name",",","encoding",")","attrs","=","[","]","if","self",".","attrs",":","for","key",",","val","in","self",".","attrs",":","fmt","=","'%s=\"%s\"'","if","isString","(","val",")",":","if","self",".","containsSubstitutions","and","'%SOUP-ENCODING%'","in","val",":","val","=","self",".","substituteEncoding","(","val",",","encoding",")","# The attribute value either:","#","# * Contains no embedded double quotes or single quotes.","# No problem: we enclose it in double quotes.","# * Contains embedded single quotes. No problem:","# double quotes work here too.","# * Contains embedded double quotes. No problem:","# we enclose it in single quotes.","# * Embeds both single _and_ double quotes. This","# can't happen naturally, but it can happen if","# you modify an attribute value after parsing","# the document. Now we have a bit of a","# problem. We solve it by enclosing the","# attribute in single quotes, and escaping any","# embedded single quotes to XML entities.","if","'\"'","in","val",":","fmt","=","\"%s='%s'\"","if","\"'\"","in","val",":","# TODO: replace with apos when","# appropriate.","val","=","val",".","replace","(","\"'\"",",","\"&squot;\"",")","# Now we're okay w\/r\/t quotes. But the attribute","# value might also contain angle brackets, or","# ampersands that aren't part of entities. We need","# to escape those to XML entities too.","val","=","self",".","BARE_AMPERSAND_OR_BRACKET",".","sub","(","self",".","_sub_entity",",","val",")","attrs",".","append","(","fmt","%","(","self",".","toEncoding","(","key",",","encoding",")",",","self",".","toEncoding","(","val",",","encoding",")",")",")","close","=","''","closeTag","=","''","if","self",".","isSelfClosing",":","close","=","' \/'","else",":","closeTag","=","'<\/%s>'","%","encodedName","indentTag",",","indentContents","=","0",",","0","if","prettyPrint",":","indentTag","=","indentLevel","space","=","(","' '","*","(","indentTag","-","1",")",")","indentContents","=","indentTag","+","1","contents","=","self",".","renderContents","(","encoding",",","prettyPrint",",","indentContents",")","if","self",".","hidden",":","s","=","contents","else",":","s","=","[","]","attributeString","=","''","if","attrs",":","attributeString","=","' '","+","' '",".","join","(","attrs",")","if","prettyPrint",":","s",".","append","(","space",")","s",".","append","(","'<%s%s%s>'","%","(","encodedName",",","attributeString",",","close",")",")","if","prettyPrint",":","s",".","append","(","\"\\n\"",")","s",".","append","(","contents",")","if","prettyPrint","and","contents","and","contents","[","-","1","]","!=","\"\\n\"",":","s",".","append","(","\"\\n\"",")","if","prettyPrint","and","closeTag",":","s",".","append","(","space",")","s",".","append","(","closeTag",")","if","prettyPrint","and","closeTag","and","self",".","nextSibling",":","s",".","append","(","\"\\n\"",")","s","=","''",".","join","(","s",")","return","s"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L626-L709"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.decompose","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Recursively destroys the contents of this tree.","docstring_summary":"Recursively destroys the contents of this tree.","docstring_tokens":["Recursively","destroys","the","contents","of","this","tree","."],"function":"def decompose(self):\n \"\"\"Recursively destroys the contents of this tree.\"\"\"\n contents = [i for i in self.contents]\n for i in contents:\n if isinstance(i, Tag):\n i.decompose()\n else:\n i.extract()\n self.extract()","function_tokens":["def","decompose","(","self",")",":","contents","=","[","i","for","i","in","self",".","contents","]","for","i","in","contents",":","if","isinstance","(","i",",","Tag",")",":","i",".","decompose","(",")","else",":","i",".","extract","(",")","self",".","extract","(",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L711-L719"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.renderContents","parameters":"(self, encoding=DEFAULT_OUTPUT_ENCODING,\n prettyPrint=False, indentLevel=0)","argument_list":"","return_statement":"return ''.join(s)","docstring":"Renders the contents of this tag as a string in the given\n encoding. If encoding is None, returns a Unicode string..","docstring_summary":"Renders the contents of this tag as a string in the given\n encoding. If encoding is None, returns a Unicode string..","docstring_tokens":["Renders","the","contents","of","this","tag","as","a","string","in","the","given","encoding",".","If","encoding","is","None","returns","a","Unicode","string",".."],"function":"def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING,\n prettyPrint=False, indentLevel=0):\n \"\"\"Renders the contents of this tag as a string in the given\n encoding. If encoding is None, returns a Unicode string..\"\"\"\n s=[]\n for c in self:\n text = None\n if isinstance(c, NavigableString):\n text = c.__str__(encoding)\n elif isinstance(c, Tag):\n s.append(c.__str__(encoding, prettyPrint, indentLevel))\n if text and prettyPrint:\n text = text.strip()\n if text:\n if prettyPrint:\n s.append(\" \" * (indentLevel-1))\n s.append(text)\n if prettyPrint:\n s.append(\"\\n\")\n return ''.join(s)","function_tokens":["def","renderContents","(","self",",","encoding","=","DEFAULT_OUTPUT_ENCODING",",","prettyPrint","=","False",",","indentLevel","=","0",")",":","s","=","[","]","for","c","in","self",":","text","=","None","if","isinstance","(","c",",","NavigableString",")",":","text","=","c",".","__str__","(","encoding",")","elif","isinstance","(","c",",","Tag",")",":","s",".","append","(","c",".","__str__","(","encoding",",","prettyPrint",",","indentLevel",")",")","if","text","and","prettyPrint",":","text","=","text",".","strip","(",")","if","text",":","if","prettyPrint",":","s",".","append","(","\" \"","*","(","indentLevel","-","1",")",")","s",".","append","(","text",")","if","prettyPrint",":","s",".","append","(","\"\\n\"",")","return","''",".","join","(","s",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L724-L743"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.find","parameters":"(self, name=None, attrs={}, recursive=True, text=None,\n **kwargs)","argument_list":"","return_statement":"return r","docstring":"Return only the first child of this Tag matching the given\n criteria.","docstring_summary":"Return only the first child of this Tag matching the given\n criteria.","docstring_tokens":["Return","only","the","first","child","of","this","Tag","matching","the","given","criteria","."],"function":"def find(self, name=None, attrs={}, recursive=True, text=None,\n **kwargs):\n \"\"\"Return only the first child of this Tag matching the given\n criteria.\"\"\"\n r = None\n l = self.findAll(name, attrs, recursive, text, 1, **kwargs)\n if l:\n r = l[0]\n return r","function_tokens":["def","find","(","self",",","name","=","None",",","attrs","=","{","}",",","recursive","=","True",",","text","=","None",",","*","*","kwargs",")",":","r","=","None","l","=","self",".","findAll","(","name",",","attrs",",","recursive",",","text",",","1",",","*","*","kwargs",")","if","l",":","r","=","l","[","0","]","return","r"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L747-L755"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag.findAll","parameters":"(self, name=None, attrs={}, recursive=True, text=None,\n limit=None, **kwargs)","argument_list":"","return_statement":"return self._findAll(name, attrs, text, limit, generator, **kwargs)","docstring":"Extracts a list of Tag objects that match the given\n criteria. You can specify the name of the Tag and any\n attributes you want the Tag to have.\n\n The value of a key-value pair in the 'attrs' map can be a\n string, a list of strings, a regular expression object, or a\n callable that takes a string and returns whether or not the\n string matches for some custom definition of 'matches'. The\n same is true of the tag name.","docstring_summary":"Extracts a list of Tag objects that match the given\n criteria. You can specify the name of the Tag and any\n attributes you want the Tag to have.","docstring_tokens":["Extracts","a","list","of","Tag","objects","that","match","the","given","criteria",".","You","can","specify","the","name","of","the","Tag","and","any","attributes","you","want","the","Tag","to","have","."],"function":"def findAll(self, name=None, attrs={}, recursive=True, text=None,\n limit=None, **kwargs):\n \"\"\"Extracts a list of Tag objects that match the given\n criteria. You can specify the name of the Tag and any\n attributes you want the Tag to have.\n\n The value of a key-value pair in the 'attrs' map can be a\n string, a list of strings, a regular expression object, or a\n callable that takes a string and returns whether or not the\n string matches for some custom definition of 'matches'. The\n same is true of the tag name.\"\"\"\n generator = self.recursiveChildGenerator\n if not recursive:\n generator = self.childGenerator\n return self._findAll(name, attrs, text, limit, generator, **kwargs)","function_tokens":["def","findAll","(","self",",","name","=","None",",","attrs","=","{","}",",","recursive","=","True",",","text","=","None",",","limit","=","None",",","*","*","kwargs",")",":","generator","=","self",".","recursiveChildGenerator","if","not","recursive",":","generator","=","self",".","childGenerator","return","self",".","_findAll","(","name",",","attrs",",","text",",","limit",",","generator",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L758-L772"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"Tag._getAttrMap","parameters":"(self)","argument_list":"","return_statement":"return self.attrMap","docstring":"Initializes a map representation of this tag's attributes,\n if not already initialized.","docstring_summary":"Initializes a map representation of this tag's attributes,\n if not already initialized.","docstring_tokens":["Initializes","a","map","representation","of","this","tag","s","attributes","if","not","already","initialized","."],"function":"def _getAttrMap(self):\n \"\"\"Initializes a map representation of this tag's attributes,\n if not already initialized.\"\"\"\n if not getattr(self, 'attrMap'):\n self.attrMap = {}\n for (key, value) in self.attrs:\n self.attrMap[key] = value\n return self.attrMap","function_tokens":["def","_getAttrMap","(","self",")",":","if","not","getattr","(","self",",","'attrMap'",")",":","self",".","attrMap","=","{","}","for","(","key",",","value",")","in","self",".","attrs",":","self",".","attrMap","[","key","]","=","value","return","self",".","attrMap"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L787-L794"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.__init__","parameters":"(self, markup=\"\", parseOnlyThese=None, fromEncoding=None,\n markupMassage=True, smartQuotesTo=XML_ENTITIES,\n convertEntities=None, selfClosingTags=None, isHTML=False)","argument_list":"","return_statement":"","docstring":"The Soup object is initialized as the 'root tag', and the\n provided markup (which can be a string or a file-like object)\n is fed into the underlying parser.\n\n sgmllib will process most bad HTML, and the BeautifulSoup\n class has some tricks for dealing with some HTML that kills\n sgmllib, but Beautiful Soup can nonetheless choke or lose data\n if your data uses self-closing tags or declarations\n incorrectly.\n\n By default, Beautiful Soup uses regexes to sanitize input,\n avoiding the vast majority of these problems. If the problems\n don't apply to you, pass in False for markupMassage, and\n you'll get better performance.\n\n The default parser massage techniques fix the two most common\n instances of invalid HTML that choke sgmllib:\n\n (No space between name of closing tag and tag close)\n (Extraneous whitespace in declaration)\n\n You can pass in a custom list of (RE object, replace method)\n tuples to get Beautiful Soup to scrub your input the way you\n want.","docstring_summary":"The Soup object is initialized as the 'root tag', and the\n provided markup (which can be a string or a file-like object)\n is fed into the underlying parser.","docstring_tokens":["The","Soup","object","is","initialized","as","the","root","tag","and","the","provided","markup","(","which","can","be","a","string","or","a","file","-","like","object",")","is","fed","into","the","underlying","parser","."],"function":"def __init__(self, markup=\"\", parseOnlyThese=None, fromEncoding=None,\n markupMassage=True, smartQuotesTo=XML_ENTITIES,\n convertEntities=None, selfClosingTags=None, isHTML=False):\n \"\"\"The Soup object is initialized as the 'root tag', and the\n provided markup (which can be a string or a file-like object)\n is fed into the underlying parser.\n\n sgmllib will process most bad HTML, and the BeautifulSoup\n class has some tricks for dealing with some HTML that kills\n sgmllib, but Beautiful Soup can nonetheless choke or lose data\n if your data uses self-closing tags or declarations\n incorrectly.\n\n By default, Beautiful Soup uses regexes to sanitize input,\n avoiding the vast majority of these problems. If the problems\n don't apply to you, pass in False for markupMassage, and\n you'll get better performance.\n\n The default parser massage techniques fix the two most common\n instances of invalid HTML that choke sgmllib:\n\n (No space between name of closing tag and tag close)\n (Extraneous whitespace in declaration)\n\n You can pass in a custom list of (RE object, replace method)\n tuples to get Beautiful Soup to scrub your input the way you\n want.\"\"\"\n\n self.parseOnlyThese = parseOnlyThese\n self.fromEncoding = fromEncoding\n self.smartQuotesTo = smartQuotesTo\n self.convertEntities = convertEntities\n # Set the rules for how we'll deal with the entities we\n # encounter\n if self.convertEntities:\n # It doesn't make sense to convert encoded characters to\n # entities even while you're converting entities to Unicode.\n # Just convert it all to Unicode.\n self.smartQuotesTo = None\n if convertEntities == self.HTML_ENTITIES:\n self.convertXMLEntities = False\n self.convertHTMLEntities = True\n self.escapeUnrecognizedEntities = True\n elif convertEntities == self.XHTML_ENTITIES:\n self.convertXMLEntities = True\n self.convertHTMLEntities = True\n self.escapeUnrecognizedEntities = False\n elif convertEntities == self.XML_ENTITIES:\n self.convertXMLEntities = True\n self.convertHTMLEntities = False\n self.escapeUnrecognizedEntities = False\n else:\n self.convertXMLEntities = False\n self.convertHTMLEntities = False\n self.escapeUnrecognizedEntities = False\n\n self.instanceSelfClosingTags = buildTagMap(None, selfClosingTags)\n SGMLParser.__init__(self)\n\n if hasattr(markup, 'read'): # It's a file-type object.\n markup = markup.read()\n self.markup = markup\n self.markupMassage = markupMassage\n try:\n self._feed(isHTML=isHTML)\n except StopParsing:\n pass\n self.markup = None","function_tokens":["def","__init__","(","self",",","markup","=","\"\"",",","parseOnlyThese","=","None",",","fromEncoding","=","None",",","markupMassage","=","True",",","smartQuotesTo","=","XML_ENTITIES",",","convertEntities","=","None",",","selfClosingTags","=","None",",","isHTML","=","False",")",":","self",".","parseOnlyThese","=","parseOnlyThese","self",".","fromEncoding","=","fromEncoding","self",".","smartQuotesTo","=","smartQuotesTo","self",".","convertEntities","=","convertEntities","# Set the rules for how we'll deal with the entities we","# encounter","if","self",".","convertEntities",":","# It doesn't make sense to convert encoded characters to","# entities even while you're converting entities to Unicode.","# Just convert it all to Unicode.","self",".","smartQuotesTo","=","None","if","convertEntities","==","self",".","HTML_ENTITIES",":","self",".","convertXMLEntities","=","False","self",".","convertHTMLEntities","=","True","self",".","escapeUnrecognizedEntities","=","True","elif","convertEntities","==","self",".","XHTML_ENTITIES",":","self",".","convertXMLEntities","=","True","self",".","convertHTMLEntities","=","True","self",".","escapeUnrecognizedEntities","=","False","elif","convertEntities","==","self",".","XML_ENTITIES",":","self",".","convertXMLEntities","=","True","self",".","convertHTMLEntities","=","False","self",".","escapeUnrecognizedEntities","=","False","else",":","self",".","convertXMLEntities","=","False","self",".","convertHTMLEntities","=","False","self",".","escapeUnrecognizedEntities","=","False","self",".","instanceSelfClosingTags","=","buildTagMap","(","None",",","selfClosingTags",")","SGMLParser",".","__init__","(","self",")","if","hasattr","(","markup",",","'read'",")",":","# It's a file-type object.","markup","=","markup",".","read","(",")","self",".","markup","=","markup","self",".","markupMassage","=","markupMassage","try",":","self",".","_feed","(","isHTML","=","isHTML",")","except","StopParsing",":","pass","self",".","markup","=","None"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1025-L1092"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.convert_charref","parameters":"(self, name)","argument_list":"","return_statement":"return self.convert_codepoint(n)","docstring":"This method fixes a bug in Python's SGMLParser.","docstring_summary":"This method fixes a bug in Python's SGMLParser.","docstring_tokens":["This","method","fixes","a","bug","in","Python","s","SGMLParser","."],"function":"def convert_charref(self, name):\n \"\"\"This method fixes a bug in Python's SGMLParser.\"\"\"\n try:\n n = int(name)\n except ValueError:\n return\n if not 0 <= n <= 127 : # ASCII ends at 127, not 255\n return\n return self.convert_codepoint(n)","function_tokens":["def","convert_charref","(","self",",","name",")",":","try",":","n","=","int","(","name",")","except","ValueError",":","return","if","not","0","<=","n","<=","127",":","# ASCII ends at 127, not 255","return","return","self",".","convert_codepoint","(","n",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1094-L1102"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.__getattr__","parameters":"(self, methodName)","argument_list":"","return_statement":"","docstring":"This method routes method call requests to either the SGMLParser\n superclass or the Tag superclass, depending on the method name.","docstring_summary":"This method routes method call requests to either the SGMLParser\n superclass or the Tag superclass, depending on the method name.","docstring_tokens":["This","method","routes","method","call","requests","to","either","the","SGMLParser","superclass","or","the","Tag","superclass","depending","on","the","method","name","."],"function":"def __getattr__(self, methodName):\n \"\"\"This method routes method call requests to either the SGMLParser\n superclass or the Tag superclass, depending on the method name.\"\"\"\n #print \"__getattr__ called on %s.%s\" % (self.__class__, methodName)\n\n if methodName.find('start_') == 0 or methodName.find('end_') == 0 \\\n or methodName.find('do_') == 0:\n return SGMLParser.__getattr__(self, methodName)\n elif methodName.find('__') != 0:\n return Tag.__getattr__(self, methodName)\n else:\n raise AttributeError","function_tokens":["def","__getattr__","(","self",",","methodName",")",":","#print \"__getattr__ called on %s.%s\" % (self.__class__, methodName)","if","methodName",".","find","(","'start_'",")","==","0","or","methodName",".","find","(","'end_'",")","==","0","or","methodName",".","find","(","'do_'",")","==","0",":","return","SGMLParser",".","__getattr__","(","self",",","methodName",")","elif","methodName",".","find","(","'__'",")","!=","0",":","return","Tag",".","__getattr__","(","self",",","methodName",")","else",":","raise","AttributeError"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1137-L1148"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.isSelfClosingTag","parameters":"(self, name)","argument_list":"","return_statement":"return self.SELF_CLOSING_TAGS.has_key(name) \\\n or self.instanceSelfClosingTags.has_key(name)","docstring":"Returns true iff the given string is the name of a\n self-closing tag according to this parser.","docstring_summary":"Returns true iff the given string is the name of a\n self-closing tag according to this parser.","docstring_tokens":["Returns","true","iff","the","given","string","is","the","name","of","a","self","-","closing","tag","according","to","this","parser","."],"function":"def isSelfClosingTag(self, name):\n \"\"\"Returns true iff the given string is the name of a\n self-closing tag according to this parser.\"\"\"\n return self.SELF_CLOSING_TAGS.has_key(name) \\\n or self.instanceSelfClosingTags.has_key(name)","function_tokens":["def","isSelfClosingTag","(","self",",","name",")",":","return","self",".","SELF_CLOSING_TAGS",".","has_key","(","name",")","or","self",".","instanceSelfClosingTags",".","has_key","(","name",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1150-L1154"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup._popToTag","parameters":"(self, name, inclusivePop=True)","argument_list":"","return_statement":"return mostRecentTag","docstring":"Pops the tag stack up to and including the most recent\n instance of the given tag. If inclusivePop is false, pops the tag\n stack up to but *not* including the most recent instqance of\n the given tag.","docstring_summary":"Pops the tag stack up to and including the most recent\n instance of the given tag. If inclusivePop is false, pops the tag\n stack up to but *not* including the most recent instqance of\n the given tag.","docstring_tokens":["Pops","the","tag","stack","up","to","and","including","the","most","recent","instance","of","the","given","tag",".","If","inclusivePop","is","false","pops","the","tag","stack","up","to","but","*","not","*","including","the","most","recent","instqance","of","the","given","tag","."],"function":"def _popToTag(self, name, inclusivePop=True):\n \"\"\"Pops the tag stack up to and including the most recent\n instance of the given tag. If inclusivePop is false, pops the tag\n stack up to but *not* including the most recent instqance of\n the given tag.\"\"\"\n #print \"Popping to %s\" % name\n if name == self.ROOT_TAG_NAME:\n return\n\n numPops = 0\n mostRecentTag = None\n for i in range(len(self.tagStack)-1, 0, -1):\n if name == self.tagStack[i].name:\n numPops = len(self.tagStack)-i\n break\n if not inclusivePop:\n numPops = numPops - 1\n\n for i in range(0, numPops):\n mostRecentTag = self.popTag()\n return mostRecentTag","function_tokens":["def","_popToTag","(","self",",","name",",","inclusivePop","=","True",")",":","#print \"Popping to %s\" % name","if","name","==","self",".","ROOT_TAG_NAME",":","return","numPops","=","0","mostRecentTag","=","None","for","i","in","range","(","len","(","self",".","tagStack",")","-","1",",","0",",","-","1",")",":","if","name","==","self",".","tagStack","[","i","]",".","name",":","numPops","=","len","(","self",".","tagStack",")","-","i","break","if","not","inclusivePop",":","numPops","=","numPops","-","1","for","i","in","range","(","0",",","numPops",")",":","mostRecentTag","=","self",".","popTag","(",")","return","mostRecentTag"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1210-L1230"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup._smartPop","parameters":"(self, name)","argument_list":"","return_statement":"","docstring":"We need to pop up to the previous tag of this type, unless\n one of this tag's nesting reset triggers comes between this\n tag and the previous tag of this type, OR unless this tag is a\n generic nesting trigger and another generic nesting trigger\n comes between this tag and the previous tag of this type.\n\n Examples:\n

FooBar *

* should pop to 'p', not 'b'.\n

FooBar *

* should pop to 'table', not 'p'.\n

Foo

Bar *

* should pop to 'tr', not 'p'.\n\n

    • *
    • * should pop to 'ul', not the first 'li'.\n
  • ** should pop to 'table', not the first 'tr'\n
    ** should pop to 'tr', not the first 'td'","docstring_summary":"We need to pop up to the previous tag of this type, unless\n one of this tag's nesting reset triggers comes between this\n tag and the previous tag of this type, OR unless this tag is a\n generic nesting trigger and another generic nesting trigger\n comes between this tag and the previous tag of this type.","docstring_tokens":["We","need","to","pop","up","to","the","previous","tag","of","this","type","unless","one","of","this","tag","s","nesting","reset","triggers","comes","between","this","tag","and","the","previous","tag","of","this","type","OR","unless","this","tag","is","a","generic","nesting","trigger","and","another","generic","nesting","trigger","comes","between","this","tag","and","the","previous","tag","of","this","type","."],"function":"def _smartPop(self, name):\n\n \"\"\"We need to pop up to the previous tag of this type, unless\n one of this tag's nesting reset triggers comes between this\n tag and the previous tag of this type, OR unless this tag is a\n generic nesting trigger and another generic nesting trigger\n comes between this tag and the previous tag of this type.\n\n Examples:\n

    FooBar *

    * should pop to 'p', not 'b'.\n

    FooBar *

    * should pop to 'table', not 'p'.\n

    Foo

    Bar *

    * should pop to 'tr', not 'p'.\n\n

    • *
    • * should pop to 'ul', not the first 'li'.\n
  • ** should pop to 'table', not the first 'tr'\n
    ** should pop to 'tr', not the first 'td'\n \"\"\"\n\n nestingResetTriggers = self.NESTABLE_TAGS.get(name)\n isNestable = nestingResetTriggers != None\n isResetNesting = self.RESET_NESTING_TAGS.has_key(name)\n popTo = None\n inclusive = True\n for i in range(len(self.tagStack)-1, 0, -1):\n p = self.tagStack[i]\n if (not p or p.name == name) and not isNestable:\n #Non-nestable tags get popped to the top or to their\n #last occurance.\n popTo = name\n break\n if (nestingResetTriggers != None\n and p.name in nestingResetTriggers) \\\n or (nestingResetTriggers == None and isResetNesting\n and self.RESET_NESTING_TAGS.has_key(p.name)):\n\n #If we encounter one of the nesting reset triggers\n #peculiar to this tag, or we encounter another tag\n #that causes nesting to reset, pop up to but not\n #including that tag.\n popTo = p.name\n inclusive = False\n break\n p = p.parent\n if popTo:\n self._popToTag(popTo, inclusive)","function_tokens":["def","_smartPop","(","self",",","name",")",":","nestingResetTriggers","=","self",".","NESTABLE_TAGS",".","get","(","name",")","isNestable","=","nestingResetTriggers","!=","None","isResetNesting","=","self",".","RESET_NESTING_TAGS",".","has_key","(","name",")","popTo","=","None","inclusive","=","True","for","i","in","range","(","len","(","self",".","tagStack",")","-","1",",","0",",","-","1",")",":","p","=","self",".","tagStack","[","i","]","if","(","not","p","or","p",".","name","==","name",")","and","not","isNestable",":","#Non-nestable tags get popped to the top or to their","#last occurance.","popTo","=","name","break","if","(","nestingResetTriggers","!=","None","and","p",".","name","in","nestingResetTriggers",")","or","(","nestingResetTriggers","==","None","and","isResetNesting","and","self",".","RESET_NESTING_TAGS",".","has_key","(","p",".","name",")",")",":","#If we encounter one of the nesting reset triggers","#peculiar to this tag, or we encounter another tag","#that causes nesting to reset, pop up to but not","#including that tag.","popTo","=","p",".","name","inclusive","=","False","break","p","=","p",".","parent","if","popTo",":","self",".","_popToTag","(","popTo",",","inclusive",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1232-L1276"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup._toStringSubclass","parameters":"(self, text, subclass)","argument_list":"","return_statement":"","docstring":"Adds a certain piece of text to the tree as a NavigableString\n subclass.","docstring_summary":"Adds a certain piece of text to the tree as a NavigableString\n subclass.","docstring_tokens":["Adds","a","certain","piece","of","text","to","the","tree","as","a","NavigableString","subclass","."],"function":"def _toStringSubclass(self, text, subclass):\n \"\"\"Adds a certain piece of text to the tree as a NavigableString\n subclass.\"\"\"\n self.endData()\n self.handle_data(text)\n self.endData(subclass)","function_tokens":["def","_toStringSubclass","(","self",",","text",",","subclass",")",":","self",".","endData","(",")","self",".","handle_data","(","text",")","self",".","endData","(","subclass",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1324-L1329"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.handle_pi","parameters":"(self, text)","argument_list":"","return_statement":"","docstring":"Handle a processing instruction as a ProcessingInstruction\n object, possibly one with a %SOUP-ENCODING% slot into which an\n encoding will be plugged later.","docstring_summary":"Handle a processing instruction as a ProcessingInstruction\n object, possibly one with a %SOUP-ENCODING% slot into which an\n encoding will be plugged later.","docstring_tokens":["Handle","a","processing","instruction","as","a","ProcessingInstruction","object","possibly","one","with","a","%SOUP","-","ENCODING%","slot","into","which","an","encoding","will","be","plugged","later","."],"function":"def handle_pi(self, text):\n \"\"\"Handle a processing instruction as a ProcessingInstruction\n object, possibly one with a %SOUP-ENCODING% slot into which an\n encoding will be plugged later.\"\"\"\n if text[:3] == \"xml\":\n text = u\"xml version='1.0' encoding='%SOUP-ENCODING%'\"\n self._toStringSubclass(text, ProcessingInstruction)","function_tokens":["def","handle_pi","(","self",",","text",")",":","if","text","[",":","3","]","==","\"xml\"",":","text","=","u\"xml version='1.0' encoding='%SOUP-ENCODING%'\"","self",".","_toStringSubclass","(","text",",","ProcessingInstruction",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1331-L1337"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.handle_comment","parameters":"(self, text)","argument_list":"","return_statement":"","docstring":"Handle comments as Comment objects.","docstring_summary":"Handle comments as Comment objects.","docstring_tokens":["Handle","comments","as","Comment","objects","."],"function":"def handle_comment(self, text):\n \"Handle comments as Comment objects.\"\n self._toStringSubclass(text, Comment)","function_tokens":["def","handle_comment","(","self",",","text",")",":","self",".","_toStringSubclass","(","text",",","Comment",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1339-L1341"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.handle_charref","parameters":"(self, ref)","argument_list":"","return_statement":"","docstring":"Handle character references as data.","docstring_summary":"Handle character references as data.","docstring_tokens":["Handle","character","references","as","data","."],"function":"def handle_charref(self, ref):\n \"Handle character references as data.\"\n if self.convertEntities:\n data = unichr(int(ref))\n else:\n data = '&#%s;' % ref\n self.handle_data(data)","function_tokens":["def","handle_charref","(","self",",","ref",")",":","if","self",".","convertEntities",":","data","=","unichr","(","int","(","ref",")",")","else",":","data","=","'&#%s;'","%","ref","self",".","handle_data","(","data",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1343-L1349"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.handle_entityref","parameters":"(self, ref)","argument_list":"","return_statement":"","docstring":"Handle entity references as data, possibly converting known\n HTML and\/or XML entity references to the corresponding Unicode\n characters.","docstring_summary":"Handle entity references as data, possibly converting known\n HTML and\/or XML entity references to the corresponding Unicode\n characters.","docstring_tokens":["Handle","entity","references","as","data","possibly","converting","known","HTML","and","\/","or","XML","entity","references","to","the","corresponding","Unicode","characters","."],"function":"def handle_entityref(self, ref):\n \"\"\"Handle entity references as data, possibly converting known\n HTML and\/or XML entity references to the corresponding Unicode\n characters.\"\"\"\n data = None\n if self.convertHTMLEntities:\n try:\n data = unichr(name2codepoint[ref])\n except KeyError:\n pass\n\n if not data and self.convertXMLEntities:\n data = self.XML_ENTITIES_TO_SPECIAL_CHARS.get(ref)\n\n if not data and self.convertHTMLEntities and \\\n not self.XML_ENTITIES_TO_SPECIAL_CHARS.get(ref):\n # TODO: We've got a problem here. We're told this is\n # an entity reference, but it's not an XML entity\n # reference or an HTML entity reference. Nonetheless,\n # the logical thing to do is to pass it through as an\n # unrecognized entity reference.\n #\n # Except: when the input is \"&carol;\" this function\n # will be called with input \"carol\". When the input is\n # \"AT&T\", this function will be called with input\n # \"T\". We have no way of knowing whether a semicolon\n # was present originally, so we don't know whether\n # this is an unknown entity or just a misplaced\n # ampersand.\n #\n # The more common case is a misplaced ampersand, so I\n # escape the ampersand and omit the trailing semicolon.\n data = \"&%s\" % ref\n if not data:\n # This case is different from the one above, because we\n # haven't already gone through a supposedly comprehensive\n # mapping of entities to Unicode characters. We might not\n # have gone through any mapping at all. So the chances are\n # very high that this is a real entity, and not a\n # misplaced ampersand.\n data = \"&%s;\" % ref\n self.handle_data(data)","function_tokens":["def","handle_entityref","(","self",",","ref",")",":","data","=","None","if","self",".","convertHTMLEntities",":","try",":","data","=","unichr","(","name2codepoint","[","ref","]",")","except","KeyError",":","pass","if","not","data","and","self",".","convertXMLEntities",":","data","=","self",".","XML_ENTITIES_TO_SPECIAL_CHARS",".","get","(","ref",")","if","not","data","and","self",".","convertHTMLEntities","and","not","self",".","XML_ENTITIES_TO_SPECIAL_CHARS",".","get","(","ref",")",":","# TODO: We've got a problem here. We're told this is","# an entity reference, but it's not an XML entity","# reference or an HTML entity reference. Nonetheless,","# the logical thing to do is to pass it through as an","# unrecognized entity reference.","#","# Except: when the input is \"&carol;\" this function","# will be called with input \"carol\". When the input is","# \"AT&T\", this function will be called with input","# \"T\". We have no way of knowing whether a semicolon","# was present originally, so we don't know whether","# this is an unknown entity or just a misplaced","# ampersand.","#","# The more common case is a misplaced ampersand, so I","# escape the ampersand and omit the trailing semicolon.","data","=","\"&%s\"","%","ref","if","not","data",":","# This case is different from the one above, because we","# haven't already gone through a supposedly comprehensive","# mapping of entities to Unicode characters. We might not","# have gone through any mapping at all. So the chances are","# very high that this is a real entity, and not a","# misplaced ampersand.","data","=","\"&%s;\"","%","ref","self",".","handle_data","(","data",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1351-L1392"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.handle_decl","parameters":"(self, data)","argument_list":"","return_statement":"","docstring":"Handle DOCTYPEs and the like as Declaration objects.","docstring_summary":"Handle DOCTYPEs and the like as Declaration objects.","docstring_tokens":["Handle","DOCTYPEs","and","the","like","as","Declaration","objects","."],"function":"def handle_decl(self, data):\n \"Handle DOCTYPEs and the like as Declaration objects.\"\n self._toStringSubclass(data, Declaration)","function_tokens":["def","handle_decl","(","self",",","data",")",":","self",".","_toStringSubclass","(","data",",","Declaration",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1394-L1396"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulStoneSoup.parse_declaration","parameters":"(self, i)","argument_list":"","return_statement":"return j","docstring":"Treat a bogus SGML declaration as raw data. Treat a CDATA\n declaration as a CData object.","docstring_summary":"Treat a bogus SGML declaration as raw data. Treat a CDATA\n declaration as a CData object.","docstring_tokens":["Treat","a","bogus","SGML","declaration","as","raw","data",".","Treat","a","CDATA","declaration","as","a","CData","object","."],"function":"def parse_declaration(self, i):\n \"\"\"Treat a bogus SGML declaration as raw data. Treat a CDATA\n declaration as a CData object.\"\"\"\n j = None\n if self.rawdata[i:i+9] == '', i)\n if k == -1:\n k = len(self.rawdata)\n data = self.rawdata[i+9:k]\n j = k+3\n self._toStringSubclass(data, CData)\n else:\n try:\n j = SGMLParser.parse_declaration(self, i)\n except SGMLParseError:\n toHandle = self.rawdata[i:]\n self.handle_data(toHandle)\n j = i + len(toHandle)\n return j","function_tokens":["def","parse_declaration","(","self",",","i",")",":","j","=","None","if","self",".","rawdata","[","i",":","i","+","9","]","==","''",",","i",")","if","k","==","-","1",":","k","=","len","(","self",".","rawdata",")","data","=","self",".","rawdata","[","i","+","9",":","k","]","j","=","k","+","3","self",".","_toStringSubclass","(","data",",","CData",")","else",":","try",":","j","=","SGMLParser",".","parse_declaration","(","self",",","i",")","except","SGMLParseError",":","toHandle","=","self",".","rawdata","[","i",":","]","self",".","handle_data","(","toHandle",")","j","=","i","+","len","(","toHandle",")","return","j"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1398-L1416"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"BeautifulSoup.start_meta","parameters":"(self, attrs)","argument_list":"","return_statement":"","docstring":"Beautiful Soup can detect a charset included in a META tag,\n try to convert the document to that charset, and re-parse the\n document from the beginning.","docstring_summary":"Beautiful Soup can detect a charset included in a META tag,\n try to convert the document to that charset, and re-parse the\n document from the beginning.","docstring_tokens":["Beautiful","Soup","can","detect","a","charset","included","in","a","META","tag","try","to","convert","the","document","to","that","charset","and","re","-","parse","the","document","from","the","beginning","."],"function":"def start_meta(self, attrs):\n \"\"\"Beautiful Soup can detect a charset included in a META tag,\n try to convert the document to that charset, and re-parse the\n document from the beginning.\"\"\"\n httpEquiv = None\n contentType = None\n contentTypeIndex = None\n tagNeedsEncodingSubstitution = False\n\n for i in range(0, len(attrs)):\n key, value = attrs[i]\n key = key.lower()\n if key == 'http-equiv':\n httpEquiv = value\n elif key == 'content':\n contentType = value\n contentTypeIndex = i\n\n if httpEquiv and contentType: # It's an interesting meta tag.\n match = self.CHARSET_RE.search(contentType)\n if match:\n if (self.declaredHTMLEncoding is not None or\n self.originalEncoding == self.fromEncoding):\n # An HTML encoding was sniffed while converting\n # the document to Unicode, or an HTML encoding was\n # sniffed during a previous pass through the\n # document, or an encoding was specified\n # explicitly and it worked. Rewrite the meta tag.\n def rewrite(match):\n return match.group(1) + \"%SOUP-ENCODING%\"\n newAttr = self.CHARSET_RE.sub(rewrite, contentType)\n attrs[contentTypeIndex] = (attrs[contentTypeIndex][0],\n newAttr)\n tagNeedsEncodingSubstitution = True\n else:\n # This is our first pass through the document.\n # Go through it again with the encoding information.\n newCharset = match.group(3)\n if newCharset and newCharset != self.originalEncoding:\n self.declaredHTMLEncoding = newCharset\n self._feed(self.declaredHTMLEncoding)\n raise StopParsing\n pass\n tag = self.unknown_starttag(\"meta\", attrs)\n if tag and tagNeedsEncodingSubstitution:\n tag.containsSubstitutions = True","function_tokens":["def","start_meta","(","self",",","attrs",")",":","httpEquiv","=","None","contentType","=","None","contentTypeIndex","=","None","tagNeedsEncodingSubstitution","=","False","for","i","in","range","(","0",",","len","(","attrs",")",")",":","key",",","value","=","attrs","[","i","]","key","=","key",".","lower","(",")","if","key","==","'http-equiv'",":","httpEquiv","=","value","elif","key","==","'content'",":","contentType","=","value","contentTypeIndex","=","i","if","httpEquiv","and","contentType",":","# It's an interesting meta tag.","match","=","self",".","CHARSET_RE",".","search","(","contentType",")","if","match",":","if","(","self",".","declaredHTMLEncoding","is","not","None","or","self",".","originalEncoding","==","self",".","fromEncoding",")",":","# An HTML encoding was sniffed while converting","# the document to Unicode, or an HTML encoding was","# sniffed during a previous pass through the","# document, or an encoding was specified","# explicitly and it worked. Rewrite the meta tag.","def","rewrite","(","match",")",":","return","match",".","group","(","1",")","+","\"%SOUP-ENCODING%\"","newAttr","=","self",".","CHARSET_RE",".","sub","(","rewrite",",","contentType",")","attrs","[","contentTypeIndex","]","=","(","attrs","[","contentTypeIndex","]","[","0","]",",","newAttr",")","tagNeedsEncodingSubstitution","=","True","else",":","# This is our first pass through the document.","# Go through it again with the encoding information.","newCharset","=","match",".","group","(","3",")","if","newCharset","and","newCharset","!=","self",".","originalEncoding",":","self",".","declaredHTMLEncoding","=","newCharset","self",".","_feed","(","self",".","declaredHTMLEncoding",")","raise","StopParsing","pass","tag","=","self",".","unknown_starttag","(","\"meta\"",",","attrs",")","if","tag","and","tagNeedsEncodingSubstitution",":","tag",".","containsSubstitutions","=","True"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1524-L1569"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"UnicodeDammit._subMSChar","parameters":"(self, orig)","argument_list":"","return_statement":"return sub","docstring":"Changes a MS smart quote character to an XML or HTML\n entity.","docstring_summary":"Changes a MS smart quote character to an XML or HTML\n entity.","docstring_tokens":["Changes","a","MS","smart","quote","character","to","an","XML","or","HTML","entity","."],"function":"def _subMSChar(self, orig):\n \"\"\"Changes a MS smart quote character to an XML or HTML\n entity.\"\"\"\n sub = self.MS_CHARS.get(orig)\n if type(sub) == types.TupleType:\n if self.smartQuotesTo == 'xml':\n sub = '&#x%s;' % sub[1]\n else:\n sub = '&%s;' % sub[0]\n return sub","function_tokens":["def","_subMSChar","(","self",",","orig",")",":","sub","=","self",".","MS_CHARS",".","get","(","orig",")","if","type","(","sub",")","==","types",".","TupleType",":","if","self",".","smartQuotesTo","==","'xml'",":","sub","=","'&#x%s;'","%","sub","[","1","]","else",":","sub","=","'&%s;'","%","sub","[","0","]","return","sub"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1751-L1760"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"UnicodeDammit._toUnicode","parameters":"(self, data, encoding)","argument_list":"","return_statement":"return newdata","docstring":"Given a string and its encoding, decodes the string into Unicode.\n %encoding is a string recognized by encodings.aliases","docstring_summary":"Given a string and its encoding, decodes the string into Unicode.\n %encoding is a string recognized by encodings.aliases","docstring_tokens":["Given","a","string","and","its","encoding","decodes","the","string","into","Unicode",".","%encoding","is","a","string","recognized","by","encodings",".","aliases"],"function":"def _toUnicode(self, data, encoding):\n '''Given a string and its encoding, decodes the string into Unicode.\n %encoding is a string recognized by encodings.aliases'''\n\n # strip Byte Order Mark (if present)\n if (len(data) >= 4) and (data[:2] == '\\xfe\\xff') \\\n and (data[2:4] != '\\x00\\x00'):\n encoding = 'utf-16be'\n data = data[2:]\n elif (len(data) >= 4) and (data[:2] == '\\xff\\xfe') \\\n and (data[2:4] != '\\x00\\x00'):\n encoding = 'utf-16le'\n data = data[2:]\n elif data[:3] == '\\xef\\xbb\\xbf':\n encoding = 'utf-8'\n data = data[3:]\n elif data[:4] == '\\x00\\x00\\xfe\\xff':\n encoding = 'utf-32be'\n data = data[4:]\n elif data[:4] == '\\xff\\xfe\\x00\\x00':\n encoding = 'utf-32le'\n data = data[4:]\n newdata = unicode(data, encoding)\n return newdata","function_tokens":["def","_toUnicode","(","self",",","data",",","encoding",")",":","# strip Byte Order Mark (if present)","if","(","len","(","data",")",">=","4",")","and","(","data","[",":","2","]","==","'\\xfe\\xff'",")","and","(","data","[","2",":","4","]","!=","'\\x00\\x00'",")",":","encoding","=","'utf-16be'","data","=","data","[","2",":","]","elif","(","len","(","data",")",">=","4",")","and","(","data","[",":","2","]","==","'\\xff\\xfe'",")","and","(","data","[","2",":","4","]","!=","'\\x00\\x00'",")",":","encoding","=","'utf-16le'","data","=","data","[","2",":","]","elif","data","[",":","3","]","==","'\\xef\\xbb\\xbf'",":","encoding","=","'utf-8'","data","=","data","[","3",":","]","elif","data","[",":","4","]","==","'\\x00\\x00\\xfe\\xff'",":","encoding","=","'utf-32be'","data","=","data","[","4",":","]","elif","data","[",":","4","]","==","'\\xff\\xfe\\x00\\x00'",":","encoding","=","'utf-32le'","data","=","data","[","4",":","]","newdata","=","unicode","(","data",",","encoding",")","return","newdata"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1790-L1813"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/BeautifulSoup.py","language":"python","identifier":"UnicodeDammit._detectEncoding","parameters":"(self, xml_data, isHTML=False)","argument_list":"","return_statement":"return xml_data, xml_encoding, sniffed_xml_encoding","docstring":"Given a document, tries to detect its XML encoding.","docstring_summary":"Given a document, tries to detect its XML encoding.","docstring_tokens":["Given","a","document","tries","to","detect","its","XML","encoding","."],"function":"def _detectEncoding(self, xml_data, isHTML=False):\n \"\"\"Given a document, tries to detect its XML encoding.\"\"\"\n xml_encoding = sniffed_xml_encoding = None\n try:\n if xml_data[:4] == '\\x4c\\x6f\\xa7\\x94':\n # EBCDIC\n xml_data = self._ebcdic_to_ascii(xml_data)\n elif xml_data[:4] == '\\x00\\x3c\\x00\\x3f':\n # UTF-16BE\n sniffed_xml_encoding = 'utf-16be'\n xml_data = unicode(xml_data, 'utf-16be').encode('utf-8')\n elif (len(xml_data) >= 4) and (xml_data[:2] == '\\xfe\\xff') \\\n and (xml_data[2:4] != '\\x00\\x00'):\n # UTF-16BE with BOM\n sniffed_xml_encoding = 'utf-16be'\n xml_data = unicode(xml_data[2:], 'utf-16be').encode('utf-8')\n elif xml_data[:4] == '\\x3c\\x00\\x3f\\x00':\n # UTF-16LE\n sniffed_xml_encoding = 'utf-16le'\n xml_data = unicode(xml_data, 'utf-16le').encode('utf-8')\n elif (len(xml_data) >= 4) and (xml_data[:2] == '\\xff\\xfe') and \\\n (xml_data[2:4] != '\\x00\\x00'):\n # UTF-16LE with BOM\n sniffed_xml_encoding = 'utf-16le'\n xml_data = unicode(xml_data[2:], 'utf-16le').encode('utf-8')\n elif xml_data[:4] == '\\x00\\x00\\x00\\x3c':\n # UTF-32BE\n sniffed_xml_encoding = 'utf-32be'\n xml_data = unicode(xml_data, 'utf-32be').encode('utf-8')\n elif xml_data[:4] == '\\x3c\\x00\\x00\\x00':\n # UTF-32LE\n sniffed_xml_encoding = 'utf-32le'\n xml_data = unicode(xml_data, 'utf-32le').encode('utf-8')\n elif xml_data[:4] == '\\x00\\x00\\xfe\\xff':\n # UTF-32BE with BOM\n sniffed_xml_encoding = 'utf-32be'\n xml_data = unicode(xml_data[4:], 'utf-32be').encode('utf-8')\n elif xml_data[:4] == '\\xff\\xfe\\x00\\x00':\n # UTF-32LE with BOM\n sniffed_xml_encoding = 'utf-32le'\n xml_data = unicode(xml_data[4:], 'utf-32le').encode('utf-8')\n elif xml_data[:3] == '\\xef\\xbb\\xbf':\n # UTF-8 with BOM\n sniffed_xml_encoding = 'utf-8'\n xml_data = unicode(xml_data[3:], 'utf-8').encode('utf-8')\n else:\n sniffed_xml_encoding = 'ascii'\n pass\n except:\n xml_encoding_match = None\n xml_encoding_match = re.compile(\n '^<\\?.*encoding=[\\'\"](.*?)[\\'\"].*\\?>').match(xml_data)\n if not xml_encoding_match and isHTML:\n regexp = re.compile('<\\s*meta[^>]+charset=([^>]*?)[;\\'\">]', re.I)\n xml_encoding_match = regexp.search(xml_data)\n if xml_encoding_match is not None:\n xml_encoding = xml_encoding_match.groups()[0].lower()\n if isHTML:\n self.declaredHTMLEncoding = xml_encoding\n if sniffed_xml_encoding and \\\n (xml_encoding in ('iso-10646-ucs-2', 'ucs-2', 'csunicode',\n 'iso-10646-ucs-4', 'ucs-4', 'csucs4',\n 'utf-16', 'utf-32', 'utf_16', 'utf_32',\n 'utf16', 'u16')):\n xml_encoding = sniffed_xml_encoding\n return xml_data, xml_encoding, sniffed_xml_encoding","function_tokens":["def","_detectEncoding","(","self",",","xml_data",",","isHTML","=","False",")",":","xml_encoding","=","sniffed_xml_encoding","=","None","try",":","if","xml_data","[",":","4","]","==","'\\x4c\\x6f\\xa7\\x94'",":","# EBCDIC","xml_data","=","self",".","_ebcdic_to_ascii","(","xml_data",")","elif","xml_data","[",":","4","]","==","'\\x00\\x3c\\x00\\x3f'",":","# UTF-16BE","sniffed_xml_encoding","=","'utf-16be'","xml_data","=","unicode","(","xml_data",",","'utf-16be'",")",".","encode","(","'utf-8'",")","elif","(","len","(","xml_data",")",">=","4",")","and","(","xml_data","[",":","2","]","==","'\\xfe\\xff'",")","and","(","xml_data","[","2",":","4","]","!=","'\\x00\\x00'",")",":","# UTF-16BE with BOM","sniffed_xml_encoding","=","'utf-16be'","xml_data","=","unicode","(","xml_data","[","2",":","]",",","'utf-16be'",")",".","encode","(","'utf-8'",")","elif","xml_data","[",":","4","]","==","'\\x3c\\x00\\x3f\\x00'",":","# UTF-16LE","sniffed_xml_encoding","=","'utf-16le'","xml_data","=","unicode","(","xml_data",",","'utf-16le'",")",".","encode","(","'utf-8'",")","elif","(","len","(","xml_data",")",">=","4",")","and","(","xml_data","[",":","2","]","==","'\\xff\\xfe'",")","and","(","xml_data","[","2",":","4","]","!=","'\\x00\\x00'",")",":","# UTF-16LE with BOM","sniffed_xml_encoding","=","'utf-16le'","xml_data","=","unicode","(","xml_data","[","2",":","]",",","'utf-16le'",")",".","encode","(","'utf-8'",")","elif","xml_data","[",":","4","]","==","'\\x00\\x00\\x00\\x3c'",":","# UTF-32BE","sniffed_xml_encoding","=","'utf-32be'","xml_data","=","unicode","(","xml_data",",","'utf-32be'",")",".","encode","(","'utf-8'",")","elif","xml_data","[",":","4","]","==","'\\x3c\\x00\\x00\\x00'",":","# UTF-32LE","sniffed_xml_encoding","=","'utf-32le'","xml_data","=","unicode","(","xml_data",",","'utf-32le'",")",".","encode","(","'utf-8'",")","elif","xml_data","[",":","4","]","==","'\\x00\\x00\\xfe\\xff'",":","# UTF-32BE with BOM","sniffed_xml_encoding","=","'utf-32be'","xml_data","=","unicode","(","xml_data","[","4",":","]",",","'utf-32be'",")",".","encode","(","'utf-8'",")","elif","xml_data","[",":","4","]","==","'\\xff\\xfe\\x00\\x00'",":","# UTF-32LE with BOM","sniffed_xml_encoding","=","'utf-32le'","xml_data","=","unicode","(","xml_data","[","4",":","]",",","'utf-32le'",")",".","encode","(","'utf-8'",")","elif","xml_data","[",":","3","]","==","'\\xef\\xbb\\xbf'",":","# UTF-8 with BOM","sniffed_xml_encoding","=","'utf-8'","xml_data","=","unicode","(","xml_data","[","3",":","]",",","'utf-8'",")",".","encode","(","'utf-8'",")","else",":","sniffed_xml_encoding","=","'ascii'","pass","except",":","xml_encoding_match","=","None","xml_encoding_match","=","re",".","compile","(","'^<\\?.*encoding=[\\'\"](.*?)[\\'\"].*\\?>'",")",".","match","(","xml_data",")","if","not","xml_encoding_match","and","isHTML",":","regexp","=","re",".","compile","(","'<\\s*meta[^>]+charset=([^>]*?)[;\\'\">]'",",","re",".","I",")","xml_encoding_match","=","regexp",".","search","(","xml_data",")","if","xml_encoding_match","is","not","None",":","xml_encoding","=","xml_encoding_match",".","groups","(",")","[","0","]",".","lower","(",")","if","isHTML",":","self",".","declaredHTMLEncoding","=","xml_encoding","if","sniffed_xml_encoding","and","(","xml_encoding","in","(","'iso-10646-ucs-2'",",","'ucs-2'",",","'csunicode'",",","'iso-10646-ucs-4'",",","'ucs-4'",",","'csucs4'",",","'utf-16'",",","'utf-32'",",","'utf_16'",",","'utf_32'",",","'utf16'",",","'u16'",")",")",":","xml_encoding","=","sniffed_xml_encoding","return","xml_data",",","xml_encoding",",","sniffed_xml_encoding"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/BeautifulSoup.py#L1815-L1880"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"_in_tag","parameters":"(text, tag)","argument_list":"","return_statement":"return text","docstring":"Extracts text from inside a tag.\n\n This function extracts the text from inside a given tag.\n It's useful to get the text between <\/body> or\n
    <\/pre> when using the validators or the colorizer.","docstring_summary":"Extracts text from inside a tag.","docstring_tokens":["Extracts","text","from","inside","a","tag","."],"function":"def _in_tag(text, tag):\n    \"\"\"Extracts text from inside a tag.\n\n    This function extracts the text from inside a given tag.\n    It's useful to get the text between <\/body> or\n    
    <\/pre> when using the validators or the colorizer.\n    \"\"\"\n    if text.count('<%s' % tag):\n        text = text.split('<%s' % tag, 1)[1]\n        if text.count('>'):\n            text = text.split('>', 1)[1]\n    if text.count('<\/%s' % tag):\n        text = text.split('<\/%s' % tag, 1)[0]\n\n    text = text.strip().replace('\\r\\n', '\\n')\n\n    return text","function_tokens":["def","_in_tag","(","text",",","tag",")",":","if","text",".","count","(","'<%s'","%","tag",")",":","text","=","text",".","split","(","'<%s'","%","tag",",","1",")","[","1","]","if","text",".","count","(","'>'",")",":","text","=","text",".","split","(","'>'",",","1",")","[","1","]","if","text",".","count","(","'<\/%s'","%","tag",")",":","text","=","text",".","split","(","'<\/%s'","%","tag",",","1",")","[","0","]","text","=","text",".","strip","(",")",".","replace","(","'\\r\\n'",",","'\\n'",")","return","text"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L167-L183"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"_debug","parameters":"(s, level=1)","argument_list":"","return_statement":"","docstring":"Outputs debug information to sys.stderr.\n\n    This function outputs debug information if DEBUGLEVEL is\n    higher than a given treshold.","docstring_summary":"Outputs debug information to sys.stderr.","docstring_tokens":["Outputs","debug","information","to","sys",".","stderr","."],"function":"def _debug(s, level=1):\n    \"\"\"Outputs debug information to sys.stderr.\n\n    This function outputs debug information if DEBUGLEVEL is\n    higher than a given treshold.\n    \"\"\"\n    if DEBUGLEVEL >= level: print >> sys.stderr, s","function_tokens":["def","_debug","(","s",",","level","=","1",")",":","if","DEBUGLEVEL",">=","level",":","print",">>","sys",".","stderr",",","s"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L258-L264"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"preg_replace","parameters":"(pattern, replacement, text)","argument_list":"","return_statement":"return p.sub(replacement_func, text)","docstring":"Alternative re.sub that handles empty groups.\n\n    This acts like re.sub, except it replaces empty groups with ''\n    instead of raising an exception.","docstring_summary":"Alternative re.sub that handles empty groups.","docstring_tokens":["Alternative","re",".","sub","that","handles","empty","groups","."],"function":"def preg_replace(pattern, replacement, text):\n    \"\"\"Alternative re.sub that handles empty groups.\n\n    This acts like re.sub, except it replaces empty groups with ''\n    instead of raising an exception.\n    \"\"\"\n\n    def replacement_func(matchobj):\n        counter = 1\n        rc = replacement\n        _debug(matchobj.groups())\n        for matchitem in matchobj.groups():\n            if not matchitem:\n                matchitem = ''\n\n            rc = rc.replace(r'\\%s' % counter, matchitem)\n            counter += 1\n\n        return rc\n        \n    p = re.compile(pattern)\n    _debug(pattern)\n\n    return p.sub(replacement_func, text)","function_tokens":["def","preg_replace","(","pattern",",","replacement",",","text",")",":","def","replacement_func","(","matchobj",")",":","counter","=","1","rc","=","replacement","_debug","(","matchobj",".","groups","(",")",")","for","matchitem","in","matchobj",".","groups","(",")",":","if","not","matchitem",":","matchitem","=","''","rc","=","rc",".","replace","(","r'\\%s'","%","counter",",","matchitem",")","counter","+=","1","return","rc","p","=","re",".","compile","(","pattern",")","_debug","(","pattern",")","return","p",".","sub","(","replacement_func",",","text",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L453-L476"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"html_replace","parameters":"(pattern, replacement, text)","argument_list":"","return_statement":"","docstring":"Replacement outside HTML tags.\n\n    Does a preg_replace only outside HTML tags.","docstring_summary":"Replacement outside HTML tags.","docstring_tokens":["Replacement","outside","HTML","tags","."],"function":"def html_replace(pattern, replacement, text):\n    \"\"\"Replacement outside HTML tags.\n\n    Does a preg_replace only outside HTML tags.\n    \"\"\"\n    # If there is no html, do a simple search and replace.\n    if not re.search(r'''<.*>''', text):\n        return preg_replace(pattern, replacement, text)\n\n    else:\n        lines = []\n        # Else split the text into an array at <>.\n        for line in re.split('(<.*?>)', text):\n            if not re.match('<.*?>', line):\n                line = preg_replace(pattern, replacement, line)\n\n            lines.append(line)\n\n        return ''.join(lines)","function_tokens":["def","html_replace","(","pattern",",","replacement",",","text",")",":","# If there is no html, do a simple search and replace.","if","not","re",".","search","(","r'''<.*>'''",",","text",")",":","return","preg_replace","(","pattern",",","replacement",",","text",")","else",":","lines","=","[","]","# Else split the text into an array at <>.","for","line","in","re",".","split","(","'(<.*?>)'",",","text",")",":","if","not","re",".","match","(","'<.*?>'",",","line",")",":","line","=","preg_replace","(","pattern",",","replacement",",","line",")","lines",".","append","(","line",")","return","''",".","join","(","lines",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L479-L497"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"textile","parameters":"(text, **args)","argument_list":"","return_statement":"return Textiler(text).process(**args)","docstring":"This is Textile.\n\n    Generates XHTML from a simple markup developed by Dean Allen.\n\n    This function should be called like this:\n    \n        textile(text, head_offset=0, validate=0, sanitize=0,\n                encoding='latin-1', output='ASCII')","docstring_summary":"This is Textile.","docstring_tokens":["This","is","Textile","."],"function":"def textile(text, **args):\n    \"\"\"This is Textile.\n\n    Generates XHTML from a simple markup developed by Dean Allen.\n\n    This function should be called like this:\n    \n        textile(text, head_offset=0, validate=0, sanitize=0,\n                encoding='latin-1', output='ASCII')\n    \"\"\"\n    return Textiler(text).process(**args)","function_tokens":["def","textile","(","text",",","*","*","args",")",":","return","Textiler","(","text",")",".","process","(","*","*","args",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L2859-L2869"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"_BaseHTMLProcessor.output","parameters":"(self)","argument_list":"","return_statement":"return \"\".join(self.pieces)","docstring":"Return processed HTML as a single string","docstring_summary":"Return processed HTML as a single string","docstring_tokens":["Return","processed","HTML","as","a","single","string"],"function":"def output(self):\n        \"\"\"Return processed HTML as a single string\"\"\"\n        return \"\".join(self.pieces)","function_tokens":["def","output","(","self",")",":","return","\"\"",".","join","(","self",".","pieces",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L569-L571"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.__init__","parameters":"(self, text='')","argument_list":"","return_statement":"","docstring":"Instantiate the class, passing the text to be formatted.\n            \n        Here we pre-process the text and collect all the link\n        lookups for later.","docstring_summary":"Instantiate the class, passing the text to be formatted.\n            \n        Here we pre-process the text and collect all the link\n        lookups for later.","docstring_tokens":["Instantiate","the","class","passing","the","text","to","be","formatted",".","Here","we","pre","-","process","the","text","and","collect","all","the","link","lookups","for","later","."],"function":"def __init__(self, text=''):\n        \"\"\"Instantiate the class, passing the text to be formatted.\n            \n        Here we pre-process the text and collect all the link\n        lookups for later.\n        \"\"\"\n        self.text = text\n\n        # Basic regular expressions.\n        self.res = res\n\n        # Smart searches.\n        self.searches = {}\n        self.searches['imdb']   = 'http:\/\/www.imdb.com\/Find?for=%s'\n        self.searches['google'] = 'http:\/\/www.google.com\/search?q=%s'\n        self.searches['python'] = 'http:\/\/www.python.org\/doc\/current\/lib\/module-%s.html'\n        if amazon_associate_id:\n            self.searches['isbn']   = ''.join(['http:\/\/', AMAZON, '\/exec\/obidos\/ASIN\/%s\/', amazon_associate_id])\n            self.searches['amazon'] = ''.join(['http:\/\/', AMAZON, '\/exec\/obidos\/external-search?mode=blended&keyword=%s&tag=', amazon_associate_id])\n        else:\n            self.searches['isbn']   = ''.join(['http:\/\/', AMAZON, '\/exec\/obidos\/ASIN\/%s'])\n            self.searches['amazon'] = ''.join(['http:\/\/', AMAZON, '\/exec\/obidos\/external-search?mode=blended&keyword=%s'])\n\n        # These are the blocks we know.\n        self.signatures = [\n                           # Paragraph.\n                           (r'''^p                       # Paragraph signature\n                                %(battr)s                # Paragraph attributes\n                                (?P\\.)              # .\n                                (?P\\.)?          # Extended paragraph denoted by a second dot\n                                \\s                       # whitespace\n                                (?P.*)             # text\n                             ''' % self.res, self.paragraph),\n   \n                           # Pre-formatted text.\n                           (r'''^pre                     # Pre signature\n                                %(battr)s                # Pre attributes\n                                (?P\\.)              # .\n                                (?P\\.)?          # Extended pre denoted by a second dot\n                                \\s                       # whitespace\n                                (?P.*)             # text\n                             ''' % self.res, self.pre),\n   \n                           # Block code.\n                           (r'''^bc                      # Blockcode signature\n                                %(battr)s                # Blockcode attributes\n                                (?P\\.)              # .\n                                (?P\\.)?          # Extended blockcode denoted by a second dot\n                                \\s                       # whitespace\n                                (?P.*)             # text\n                             ''' % self.res, self.bc),\n   \n                           # Blockquote.\n                           (r'''^bq                      # Blockquote signature\n                                %(battr)s                # Blockquote attributes\n                                (?P\\.)              # .\n                                (?P\\.)?          # Extended blockquote denoted by a second dot\n                                (:(?P              # Optional cite attribute\n                                (                        #\n                                    %(url)s              #     URL\n                                |   \"[\\w]+(?:\\s[\\w]+)*\"  #     \"Name inside quotes\"\n                                ))                       #\n                                )?                       #\n                                \\s                       # whitespace\n                                (?P.*)             # text\n                             ''' % self.res, self.blockquote),\n   \n                           # Header.\n                           (r'''^h                       # Header signature\n                                (?P
    \\d) # Header number\n %(battr)s # Header attributes\n (?P\\.) # .\n (?P\\.)? # Extended header denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n ''' % self.res, self.header),\n \n # Footnote.\n (r'''^fn # Footnote signature\n (?P[\\d]+) # Footnote number\n (?P\\.) # .\n (?P\\.)? # Extended footnote denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n ''', self.footnote),\n \n # Definition list.\n (r'''^dl # Definition list signature\n %(battr)s # Definition list attributes\n (?P\\.) # .\n (?P\\.)? # Extended definition list denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n ''' % self.res, self.dl),\n \n # Ordered list (attributes to first
  • ).\n (r'''^%(olattr)s # Ordered list attributes\n \\# # Ordered list signature\n %(liattr)s # List item attributes\n (?P\\.)? # .\n \\s # whitespace\n (?P.*) # text\n ''' % self.res, self.ol),\n \n # Unordered list (attributes to first
  • ).\n (r'''^%(olattr)s # Unrdered list attributes\n \\* # Unordered list signature\n %(liattr)s # Unordered list attributes\n (?P\\.)? # .\n \\s # whitespace\n (?P.*) # text\n ''' % self.res, self.ul),\n \n # Escaped text.\n (r'''^==?(?P.*?)(==)?$ # Escaped text\n ''', self.escape),\n \n (r'''^(?P<.*)$ # XHTML tag\n ''', self.escape),\n \n # itex code.\n (r'''^(?P # itex code\n \\\\\\[ # starts with \\[\n .*? # complicated mathematical equations go here\n \\\\\\]) # ends with \\]\n ''', self.itex),\n \n # Tables.\n (r'''^table # Table signature\n %(tattr)s # Table attributes\n (?P\\.) # .\n (?P\\.)? # Extended blockcode denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n ''' % self.res, self.table),\n \n # Simple tables.\n (r'''^(?P\n \\|\n .*)\n ''', self.table),\n \n # About.\n (r'''^(?Ptell\\sme\\sabout\\stextile\\.)$''', self.about),\n ]","function_tokens":["def","__init__","(","self",",","text","=","''",")",":","self",".","text","=","text","# Basic regular expressions.","self",".","res","=","res","# Smart searches.","self",".","searches","=","{","}","self",".","searches","[","'imdb'","]","=","'http:\/\/www.imdb.com\/Find?for=%s'","self",".","searches","[","'google'","]","=","'http:\/\/www.google.com\/search?q=%s'","self",".","searches","[","'python'","]","=","'http:\/\/www.python.org\/doc\/current\/lib\/module-%s.html'","if","amazon_associate_id",":","self",".","searches","[","'isbn'","]","=","''",".","join","(","[","'http:\/\/'",",","AMAZON",",","'\/exec\/obidos\/ASIN\/%s\/'",",","amazon_associate_id","]",")","self",".","searches","[","'amazon'","]","=","''",".","join","(","[","'http:\/\/'",",","AMAZON",",","'\/exec\/obidos\/external-search?mode=blended&keyword=%s&tag='",",","amazon_associate_id","]",")","else",":","self",".","searches","[","'isbn'","]","=","''",".","join","(","[","'http:\/\/'",",","AMAZON",",","'\/exec\/obidos\/ASIN\/%s'","]",")","self",".","searches","[","'amazon'","]","=","''",".","join","(","[","'http:\/\/'",",","AMAZON",",","'\/exec\/obidos\/external-search?mode=blended&keyword=%s'","]",")","# These are the blocks we know.","self",".","signatures","=","[","# Paragraph.","(","r'''^p # Paragraph signature\n %(battr)s # Paragraph attributes\n (?P\\.) # .\n (?P\\.)? # Extended paragraph denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","paragraph",")",",","# Pre-formatted text.","(","r'''^pre # Pre signature\n %(battr)s # Pre attributes\n (?P\\.) # .\n (?P\\.)? # Extended pre denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","pre",")",",","# Block code.","(","r'''^bc # Blockcode signature\n %(battr)s # Blockcode attributes\n (?P\\.) # .\n (?P\\.)? # Extended blockcode denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","bc",")",",","# Blockquote.","(","r'''^bq # Blockquote signature\n %(battr)s # Blockquote attributes\n (?P\\.) # .\n (?P\\.)? # Extended blockquote denoted by a second dot\n (:(?P # Optional cite attribute\n ( #\n %(url)s # URL\n | \"[\\w]+(?:\\s[\\w]+)*\" # \"Name inside quotes\"\n )) #\n )? #\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","blockquote",")",",","# Header.","(","r'''^h # Header signature\n (?P
    \\d) # Header number\n %(battr)s # Header attributes\n (?P\\.) # .\n (?P\\.)? # Extended header denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","header",")",",","# Footnote.","(","r'''^fn # Footnote signature\n (?P[\\d]+) # Footnote number\n (?P\\.) # .\n (?P\\.)? # Extended footnote denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''",",","self",".","footnote",")",",","# Definition list.","(","r'''^dl # Definition list signature\n %(battr)s # Definition list attributes\n (?P\\.) # .\n (?P\\.)? # Extended definition list denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","dl",")",",","# Ordered list (attributes to first
  • ).","(","r'''^%(olattr)s # Ordered list attributes\n \\# # Ordered list signature\n %(liattr)s # List item attributes\n (?P\\.)? # .\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","ol",")",",","# Unordered list (attributes to first
  • ).","(","r'''^%(olattr)s # Unrdered list attributes\n \\* # Unordered list signature\n %(liattr)s # Unordered list attributes\n (?P\\.)? # .\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","ul",")",",","# Escaped text.","(","r'''^==?(?P.*?)(==)?$ # Escaped text\n '''",",","self",".","escape",")",",","(","r'''^(?P<.*)$ # XHTML tag\n '''",",","self",".","escape",")",",","# itex code.","(","r'''^(?P # itex code\n \\\\\\[ # starts with \\[\n .*? # complicated mathematical equations go here\n \\\\\\]) # ends with \\]\n '''",",","self",".","itex",")",",","# Tables.","(","r'''^table # Table signature\n %(tattr)s # Table attributes\n (?P\\.) # .\n (?P\\.)? # Extended blockcode denoted by a second dot\n \\s # whitespace\n (?P.*) # text\n '''","%","self",".","res",",","self",".","table",")",",","# Simple tables.","(","r'''^(?P\n \\|\n .*)\n '''",",","self",".","table",")",",","# About.","(","r'''^(?Ptell\\sme\\sabout\\stextile\\.)$'''",",","self",".","about",")",",","]"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L640-L784"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.preprocess","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Pre-processing of the text.\n\n Remove whitespace, fix carriage returns.","docstring_summary":"Pre-processing of the text.","docstring_tokens":["Pre","-","processing","of","the","text","."],"function":"def preprocess(self):\n \"\"\"Pre-processing of the text.\n\n Remove whitespace, fix carriage returns.\n \"\"\"\n # Remove whitespace.\n self.text = self.text.strip()\n\n # Zap carriage returns.\n self.text = self.text.replace(\"\\r\\n\", \"\\n\")\n self.text = self.text.replace(\"\\r\", \"\\n\")\n\n # Minor sanitizing.\n self.text = self.sanitize(self.text)","function_tokens":["def","preprocess","(","self",")",":","# Remove whitespace.","self",".","text","=","self",".","text",".","strip","(",")","# Zap carriage returns.","self",".","text","=","self",".","text",".","replace","(","\"\\r\\n\"",",","\"\\n\"",")","self",".","text","=","self",".","text",".","replace","(","\"\\r\"",",","\"\\n\"",")","# Minor sanitizing.","self",".","text","=","self",".","sanitize","(","self",".","text",")"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L787-L800"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.grab_links","parameters":"(self)","argument_list":"","return_statement":"return links","docstring":"Grab link lookups.\n\n Check the text for link lookups, store them in a \n dictionary, and clean them up.","docstring_summary":"Grab link lookups.","docstring_tokens":["Grab","link","lookups","."],"function":"def grab_links(self):\n \"\"\"Grab link lookups.\n\n Check the text for link lookups, store them in a \n dictionary, and clean them up.\n \"\"\"\n # Grab links like this: '[id]example.com'\n links = {}\n p = re.compile(r'''(?:^|\\n)\\[([\\w]+?)\\](%(url)s)(?:$|\\n)''' % self.res, re.VERBOSE)\n for key, link in p.findall(self.text):\n links[key] = link\n\n # And clear them from the text.\n self.text = p.sub('', self.text)\n\n return links","function_tokens":["def","grab_links","(","self",")",":","# Grab links like this: '[id]example.com'","links","=","{","}","p","=","re",".","compile","(","r'''(?:^|\\n)\\[([\\w]+?)\\](%(url)s)(?:$|\\n)'''","%","self",".","res",",","re",".","VERBOSE",")","for","key",",","link","in","p",".","findall","(","self",".","text",")",":","links","[","key","]","=","link","# And clear them from the text.","self",".","text","=","p",".","sub","(","''",",","self",".","text",")","return","links"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L803-L818"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.process","parameters":"(self, head_offset=HEAD_OFFSET, validate=VALIDATE, sanitize=SANITIZE, output=OUTPUT, encoding=ENCODING)","argument_list":"","return_statement":"return text","docstring":"Process the text.\n\n Here we actually process the text, splitting the text in\n blocks and applying the corresponding function to each\n one of them.","docstring_summary":"Process the text.","docstring_tokens":["Process","the","text","."],"function":"def process(self, head_offset=HEAD_OFFSET, validate=VALIDATE, sanitize=SANITIZE, output=OUTPUT, encoding=ENCODING):\n \"\"\"Process the text.\n\n Here we actually process the text, splitting the text in\n blocks and applying the corresponding function to each\n one of them.\n \"\"\"\n # Basic global changes.\n self.preprocess()\n\n # Grab lookup links and clean them from the text.\n self._links = self.grab_links()\n\n # Offset for the headers.\n self.head_offset = head_offset\n\n # Process each block.\n self.blocks = self.split_text()\n\n text = []\n for [function, captures] in self.blocks:\n text.append(function(**captures))\n\n text = '\\n\\n'.join(text)\n\n # Add titles to footnotes.\n text = self.footnotes(text)\n\n # Convert to desired output.\n text = unicode(text, encoding)\n text = text.encode(output, 'xmlcharrefreplace')\n\n # Sanitize?\n if sanitize:\n p = _HTMLSanitizer()\n p.feed(text)\n text = p.output()\n\n # Validate output.\n if _tidy and validate:\n text = _tidy(text)\n\n return text","function_tokens":["def","process","(","self",",","head_offset","=","HEAD_OFFSET",",","validate","=","VALIDATE",",","sanitize","=","SANITIZE",",","output","=","OUTPUT",",","encoding","=","ENCODING",")",":","# Basic global changes.","self",".","preprocess","(",")","# Grab lookup links and clean them from the text.","self",".","_links","=","self",".","grab_links","(",")","# Offset for the headers.","self",".","head_offset","=","head_offset","# Process each block.","self",".","blocks","=","self",".","split_text","(",")","text","=","[","]","for","[","function",",","captures","]","in","self",".","blocks",":","text",".","append","(","function","(","*","*","captures",")",")","text","=","'\\n\\n'",".","join","(","text",")","# Add titles to footnotes.","text","=","self",".","footnotes","(","text",")","# Convert to desired output.","text","=","unicode","(","text",",","encoding",")","text","=","text",".","encode","(","output",",","'xmlcharrefreplace'",")","# Sanitize?","if","sanitize",":","p","=","_HTMLSanitizer","(",")","p",".","feed","(","text",")","text","=","p",".","output","(",")","# Validate output.","if","_tidy","and","validate",":","text","=","_tidy","(","text",")","return","text"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L821-L863"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.sanitize","parameters":"(self, text)","argument_list":"","return_statement":"return text","docstring":"Fix single tags.\n\n Fix tags like ,
    and
    .\n\n ---\n h1. Sanitizing\n\n Textile can help you generate valid XHTML(eXtensible HyperText Markup Language).\n It will fix any single tags that are not properly closed, like\n @@, @
    @ and @
    @.\n\n If you have \"mx.Tidy\":http:\/\/www.egenix.com\/files\/python\/mxTidy.html\n and\/or \"µTidyLib\":http:\/\/utidylib.sourceforge.net\/ installed,\n it also can optionally validade the generated code with these wrappers\n to ensure 100% valid XHTML(eXtensible HyperText Markup Language).","docstring_summary":"Fix single tags.","docstring_tokens":["Fix","single","tags","."],"function":"def sanitize(self, text):\n \"\"\"Fix single tags.\n\n Fix tags like ,
    and
    .\n\n ---\n h1. Sanitizing\n\n Textile can help you generate valid XHTML(eXtensible HyperText Markup Language).\n It will fix any single tags that are not properly closed, like\n @@, @
    @ and @
    @.\n\n If you have \"mx.Tidy\":http:\/\/www.egenix.com\/files\/python\/mxTidy.html\n and\/or \"µTidyLib\":http:\/\/utidylib.sourceforge.net\/ installed,\n it also can optionally validade the generated code with these wrappers\n to ensure 100% valid XHTML(eXtensible HyperText Markup Language).\n \"\"\"\n # Fix single tags like and
    .\n text = preg_replace(r'''<(img|br|hr)(.*?)(?:\\s*\/?\\s*)?>''', r'''<\\1\\2 \/>''', text)\n\n # Remove ampersands.\n text = preg_replace(r'''&(?!#?[xX]?(?:[0-9a-fA-F]+|\\w{1,8});)''', r'''&''', text)\n\n return text","function_tokens":["def","sanitize","(","self",",","text",")",":","# Fix single tags like and
    .","text","=","preg_replace","(","r'''<(img|br|hr)(.*?)(?:\\s*\/?\\s*)?>'''",",","r'''<\\1\\2 \/>'''",",","text",")","# Remove ampersands.","text","=","preg_replace","(","r'''&(?!#?[xX]?(?:[0-9a-fA-F]+|\\w{1,8});)'''",",","r'''&'''",",","text",")","return","text"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L866-L889"} {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.split_text","parameters":"(self)","argument_list":"","return_statement":"return output","docstring":"Process the blocks from the text.\n\n Split the blocks according to the signatures, join extended\n blocks and associate each one of them with a function to\n process them.\n\n ---\n h1. Blocks\n\n Textile process your text by dividing it in blocks. Each block\n is identified by a signature and separated from other blocks by\n an empty line.\n\n All signatures should end with a period followed by a space. A\n header @

    <\/h1>@ can be done this way:\n\n pre. h1. This is a header 1.\n\n Blocks may continue for multiple paragraphs of text. If you want\n a block signature to stay \"active\", use two periods after the\n signature instead of one. For example:\n\n pre.. bq.. This is paragraph one of a block quote.\n\n This is paragraph two of a block quote.\n\n =p. Now we're back to a regular paragraph.\n\n p. Becomes:\n \n pre..
    \n

    This is paragraph one of a block quote.<\/p>\n\n

    This is paragraph two of a block quote.<\/p>\n <\/blockquote>\n\n

    Now we’re back to a regular paragraph.<\/p>\n\n p. The blocks can be customised by adding parameters between the\n signature and the period. These include:\n\n dl. {style rule}:A CSS(Cascading Style Sheets) style rule.\n [ll]:A language identifier (for a \"lang\" attribute).\n (class) or (#id) or (class#id):For CSS(Cascading Style Sheets) class and id attributes.\n >, <, =, <>:Modifier characters for alignment. Right-justification, left-justification, centered, and full-justification. The paragraph will also receive the class names \"right\", \"left\", \"center\" and \"justify\", respectively.\n ( (one or more):Adds padding on the left. 1em per \"(\" character is applied. When combined with the align-left or align-right modifier, it makes the block float. \n ) (one or more):Adds padding on the right. 1em per \")\" character is applied. When combined with the align-left or align-right modifier, it makes the block float.\n\n Here's an overloaded example:\n\n pre. p(())>(class#id)[en]{color:red}. A simple paragraph.\n\n Becomes:\n\n pre.

    A simple paragraph.<\/p>","docstring_summary":"Process the blocks from the text.","docstring_tokens":["Process","the","blocks","from","the","text","."],"function":"def split_text(self):\n \"\"\"Process the blocks from the text.\n\n Split the blocks according to the signatures, join extended\n blocks and associate each one of them with a function to\n process them.\n\n ---\n h1. Blocks\n\n Textile process your text by dividing it in blocks. Each block\n is identified by a signature and separated from other blocks by\n an empty line.\n\n All signatures should end with a period followed by a space. A\n header @

    <\/h1>@ can be done this way:\n\n pre. h1. This is a header 1.\n\n Blocks may continue for multiple paragraphs of text. If you want\n a block signature to stay \"active\", use two periods after the\n signature instead of one. For example:\n\n pre.. bq.. This is paragraph one of a block quote.\n\n This is paragraph two of a block quote.\n\n =p. Now we're back to a regular paragraph.\n\n p. Becomes:\n \n pre..
    \n

    This is paragraph one of a block quote.<\/p>\n\n

    This is paragraph two of a block quote.<\/p>\n <\/blockquote>\n\n

    Now we’re back to a regular paragraph.<\/p>\n\n p. The blocks can be customised by adding parameters between the\n signature and the period. These include:\n\n dl. {style rule}:A CSS(Cascading Style Sheets) style rule.\n [ll]:A language identifier (for a \"lang\" attribute).\n (class) or (#id) or (class#id):For CSS(Cascading Style Sheets) class and id attributes.\n >, <, =, <>:Modifier characters for alignment. Right-justification, left-justification, centered, and full-justification. The paragraph will also receive the class names \"right\", \"left\", \"center\" and \"justify\", respectively.\n ( (one or more):Adds padding on the left. 1em per \"(\" character is applied. When combined with the align-left or align-right modifier, it makes the block float. \n ) (one or more):Adds padding on the right. 1em per \")\" character is applied. When combined with the align-left or align-right modifier, it makes the block float.\n\n Here's an overloaded example:\n\n pre. p(())>(class#id)[en]{color:red}. A simple paragraph.\n\n Becomes:\n\n pre.

    A simple paragraph.<\/p>\n \"\"\"\n # Clear signature.\n clear_sig = r'''^clear(?P[<>])?\\.$'''\n clear = None\n\n extending = 0\n\n # We capture the \\n's because they are important inside \"pre..\".\n blocks = re.split(r'''((\\n\\s*){2,})''', self.text)\n output = []\n for block in blocks:\n # Check for the clear signature.\n m = re.match(clear_sig, block)\n if m:\n clear = m.group('alignment')\n if clear:\n clear = {'<': 'clear:left;', '>': 'clear:right;'}[clear]\n else:\n clear = 'clear:both;'\n\n else:\n # Check each of the code signatures.\n for regexp, function in self.signatures:\n p = re.compile(regexp, (re.VERBOSE | re.DOTALL))\n m = p.match(block)\n if m:\n # Put everything in a dictionary.\n captures = m.groupdict()\n\n # If we are extending a block, we require a dot to\n # break it, so we can start lines with '#' inside\n # an extended

     without matching an ordered list.\n                        if extending and not captures.get('dot', None):\n                            output[-1][1]['text'] += block\n                            break \n                        elif captures.has_key('dot'):\n                            del captures['dot']\n                            \n                        # If a signature matches, we are not extending a block.\n                        extending = 0\n\n                        # Check if we should extend this block.\n                        if captures.has_key('extend'):\n                            extending = captures['extend']\n                            del captures['extend']\n                            \n                        # Apply head_offset.\n                        if captures.has_key('header'):\n                            captures['header'] = int(captures['header']) + self.head_offset\n\n                        # Apply clear.\n                        if clear:\n                            captures['clear'] = clear\n                            clear = None\n\n                        # Save the block to be processed later.\n                        output.append([function, captures])\n\n                        break\n\n                else:\n                    if extending:\n                        # Append the text to the last block.\n                        output[-1][1]['text'] += block\n                    elif block.strip():\n                        output.append([self.paragraph, {'text': block}])\n    \n        return output","function_tokens":["def","split_text","(","self",")",":","# Clear signature.","clear_sig","=","r'''^clear(?P[<>])?\\.$'''","clear","=","None","extending","=","0","# We capture the \\n's because they are important inside \"pre..\".","blocks","=","re",".","split","(","r'''((\\n\\s*){2,})'''",",","self",".","text",")","output","=","[","]","for","block","in","blocks",":","# Check for the clear signature.","m","=","re",".","match","(","clear_sig",",","block",")","if","m",":","clear","=","m",".","group","(","'alignment'",")","if","clear",":","clear","=","{","'<'",":","'clear:left;'",",","'>'",":","'clear:right;'","}","[","clear","]","else",":","clear","=","'clear:both;'","else",":","# Check each of the code signatures.","for","regexp",",","function","in","self",".","signatures",":","p","=","re",".","compile","(","regexp",",","(","re",".","VERBOSE","|","re",".","DOTALL",")",")","m","=","p",".","match","(","block",")","if","m",":","# Put everything in a dictionary.","captures","=","m",".","groupdict","(",")","# If we are extending a block, we require a dot to","# break it, so we can start lines with '#' inside","# an extended 
     without matching an ordered list.","if","extending","and","not","captures",".","get","(","'dot'",",","None",")",":","output","[","-","1","]","[","1","]","[","'text'","]","+=","block","break","elif","captures",".","has_key","(","'dot'",")",":","del","captures","[","'dot'","]","# If a signature matches, we are not extending a block.","extending","=","0","# Check if we should extend this block.","if","captures",".","has_key","(","'extend'",")",":","extending","=","captures","[","'extend'","]","del","captures","[","'extend'","]","# Apply head_offset.","if","captures",".","has_key","(","'header'",")",":","captures","[","'header'","]","=","int","(","captures","[","'header'","]",")","+","self",".","head_offset","# Apply clear.","if","clear",":","captures","[","'clear'","]","=","clear","clear","=","None","# Save the block to be processed later.","output",".","append","(","[","function",",","captures","]",")","break","else",":","if","extending",":","# Append the text to the last block.","output","[","-","1","]","[","1","]","[","'text'","]","+=","block","elif","block",".","strip","(",")",":","output",".","append","(","[","self",".","paragraph",",","{","'text'",":","block","}","]",")","return","output"],"url":"https:\/\/github.com\/DocSavage\/bloog\/blob\/ba3e32209006670fbac1beda1e3b631608c2b6cb\/utils\/external\/textile.py#L892-L1015"}
    {"nwo":"DocSavage\/bloog","sha":"ba3e32209006670fbac1beda1e3b631608c2b6cb","path":"utils\/external\/textile.py","language":"python","identifier":"Textiler.parse_params","parameters":"(self, parameters, clear=None, align_type='block')","argument_list":"","return_statement":"return output","docstring":"Parse the parameters from a block signature.\n\n        This function parses the parameters from a block signature,\n        splitting the information about class, id, language and\n        style. The positioning (indentation and alignment) is parsed\n        and stored in the style.\n\n        A paragraph like:\n\n            p>(class#id){color:red}[en]. Paragraph.\n\n        or:\n            \n            p{color:red}[en](class#id)>. Paragraph.\n\n        will have its parameters parsed to:\n\n            output = {'lang' : 'en',\n                      'class': 'class',\n                      'id'   : 'id',\n                      'style': 'color:red;text-align:right;'}\n\n        Note that order is not important.","docstring_summary":"Parse the parameters from a block signature.","docstring_tokens":["Parse","the","parameters","from","a","block","signature","."],"function":"def parse_params(self, parameters, clear=None, align_type='block'):\n        \"\"\"Parse the parameters from a block signature.\n\n        This function parses the parameters from a block signature,\n        splitting the information about class, id, language and\n        style. The positioning (indentation and alignment) is parsed\n        and stored in the style.\n\n        A paragraph like:\n\n            p>(class#id){color:red}[en]. Paragraph.\n\n        or:\n            \n            p{color:red}[en](class#id)>. Paragraph.\n\n        will have its parameters parsed to:\n\n            output = {'lang' : 'en',\n                      'class': 'class',\n                      'id'   : 'id',\n                      'style': 'color:red;text-align:right;'}\n\n        Note that order is not important.\n        \"\"\"\n        if not parameters:\n            if clear:\n                return {'style': clear}\n            else:\n                return {}\n\n        output = {}\n        \n        # Match class from (class) or (class#id).\n        m = re.search(r'''\\((?P[\\w]+(\\s[\\w]+)*)(\\#[\\w]+)?\\)''', parameters)\n        if m: output['class'] = m.group('class')\n\n        # Match id from (#id) or (class#id).\n        m = re.search(r'''\\([\\w]*(\\s[\\w]+)*\\#(?P[\\w]+)\\)''', parameters)\n        if m: output['id'] = m.group('id')\n\n        # Match [language].\n        m = re.search(r'''\\[(?P[\\w-]+)\\]''', parameters)\n        if m: output['lang'] = m.group('lang')\n\n        # Match {style}.\n        m = re.search(r'''{(?P