コード例 #1
0
ファイル: tela.py プロジェクト: sbausson/wxflore
        id_coste = ""
        n_coste = ""
        syn = []

    read_url(s, id, "synthese")
    read_url(s, id, "description")
    # syn removed
    # read_url(s,id,"nomenclature")

    name = s.nl.replace("× ", "").strip()
    name = name.split("[")[0].strip()
    name = name.replace(" subsp. ", "-")
    name = name.replace(" f. ", "-")
    name = name.replace(" var. ", "-")
    name = name.replace(" ", ".")
    sys.stderr.write(color.scol('Writting "{}" ...\n'.format(name), color.YELLOW))
    # f = open(name,"w")
    f = codecs.open(name, "bw", "utf-8")

    f.write("FA: {}\n".format(s.fa))
    f.write("NL: {}\n".format(s.nl))
    f.write("NV: {}\n".format(s.nv))
    # syn removed
    #    f.write("SY:\n")
    #    for syn in s.syn:
    #        f.write("    {}\n".format(syn))
    f.write("ID.tela: {}\n".format(s.id_tela))

    try:
        f.write("ID.inpn: {}\n".format(s.id_inpn))
    except:
コード例 #2
0
ファイル: fldb.py プロジェクト: sbausson/wxflore
def display_struct(struct,compressed,i,options):

    global line_parity

    nl = struct["NL"]

    if "NV" not in struct:
        nv = ""
    else:
        nv = struct["NV"]


    if "N.UK" not in struct:
        nuk = ""
    else:
        nuk = struct["N.UK"]

    if "N.NL" not in struct:
        nnl = ""
    else:
        nnl = struct["N.NL"]

    if "N.ES" not in struct:
        nes = ""
    else:
        nes = struct["N.ES"]

    if "N.IT" not in struct:
        nit = ""
    else:
        nit = struct["N.IT"]

    if "N.DE" not in struct:
        nde = ""
    else:
        nde = struct["N.DE"]



    if "NE" not in struct:
        ne = ""
    else:
        ne = struct["NE"]

    if "SY" not in struct:
        sy = ""
    else:
        sy = struct["SY"]

    if "FA" not in struct:
        fa = ""
    else:
        fa = struct["FA"]

    if "ZO" not in struct:
        zo = ""
    else:
        zo = struct["ZO"]

    tg = ""
    #if struct.has_key("TG") and struct["TG"] == "y":
    #    tg = "***"
    #else:
    #    tg = ""


    if compressed == 1:
        if options.short == 2:
            s="%-20s %-50s %-50s" % (fa,nl,nv)
        elif options.short == 3:
            s="- {0} / {1}".format(nl.replace("[","").replace("]",""),nv)
        elif options.short == 4:
            s="- {0:70} {1}".format(nl,nv)
        else:
            s="\n"
            s+="[ %s ]\n" % struct["FN"]
            s+="-"*90
            s+="\n"
            s+="%-25s : %-50s %s\n" % ("Nom latin",nl,tg)

            # Nom vernaculaire
            nv_=nv.split(";")
            if len(nv_) == 1:
                s+="%-25s : %s\n" % ("Nom vernacualire",nv)
            else:
                s+="%-25s : %s\n" % ("Noms vernacualires",",".join(nv_))

            # Nom anglais
            if nuk != "":
                nuk_=nuk.split(";")
                if len(nuk_) == 1:
                    s+="%-25s : %s\n" % ("Nom anglais",nuk)
                else:
                    s+="%-25s : %s\n" % ("Noms anglais",",".join(nuk_))

            # NL
            if nnl != "":
                nnl_=nnl.split(";")
                if len(nnl_) == 1:
                    s+="%-25s : %s\n" % ("Nom Néerlandais",nnl)
                else:
                    s+="%-25s : %s\n" % ("Noms Néerlandais",",".join(nnl_))

            # ES
            if nes != "":
                nes_=nes.split(";")
                if len(nes_) == 1:
                    s+="%-25s : %s\n" % ("Nom Espagnol",nes)
                else:
                    s+="%-25s : %s\n" % ("Noms Espagnol",",".join(nes_))

            # IT
            if nit != "":
                nit_=nit.split(";")
                if len(nit_) == 1:
                    s+="%-25s : %s\n" % ("Nom Italien",nit)
                else:
                    s+="%-25s : %s\n" % ("Noms Italien",",".join(nit_))

            # DE
            if nde != "":
                nde_=nde.split(";")
                if len(nde_) == 1:
                    s+="%-25s : %s\n" % ("Nom Allemand",nde)
                else:
                    s+="%-25s : %s\n" % ("Noms Allemand",",".join(nde_))

            # Famille
            s+="%-25s : %s\n" % ("Famille",fa)
            if 0 and struct.has_key("CN") and struct["CN"] != "":
                print("%-25s : %s\n" % ("Code nomenclatural",struct["CN"]))

            if options.short == 0:
                # Synonyme
                if len(sy) == 1:
                    s+="{0:25} : {1}\n".format("Synonyme",', '.join(sy))
                elif len(sy) > 1:
                    s+="%-25s :\n" % ("Synonymes")
                    for syn in sy:
                        s+="\t- %s\n" % syn #s+="{0:25} : {1}\n".format("Synonyme(s)",', '.join(sy))

                if options.short in  [0,1]:
                    s+="%s :\n" % ("Description")
                    for ds in struct["DS"]:
                        s+="\t- %s\n" % ds


        #print "-"*90

            if options.short == 0:

                try:
                    s+="%-25s : %s\n" % ("Habitat",struct["HB"])
                except:
                    pass

                try:
                    s+="%-25s : %s\n" % ("Zone Géographique",struct["ZO"])
                except:
                    pass

                try:
                    s+="%-25s : %s\n" % ("Floraison",struct["FL"])
                except:
                    pass

                try:
                    s+="%-25s : %s\n" % ("Usage",struct["US"])
                except:
                    pass

                try:
                    if struct["true_coste"]:
                        c = color.GREEN
                    else:
                        c = color.RED

                    s+=color.scol("%-25s : N°%s " % ("Ref. Coste",struct["ID.coste"]),c)
                    s+=color.scol("({})".format(struct["N.coste"]),c)

                except:
                    pass

                s+="\n"

                if "ID.tela" in struct and struct["ID.tela"] != "":
                    s+="%-25s : N°%s  http://www.tela-botanica.org/bdtfx-nn-%s-synthese\n" % ("Ref. Tela",struct["ID.tela"],struct["ID.tela"])

                try:
                    s+="%-25s : N°%s  http://inpn.mnhn.fr/espece/cd_nom/%s\n" % ("Ref. INPN",struct["ID.inpn"],struct["ID.inpn"])
                    s+="%-25s : http://siflore.fcbn.fr/?cd_ref=%s&r=metro\n" % ("Répartition FCNB",struct["ID.inpn"])
                except:
                    pass

                try:
                    s+="%-25s : %s\n" % ("Wiki.Fr",struct["REF.wiki.fr"])
                except:
                    pass


        print(s) #.encode("utf-8"))

        #print "-"*90


    else:
        for key in key_list:
            if struct.has_key(key):
                print("{0}: {1}".format(key,struct[key]))
        print("")
コード例 #3
0
ファイル: fona2.py プロジェクト: sbausson/wxflore
        nus=""
        syn=""
        id_coste = ""
        n_coste = ""
        syn = []
        oi = []


#    read_file(s,sys.argv[-1])

    read_url(s,id,options)
#    read_url(s,id,"description")
#    read_url(s,id,"nomenclature")

    name = "{}.fona".format(id)
    sys.stderr.write(color.scol("Writting \"{}\" ...\n".format(name),color.YELLOW))
    f = open(name,"w")
    
    f.write("NL: {}\n".format(s.nl))
    f.write("N.US: {}\n".format(s.nus))
    f.write("SY: {}\n".format(s.syn))
    f.write("ID.fona: {}\n".format(s.id_fona))
    f.write("DS:\n{}\n".format(s.ds))
    f.write("FL: {}\n".format(s.fl))
    f.write("HB: {}\n".format(s.hb))
    f.write("HG: {}\n".format(s.hg))    
    f.write("ZG: {}\n".format(s.zg))    
    f.write("OI:\n{}\n".format("\n".join(s.oi)))
        
    f.close()            
    
コード例 #4
0
ファイル: efloras.py プロジェクト: sbausson/wxflore
        fr=""
        nv=""
        us=""
        id_coste = ""
        n_coste = ""
        syn = []


#    read_file(s,sys.argv[-1])

    read_url(s,id,options)
#    read_url(s,id,"description")
#    read_url(s,id,"nomenclature")

    name = "{}.efloras".format(id)
    sys.stderr.write(color.scol("Writting \"{}\" ...\n".format(name),color.YELLOW))
    f = open(name,"w")
    
    f.write("NL: {}\n".format(s.nl))
    f.write("N.US: {}\n".format(s.nus))
    f.write("SY: {}\n".format(s.sy))
    f.write("ID.efloras: {}\n".format(s.id_fona))
    f.write("DS:\n{}\n".format(s.ds))
    f.write("FL: {}\n".format(s.fl))
    f.write("HB: {}\n".format(s.hb))
    f.write("HG: {}\n".format(s.hg))    
    f.write("ZG: {}\n".format(s.zg))    
    f.write("OI:\n{}\n".format("\n".join(s.oi)))
        
    f.close()