utab wrote:
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" )
Okay! Please clarify:
Question 1: Is it always line 10 or is it always a path-file-name, which could be on another line? Question 2: Are there other lines you want to translate? If yes, how do you identify them? By line number or by content? Question 3: If you identify your target by content, what ist the distinctive feature which it doesn't share with non-target lines? (e.g. Path-file name format and nothing else) Question 4: Do you want to substitute the path name with another path name and the file name with another file name, both of which you supply on the command line? Question 5: If your input has a number of different names, do you want to translate them all to the same name, in which case you'd only have to supply a single pair of names on the command line? Question 6: If your input has a number of different names and your translation also consists of a number of path-file-name pairs, how do the targets and substitutes correlate? Sequentially? By pattern? Question 7: Can you estimate how many different path-file-names your complete session file contains? And how many different substitutes you may have in extreme cases?
    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
Question 8: Here you have a file name. What do you do with it?
    16 $# /home/utabak/PATRAN/cavityModels/fromGmsh.db
Question 9: Here line 10 repeats. What do you do with it?
    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
Question 10: Here the file name of line 10 repeats. What do you do?
    22 $# 05-May-09 11:12:43
    23 nastran_input_import( "/home/utabak/PATRAN/cavityModels/
toPatran.bdf",  @
Question 11: Here the file name of line 10 repeats. What do you do?

    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


Frederic

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to