File: cree_exemple_simple.py

package info (click to toggle)
scolasync 5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 16,324 kB
  • sloc: javascript: 4,094; python: 3,849; xml: 3,814; makefile: 116; sh: 31
file content (47 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python3

import sys

def ecrit_entete(out):
    entete="""\
<?xml version="1.0" encoding="ISO-8859-1"?>
<BEE_ELEVES VERSION="1.7">
  <DONNEES>
"""
    out.write(entete)
    return

def ecrit_fin(out):
    fin="""\
  </DONNEES>
</BEE_ELEVES>
"""
    out.write(fin)
    return

def donnees(out, n):
    out.write("    <ELEVES>\n")
    for i in range(1,1+n):
        out.write("      <ELEVE ELEVE_ID=\"%d\">\n" %(1000+i))
        out.write("        <NOM>N°</NOM>\n")
        out.write("        <PRENOM>{0:02d}</PRENOM>\n".format(i))
        out.write("      </ELEVE>\n")
    out.write("    </ELEVES>\n")
    out.write("    <STRUCTURES>\n")
    for i in range(1,1+n):
        out.write("      <STRUCTURES_ELEVE ELEVE_ID=\"%d\">\n" %(1000+i))
        out.write("        <STRUCTURE>\n")
        out.write("          <CODE_STRUCTURE>Suite de numéros</CODE_STRUCTURE>\n")
        out.write("          <TYPE_STRUCTURE>D</TYPE_STRUCTURE>\n")
        out.write("        </STRUCTURE>\n")
        out.write("      </STRUCTURES_ELEVE>\n")
    out.write("    </STRUCTURES>\n")

if __name__=="__main__":
    out=open(sys.argv[1], "w", encoding="latin-1")
    ecrit_entete(out)
    donnees(out, 35)
    ecrit_fin(out)
    out.close()