Commit 7dba720f authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

typos

parent 41b87690
......@@ -54,14 +54,12 @@ class MmBot(irc.IRCClient):
self.codes = legifrance.legi('legifrance.conf')
self.view = {}
self.view_content = {}
def connectionMade(self):
irc.IRCClient.connectionMade(self)
self.logger = MessageLogger()
self.logger.log("[connected at %s]" %
time.asctime(time.localtime(time.time())))
for c in self.botconf['chans']:
self.join(c)
def connectionLost(self, reason):
irc.IRCClient.connectionLost(self, reason)
......@@ -70,7 +68,9 @@ class MmBot(irc.IRCClient):
def signedOn(self):
"""Called when bot has succesfully signed on to server."""
pass
for c in self.botconf['chans']:
self.logger.log("[asked to join %s]" % c)
self.join(c)
def kickedFrom(self, channel, kicker, message):
self.logger.log("[kicked from %s by %s at %s]" %
......@@ -238,8 +238,9 @@ class MmBot(irc.IRCClient):
article = d['article3']
form = '%s de la %s' % (article, codename)
marks = (d['mark3a'],d['mark3b'])
self.logger.log("[match] %s" % form)
if (marks[0] == '{' and marks[1]=='}') or (marks[0]=='[' and marks[1]=']') :
if (marks[0] == '{' and marks[1]=='}') or (marks[0]=='[' and marks[1]==']') :
trop_jeune = False
......@@ -260,7 +261,7 @@ class MmBot(irc.IRCClient):
else:
txt = self.codes.get_content(codename,article)
if not txt is None:
self.msg(channel,'{%s}:\n%s' (form, txt))
self.msg(channel,'{%s}:\n%s' % (form, txt))
used_view[(channel,codename,article)] = time.time()
m= re.sub(reg,'',m,1)
......
......@@ -36,7 +36,7 @@ def get_articles_from_page(link):
r = requests.get(link)
reg = '^.*?<a href="/?(affich[A-Za-z]*Article\.do[^"]*idArticle[^"]*)" title="En savoir plus sur l\'article ([^"]+)"'
c=r.content.decode()
c=r.content
while True:
a = re.match(reg, c, re.DOTALL)
......@@ -54,14 +54,14 @@ def get_articles_from_page(link):
def get_article_content(link):
r = requests.get(link)
reg = '^.*<div class="corpsArt">(.*)</div>.*?Liens relatifs à cet article'
c = r.content.decode()
reg = '^.*<div class="corpsArt">(.*)</div>.*?Liens relatifs'
c = r.content.decode('utf8')
a = re.match(reg, c, re.DOTALL)
if a:
content = a.groups()[0]
h = html2text.HTML2Text()
h.ignore_links=True
return h.handle(content)
return h.handle(content).encode('utf8')
return None
def get_code(codename,codeids):
......@@ -74,7 +74,7 @@ def get_code(codename,codeids):
r=requests.get('https://www.legifrance.gouv.fr/affichCode.do?cidTexte='+codeid)
reg = '^.*?href="(affichCode\.do[^"]*idSectionTA[^"]*)"'
c=r.content.decode()
c=r.content
links=set()
while True:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment