Returns a new Period instance from the given beautifulsoup tag.
489666
def from_soup_tag(tag):
        ""
        days = []
        for elem in tag.findAll(recursive=False):
            if elem.name != 'day':
                raise TypeError("Unknown tag found: " + str(elem))
            days.append(elem.string)
        return Period(
            tag['type'], tag['instructor'], tag['start'], tag['end'],
            tag['location'], days
        )
889030
def get_period_last_3_months() -> str:
    
    today = Datum()
    today.today()

    # start_date = today - timedelta(weeks=13)
    start_date = today.clone()
    start_date.subtract_months(3)

    period = get_period(start_date.date, today.date)
    return period
840887
def _get_once(self, page_text):
        """"""
        soup = BeautifulSoup(page_text, 'html.parser')
        once = soup.find('input', attrs={'name': 'once'})['value']
        return once
356710
def initialize_period(self, period=None):
        
        if not period:
            self.current_period = dt.datetime.now()
        else:
            self.current_period = period
        self.current_period = dt.datetime(self.current_period.year, self.current_period.month, self.current_period.day)
        self.date = self.current_period.strftime("%Y-%m-%d")
354125
def from_time(cls, source):
        
        return cls(hours=source.hour, minutes=source.minute,
            seconds=source.second, milliseconds=source.microsecond // 1000)
688334
def semantic_date_range_tag(date_from, date_to, options = {})
      SemanticDateTimeTags::Tag::DateRange.new(date_from, date_to, options).to_html
    end
41327
public function getIsoWeek(): Period
    {
        $startDate = $this
            ->setTime(0, 0)
            ->setISODate((int) $this->format('o'), (int) $this->format('W'), 1);

        return new Period($startDate, $startDate->add(new DateInterval('P7D')));
    }
1359844
def get_period_last_30_days() -> str:
    
    today = Datum()
    today.today()
    # start_date = today - timedelta(days=30)
    start_date = today.clone()
    start_date.subtract_days(30)

    period = get_period(start_date.value, today.value)
    return period
15013
public function getSecond(): Period
    {
        $datepoint = $this->setTime(
            (int) $this->format('H'),
            (int) $this->format('i'),
            (int) $this->format('s')
        );

        return new Period($datepoint, $datepoint->add(new DateInterval('PT1S')));
    }
537739
public static ReadablePeriod parsePeriodString(final String periodStr) {
    final ReadablePeriod period;
    final char periodUnit = periodStr.charAt(periodStr.length() - 1);
    if (periodStr.equals("null") || periodUnit == 'n') {
      return null;
    }

    final int periodInt =
        Integer.parseInt(periodStr.substring(0, periodStr.length() - 1));
    switch (periodUnit) {
      case 'y':
        period = Years.years(periodInt);
        break;
      case 'M':
        period = Months.months(periodInt);
        break;
      case 'w':
        period = Weeks.weeks(periodInt);
        break;
      case 'd':
        period = Days.days(periodInt);
        break;
      case 'h':
        period = Hours.hours(periodInt);
        break;
      case 'm':
        period = Minutes.minutes(periodInt);
        break;
      case 's':
        period = Seconds.seconds(periodInt);
        break;
      default:
        throw new IllegalArgumentException("Invalid schedule period unit '"
            + periodUnit);
    }

    return period;
  }
142828
public static String createPeriodString(final ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
      return periodStr;
    }

    if (period.get(DurationFieldType.years()) > 0) {
      final int years = period.get(DurationFieldType.years());
      periodStr = years + "y";
    } else if (period.get(DurationFieldType.months()) > 0) {
      final int months = period.get(DurationFieldType.months());
      periodStr = months + "M";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
      final int weeks = period.get(DurationFieldType.weeks());
      periodStr = weeks + "w";
    } else if (period.get(DurationFieldType.days()) > 0) {
      final int days = period.get(DurationFieldType.days());
      periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
      final int hours = period.get(DurationFieldType.hours());
      periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
      final int minutes = period.get(DurationFieldType.minutes());
      periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
      final int seconds = period.get(DurationFieldType.seconds());
      periodStr = seconds + "s";
    }

    return periodStr;
  }
1098547
def do_get_pages_with_tag(parser, token):
    
    bits = token.split_contents()
    if 4 != len(bits):
        raise TemplateSyntaxError('%r expects 2 arguments' % bits[0])
    if bits[-2] != 'as':
        raise TemplateSyntaxError(
            '%r expects "as" as the second last argument' % bits[0])
    varname = bits[-1]
    tag = parser.compile_filter(bits[1])
    varname = bits[-1]
    return GetPagesWithTagNode(tag, varname)
484062
def new_format(self, navbar: BeautifulSoup, content: BeautifulSoup) -> List[str]:

        
        
        sender = content.find(id='from').text.split('via')[0][6:].strip()
        date_str = content.find(id='date').text.split(': ')[1].strip()
        date = parsedate_to_datetime(date_str).isoformat()[:19]
        body = content.find(id='body').text.strip()
        nxt, rep_to = None, None
        
        links = navbar.findAll('a')
        for l in links:
            if 'Next in thread' in str(l):
                nxt = '/'.join(self.email_url.split('/')[:-1]) + '/' + l['href']
                nxt = nxt[1:] if nxt[0] == '/' else nxt
            elif 'reply to' in str(l):
                rep_to = '/'.join(self.email_url.split('/')[:-1]) + '/' + l['href']
                rep_to = rep_to[1:] if rep_to[0] == '/' else rep_to
        return [str(i) for i in [sender, date, body, nxt, rep_to]]
639495
def tag_from_element(el):
    
    tag = el.tag
    namespace = None
    if tag.startswith('{'):
        # Strip namespace of the form "{namespace}tag"
        namespace,tag = tag[1:].split('}')
    try:
        cls = globals()[tag.title()]
        if not issubclass(cls, TagBase):
            raise KeyError()
    except KeyError:
        raise ValueError("TagBase doesn't have a subclass for '%s'." % tag)
    children = [tag_from_element(c) for c in el]
    tag = cls(*children, **el.attrib)
    tag.text = el.text
    tag.tail = el.tail
    if namespace:
        tag.attrib['xmlns'] = namespace
    return tag
995430
def get_tag(self, tagtype):
        ''' '''
        for tag in self.__tags:
            if tag.tagtype == tagtype:
                return tag
        return None
308008
def ensure_soup(value, parser=None):
    
    if isinstance(value, BeautifulSoup):
        return value.find()
    if isinstance(value, Tag):
        return value
    if isinstance(value, list):
        return [
            ensure_soup(item, parser=parser)
            for item in value
        ]
    parsed = BeautifulSoup(value, features=parser)
    return parsed.find()
692172
def tag_namespace(cls, tag):
        """"""
        md = re.match("^(?:\{([^\}]*)\})", tag)
        if md is not None:
            return md.group(1)