Example #1
0
 def getByUsername(username):
     '''
     Helper to find Users by username.
     Returns only if there is a single exact case match
     '''
     return utils.firstOrNone(
         User.query.filter(User.username == username).all())
    def _getBlockFromList(self, soup, selector, blockName):
        elems = utils.firstOrNone(soup.select(selector))
        if not elems:
            logger.warning(f'No blocklist {selector}')
            return None

        def _isBlock(elem):
            return elem.text.strip().lower() == blockName

        detailsLabel = elems.findChild(_isBlock)
        if not detailsLabel:
            logger.warning(f'No label {blockName}')
            return None

        return detailsLabel.findNextSibling()
Example #3
0
        def _getLink(elem, base):
            def _matchesEventLink(link):
                if not link:
                    return False

                try:
                    parsed = urlparse(link)
                except ValueError:
                    return False
                return (parsed.netloc == 'www.chemistry.gatech.edu'
                        and parsed.path.startswith(self.LINK_PREFIX_INCLUDE))

            links = elem.select(self.SELECTOR_EVENT_LINK)
            links = map(utils.Soup.getElemLink, links)
            links = map(utils.normalizeURL(base=base), links)
            links = filter(_matchesEventLink, links)
            return utils.firstOrNone(links)
Example #4
0
    def _getEventDetails(self, eventURL):
        details = self.requester.fetchURL(eventURL)
        if not details:
            return None

        soup = BeautifulSoup(details, 'html.parser')

        title1 = utils.Soup.getTextAt(soup, self.SELECTOR_EVENT_TITLE1)
        title2 = utils.Soup.getTextAt(soup, self.SELECTOR_EVENT_TITLE2)
        if title1 and title2:
            title = '%s: %s' % (title1, title2)
        else:
            title = utils.firstOrNone(filter(None, (title1, title2)))

        singleStr = utils.Soup.getTextAt(soup, self.SELECTOR_EVENT_TIMESINGLE)
        startStr = utils.Soup.getTextAt(soup, self.SELECTOR_EVENT_TIMESTART)
        endStr = utils.Soup.getTextAt(soup, self.SELECTOR_EVENT_TIMEEND)
        startTime, endTime = self._parseEventTime(singleStr, startStr, endStr)
        startTime = utils.normalizeDate(startTime,
                                        self.config['defaults']['timezone'])

        event = RawEvent(self.IDENTIFIER, eventURL, title, startTime)
        event.setEnd(
            utils.normalizeDate(endTime, self.config['defaults']['timezone']))
        event.setLocation(
            utils.Soup.getTextAt(soup, self.SELECTOR_EVENT_LOCATION))

        description, links = utils.Soup.tokenizeElemAt(
            soup, self.SELECTOR_EVENT_DESCRIPTION, base=eventURL)
        links |= set(utils.Soup.getLinksAt(soup, self.SELECTOR_EVENT_LINKS))
        links = map(utils.normalizeURL(base=eventURL), links)
        links = set(filter(None, links))
        event.setDescription(description)
        event.setLinks(links)

        return event
Example #5
0
 def getByOAuthId(oauth_uid):
     return utils.firstOrNone(
         FacebookUser.query.filter(
             FacebookUser.oauth_uid == oauth_uid).all())
Example #6
0
 def getById(id):
     '''
     Helper to find Users by id.
     Returns only if there is a single exact case match
     '''
     return utils.firstOrNone(User.query.filter(User.id == id).all())
Example #7
0
 def getByEmail(email):
     '''
     Helper to find Users by email.
     Returns only if there is a single exact case match
     '''
     return utils.firstOrNone(User.query.filter(User.email == email).all())
Example #8
0
 def getByOAuthId(oauth_uid):
     return utils.firstOrNone(FacebookUser.query.filter(FacebookUser.oauth_uid == oauth_uid).all())
Example #9
0
 def getById(id):
     '''
     Helper to find Users by id.
     Returns only if there is a single exact case match
     '''
     return utils.firstOrNone(User.query.filter(User.id == id).all())
Example #10
0
 def getByEmail(email):
     '''
     Helper to find Users by email.
     Returns only if there is a single exact case match
     '''
     return utils.firstOrNone(User.query.filter(User.email == email).all())
Example #11
0
 def getByUsername(username):
     '''
     Helper to find Users by username.
     Returns only if there is a single exact case match
     '''
     return utils.firstOrNone(User.query.filter(User.username == username).all())