xml application advice

Jorgen Grahn grahn+nntp at snipabacken.se
Wed Jun 10 12:34:29 EDT 2009


On Wed, 10 Jun 2009 08:57:42 -0500, William Purcell <flyeng4 at gmail.com> wrote:
...
> I am writing a application to calculate pressure drop for a piping
> network.  Namely a building sprinkler system.  This will be a
> command line program at first with the system described in xml (at
> least that is how I think I want to do it).

How about (re)using the dot graph language from Graphviz?  It's a file
format for describing directed graphs, which I suppose a sprinkler
system is. It might fit; it might not.

> An important part of this calculation is finding the 'hydraulically
> most remote' sprinkler.  This is something that I could specify with
> an attribute for now and later think about how to automate it.  I
> need to walk through the dom tree until I find a node of type
> "sprinkler" that has an attribute of hydraulically_most_remote with
> a value of True.
>
> After I find this I need to break the itterator/for loop and then
> start walking backwards keeping a running total of the pressure drop
> until I reach a node that has multiple pipesections and then walk to
> the end of each branch and calculate the pressure drop, and then add
> them to the branch that contained the hydraulically most remote
> sprinkler, and then move on, repeating this until I walk all the way
> back to the inflow node.
>
> I am having trouble finding a decent python/xml resource on the web.
> I have ordered Python & XML by Jones and Drake, but I am anxious to
> get something started.

If what you're interested in is to get real work done, why decide to
make XML a showstopper?

I see two tasks: (a) transforming a text file description of a sprinkler
system into a Python data structure, and (b) implementing algorithms
to find out important stuff about such a data structure.

You do not need (a) before you can do (b). You can even have Python as
your input format, and eval() the file. Crude and insecure, but it
works, at almost zero cost.

/Jorgen

-- 
  // Jorgen Grahn <grahn@        Ph'nglui mglw'nafh Cthulhu
\X/     snipabacken.se>          R'lyeh wgah'nagl fhtagn!



More information about the Python-list mailing list