Merge lp:~edvm-j/lalita/bug_url_plugin into lp:lalita

Proposed by Emiliano Dalla Verde Marcozzi
Status: Needs review
Proposed branch: lp:~edvm-j/lalita/bug_url_plugin
Merge into: lp:lalita
Diff against target: 132 lines (+30/-19)
4 files modified
README.txt (+1/-1)
lalita.cfg.sample (+1/-1)
lalita/plugins/url.py (+19/-12)
setup.py (+9/-5)
To merge this branch: bzr merge lp:~edvm-j/lalita/bug_url_plugin
Reviewer Review Type Date Requested Status
laliputienses Pending
Review via email: mp+113878@code.launchpad.net

Description of the change

Arreglo el plugin de URL y manejamos mejor el tema del import magic

To post a comment you must log in.
Revision history for this message
Marcos Dione (mdione) wrote :

the patch is a little dirty, specially where if changes the default server and where it changes the required beautifoulsoup version.

Revision history for this message
Marcos Dione (mdione) wrote :

i think I fixed everything. anyone cares to re-check?

Unmerged revisions

174. By Emiliano Dalla Verde Marcozzi

fix de bug en plugin url

173. By Emiliano Dalla Verde Marcozzi

link bug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.txt'
2--- README.txt 2010-07-19 20:53:28 +0000
3+++ README.txt 2012-07-08 22:56:19 +0000
4@@ -19,7 +19,7 @@
5
6 The project page is::
7
8- https://edge.launchpad.net/lalita
9+ https://launchpad.net/lalita
10
11 To run the bot, create a config file (you can use the sample lalita.cfg.sample)
12 as a guideline, and run::
13
14=== modified file 'lalita.cfg.sample'
15--- lalita.cfg.sample 2011-04-11 02:05:31 +0000
16+++ lalita.cfg.sample 2012-07-08 22:56:19 +0000
17@@ -83,7 +83,7 @@
18 ),
19 'freenode': dict (
20 encoding='utf8',
21- host='irc.freenode.net', port=6667,
22+ host='ezequielchan', port=6667,
23 nickname='lalita',
24 channels= {
25 '#not-grulic': dict (plugins={
26
27=== modified file 'lalita/plugins/url.py'
28--- lalita/plugins/url.py 2011-03-01 21:53:42 +0000
29+++ lalita/plugins/url.py 2012-07-08 22:56:19 +0000
30@@ -6,23 +6,28 @@
31
32 import os
33 import re
34-
35-from twisted.web import client
36-from twisted.internet import defer, reactor
37-from twisted.python import failure
38-
39-from BeautifulSoup import BeautifulStoneSoup
40-
41-import magic
42+import random
43 import chardet
44-
45 import sqlite3
46 import datetime
47
48-import random
49+import magic
50+if not hasattr(magic, 'open'):
51+ exc = "\n\tpython-magic wrapper version must be >= 5.05.\n"
52+ exc += "\tif you have a version below 5.05 you will not\n"
53+ exc += "\thave the 'open' method in magic module and i will fail.\n"
54+ exc += "\tAt ubuntu and fedora, you can install python-magic packages"
55+ raise ValueError(exc)
56
57 from lalita import Plugin
58
59+from twisted.web import client
60+from twisted.internet import reactor
61+from twisted.python import failure
62+
63+from BeautifulSoup import BeautifulStoneSoup
64+
65+
66 class Url (Plugin):
67 url_re= re.compile ('((https?|ftp)://[^ ]+)', re.IGNORECASE|re.DOTALL)
68 title_re= re.compile (
69@@ -44,6 +49,8 @@
70 self.config.update (config)
71 self.logger.debug (self.config)
72 self.titleFound= False
73+
74+
75 self.magic= magic.open (magic.MAGIC_MIME)
76 self.magic.load ()
77
78@@ -179,7 +186,7 @@
79 self.say(channel,
80 u"%s: necesito un ID y el nuevo título para poder renombrar", user)
81 return
82-
83+
84 try:
85 url_id = int(what[0])
86 except ValueError:
87@@ -190,7 +197,7 @@
88 self.cursor.execute('''select title, poster from url where id = ?''', (url_id, ))
89
90 result= list (self.cursor.fetchone ())
91-
92+
93 if not result:
94 self.say(channel,
95 '%s: 404 ID %s not found', user, url_id)
96
97=== modified file 'setup.py'
98--- setup.py 2010-11-18 21:20:21 +0000
99+++ setup.py 2012-07-08 22:56:19 +0000
100@@ -1,5 +1,8 @@
101 #!/usr/bin/env python
102-from distutils.core import setup
103+
104+#from distutils.core import setup
105+from setuptools import setup
106+
107
108 setup(
109 # metadata
110@@ -24,7 +27,7 @@
111 ],
112
113 # content
114- packages = ['lalita', 'lalita.core', 'lalita.core.tests',
115+ packages = ['lalita', 'lalita.contrib', 'lalita.core', 'lalita.core.tests',
116 'lalita.core.tests.plugins', 'lalita.plugins',
117 'lalita.plugins.randomer_utils', 'lalita.plugins.tests'],
118 package_data = {
119@@ -35,9 +38,10 @@
120 scripts = ['lalita/ircbot.py'],
121
122 # dependencies
123- requires = [
124- 'twisted',
125- 'beautifulsoup >= 3.1',
126+ install_requires = [
127+ 'Twisted',
128+ 'beautifulsoup',
129 'chardet',
130+ 'pyOpenSSL',
131 ],
132 )

Subscribers

People subscribed via source and target branches