Skip to content

Code review ideas: python xml libs instead of grep/echo/sed code #15

@ghost

Description

kml2wld.sh contains this code

imgcoord=$(grep -A 10 "$imgname" "$path/$bn.kml") north=$(echo $imgcoord | sed 's/^.*<north>\([0-9-][0-9\.]*\)<\/north>.*/\1/') south=$(echo $imgcoord | sed 's/^.*<south>\([0-9-][0-9\.]*\)<\/south>.*/\1/') east=$(echo $imgcoord | sed 's/^.*<east>\([0-9-][0-9\.]*\)<\/east>.*/\1/') west=$(echo $imgcoord | sed 's/^.*<west>\([0-9-][0-9\.]*\)<\/west>.*/\1/')

Fast, full of zen, fairly self documenting, but a nightmare for a python dev to debug.

The kml could be opened with an xml parser (ElementTree XML API has been build into python since 2.5 AFAIK) and much of the manipulation could be done in pure python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions