Python 2.4, libxslt and MacPorts snafu

I struggled for quite a long time to get the MacPorts libxslt module for python 2.4 (required for a legacy project) to install. A lot of searching turned up many leads but no bug report, and this is a low-priority situation for port maintainers because python 2.4 is now very out of date. This is what I did.

Installed python24.

Installed py-libxslt.

At the end of the port install process for py-libxslt I received an error message. A read of the log said:

[…] :debug:activate activate phase started at Tue Jul 6 11:48:03 BST 2010 :debug:activate Executing org.macports.activate (py-libxslt) :error:activate Target org.macports.activate returned: Registry error: py-libxslt 2.6.210 not registered as installed. :debug:activate Backtrace: Registry error: py-libxslt 2.6.210 not registered as installed.

while executing

“registry::installed $name $v”

(procedure "_check_registry" line 38)
invoked from within

checkregistry $name $v”

(procedure "portimage::activate" line 58)
invoked from within

“registryactivate $name “${version}${revision}${portvariants}” [array get user_options]”

(procedure "portactivate::activate_main" line 6)
invoked from within

“$procedure $targetname” :info:activate Warning: the following items did not execute (for py-libxslt): org.macports.activate :notice:activate Log for py-libxslt is at: /opt/local/var/macports/logs/optlocalvarmacportssourcesrsync.macports.orgreleaseportspythonpy-libxslt/main.log </typo:code>

This indicated that everything was happily built, but the software was not installed in its correct directory for some reason (not evident in the log). I found it difficult to get my head around the way MacPorts works in the time available and establish what went wrong. So I short-circuited the problem by copying the software (libxslt.py) from the MacPorts build directory into the lib directory where it should have been put (/opt/local/lib/python2.4/site-packages).

This will mess up MacPorts’ information about what is installed, so other python 2.4 dependent things might conceivably not be installable. Equally it might be tricky to remove the /opt/local/lib/python2.4/site-packages directory using MacPorts commands without forcing it. But meanwhile I have a working python libxslt module and that’s what I needed.

Published on 06/07/2010 at 12:40 by Technophile, tags , ,

Amending vector map artwork from Osmarender

I’ve been playing with Osmarender in an effort to generate vector map artwork for a design project. The map needs to have different visual styling from the way Open Streetmap looks and also will lack things like street names and bus stops which are not relevant outside the navigation context for which OSM’s maps are primarily intended.

The Osmarender SVG forms one step of the conversion process from raw information collected on the ground and the presentation of maps online at openstreetmap.org. For me, one problem has been the close tailoring of this transformation to the visual style used in Open Streetmap’s map images. Various ruses are used to create an image that suits a web interface; these are not so beneficial when working with vector data because they tend to exploit the fact that the final images will be seen at a pre-determined and fixed resolution.

After deleting quite a lot of stuff, and latterly separating the land use, waterways, routes and labels, I think I might be getting somewhere. I will post the modified rules files and stylesheet if I do make things work. I can see that I will still have to tidy up the files in a vector editor at the end – but of course OSM is permanently under revision, which implies errors in the data as well as acknowledging that features on the ground will change.

Published on 04/07/2010 at 23:52 by Technophile, tags , , ,

Ruby Mendicant University

I came across this post about Ruby Mendicant University while reading up on Prawn, a Ruby PDF generation library. RMU is an interesting idea in its own right – is it a new idea? – but what I liked about the post, what connected with me, was the discussion of the ‘plateau’ of learning that comes after grasping the basics of the language, when the need is to discover about good style and efficient, elegant coding. That’s something very familiar.

There are a lot of people who have gone through the initial gauntlet only to plateau and find that while they can play by ear, they can’t quite read the music

Because I often work alone and I have to somehow solve the problems I take on I am slowly grinding away at my Ruby ignorance. It’s great to find neat and expressive ways to achieve things, and it’s always depressing to leave a trail of ugly-looking code in one’s wake, so there are sticks as well as carrots. But as the interviewer prompts, ‘Underwear + ??? = Ruby Knowledge. Meaning, there’s bloody nothing in the middle range.’ In other words, there’s a deafening internet silence just at the point when guidance could be most valuable. This stage includes all sorts of really interesting things, things I know I want to know about but which are nevertheless frustratingly unknown unknowns.

My previous post perhaps illustrates the rather unfocused understanding I have gained so far; I wasn’t able to make the correct assumption about the precedence of the operators because I wasn’t taking into account the = operator in the statement. Un-fluent thinking.

I would guess that in a team with a strong leader, or with a mentor, this stage can be crossed pretty fast. But for those people who are more isolated, the idea of focused group learning online, via IRC, sounds smart. And it looks to be a success so far.

Published on 24/06/2010 at 09:01 by Technophile, tags , , , ,

Ruby or and || operator evaluation

I wanted to define a variable in a way that allowed it either to be the result of a method or, if that method didn’t produce anything, a preset default value.

The method was written so that it would return nothing if a certain condition was not met. Here’s my experimental version:

def foo(argument) if argument.class == “”.class

return argument

end end

foo(“bar”) => “bar”

foo(123) => nil

</typo:code>

Then I tested to see what happened if I wrote an expression to evaluate the output. I used the ‘or’ operator. It behaved as expected:

foo(“bar”) or “Nope!” => “bar”

foo(123) or “Nope!” => “Nope!”</typo:code>

But although when calling experimental method it does not seem to matter what kind of object is given on the right hand side of the evaluation…

foo(“bar”) or {“test”=>1, “me”=>2} => “bar”

foo(123) or {“test”=>1, “me”=>2} => {“me”=>2, “test”=>1}</typo:code>

… a similarly written expression in the real script would receive nil from a method, yet that returned value of nil would be chosen in preference to the object on the right hand side. Effectively:

foo(123) or {“test”=>1, “me”=>2} => nil</typo:code>

I changed the evaluation operator from ‘or’ to ‘||’, and it worked nicely, effectively:

foo(123) || {“test”=>1, “me”=>2} => {“me”=>2, “test”=>1}</typo:code>

Here is Programming Ruby 1/e on the or and || operators:

… both “or” and “||” evaluate to true if either operand is true. They evaluate their second operand only if the first is false. As with “and”, the only difference between “or” and “||” is their precedence.

http://ruby-doc.org/docs/ProgrammingRuby/html/tut_expressions.html#S1

Published on 23/06/2010 at 15:34 by Technophile, tags , , , ,

A remarkably small terrier

On Monday I had the privilege to see a 4mm/ft scale model of a Terrier, a small British railway steam locomotive of the 1870s, that can run on live steam. It’s quite common for people to construct motorized models at this scale, but not to build ones that run on the same principles as the original. The cylinders, where power is developed, are 12” diameter by 20” stroke on the full-size locomotive; that means those of the model, to scale, are 4mm diameter by 6.6mm stroke. The valves, which control the admission and exhaust of steam, will be a fraction of that size. Truly remarkable.

Published on 18/06/2010 at 14:54 by Technophile, tags , , ,

Web fonts: the public face

Three recent things show how far, at least in public, web fonts have moved.

Google’s web fonts subscription service, with its previewer

Apple’s attempt to own HTML5 (associated with its efforts to diss Flash), including a natty web fonts/visual effects demo that only runs on Safari (unless you play with the referer string, I hear)

And finally, an excellent roundup of the state of play by Richard Fink on A List Apart.

Slightly further behind the scenes, the W3C Web Fonts Working Group is currently bickering about the format of metadata in WOFF files, so I am confident that the spec will move forward in the none too distant future. Happy days!

Published on 09/06/2010 at 00:42 by Technophile, tags ,

Powered by Publify – Thème Frédéric de Villamil | Photo Glenn