Parsing files in python

Discussion in 'Python' started by Kene Meniru, Dec 23, 2012.

  1. Kene Meniru

    Kene Meniru Guest

    Hello: I am writing a program that is made up of a collection of POV-Ray macros. POV-Ray is available at povray.org. It is a ray-tracing program that reads a scene description language (SDL) to create photo-realistic images. At this time my program (for modeling building information) is so huge that I am finding it difficult managing the macros and I am not even near completion.

    I am hoping to move this program to python and am wondering the best way to approach this.

    I would like to model my program after LaTeX. Basically the user writes a text file using certain key words and numbers and my python program reads this file, calls the classes that will then work together to calculate the information that is needed to create an accurate model. The result of this calculation will be an output to another text file in the appropriate format such as POV-Ray SDL, OpenSCAD script, etc. This file output can then be rendered by the corresponding program to produce the actual 3D model. The macros I have now currently does this but like I said it is getting tedious and most importantly the fun factor is losing its strength for me.

    I have been advised to check out python-ply and I have come across others. I have not really tried any yet and before I dive into any one of them I was wondering what else I should know. The following is a sample of what the text file that will be processed by this proposed system will contain. I appreciate any pointers and suggestions. Thank you very much.

    ------------possible user file content for parsing ------------
    // in the following the python interface program reads
    //+ the contents of the file "other.file" as if its content
    //+ were located at this point.
    include other.file

    //In the following the python interface makes "snap_size" a
    //+ global parameter
    declare snap_size = 10


    // In the following "buildingLevel" is a class that is
    //+ called and passed the parameters in parenthesis.
    buildingLevel("FirstLevel", 3000)

    // In the following "snapOffset" is a class that is
    //+ called and passed the parameters in parenthesis.
    snapOffset("Closet-S1_r1", "Closet-S2_r3", <0,0,0>)
    ------------end of user file content

    It should also be possible to include comments using double-slashes, etc.

    Sincerely,
    Kene ()
    Kene Meniru, Dec 23, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GIMME
    Replies:
    2
    Views:
    874
    GIMME
    Feb 11, 2004
  2. Naren
    Replies:
    0
    Views:
    579
    Naren
    May 11, 2004
  3. Christopher Diggins
    Replies:
    0
    Views:
    610
    Christopher Diggins
    Jul 9, 2007
  4. Christopher Diggins
    Replies:
    0
    Views:
    435
    Christopher Diggins
    Jul 9, 2007
  5. John Levine
    Replies:
    0
    Views:
    730
    John Levine
    Feb 2, 2012
Loading...

Share This Page