Re: [Python-Dev] More tracker demos online

2006-07-25 Thread Christian Robottom Reis
On Tue, Jul 25, 2006 at 09:44:12PM +0200, "Martin v. Löwis" wrote:
> You'll notice that it also lists Trac and Malone, however,
> it seems that there is no progress on importing SF data
> into these.

Actually, James Henstridge has been working on an import into Launchpad
(Malone is the codename for the bugtracker component of it) over last
week. We have a demo site up at:

https://demo.launchpad.net/products/python/+bugs

Note that we're still ironing out some of the kinks with the import and
the code running there, so there will be changes before the official
announcement.
-- 
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3376 0125
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Difflib modifications [reposted]

2004-12-01 Thread Christian Robottom Reis

[Reposted to python-dev!]

Hello there,

We've has done some customizations to difflib to make it work well
with pagetests we are running on a project at Canonical, and we are
looking for some guidance as to what's the best way to do them. There
are some tricky bits that have to do with how the class inheritance is
put together, and since we would want to avoid duplicating difflib I
figured we'd ask and see if some grand ideas come up.

A [rough first cut of the] patch is inlined below. Essentially, it does:

- Implements a custom Differ.fancy_compare function that supports
  ellipsis and omits equal content

- Hacks _fancy_replace to skip ellipsis as well.

- Hacks best_ratio and cutoff. I'm a bit fuzzy on why this was
  changed, to be honest, and Celso's travelling today, but IIRC it
  had to do with how difflib grouped changes.

Essentially, what we aim for is:

- Ignoring ellipsisized(!) content
- Omitting content which is equal

I initially thought the best way to do this would be to inherit from
SequenceMatcher and make it not return opcodes for ellipsis. However,
there is no easy way to replace the class short of rewriting major bits
of Differ. I suspect this could be easily changed to use a class
attribute that we could override, but let me know what you think of the
whole thing.

--- /usr/lib/python2.3/difflib.py   2004-11-18 20:05:38.720109040 -0200
+++ difflib.py  2004-11-18 20:24:06.731665680 -0200
@@ -885,6 +885,45 @@
 for line in g:
 yield line
 
+def fancy_compare(self, a, b):
+"""
+>>> import difflib
+>>> engine = difflib.Differ()
+>>> got = ['World is Cruel', 'Dudes are Cool']
+>>> want = ['World ... Cruel', 'Dudes ... Cool']
+>>> list(engine.fancy_compare(want, got))
+[]
+ 
+"""
+cruncher = SequenceMatcher(self.linejunk, a, b)
+for tag, alo, ahi, blo, bhi in cruncher.get_opcodes():
+
+if tag == 'replace':
+## replace single line
+if a[alo:ahi][0].rstrip() == '...' and ((ahi - alo) == 1):   
+g = None
+## two lines replaced  
+elif a[alo:ahi][0].rstrip() == '...' and ((ahi - alo) > 1):   
+g = self._fancy_replace(a, (ahi - 1), ahi,
+b, (bhi - 1), bhi)
+## common
+else:
+g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
+elif tag == 'delete':
+g = self._dump('-', a, alo, ahi)
+elif tag == 'insert':
+g = self._dump('+', b, blo, bhi)
+elif tag == 'equal':
+# do not show anything
+g = None
+else:
+raise ValueError, 'unknown tag ' + `tag`
+
+if g:
+for line in g:
+yield line
+
+
 def _dump(self, tag, x, lo, hi):
 """Generate comparison results for a same-tagged range."""
 for i in xrange(lo, hi):
@@ -926,7 +965,13 @@
 
 # don't synch up unless the lines have a similarity score of at
 # least cutoff; best_ratio tracks the best score seen so far
-best_ratio, cutoff = 0.74, 0.75
+#best_ratio, cutoff = 0.74, 0.75
+
+## reduce the cutoff to have enough similarity
+## between ' ... ' and ' blabla '
+## for example 
+best_ratio, cutoff = 0.009, 0.01
+
 cruncher = SequenceMatcher(self.charjunk)
 eqi, eqj = None, None   # 1st indices of equal lines (if any)
 
@@ -981,7 +1026,11 @@
 cruncher.set_seqs(aelt, belt)
 for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes():
 la, lb = ai2 - ai1, bj2 - bj1
-    if tag == 'replace':
+
+if aelt[ai1:ai2] == '...':
+return
+
+if tag == 'replace':
 atags += '^' * la
 btags += '^' * lb
 elif tag == 'delete':

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3361 2331
___
Python-Dev mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Deprecating builtin id (and moving it to sys())

2005-08-17 Thread Christian Robottom Reis

In Launchpad (mainly because SQLObject is used) we end up with quite a
few locals named id. Apart from the fact that naturally clobbering
builtins is a bad idea, we get quite a few warnings when linting
throughout the codebase. I've fixed these as I've found them, but today
Andrew pointed out to me that this is noted in:

http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.ppt

I wonder: is moving id() to sys doable in the 2.5 cycle, with a
deprecation warning being raised for people using the builtin? We'd then
phase it out in one of the latter 2.x versions.

I've done some searching through my code and id() isn't the most-used
builtin, so from my perspective the impact would be limited, but of
course others might think otherwise.

Is it worth writing a PEP for this, or is it crack?

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3376 0125
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com