Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Portage Developer (http://www.linux-archive.org/gentoo-portage-developer/)
-   -   portage-py3k status report (http://www.linux-archive.org/gentoo-portage-developer/143436-portage-py3k-status-report.html)

Ali Polatel 08-15-2008 12:00 PM

portage-py3k status report
 
Hi,
I've written a status report╣ about portage py3k conversion. It tells
about the current state, what needs to be done etc.
I'll be updating the page so people can learn about the current status.

╣: http://dev.gentoo.org/~hawking/portage-2to3/status.xml

--
Regards,
Ali Polatel

RenÚ 'Necoro' Neumann 08-15-2008 01:22 PM

portage-py3k status report
 
What's the best way to send patches for the patches ;) ?

For example in
http://dev.gentoo.org/~hawking/portage-2to3/auto/11-portage-2to3-map.patch
- there is the following hunk:

<hunk>
diff --git a/pym/portage/process.py b/pym/portage/process.py
index f766d30..dc425af 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -21,7 +21,7 @@ except ImportError:

if os.path.isdir("/proc/%i/fd" % os.getpid()):
def get_open_fds():
- return map(int, [fd for fd in os.listdir("/proc/%i/fd" % os.getpid()) if
fd.isdigit()])
+ return list(map(int, [fd for fd in os.listdir("/proc/%i/fd" %
os.getpid()) if fd.isdigit()]))
else:
def get_open_fds():
return xrange(max_fd_limit)
</hunk>

But the complete expression could be rewritten as:

return [int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) if
fd.isdigit()]

This is more readable - and you don't need to traverse the list multiple
times.

Alternatively - if you like the functional style more:

return list(map(int, filter(str.isdigit, os.listdir("/proc/%i/fd" %
os.getpid()))))

Again more readable (if you are used to the functional style ;)) - and only
one traversal (as iterators are used).


/edit: I sent this mail twice, because Roundcube had chosen the wrong
sender name and I guess, that this mail was blocked then. Excuses if you
get the mail twice.

Regards,
Necoro

Ali Polatel 08-15-2008 02:26 PM

portage-py3k status report
 
Ren├ę 'Necoro' Neumann yazm─▒┼č:
> What's the best way to send patches for the patches ;) ?

In this particular case you shouldn't send patches for patches, so it's
not a problem, see below ;)

<snip>
> But the complete expression could be rewritten as:
>
> return [int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) if
> fd.isdigit()]
>
> This is more readable - and you don't need to traverse the list multiple
> times.
>
> Alternatively - if you like the functional style more:
>
> return list(map(int, filter(str.isdigit, os.listdir("/proc/%i/fd" %
> os.getpid()))))
>
> Again more readable (if you are used to the functional style ;)) - and only
> one traversal (as iterators are used).
>

Portage aims for 2.4 compatibility and your snippets should work on 2.4
afaik. So you can submit it as a patch to the current trunk.
Changing the automatically generated output is not a good idea.

> Regards,
> Necoro

--
Regards,
Ali Polatel

Zac Medico 08-15-2008 06:12 PM

portage-py3k status report
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

RenÚ 'Necoro' Neumann wrote:
> But the complete expression could be rewritten as:
>
> return [int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) if
> fd.isdigit()]
>

Applied, thanks.

- --
Thanks,
Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkilxyUACgkQ/ejvha5XGaPxXgCgkGAmT1Gf2lF840SXov8RbL31
7ucAnRyJnA3/HSKbV538YBQ0cRxqTSdG
=pcZr
-----END PGP SIGNATURE-----


All times are GMT. The time now is 01:43 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.