Salome HOME
Correction d'une erreur sur le tri entre raffinement et déraffinement.
[modules/homard.git] / doc / files / tutorial_util.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011-2014  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """
21 Python script for HOMARD
22 Copyright EDF-R&D 2014
23 """
24 __revision__ = "V1.0"
25
26 import os
27 import sys
28 #========================================================================
29 #========================================================================
30 def gzip_gunzip(data_dir, num_tuto, option) :
31   """
32 Compression/Uncompression of the med files of a directory such as tutorial_x.nn.med
33 data_dir: directory
34 num_tuto: number of the tutorial
35 option  : 1: compression, -1: uncompression
36 Copyright EDF-R&D 2014
37   """
38 #
39   ficloc_basis = "tutorial_%d" % num_tuto
40 #
41   ok = True
42   num = -1
43 #
44 # Uncompression
45 #
46   if ( option == -1 ) :
47 #
48     while ok :
49       num += 1
50       ficloc = ficloc_basis + ".%02d.med" % num
51       nomfic = os.path.join(data_dir, ficloc)
52       if not os.path.isfile(nomfic) :
53         ficloc += ".gz"
54         nomfic = os.path.join(data_dir, ficloc)
55         if os.path.isfile(nomfic) :
56           os.system("gunzip "+nomfic)
57         else :
58           ok = False
59           break
60 #
61     ficloc = ficloc_basis + ".fr.med"
62     nomfic = os.path.join(data_dir, ficloc)
63     if not os.path.isfile(nomfic) :
64       ficloc += ".gz"
65       nomfic = os.path.join(data_dir, ficloc)
66       if os.path.isfile(nomfic) :
67         os.system("gunzip "+nomfic)
68 #
69 # Compression
70 #
71   elif ( option == 1 ) :
72 #
73     while ok :
74       num += 1
75       ficloc = ficloc_basis + ".%02d.med.gz" % num
76       nomfic = os.path.join(data_dir, ficloc)
77       if not os.path.isfile(nomfic) :
78         ficloc = ficloc_basis + ".%02d.med" % num
79         nomfic = os.path.join(data_dir, ficloc)
80         if os.path.isfile(nomfic) :
81           os.system("gzip "+nomfic)
82         else :
83           ok = False
84           break
85 #
86     ficloc = ficloc_basis + ".fr.med.gz"
87     nomfic = os.path.join(data_dir, ficloc)
88     if not os.path.isfile(nomfic) :
89       ficloc = ficloc_basis + ".fr.med"
90       nomfic = os.path.join(data_dir, ficloc)
91       if os.path.isfile(nomfic) :
92         os.system("gzip "+nomfic)
93 #
94   return
95 #
96 #========================================================================
97 #========================================================================