Include URL in live.yaml
This commit is contained in:
		
							parent
							
								
									aa22d76699
								
							
						
					
					
						commit
						ff0d81f32c
					
				
							
								
								
									
										39
									
								
								check.py
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								check.py
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -7,6 +7,7 @@ import os
 | 
			
		|||
import re
 | 
			
		||||
import smtplib
 | 
			
		||||
import warnings
 | 
			
		||||
from dataclasses import dataclass
 | 
			
		||||
from datetime import date
 | 
			
		||||
from email.mime.text import MIMEText
 | 
			
		||||
from email.utils import formatdate, make_msgid
 | 
			
		||||
| 
						 | 
				
			
			@ -168,20 +169,15 @@ def parse_opengraph_tags(html: str) -> dict[str, str]:
 | 
			
		|||
    return og_tags
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@dataclass
 | 
			
		||||
class Conference:
 | 
			
		||||
    """Conference."""
 | 
			
		||||
 | 
			
		||||
    name: str
 | 
			
		||||
    src_url: str
 | 
			
		||||
    year: int
 | 
			
		||||
    response: None | requests.models.Response
 | 
			
		||||
 | 
			
		||||
    def __init__(self, name: str, src_url: str, year: int):
 | 
			
		||||
        """Init."""
 | 
			
		||||
        self.name = name
 | 
			
		||||
        self.src_url = src_url
 | 
			
		||||
        self.year = year
 | 
			
		||||
        self.response = None
 | 
			
		||||
    response: requests.models.Response | None = None
 | 
			
		||||
    redirect_to_url: str | None = None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def url(self) -> str:
 | 
			
		||||
| 
						 | 
				
			
			@ -246,6 +242,7 @@ class Conference:
 | 
			
		|||
        ):
 | 
			
		||||
            body = f"{self.name}\n{self.url}\n"
 | 
			
		||||
        else:
 | 
			
		||||
            self.redirect_to_url = redirect_to_url
 | 
			
		||||
            body = f"{self.name}\n{self.url} redirects to {redirect_to_url}\n"
 | 
			
		||||
 | 
			
		||||
        body += f"Web page title: {msg}{og}" ""
 | 
			
		||||
| 
						 | 
				
			
			@ -277,12 +274,6 @@ def send_mail(subject: str, body: str) -> None:
 | 
			
		|||
    s.quit()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def check(name: str, src_url: str, year: int) -> bool:
 | 
			
		||||
    """Check to see if conference site is live."""
 | 
			
		||||
    conf = Conference(name, src_url, year)
 | 
			
		||||
    return conf.check_web_site()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def find_new_conference_web_sites(
 | 
			
		||||
    today: date, live: list[LiveConference]
 | 
			
		||||
) -> list[LiveConference]:
 | 
			
		||||
| 
						 | 
				
			
			@ -293,11 +284,21 @@ def find_new_conference_web_sites(
 | 
			
		|||
 | 
			
		||||
    live_set = {(c["conference"], c["year"]) for c in live}
 | 
			
		||||
    for name, src_url in load_yaml("conferences").items():
 | 
			
		||||
        new += [
 | 
			
		||||
            {"conference": name, "year": year, "live": today}
 | 
			
		||||
            for year in (this_year, this_year + 1)
 | 
			
		||||
            if (name, year) not in live_set and check(name, src_url, year)
 | 
			
		||||
        ]
 | 
			
		||||
        for year in (this_year, this_year + 1):
 | 
			
		||||
            if (name, year) in live_set:
 | 
			
		||||
                continue
 | 
			
		||||
            conf = Conference(name, src_url, year)
 | 
			
		||||
            if not conf.check_web_site():
 | 
			
		||||
                continue
 | 
			
		||||
            c: LiveConference = {
 | 
			
		||||
                "conference": name,
 | 
			
		||||
                "year": year,
 | 
			
		||||
                "live": today,
 | 
			
		||||
                "url": conf.url,
 | 
			
		||||
            }
 | 
			
		||||
            if conf.redirect_to_url:
 | 
			
		||||
                c["redirect_to_url"] = conf.redirect_to_url
 | 
			
		||||
            new.append(c)
 | 
			
		||||
    return new
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,6 +28,7 @@ class LiveConference(typing.TypedDict, total=False):
 | 
			
		|||
    year: int
 | 
			
		||||
    live: date
 | 
			
		||||
    url: str | None
 | 
			
		||||
    redirect_to_url: str | None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def load_yaml(name: str) -> typing.Any:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue