Alealejandrooo commited on
Commit
2ff13c7
1 Parent(s): 526fd5a

fixed typo

Browse files
Files changed (1) hide show
  1. app.py +98 -98
app.py CHANGED
@@ -1,99 +1,99 @@
1
- import gradio as gr
2
- import os
3
-
4
- from process import process_data
5
-
6
- def makeButtonClickableFiles(files):
7
- """Makes a button interactive only if all files in the list have correct extensions.
8
-
9
- Args:
10
- files (list): List of uploaded file objects.
11
-
12
- Returns:
13
- _type_: Button state (interactive or not) and possibly a warning message.
14
- """
15
- if not files:
16
- return gr.Button(interactive=False)
17
-
18
- allowed_extensions = ["xls", "xlsx"]
19
- for file in files:
20
- base_name = os.path.basename(file.name)
21
- # Extract the file extension and check if it's in the allowed list.
22
- if base_name.split('.')[-1].lower() not in allowed_extensions:
23
- raise gr.Error(f"Unsupported file: {base_name}.Allowed extensions: .xls .xlsx")
24
-
25
- return gr.Button(interactive=True)
26
-
27
-
28
- # Define a Gradio interface
29
-
30
- with gr.Blocks() as demo:
31
-
32
- with gr.Row():
33
- header = gr.Markdown(("<h1>MindBody VS. Medserv Checker </h1>"))
34
-
35
- with gr.Row():
36
-
37
- with gr.Column():
38
- file_uploader_mindbody = gr.Files(
39
- label=("Upload MindBody"),
40
- file_count="multiple",
41
- file_types=[".xlsx", '.xls'],
42
- container=True,
43
- interactive=True,
44
- scale=1,
45
- )
46
-
47
-
48
- with gr.Column():
49
- file_uploader_medserv = gr.Files(
50
- label=("Upload Medserv"),
51
- file_count= "multiple",
52
- file_types=[".xlsx", '.xls'],
53
- container=True,
54
- interactive=True,
55
- scale=1,
56
- )
57
-
58
- with gr.Row():
59
- tollerance = gr.Slider(0, 7, value = 1, step = 1, interactive = True, label="Days Tollerance",
60
- info="Set the number of days of tolerance to match the sale dates between MindBody and Medserve (0 = no tolerance / exact match).")
61
-
62
- with gr.Row():
63
-
64
- file_process_button = gr.Button(
65
- value="PROCESS FILES",
66
- interactive=False,
67
- )
68
-
69
- with gr.Row():
70
- processed_file = gr.Files(
71
- label=("Output File"),
72
- file_count="single",
73
- interactive=False,
74
- elem_classes="gradio-file",
75
- )
76
-
77
-
78
-
79
-
80
- file_uploader_mindbody.change(
81
- fn=makeButtonClickableFiles,
82
- inputs=[file_uploader_mindbody],
83
- outputs=[file_process_button])
84
-
85
-
86
- file_uploader_medserv.change(
87
- fn=makeButtonClickableFiles,
88
- inputs=[file_uploader_medserv],
89
- outputs=[file_process_button])
90
-
91
-
92
- file_process_button.click(
93
- fn = process_data,
94
- inputs = [file_uploader_mindbody, file_uploader_medserv, tollerance],
95
- outputs = processed_file)
96
-
97
-
98
- if __name__ == "__main__":
99
  demo.queue().launch()
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ from process import process_data
5
+
6
+ def makeButtonClickableFiles(files):
7
+ """Makes a button interactive only if all files in the list have correct extensions.
8
+
9
+ Args:
10
+ files (list): List of uploaded file objects.
11
+
12
+ Returns:
13
+ _type_: Button state (interactive or not) and possibly a warning message.
14
+ """
15
+ if not files:
16
+ return gr.Button(interactive=False)
17
+
18
+ allowed_extensions = ["xls", "xlsx"]
19
+ for file in files:
20
+ base_name = os.path.basename(file.name)
21
+ # Extract the file extension and check if it's in the allowed list.
22
+ if base_name.split('.')[-1].lower() not in allowed_extensions:
23
+ raise gr.Error(f"Unsupported file: {base_name}.Allowed extensions: .xls .xlsx")
24
+
25
+ return gr.Button(interactive=True)
26
+
27
+
28
+ # Define a Gradio interface
29
+
30
+ with gr.Blocks() as demo:
31
+
32
+ with gr.Row():
33
+ header = gr.Markdown(("<h1>MindBody VS. Medserv Checker </h1>"))
34
+
35
+ with gr.Row():
36
+
37
+ with gr.Column():
38
+ file_uploader_mindbody = gr.Files(
39
+ label=("Upload MindBody"),
40
+ file_count="multiple",
41
+ file_types=[".xlsx", '.xls'],
42
+ container=True,
43
+ interactive=True,
44
+ scale=1,
45
+ )
46
+
47
+
48
+ with gr.Column():
49
+ file_uploader_medserv = gr.Files(
50
+ label=("Upload Medserv"),
51
+ file_count= "multiple",
52
+ file_types=[".xlsx", '.xls'],
53
+ container=True,
54
+ interactive=True,
55
+ scale=1,
56
+ )
57
+
58
+ with gr.Row():
59
+ tollerance = gr.Slider(0, 7, value = 1, step = 1, interactive = True, label="Days Tolerance",
60
+ info="Set the number of days of tolerance to match the sale dates between MindBody and Medserve (0 = no tolerance / exact match).")
61
+
62
+ with gr.Row():
63
+
64
+ file_process_button = gr.Button(
65
+ value="PROCESS FILES",
66
+ interactive=False,
67
+ )
68
+
69
+ with gr.Row():
70
+ processed_file = gr.Files(
71
+ label=("Output File"),
72
+ file_count="single",
73
+ interactive=False,
74
+ elem_classes="gradio-file",
75
+ )
76
+
77
+
78
+
79
+
80
+ file_uploader_mindbody.change(
81
+ fn=makeButtonClickableFiles,
82
+ inputs=[file_uploader_mindbody],
83
+ outputs=[file_process_button])
84
+
85
+
86
+ file_uploader_medserv.change(
87
+ fn=makeButtonClickableFiles,
88
+ inputs=[file_uploader_medserv],
89
+ outputs=[file_process_button])
90
+
91
+
92
+ file_process_button.click(
93
+ fn = process_data,
94
+ inputs = [file_uploader_mindbody, file_uploader_medserv, tollerance],
95
+ outputs = processed_file)
96
+
97
+
98
+ if __name__ == "__main__":
99
  demo.queue().launch()