commited all contents created by participants
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
def obtenir ( option ) :
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
if len( sys.argv ) > index :
|
||||
return sys.argv[ index ]
|
||||
return False
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
if len( sys.argv ) > index :
|
||||
return sys.argv[ index ]
|
||||
return fallback
|
||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
if len( sys.argv ) > index :
|
||||
print type( sys.argv[ index - 1 ])
|
||||
return sys.argv[ index ]
|
||||
return fallback
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
if len( sys.argv ) > index :
|
||||
print type( sys.argv[ index - 1 ])
|
||||
print type( sys.argv[ index ])
|
||||
print sys.argv[ index ]
|
||||
return sys.argv[ index ]
|
||||
return fallback
|
||||
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
if len( sys.argv ) > index :
|
||||
print type( sys.argv[ index - 1 ])
|
||||
print type( sys.argv[ index ])
|
||||
print sys.argv[ index ][0]
|
||||
return sys.argv[ index ]
|
||||
return fallback
|
||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
# si on a quelque chose après notre option
|
||||
if len( sys.argv ) > index :
|
||||
# si ce quelque chose ne commence pas par -
|
||||
if sys.argv[ index ][0] != '-':
|
||||
return sys.argv[ index ]
|
||||
# si c'est le cas on a à priori une option booléenne, on renvoie true
|
||||
else:
|
||||
return True
|
||||
# dans les autres cas on renvoie False ou le fallback si défini
|
||||
return fallback
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
# si on a quelque chose après notre option
|
||||
if len( sys.argv ) > index :
|
||||
# si ce quelque chose ne commence pas par -
|
||||
if sys.argv[ index ][0] != '-':
|
||||
return sys.argv[ index ]
|
||||
# si c'est le cas on a à priori une option booléenne
|
||||
else:
|
||||
# si pas de fallback
|
||||
if !(fallback):
|
||||
return True
|
||||
# sinon on retourne le fallback
|
||||
else:
|
||||
return fallback
|
||||
# dans les autres cas on renvoie False ou le fallback si défini
|
||||
return fallback
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
# si on a quelque chose après notre option
|
||||
if len( sys.argv ) > index :
|
||||
# si ce quelque chose ne commence pas par -
|
||||
if sys.argv[ index ][0] != '-':
|
||||
return sys.argv[ index ]
|
||||
# si c'est le cas on a à priori une option booléenne
|
||||
else:
|
||||
# si pas de fallback
|
||||
if not fallback:
|
||||
return True
|
||||
# sinon on retourne le fallback
|
||||
else:
|
||||
return fallback
|
||||
# dans les autres cas on renvoie False ou le fallback si défini
|
||||
return fallback
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
# si on a l'option
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
# si on a quelque chose après notre option
|
||||
if len( sys.argv ) > index :
|
||||
# si ce quelque chose ne commence pas par -
|
||||
if sys.argv[ index ][0] != '-':
|
||||
return sys.argv[ index ]
|
||||
# si c'est le cas on a à priori une option booléenne
|
||||
else:
|
||||
# si pas de fallback
|
||||
if not fallback:
|
||||
return True
|
||||
# sinon on retourne le fallback
|
||||
else:
|
||||
return fallback
|
||||
else:
|
||||
return True
|
||||
# dans les autres cas on renvoie False ou le fallback si défini
|
||||
return fallback
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
def obtenir ( option, fallback=False ) :
|
||||
'''String -> String/Boolean
|
||||
Si l'option demandée n'existe pas, renvoie False.
|
||||
Si l'option demandée existe'''
|
||||
# si on a l'option
|
||||
if option in sys.argv:
|
||||
index = sys.argv.index( option ) + 1
|
||||
# si on a quelque chose après notre option
|
||||
if len( sys.argv ) > index :
|
||||
# si ce quelque chose ne commence pas par -
|
||||
if sys.argv[ index ][0] != '-':
|
||||
return sys.argv[ index ]
|
||||
# si c'est le cas on a à priori une option booléenne
|
||||
else:
|
||||
# si pas de fallback
|
||||
if not fallback:
|
||||
return True
|
||||
# sinon on retourne le fallback
|
||||
else:
|
||||
return fallback
|
||||
# si on a l'option mais rien derrière
|
||||
else:
|
||||
# on renvoie True
|
||||
return True
|
||||
# dans les autres cas on renvoie False ou le fallback si défini
|
||||
return fallback
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Ce module facilite l'import/export de fichiers
|
||||
'''
|
||||
|
||||
|
||||
def importer ( chemin ) :
|
||||
'''String -> File
|
||||
tente d'importer le fichier dont le chemin est spécifié'''
|
||||
try:
|
||||
fichier = open( chemin, 'r' )
|
||||
lignes = fichier.readlines()
|
||||
fichier.close()
|
||||
return lignes
|
||||
except Exception as erreur:
|
||||
print erreur
|
||||
return False
|
||||
|
||||
def exporter ( contenu, chemin=False ):
|
||||
''''''
|
||||
if ( chemin == False ):
|
||||
chemin = generer_nom_de_fichier()
|
||||
fichier = open( chemin, 'w' )
|
||||
fichier.write( contenu )
|
||||
fichier.close()
|
||||
|
||||
def generer_nom_de_fichier ():
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d-%Hh%Mm%Ss.txt")
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Ce module facilite l'import/export de fichiers
|
||||
'''
|
||||
|
||||
|
||||
def importer ( chemin ) :
|
||||
'''String -> File
|
||||
tente d'importer le fichier dont le chemin est spécifié'''
|
||||
try:
|
||||
fichier = open( chemin, 'r' )
|
||||
fichier.close()
|
||||
return fichier
|
||||
except Exception as erreur:
|
||||
print erreur
|
||||
return False
|
||||
|
||||
def exporter ( contenu, chemin=False ):
|
||||
''''''
|
||||
if ( chemin == False ):
|
||||
chemin = generer_nom_de_fichier()
|
||||
fichier = open( chemin, 'w' )
|
||||
fichier.write( contenu )
|
||||
fichier.close()
|
||||
|
||||
def generer_nom_de_fichier ():
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d-%Hh%Mm%Ss.txt")
|
||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Ce module facilite l'import/export de fichiers
|
||||
'''
|
||||
|
||||
|
||||
def importer ( chemin ) :
|
||||
'''String -> File
|
||||
tente d'importer le fichier dont le chemin est spécifié'''
|
||||
try:
|
||||
fichier = open( chemin, 'r' )
|
||||
return fichier
|
||||
except Exception as erreur:
|
||||
print erreur
|
||||
return False
|
||||
|
||||
def exporter ( contenu, chemin=False ):
|
||||
''''''
|
||||
if ( chemin == False ):
|
||||
chemin = generer_nom_de_fichier()
|
||||
fichier = open( chemin, 'w' )
|
||||
fichier.write( contenu )
|
||||
fichier.close()
|
||||
|
||||
def generer_nom_de_fichier ():
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d-%Hh%Mm%Ss.txt")
|
||||
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Ce module facilite l'import/export de fichiers
|
||||
'''
|
||||
|
||||
|
||||
def importer ( chemin ) :
|
||||
'''String -> File
|
||||
tente d'importer le fichier dont le chemin est spécifié'''
|
||||
try:
|
||||
fichier = open( chemin, 'r' )
|
||||
return fichier
|
||||
except Exception as erreur:
|
||||
print erreur
|
||||
return False
|
||||
|
||||
def exporter ( contenu, chemin=False ):
|
||||
''''''
|
||||
if ( chemin == False ):
|
||||
chemin = generer_nom_de_fichier()
|
||||
fichier = open( chemin, 'w' )
|
||||
if ( isinstance( contenu, basestring) ):
|
||||
fichier.write( contenu )
|
||||
elif ( isinstance( contenu, (list, tuple) ) ):
|
||||
traiter_liste ( contenu, fichier )
|
||||
fichier.close()
|
||||
|
||||
def generer_nom_de_fichier ():
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d-%Hh%Mm%Ss.txt")
|
||||
|
||||
def traiter_liste ( liste, fichier ):
|
||||
if ( isinstance( contenu, basestring) ):
|
||||
fichier.write( contenu )
|
||||
else if isinstance( contenu, (list, tuple)):
|
||||
pass
|
||||
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
Ce module facilite l'import/export de fichiers
|
||||
'''
|
||||
|
||||
|
||||
def importer ( chemin ) :
|
||||
'''String -> File
|
||||
tente d'importer le fichier dont le chemin est spécifié'''
|
||||
try:
|
||||
fichier = open( chemin, 'r' )
|
||||
return fichier
|
||||
except Exception as erreur:
|
||||
print erreur
|
||||
return False
|
||||
|
||||
def exporter ( contenu, chemin=False ):
|
||||
''''''
|
||||
if ( chemin == False ):
|
||||
chemin = generer_nom_de_fichier()
|
||||
fichier = open( chemin, 'w' )
|
||||
if ( isinstance( contenu, basestring) ):
|
||||
fichier.write( contenu )
|
||||
elif ( isinstance( contenu, (list, tuple) ) ):
|
||||
traiter_liste ( contenu, fichier )
|
||||
fichier.close()
|
||||
|
||||
def generer_nom_de_fichier ():
|
||||
''''''
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d-%Hh%Mm%Ss.txt")
|
||||
|
||||
def traiter_liste ( liste, fichier ):
|
||||
''''''
|
||||
for item in liste:
|
||||
if ( isinstance( item, basestring) ):
|
||||
fichier.write( item )
|
||||
elif isinstance( item, (list, tuple)):
|
||||
traiter_liste ( item, fichier )
|
||||
Binary file not shown.
Reference in New Issue
Block a user