MCPcopy Index your code
hub / github.com/pyload/pyload / _MicroformatsParser

Class _MicroformatsParser

module/lib/feedparser.py:2005–2406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2003 return ''.join([' %s="%s"' % (n,v.replace('"','"')) for n,v in attrs])
2004
2005class _MicroformatsParser:
2006 STRING = 1
2007 DATE = 2
2008 URI = 3
2009 NODE = 4
2010 EMAIL = 5
2011
2012 known_xfn_relationships = ['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']
2013 known_binary_extensions = ['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']
2014
2015 def __init__(self, data, baseuri, encoding):
2016 self.document = BeautifulSoup.BeautifulSoup(data)
2017 self.baseuri = baseuri
2018 self.encoding = encoding
2019 if type(data) == type(u''):
2020 data = data.encode(encoding)
2021 self.tags = []
2022 self.enclosures = []
2023 self.xfn = []
2024 self.vcard = None
2025
2026 def vcardEscape(self, s):
2027 if type(s) in (type(''), type(u'')):
2028 s = s.replace(',', '\\,').replace(';', '\\;').replace('\n', '\\n')
2029 return s
2030
2031 def vcardFold(self, s):
2032 s = re.sub(';+$', '', s)
2033 sFolded = ''
2034 iMax = 75
2035 sPrefix = ''
2036 while len(s) > iMax:
2037 sFolded += sPrefix + s[:iMax] + '\n'
2038 s = s[iMax:]
2039 sPrefix = ' '
2040 iMax = 74
2041 sFolded += sPrefix + s
2042 return sFolded
2043
2044 def normalize(self, s):
2045 return re.sub(r'\s+', ' ', s).strip()
2046
2047 def unique(self, aList):
2048 results = []
2049 for element in aList:
2050 if element not in results:
2051 results.append(element)
2052 return results
2053
2054 def toISO8601(self, dt):
2055 return time.strftime('%Y-%m-%dT%H:%M:%SZ', dt)
2056
2057 def getPropertyValue(self, elmRoot, sProperty, iPropertyType=4, bAllowMultiple=0, bAutoEscape=0):
2058 all = lambda x: 1
2059 sProperty = sProperty.lower()
2060 bFound = 0
2061 bNormalize = 1
2062 propertyMatch = {'class': re.compile(r'\b%s\b' % sProperty)}

Callers 1

_parseMicroformatsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected