-# 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
#
import sys
import os
-from optparse import OptionParser
+from argparse import ArgumentParser
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
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()