MCPcopy Index your code
hub / github.com/clips/pattern / _MicroformatsParser

Class _MicroformatsParser

pattern/web/feed/feedparser.py:2091–2511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2089 return ''.join([' %s="%s"' % (n,v.replace('"','"')) for n,v in attrs])
2090
2091class _MicroformatsParser:
2092 STRING = 1
2093 DATE = 2
2094 URI = 3
2095 NODE = 4
2096 EMAIL = 5
2097
2098 known_xfn_relationships = set(['contact', 'acquaintance', 'friend', 'met', 'co-worker', 'coworker', 'colleague', 'co-resident', 'coresident', 'neighbor', 'child', 'parent', 'sibling', 'brother', 'sister', 'spouse', 'wife', 'husband', 'kin', 'relative', 'muse', 'crush', 'date', 'sweetheart', 'me'])
2099 known_binary_extensions = set(['zip','rar','exe','gz','tar','tgz','tbz2','bz2','z','7z','dmg','img','sit','sitx','hqx','deb','rpm','bz2','jar','rar','iso','bin','msi','mp2','mp3','ogg','ogm','mp4','m4v','m4a','avi','wma','wmv'])
2100
2101 def __init__(self, data, baseuri, encoding):
2102 self.document = BeautifulSoup.BeautifulSoup(data)
2103 self.baseuri = baseuri
2104 self.encoding = encoding
2105 if isinstance(data, unicode):
2106 data = data.encode(encoding)
2107 self.tags = []
2108 self.enclosures = []
2109 self.xfn = []
2110 self.vcard = None
2111
2112 def vcardEscape(self, s):
2113 if isinstance(s, basestring):
2114 s = s.replace(',', '\\,').replace(';', '\\;').replace('\n', '\\n')
2115 return s
2116
2117 def vcardFold(self, s):
2118 s = re.sub(';+$', '', s)
2119 sFolded = ''
2120 iMax = 75
2121 sPrefix = ''
2122 while len(s) > iMax:
2123 sFolded += sPrefix + s[:iMax] + '\n'
2124 s = s[iMax:]
2125 sPrefix = ' '
2126 iMax = 74
2127 sFolded += sPrefix + s
2128 return sFolded
2129
2130 def normalize(self, s):
2131 return re.sub(r'\s+', ' ', s).strip()
2132
2133 def unique(self, aList):
2134 results = []
2135 for element in aList:
2136 if element not in results:
2137 results.append(element)
2138 return results
2139
2140 def toISO8601(self, dt):
2141 return time.strftime('%Y-%m-%dT%H:%M:%SZ', dt)
2142
2143 def getPropertyValue(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0):
2144 all = lambda x: 1
2145 sProperty = sProperty.lower()
2146 bFound = 0
2147 bNormalize = 1
2148 propertyMatch = {'class': re.compile(r'\b%s\b' % sProperty)}

Callers 1

_parseMicroformatsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…