Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

need help updating imgsizer for python2.1

0 views
Skip to first unread message

Peter S Galbraith

unread,
Jan 7, 2002, 9:18:42 PM1/7/02
to

Hello all,

First, let me say I'm not subscribed to the list. Please CC me in your
replies.

I'm the maintainer for imgsizer,

http://packages.debian.org/unstable/web/imgsizer.html

which used to be a perl script and is
now a python script. I don't know python. The scripts loads "cmp.py"
which is either:

/usr/lib/python1.5/cmp.py
/usr/lib/python2.1/lib-old/cmp.py

The lib-old directory is _not_ in the load path for python2.1, so I've
modified it to run with python1.5 only. How would I modify the script
to work with any version of python?

The package currently depends on python1.5. What should it depend on
when fixed?

Thanks,
Peter


--
To UNSUBSCRIBE, email to debian-pyt...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Kim Oldfield

unread,
Jan 7, 2002, 11:15:17 PM1/7/02
to
On 8 Jan 2002, Peter S Galbraith typed:
] I'm the maintainer for imgsizer,
]
] http://packages.debian.org/unstable/web/imgsizer.html
]
] which used to be a perl script and is
] now a python script. I don't know python. The scripts loads "cmp.py"

The cmp module has been replace by filecmp. One (untested) way of fixing
it would be to change the line:

import sys, os, getopt, cmp, string, re, urllib, commands

to

import sys, os, getopt, string, re, urllib, commands
if sys.version > '1.6':
import filecmp as cmp
else:
import cmp

] The package currently depends on python1.5. What should it depend on
] when fixed?

python


Regards,
Kim Oldfield

dman

unread,
Jan 8, 2002, 6:44:31 AM1/8/02
to
On Tue, Jan 08, 2002 at 03:12:43PM +1100, Kim Oldfield wrote:
| On 8 Jan 2002, Peter S Galbraith typed:
| ] I'm the maintainer for imgsizer,
| ]
| ] http://packages.debian.org/unstable/web/imgsizer.html
| ]
| ] which used to be a perl script and is
| ] now a python script. I don't know python. The scripts loads "cmp.py"
|
| The cmp module has been replace by filecmp. One (untested) way of fixing
| it would be to change the line:
|
| import sys, os, getopt, cmp, string, re, urllib, commands
|
| to
|
| import sys, os, getopt, string, re, urllib, commands
| if sys.version > '1.6':
| import filecmp as cmp
| else:
| import cmp

I'd prefer to write this as

try :
import filecmp as cmp
except ImportError :
import cmp

It is more pythonic to just try to do what it is you want, and handle
the situation when it fails, than it is do try and figure out what is
write and do only that which works.

| ] The package currently depends on python1.5. What should it depend on
| ] when fixed?
|
| python

This must be versioned though.
python >= (2.1) , python << (2.2)
will get you the current default version.

-D

--

All a man's ways seem innocent to him,
but motives are weighed by the Lord.
Proverbs 16:2

Andrew Bennetts

unread,
Jan 8, 2002, 7:11:40 AM1/8/02
to
On Tue, Jan 08, 2002 at 06:51:44AM -0500, dman wrote:
> I'd prefer to write this as
>
> try :
> import filecmp as cmp
> except ImportError :
> import cmp
>
> It is more pythonic to just try to do what it is you want, and handle
> the situation when it fails, than it is do try and figure out what is
> write and do only that which works.

Except that in this case, versions of python before 2.0 will give a
SyntaxError, because "import spam as eggs" is a new feature as of 2.0.

To be backwards compatible, use:

try:
import filecmp
cmp = filecmp
del filecmp
except ImportError:
import cmp

-Andrew.

0 new messages