begin process at 2008 07 25 10:17:09
1 216 107 membres
84 nouveaux aujourd'hui
14 180 membres club

Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

CS2PY (FROM CODESOURCE TO PYTHON)


Information sur la source

Catégorie :Divers Classé sous : nettoyer, source, utilitaire Niveau : Débutant Date de création : 01/09/2006 Vu : 1 487

Note :
10 / 10 - par 3 personnes
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

Description

A propos d'un source python du site, jpountz écrit le 27/08/2006 : "ça serait bien si tu pouvais mettre un zip, parce que le copier/coller depuis le site n'est pas top."

Pour résoudre ce problème, j'utilise un petit script python qui fait le ménage après un copier/coller :

- supression des dièse+espace
ou
- suppression des numéro_de_ligne+point+espace

selon les cas.

C'est sous GPL.

Source

  • #!/usr/bin/env python
  • # -*- coding: iso-8859-15 -*-
  • # nettoyer le copier/coller du CodeSource vers python
  • # en effacant le # ou le numero de ligne
  • ############################################################################
  • # Copyright (C) 2006 Andre Connes
  • #
  • # This program is free software; you can redistribute it and/or modify
  • # it under the terms of the GNU General Public License as published by
  • # the Free Software Foundation; either version 2 of the License, or
  • # any later version.
  • #
  • # This program is distributed in the hope that it will be useful,
  • # but WITHOUT ANY WARRANTY; without even the implied warranty of
  • # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • # GNU General Public License for more details.
  • #
  • # You should have received a copy of the GNU General Public License
  • # along with this program; if not, write to the Free Software
  • # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
  • ############################################################################
  • # File : cs2py.py
  • # Author : Andre Connes
  • # Mailto : andre.connes@wanadoo.fr
  • # Date : 29/08/2006
  • # Licence : GNU/GPL Version 2 ou plus
  • #
  • # Description:
  • # ------------
  • #
  • # @version $Id: Exp $
  • # @author Andre Connes
  • # @project
  • # @copyright Andre Connes 29/08/2006
  • #
  • #
  • #########################################################################
  • import sys
  • if len(sys.argv) < 3:
  • print "Usage : %s fichier_source fichier_but" % sys.argv[0]
  • sys.exit(1)
  • fsname = sys.argv[1]
  • fbname = sys.argv[2]
  • fs =open(fsname,'r')
  • fb =open(fbname,'w')
  • while 1:
  • ligne=fs.readline() # lit le caractere eol
  • if ligne=="":
  • break
  • if ligne[0] == "#":
  • nouvelleligne = ligne[2:]
  • else:
  • nouvelleligne = ligne[ligne.index(".")+2:]
  • print ".",
  • fb.write(nouvelleligne)
  • print "\nTermine !\n\n*** Faites un chmod +x fichier_but (sous *NIX) ***"
  • fs.close()
  • fb.close
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-

# nettoyer le copier/coller du CodeSource vers python
# en effacant le # ou le numero de ligne

############################################################################
# Copyright (C) 2006 Andre Connes
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
############################################################################
# File    : cs2py.py
# Author  : Andre Connes
# Mailto  : andre.connes@wanadoo.fr
# Date    : 29/08/2006
# Licence : GNU/GPL Version 2 ou plus
#
# Description:
# ------------
#
# @version    $Id: Exp $
# @author     Andre Connes
# @project
# @copyright  Andre Connes 29/08/2006
#
#
#########################################################################

import sys

if len(sys.argv) < 3:
    print "Usage : %s fichier_source fichier_but" % sys.argv[0]
    sys.exit(1)

fsname = sys.argv[1]
fbname = sys.argv[2]
  
fs  =open(fsname,'r')
fb  =open(fbname,'w')

while 1:
    ligne=fs.readline()	# lit le caractere eol
    if ligne=="":
      break
    if ligne[0] == "#":
        nouvelleligne = ligne[2:]
    else:
        nouvelleligne = ligne[ligne.index(".")+2:]
    print ".",
    fb.write(nouvelleligne)
print "\nTermine !\n\n*** Faites un chmod +x fichier_but (sous *NIX) ***"
fs.close()
fb.close

Sources en rapport avec celle ci

  • signaler à un administrateur
    Commentaire de jpountz le 02/09/2006 12:14:39

    Mon sauveur! ^^

  • signaler à un administrateur
    Commentaire de econs le 06/09/2006 23:52:53 administrateur CS

    Tu vas faire des heureux avec ce script.
    Tout le monde va vouloir se mettre au python !! (Bien que ce soit aisément transportable dans d'autres langages)

  • signaler à un administrateur
    Commentaire de beltegeuse le 05/06/2007 11:26:57

    Super! je n'avais même pas y penser mais c'est tellement pratique!
    Merci encore!

Ajouter un commentaire

Discussions en rapport avec ce code source

Pub



Appels d'offres

Creation portail video
Budget : 3 000€
Site de e-commerce
Budget : 5 000€
Demande de devis pour ...
Budget : 7 000€

CalendriCode

Juillet 2008
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

VS Express FR Gratuit !

VS Express en français et 100% gratuit !

Téléchargements

Logiciels à télécharger sur le même thème :

Boutique

Boutique de goodies CodeS-SourceS