DansTonCode.net
quote.smartness() == 42FORTRAN is not a flower but a weed — it is hardy, occasionally blooms, and grows in every computer.@author Alan J. Perlis
Quote #278
python
@
author 
Anonymous
0
""" macro funcion  para buscar una imagen independientemente del tipo de
extension que tenga. Habría que comprobar todas las extensiones. De momento
se han puesto las más usadas"""
def buscarFicheroCorrecto(self,id):
    flWEB = conf.get_conf( "DOCUMENTGALLERY_WEB_FOLDER" ) 
    flFS = conf.get_conf( "DOCUMENTGALLERY_FS_FOLDER" )

    f = None

    try:
        f = "imagen_%s.gif" % id
        logINFO('img', "".join( ( flFS, "/", f )), os.stat( "".join( ( flFS, "/", f ) ) ))
    except OSError:
        try:
    	f = "imagen_%s.jpeg" %id
    	os.stat( "".join( ( flFS, "/", f ) ) )
        except OSError:
            try:
                f = "imagen_%s.jpg" % id
                os.stat( "".join( ( flFS, "/", f ) ) )
            except OSError:
                try:
            	f = "imagen_%s.jpe" % id
            	os.stat( "".join( ( flFS, "/", f ) ) )
                except OSError:
                    try:
                        f = "imagen_%s.webp" % id
                        os.stat( "".join( ( flFS, "/", f ) ) )
                    except OSError:
                        try:
                    	f = "imagen_%s.jp2" %id
                    	os.stat( "".join( ( flFS, "/", f ) ) )
                        except OSError:
                            try:
                                f = "imagen_%s.jpx" %id
                                os.stat( "".join( ( flFS, "/", f ) ) )
                            except OSError:
                                try:
                            	f = "imagen_%s.j2k" % id
                            	os.stat( "".join( ( flFS, "/", f ) ) )
                                except OSError:
                                    try:
                                        f = "imagen_%s.jxr" % id
                                        os.stat( "".join( ( flFS, "/", f ) ) )
                                    except OSError:
                                        try:
                                    	f = "imagen_%s.hdp" % id
                                    	os.stat( "".join( ( flFS, "/", f ) ) )
                                        except OSError:
                                            try:
                                                f = "imagen_%s.bmp" % id
                                                os.stat( "".join( ( flFS, "/", f ) ) )
                                            except OSError:
                                                try:
                                            	f = "imagen_%s.dib" % id
                                            	os.stat( "".join( ( flFS, "/", f ) ) )
                                                except OSError:
                                                    try:
                                                        f = "imagen_%s.png" % id
                                                        os.stat( "".join( ( flFS, "/", f ) ) )
                                                    except OSError:
                                                        try:
                                                    	f = "imagen_%s.tiff" % id
                                                    	os.stat( "".join( ( flFS, "/", f ) ) )
                                                        except OSError:
                                                            try:
                                                                f = "imagen_%s.tif" % id
                                                                os.stat( "".join( ( flFS, "/", f ) ) )
                                                            except OSError:
                                                                pass

    		 
    return f
Code-source en python proposé par Anonymous
 
 0