00001 __copyright__ = """\ 00002 (c). Copyright 1990-2008, Vyper Logix Corp., All Rights Reserved. 00003 00004 Published under Creative Commons License 00005 (http://creativecommons.org/licenses/by-nc/3.0/) 00006 restricted to non-commercial educational use only., 00007 00008 See also: http://www.VyperLogix.com and http://www.pypi.info for details. 00009 00010 THE AUTHOR VYPER LOGIX CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO 00011 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 00012 FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00013 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00014 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00015 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00016 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! 00017 00018 USE AT YOUR OWN RISK. 00019 """ 00020 00021 import re 00022 00023 _parse = lambda foo, _re:[match for match in _re.finditer(foo)] 00024 00025 ## 00026 # Returns the contents of the opening tag for an HTML anchor. 00027 def __parse_for_anchor_heads(toks): 00028 _re_anchor2 = re.compile(r"""</?\w+((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)/?>""") 00029 return [t[0] if (len(t) > 0) else t for t in [_parse(t.group(),_re_anchor2) for t in toks]] 00030 00031 ## 00032 # Returns the matches where match.start(), match.stop() and match.group() are meaningful. 00033 def parse_for_anchors(source): 00034 _re_anchor = re.compile("<a[^>]*>(.*?)</a>") 00035 return _parse(aContent.content,_re_anchor) 00036 00037 ## 00038 # Returns the contents of the opening tag for an HTML anchor. 00039 def parse_for_anchor_heads(source): 00040 return __parse_for_anchor_heads(parse_for_anchors(source)) 00041 00042 def parse_for_hrefs(aTag,source): 00043 from vyperlogix.html.parsers.HTMLParsers import TargetedHTMLParser 00044 00045 myParser = TargetedHTMLParser() 00046 myParser.targetTag(aTag) 00047 myParser.feed(source) 00048 00049 if (myParser.tagCount > 0): 00050 return myParser.tagContents 00051 return [] 00052 00053 if (__name__ == '__main__'): 00054 import sys 00055 print >>sys.stdout, __copyright__ 00056 print >>sys.stderr, __copyright__ 00057 00058 00059
© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."
Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.
122,241 lines of code and growing...