On May 4, 10:06 pm, Anthra Norell <anthra.nor...@bluewin.ch> wrote: > utab wrote: > > Dear all, > > > I have to change some lines from a template file, which is rather long > > to paste here, but I would like to make some parts of some lines > > optional with my command line arguments but I could not see this > > directly, I can count the line numbers and decide on this basis to > > decide the lines to be configured to my will. > > > More specifically, say, I have a that file includes > > > this is an example python file to play around > > . > > . > > . > > some lines > > . > > . > > . > > . -> an option line for example. > > . > > . > > . > > -> another option line so on. > > > and execute the script > > ./myScript option1 option2 > > > so that the options at correct locations will be written. > > > Any other options for this simple job that i can improve my Python a > > bit as well. > > > Best, > > Umut > > -- > >http://mail.python.org/mailman/listinfo/python-list > > Your description is not explicit enough to convey your intention. If > your template file is too long to post, post a short representative > section, an input data sample and a hand-edited sample of the output > data you want to generate. You will get more and better advice. . > > Frederic
Thanks here is a sample Session file from a commercial finite element pre-post processor PATRAN, the file longer but the ideas are the same so that let me give an example, say I would like to make write line 10 composed of some command line arguments: path+database_name, Also there are some lines similar to this in the below sections of the file. I am doing it with a if-elif-else clause checking the line numbers with which I thought of there should be a better way and ended up asking... 1 $# Session file patran.ses.02 started recording at 05-May-09 11:12:25 2 $# Build: 15.0.038 Mon Aug 20 21:31:45 PDT 2007 3 $# Recorded by: Patran 2007 r1b 4 $# FLEXlm initialization complete. Acquiring license(s)... 5 $# License File: /opt/patran-2007r1b/license.dat 6 $# Patran 2007 r1b has obtained 1 concurrent license(s) from FLEXlm per a 7 $# request to execute on Linux node hpc06(001e4f20c494) (Linux 8 $# 2.6.23.15-80.fc7) at 05-May-09 11:12:25. 9 uil_file_new.go( "/opt/patran-2007r1b/template.db", @ 10 "/home/utabak/PATRAN/cavityModels/fromGmsh.db" ) 11 $# Question from application FILE 12 $# Database /home/utabak/PATRAN/cavityModels/fromGmsh.db already exists. 13 $# Do you wish to delete the existing database and create a new one ? 14 $? YES 36000002 15 $# Copying /opt/patran-2007r1b/template.db to 16 $# /home/utabak/PATRAN/cavityModels/fromGmsh.db 17 $# Template copy complete. 18 $# Database version 3.8 created by Patran 2007 r1b successfully opened. 19 ga_viewport_size_set( "default_viewport", 14.571214, 7.509466, 1 ) 20 ga_viewport_location_set( "default_viewport", 0.000000, 1.088771, 1 ) 21 $# Creating journal file /home/utabak/PATRAN/cavityModels/ fromGmsh.db.jou at 22 $# 05-May-09 11:12:43 23 nastran_input_import( "/home/utabak/PATRAN/cavityModels/ toPatran.bdf", @ 24 "default_group", 10, [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, @ 25 TRUE], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [ @ 26 -2000000000, -2000000000, -2000000000, -2000000000, -2000000000, -2000000000, @ 27 -2000000000, -2000000000, 0, 0] ) 28 $# Reading of MSC.Nastran input file completed. 29 ui_exec_function( "mesh_seed_display_mgr", "init" ) Best, -- http://mail.python.org/mailman/listinfo/python-list