Salome HOME
Updated copyright comment
[modules/hexablock.git] / doc / pyplots / process_vtk.py
index 42265cc4a1d634639a076af53a91b58860924d72..41c998bda0b19b986448dfa4acc7d6a98deaa00a 100755 (executable)
@@ -1,9 +1,9 @@
-# Copyright (C) 2009-2012  CEA/DEN, EDF R&D
+# Copyright (C) 2009-2024  CEA, EDF
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,7 +18,7 @@
 #
 import sys
 import os
-from optparse import OptionParser
+from argparse import ArgumentParser
 
 def process (file_name):
     """
@@ -27,12 +27,12 @@ def process (file_name):
     """
 
     wr_data = ""
-    with open(file_name, 'r') as f:
+    with open(file_name, 'r', encoding='utf8') as f:
         read_data = f.read()
         wr_data = read_data.replace(',', '.')
         pass
 
-    with open(file_name, 'w') as f:
+    with open(file_name, 'w', encoding='utf8') as f:
         f.write(wr_data)
         pass
 
@@ -40,17 +40,13 @@ def process (file_name):
 
 if __name__ == '__main__':
 
-    usage = "usage: %prog file_name"
-    parser = OptionParser(usage=usage)
-    (options, args) = parser.parse_args()
-
-    if len(args) != 1:
-        print usage
-        sys.exit(1)
+    parser = ArgumentParser()
+    parser.add_argument('file_name', help='Nom du fichier vtk dans $TMP')
+    args = parser.parse_args()
     
-    file_name = os.path.join(os.environ['TMP'], args[0])
+    file_name = os.path.join(os.environ['TMP'], args.file_name)
 
-    print file_name
+    print(file_name)
     process(file_name)
     
     sys.exit()