Brackets

Check-in [f361b4de39]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:wrapping for night2
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:f361b4de399e17d79b3e8e101d77389409c0d8c9f7a946f48a1ed80ae435f7d9
User & Date: scott 2018-03-21 07:36:46
Context
2018-03-21
16:24
working code check-in: 5ffa5ced86 user: scott tags: trunk
07:36
wrapping for night2 check-in: f361b4de39 user: scott tags: trunk
06:52
wrapping for night check-in: ff8044da96 user: scott tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Bracket-Builder.py.

24
25
26
27
28
29
30








31
32
33
34
35
36
37
38
39


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
95
96












97
98
99
100
101
102
        csv_data = tuple(csv_input)
    # this section sets all of the divisions into a tuple  
    for aclass in csv_data:
            t = aclass[0] 
            if t not in divisions:
                divisions.append(t)
    divisions = tuple(divisions)








    # This section counts how many are in each division
    for div_num in divisions:
            # below is division, number of athletes per division, Remainder, and # of heats required to get all athletes into a heat
            x = div_num.split("_")
            x = x[0]
            y = nested_count(csv_data, x)
            n = div_num, y, y % 4, y//4 
            div_count.append(n)
    div_count = tuple(div_count)


    return csv_data, divisions, div_count

def main(args):
#the main program that makes everything work

#feed in filename of csv file in base path
    csv_fname = input("Enter the name of the CSV File: ")
    if csv_fname == "":
        csv_fname = 'F:\Python-Dev\Brackets-Nationals\sample1-bxlist.csv'
    csv_data, divisions, div_count = csv_import(csv_fname)
    sheet_build(csv_data, divisions)

    return 0 

def sheet_build(csv_data, divisions):
    import pyoo
    # Stuff around opening up a sheet and feeding in data
    desktop = pyoo.Desktop('localhost', 2002)
    doc = desktop.open_spreadsheet('F:\Python-Dev\Brackets-Nationals\Bracket-template.ods')
    #doc = desktop.create_spreadsheet()

    # Create all of the worksheets and populate with basic information
................................................................................
        doc.sheets.copy('Bracket-Template', get_sheet_name(dname))
        # libreoffice tab length is 31 characters, this will correct this but still put in full name
        sheetNames = []
        if len(dname) > 31:
            dshort = dname[:31]
            tlist = doc.sheets[dshort]
            tlist[0,1].value = dname
            #Collect the sheet names for returning to later
            sheetNames.append(dshort)
        else:
            tlist = doc.sheets[dname]
            tlist[0,1].value = dname
            # collect the sheet names for returning to later
            sheetNames.append(dname)
    # Enter all of the Sheet names into the DivCounts Sheet
    print(sheetNames)
    DivCountsSheet = doc.sheets['DivCounts']
    row = 1
    col = 0
    for sname in sheetNames:
        DivCountsSheet[row, col].value = sname
        row = row + 1


    alist = doc.sheets[1]
    # Feed the athlete list
    # Geometry set for putting data in the startlist (counting starts at 0; r is row and c is column)
    rstart = 3
    cstart = 0
    rstop = len(csv_data) + rstart
    cstop = len(csv_data[1]) + cstart
    alist[rstart:rstop, cstart:cstop].values = csv_data

    return 0













if __name__ == '__main__':
    sys.exit(main(sys.argv))










>
>
>
>
>
>
>
>









>
>










|



|







 







|




|

|
|

|
|
|
|
|
>







|


|
>
>
>
>
>
>
>
>
>
>
>
>






24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        csv_data = tuple(csv_input)
    # this section sets all of the divisions into a tuple  
    for aclass in csv_data:
            t = aclass[0] 
            if t not in divisions:
                divisions.append(t)
    divisions = tuple(divisions)
    # Identify Divisions and Athlete Count
    for div_num in divisions:
        x = csv_data.count(div_num)
        n = div_num, x
        div_count.append(n)
    div_count = tuple(div_count)
    print("div count", div_count)
    '''
    # This section counts how many are in each division
    for div_num in divisions:
            # below is division, number of athletes per division, Remainder, and # of heats required to get all athletes into a heat
            x = div_num.split("_")
            x = x[0]
            y = nested_count(csv_data, x)
            n = div_num, y, y % 4, y//4 
            div_count.append(n)
    div_count = tuple(div_count)
    print("div_count: ", div_count)
    '''
    return csv_data, divisions, div_count

def main(args):
#the main program that makes everything work

#feed in filename of csv file in base path
    csv_fname = input("Enter the name of the CSV File: ")
    if csv_fname == "":
        csv_fname = 'F:\Python-Dev\Brackets-Nationals\sample1-bxlist.csv'
    csv_data, divisions, div_count = csv_import(csv_fname)
    doc = sheet_build(csv_data, divisions, div_count)

    return 0 

def sheet_build(csv_data, divisions, div_count):
    import pyoo
    # Stuff around opening up a sheet and feeding in data
    desktop = pyoo.Desktop('localhost', 2002)
    doc = desktop.open_spreadsheet('F:\Python-Dev\Brackets-Nationals\Bracket-template.ods')
    #doc = desktop.create_spreadsheet()

    # Create all of the worksheets and populate with basic information
................................................................................
        doc.sheets.copy('Bracket-Template', get_sheet_name(dname))
        # libreoffice tab length is 31 characters, this will correct this but still put in full name
        sheetNames = []
        if len(dname) > 31:
            dshort = dname[:31]
            tlist = doc.sheets[dshort]
            tlist[0,1].value = dname
            #Collect the sheet names for returning to later !!! broken
            sheetNames.append(dshort)
        else:
            tlist = doc.sheets[dname]
            tlist[0,1].value = dname
            # collect the sheet names for returning to later !!! broken
            sheetNames.append(dname)
    '''  Broken above, not getting the counts in the nested list
    # Enter all of the divisions with # of athletes into the DivCounts Sheet
    DivCountsSheet = doc.sheets['DivCounts']
    rstart = 1
    cstart = 0
    rstop = len(div_count)
    cstop = len(div_count[0])
    DivCountsSheet[rstart:rstop, cstart,cstop].values = div_count
    '''

    alist = doc.sheets[1]
    # Feed the athlete list
    # Geometry set for putting data in the startlist (counting starts at 0; r is row and c is column)
    rstart = 3
    cstart = 0
    rstop = len(csv_data) + rstart
    cstop = len(csv_data[0]) + cstart
    alist[rstart:rstop, cstart:cstop].values = csv_data

    return doc

def wavecount():
    #This will identify how many waves for the # of athletes including how many LCQ spots
    pass

def heatshape(waves):
    startrow = 0
    startcol = 0

    #Add below variables for Heat and OHeat# (Oheet is overall heat number for comps that day)
    headers = [["Heat#", ,"OHeat#",,],["Seed","Bib#","Name","Color","PL"]]


if __name__ == '__main__':
    sys.exit(main(sys.argv))