-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConvertMenu.py
1728 lines (967 loc) · 47.7 KB
/
ConvertMenu.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# TODO - clarify this description
#
# This code reads in two documents and creates a third file to combine them.
#
# This version separates sections of the menu into 5 distinct arrays.
#
# CoreArrays.py
#
# Updated 11.3.22
# Open the Template file
with open('indexOutline.html') as templateFile:
templateCode = templateFile.readlines()
#This can likely be deleted
import json
from os.path import exists
#delete?
#resultFileName = "CurrentObjectTypes.html"
import datetime
# Create current date in mm.dd.yyyy format
today = datetime.date.today()
date_str = today.strftime("%m.%d.%Y")
# Create file name with date
resultFileName = f"MobileMenu{date_str}.html"
# Write contents of .html file to new file with that name
#with open(datedMenuName, "w") as f:
# f.write("<!-- Insert menu items here -->\n")
# this variable should be renamed or include the date
datedMenuName = 'CurrentMenu.txt'
fileExists = exists(resultFileName)
import os
if fileExists == True:
# Remove the old result file
os.remove(resultFileName)
# Create the new Result HTML file
resultFile = open(resultFileName, "a")
# Define Arrays (2D?) for Template
template1A = []
template1B = []
template1AAStart = []
template1AAEnd = []
template2A = []
template2B = []
template2C = []
template2D = []
template2E = []
template2F = []
template2G = []
template2H = [] #price
template2I = [] #price-end
template2J = []
template2K = []
template3 = []
templateBStart = []
templateB1Start = []
templateB1aStart = []
templateB1aEnd = []
templateB1bStart = []
templateB1bEnd = []
templateB1cStart = []
templateB1cEnd = []
templateB1dStart = []
templateB1dEnd = []
templateBEnd = []
templateCStart = []
templateC1Start = []
templateC1aStart = []
templateC1aEnd = []
templateC1bStart = []
templateC1bEnd = []
templateC1cStart = []
templateC1cEnd = []
templateC1dStart = []
templateC1dEnd = []
templateCEnd = []
templateDStart = []
templateD1Start = []
templateD3Start = []
templateD3End = []
templateD3Endb = []
templateD3aStart = []
templateD3aEnd = []
templateD1bStart = []
templateD1bEnd = []
templateD1cStart = []
templateD1cEnd = []
templateD1dStart = []
templateD1dEnd = []
templateD1eStart = []
templateD1eEnd = []
templateDEnd = []
templateIEnd = []
singleProduct = []
#Define the key word to look for within the Template file.
keyWord = 'BY THE GLASS HEADER\n'
keyWord1A = '<!--__________ HTML HEADER START __________-->\n'
keyWord1B = '<!--__________ HTML HEADER END __________-->\n'
keyWord2_1A = '<!--__________ BY THE GLASS SECTION HEADER START __________-->\n'
keyWord2_1B = '<!--__________ BY THE GLASS SECTION HEADER END __________-->\n'
keyWord2_1Aa = '<!--__________ BY THE GLASS CATEGORY HEADER START __________-->\n'
keyWord2_1Bb = '<!--__________ BY THE GLASS CATEGORY HEADER END __________-->\n'
keyWord2_2A = '<!--__________ BY THE GLASS TITLE HEADER START __________-->\n'
keyWord2_2B = '<!--__________ BY THE GLASS TITLE HEADER END __________-->\n'
keyWord2_3A = '<!--__________ BY THE GLASS TITLE FOOTER START __________-->\n'
keyWord2_3B = '<!--__________ BY THE GLASS TITLE FOOTER END __________-->\n'
keyWord2_4A = '<!--__________ BY THE GLASS ITEM HEADER START __________-->\n'
keyWord2_4B = '<!--__________ BY THE GLASS ITEM HEADER END __________-->\n'
keyWord2_5A = '<!--__________ BY THE GLASS NAME HEADER START __________-->\n'
keyWord2_5B = '<!--__________ BY THE GLASS NAME HEADER END __________-->\n'
keyWord2_6A = '<!--__________ BY THE GLASS NAME FOOTER START __________-->\n'
keyWord2_6B = '<!--__________ BY THE GLASS NAME FOOTER END __________-->\n'
keyWord2_7A = '<!--__________ BY THE GLASS GRAPE HEADER START __________-->\n'
keyWord2_7B = '<!--__________ BY THE GLASS GRAPE HEADER END __________-->\n'
keyWord2_8A = '<!--__________ BY THE GLASS GRAPE FOOTER START __________-->\n'
keyWord2_8B = '<!--__________ BY THE GLASS GRAPE FOOTER END __________-->\n'
keyWord2_9A = '<!--__________ BY THE GLASS PRICE HEADER START __________-->\n'
keyWord2_9B = '<!--__________ BY THE GLASS PRICE HEADER END __________-->\n'
keyWord2_10A = '<!--__________ BY THE GLASS PRICE FOOTER START __________-->\n'
keyWord2_10B = '<!--__________ BY THE GLASS PRICE FOOTER END __________-->\n'
keyWord2_11A = '<!--__________ BY THE GLASS ORIGIN HEADER START __________-->\n'
keyWord2_11B = '<!--__________ BY THE GLASS ORIGIN HEADER END __________-->\n'
keyWord2_12A = '<!--__________ BY THE GLASS ORIGIN FOOTER START __________-->\n'
keyWord2_12B = '<!--__________ BY THE GLASS ORIGIN FOOTER END __________-->\n'
keyWord2_13A = '<!--__________ BY THE GLASS CATEGORY FOOTER START __________-->\n'
keyWord2_13B = '<!--__________ BY THE GLASS CATEGORY FOOTER END __________-->\n'
keyWord3_A = '<!--__________ BY THE GLASS SECTION FOOTER START __________-->\n'
keyWord3_B = '<!--__________ BY THE GLASS SECTION FOOTER END __________-->\n'
keyWord4_1A = '<!--__________ BEER SECTION HEADER START __________-->\n'
keyWord4_1B = '<!--__________ BEER SECTION HEADER END __________-->\n'
keyWord4_2A = '<!--__________ BEER ITEM HEADER START __________-->\n'
keyWord4_2B = '<!--__________ BEER ITEM HEADER END __________-->\n'
keyWord4_3A = '<!--__________ BEER TITLE HEADER START __________-->\n'
keyWord4_3B = '<!--__________ BEER TITLE HEADER END __________-->\n'
keyWord4_4A = '<!--__________ BEER TITLE FOOTER START __________-->\n'
keyWord4_4B = '<!--__________ BEER TITLE FOOTER END __________-->\n'
keyWord4_5A = '<!--__________ BEER ORIGIN HEADER START __________-->\n'
keyWord4_5B = '<!--__________ BEER ORIGIN HEADER END __________-->\n'
keyWord4_6A = '<!--__________ BEER ORIGIN FOOTER START __________-->\n'
keyWord4_6B = '<!--__________ BEER ORIGIN FOOTER END __________-->\n'
keyWord4_7A = '<!--__________ BEER PRICE HEADER START __________-->\n'
keyWord4_7B = '<!--__________ BEER PRICE HEADER END __________-->\n'
keyWord4_8A = '<!--__________ BEER PRICE FOOTER START __________-->\n'
keyWord4_8B = '<!--__________ BEER PRICE FOOTER END __________-->\n'
keyWord4_9A = '<!--__________ BEER DESCRIPTION HEADER START __________-->\n'
keyWord4_9B = '<!--__________ BEER DESCRIPTION HEADER END __________-->\n'
keyWord4_10A = '<!--__________ BEER DESCRIPTION FOOTER START __________-->\n'
keyWord4_10B = '<!--__________ BEER DESCRIPTION FOOTER END __________-->\n'
keyWord4_11A = '<!--__________ BEER SECTION FOOTER START __________-->\n'
keyWord4_11B = '<!--__________ BEER SECTION FOOTER END __________-->\n'
keyWord6_1A = '<!--__________ FOOD SECTION HEADER START __________-->\n'
keyWord6_1B = '<!--__________ FOOD SECTION HEADER END __________-->\n'
keyWord6_2A = '<!--__________ FOOD TITLE HEADER START __________-->\n'
keyWord6_2B = '<!--__________ FOOD TITLE HEADER END __________-->\n'
keyWord6_3A = '<!--__________ FOOD TITLE FOOTER START __________-->\n'
keyWord6_3B = '<!--__________ FOOD TITLE FOOTER END __________-->\n'
keyWord6_4A = '<!--__________ FOOD NAME HEADER START __________-->\n'
keyWord6_4B = '<!--__________ FOOD NAME HEADER END __________-->\n'
keyWord6_5A = '<!--__________ FOOD NAME FOOTER START __________-->\n'
keyWord6_5B = '<!--__________ FOOD NAME FOOTER END __________-->\n'
keyWord6_6A = '<!--__________ FOOD PRICE HEADER START __________-->\n'
keyWord6_6B = '<!--__________ FOOD PRICE HEADER END __________-->\n'
keyWord6_7A = '<!--__________ FOOD PRICE FOOTER START __________-->\n'
keyWord6_7B = '<!--__________ FOOD PRICE FOOTER END __________-->\n'
keyWord6_8A = '<!--__________ FOOD DESCRIPTION HEADER START __________-->\n'
keyWord6_8B = '<!--__________ FOOD DESCRIPTION HEADER END __________-->\n'
keyWord6_9A = '<!--__________ FOOD DESCRIPTION FOOTER START __________-->\n'
keyWord6_9B = '<!--__________ FOOD DESCRIPTION FOOTER END __________-->\n'
keyWord6_12A = '<!--__________ FOOD SECTION FOOTER START __________-->\n'
keyWord6_12B = '<!--__________ FOOD SECTION FOOTER END __________-->\n'
keyWord8_1A = '<!--__________ BOTTLE SECTION HEADER START __________-->\n'
keyWord8_1B = '<!--__________ BOTTLE SECTION HEADER END __________-->\n'
keyWord8_1x5xA = '<!--__________ BOTTLE CATEGORY HEADER START __________-->\n'
keyWord8_1x5xB = '<!--__________ BOTTLE CATEGORY HEADER END __________-->\n'
keyWord8_2A = '<!--__________ BOTTLE TITLE HEADER START __________-->\n'
keyWord8_2B = '<!--__________ BOTTLE TITLE HEADER END __________-->\n'
keyWord8_3A = '<!--__________ BOTTLE TITLE FOOTER START __________-->\n'
keyWord8_3B = '<!--__________ BOTTLE TITLE FOOTER END __________-->\n'
keyWord8_3Ba = '<!--__________ LARGE BOTTLE NOTICE START __________-->'
keyWord8_3Bb = '<!--__________ LARGE BOTTLE NOTICE END __________-->'
keyWord8_4A = '<!--__________ BOTTLE NAME HEADER START __________-->\n'
keyWord8_4B = '<!--__________ BOTTLE NAME HEADER END __________-->\n'
keyWord8_5A = '<!--__________ BOTTLE NAME FOOTER START __________-->\n'
keyWord8_5B = '<!--__________ BOTTLE NAME FOOTER END __________-->\n'
keyWord8_6A = '<!--__________ BOTTLE PRICE HEADER START __________-->\n'
keyWord8_6B = '<!--__________ BOTTLE PRICE HEADER END __________-->\n'
keyWord8_7A = '<!--__________ BOTTLE PRICE FOOTER START __________-->\n'
keyWord8_7B = '<!--__________ BOTTLE PRICE FOOTER END __________-->\n'
keyWord8_8A = '<!--__________ BOTTLE ORIGIN HEADER START __________-->\n'
keyWord8_8B = '<!--__________ BOTTLE ORIGIN HEADER END __________-->\n'
keyWord8_9A = '<!--__________ BOTTLE ORIGIN FOOTER START __________-->\n'
keyWord8_9B = '<!--__________ BOTTLE ORIGIN FOOTER END __________-->\n'
keyWord8_10A = '<!--__________ BOTTLE GRAPE HEADER START __________-->\n'
keyWord8_10B = '<!--__________ BOTTLE GRAPE HEADER END __________-->\n'
keyWord8_11A = '<!--__________ BOTTLE GRAPE FOOTER START __________-->\n'
keyWord8_11B = '<!--__________ BOTTLE GRAPE FOOTER END __________-->\n'
keyWord8_12A = '<!--__________ BOTTLE DESCRIPTION HEADER START __________-->\n'
keyWord8_12B = '<!--__________ BOTTLE DESCRIPTION HEADER END __________-->\n'
keyWord8_13A = '<!--__________ BOTTLE DESCRIPTION FOOTER START __________-->\n'
keyWord8_13B = '<!--__________ BOTTLE DESCRIPTION FOOTER END __________-->\n'
keyWord8_13x5xA = '<!--__________ BOTTLE CATEGORY FOOTER START __________-->\n'
keyWord8_13x5xB = '<!--__________ BOTTLE CATEGORY FOOTER END __________-->\n'
keyWord8_14A = '<!--__________ BOTTLE SECTION FOOTER START __________-->\n'
keyWord8_14B = '<!--__________ BOTTLE SECTION FOOTER END __________-->\n'
keyWord_ZA = '<!--__________ HTML FOOTER START __________-->\n'
keyWord_ZB = '<!--__________ HTML FOOTER END __________-->\n'
#--------------------------------------------------------------------------------------
# This function takes in an array and prints it as lines.
#--------------------------------------------------------------------------------------
def writeLines (arrayOfLines):
totalLines = len(arrayOfLines)
p = 0
# While there are at least two lines left
while p < totalLines:
resultFile.write(arrayOfLines[p])
p += 1
resultFile.write('\n')
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function takes in a string and checks for multiple blanks.
#
# Returns an array of two strings if there are blanks.
#
# Returns -1 if not.
#
# Other white space and end of line characters are also removed.
#--------------------------------------------------------------------------------------
def splitBlank(checkForBlanks):
splitLine = ['blank']
k = 0
componentLength = len(checkForBlanks)
#split the string where there are more than three spaces
while k < componentLength:
if checkForBlanks[k] == " ":
if checkForBlanks[k+1] == " " and checkForBlanks[k+2] == " ":
beforeBlanks = checkForBlanks[:k]
afterBlanks = checkForBlanks[k+1:]
afterBlanks = afterBlanks.lstrip()
afterBlanks = afterBlanks.strip("\n")
splitLine = [beforeBlanks, afterBlanks]
k = componentLength
k += 1
if splitLine != ['blank']:
return splitLine
else:
return -1
#ALT
#--------------------------------------------------------------------------------------
# This function takes in a string and checks for multiple blanks.
#
# Returns an array of two strings if there are blanks.
#
# Returns -1 if not.
#
# Other white space and end of line characters are also removed.
#--------------------------------------------------------------------------------------
def alternateSplitBlank(checkForBlanks):
splitLine = ['blank']
k = 0
componentLength = len(checkForBlanks)
#split the string where there are more than two spaces
while componentLength > k:
if checkForBlanks[componentLength-1] == " ":
if checkForBlanks[componentLength-1] == " ":
beforeBlanks = checkForBlanks[:componentLength-2]
afterBlanks = checkForBlanks[componentLength-1:]
afterBlanks = afterBlanks.lstrip()
afterBlanks = afterBlanks.strip("\n")
splitLine = [beforeBlanks, afterBlanks]
componentLenth = k
componentLength -= 1
if splitLine != ['blank']:
return splitLine
else:
return -1
#--------------------------------------------------------------------------------------
# This function adjusts for lines not having a carriage return in the original document.
#--------------------------------------------------------------------------------------
def parseForNoCarriageReturn(longContent):
individualWords = longContent.split()
number = 'blank'
n = 0
yWords = ['initalA', 'initialB']
for j in individualWords:
p = j.isdigit()
if p == True:
priceCheck = longContent.find(j)
if longContent[priceCheck-1] == " ":
#Rename these variables, "number", "j"
number = j
before = individualWords[:n+1]
after = individualWords[n+1:]
n += 1
#txt = "De La Soif, 'L'inattendu' - Chardonnay, Assyrtiko, Picpoul, Malvasia 17 California, USA"
xWord = longContent.replace(number, number + "||")
if xWord.find('||') != -1:
yWords = xWord.split("||")
if yWords[1] != "initialB":
return yWords[0], yWords[1]
else:
return False
#infoA = " ".join(before)
# CURRENTLY WORKING
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function takes in a string and checks for the word "chilled".
#
# Returns an array of two strings - one being the price, the other being "chilled".
#
# Returns -1 if "chilled" is not present.
#
# White space and end of line characters are also removed.
#--------------------------------------------------------------------------------------
def splitPrice(checkForDescription):
x = checkForDescription.rfind("Chilled")
if x != -1:
extractedPrice = checkForChilled.strip('Chilled')
extractedPrice = extractedPrice.strip("\n")
extractedPrice = extractedPrice.lstrip()
splitLine = ["Chilled", extractedPrice]
return splitLine
else:
return -1
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function takes in a string and checks for the word "chilled".
#
# Returns an array of two strings - one being the price, the other being "chilled".
#
# Returns -1 if "chilled" is not present.
#
# White space and end of line characters are also removed.
#--------------------------------------------------------------------------------------
def splitChilled(checkForChilled):
x = checkForChilled.rfind("Chilled")
if x != -1:
extractedPrice = checkForChilled.strip('Chilled')
extractedPrice = extractedPrice.strip("\n")
extractedPrice = extractedPrice.lstrip()
splitLine = ["Chilled", extractedPrice]
return splitLine
else:
return -1
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function takes in a string and checks for a hyphen.
#
# Returns an array of two strings if there is a hyphen.
#
# Returns -1 if not.
#
# White space and end of line characters are also removed.
#--------------------------------------------------------------------------------------
def splitHyphen(checkForHyphen):
x = checkForHyphen.rfind("- ")
if x != -1:
splitLine = checkForHyphen.split('- ')
beforeHyphen = splitLine[0]
afterHyphen = splitLine[1]
afterHyphen = afterHyphen.lstrip()
afterHyphen = afterHyphen.strip("\n")
splitLine = [beforeHyphen, afterHyphen]
return splitLine
else:
return -1
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function writes a by the glass non-wine item.
#
# Included are all associated attributes - description, origin, price, etc.
#--------------------------------------------------------------------------------------
def writeSingleNonWineByTheGlassInfo(singleLine):
nonWineName = 'blank'
nonWineOrigin = 'blank'
nonWineDescription = 'blank'
price = 'blank'
writeLines(templateB1Start)
# If the line is separated by multiple blanks, assign wine info and price
split = splitBlank(singleLine)
if split != -1:
nonWineInfo = split[0]
price = split[1]
# Look for a hyphen in the wine info and split into wine name and grapes
split = splitHyphen(nonWineInfo)
#This variable 'price' should be renamed to something like priceInfo since it is not yet definitely the price
price = price.lstrip()
#rename this function to splitPrice?
descriptionCheck = splitBlank(price)
if descriptionCheck != -1:
nonWineDescription = descriptionCheck[0]
price = descriptionCheck[1]
if split != -1:
nonWineName = split[0]
nonWineOrigin = split[1]
# If there is no additional information other than price, that is the name to print
else:
nonWineName = nonWineInfo
if nonWineName != 'blank':
writeLines(templateB1aStart)
resultFile.write(nonWineName)
writeLines(templateB1aEnd)
#edit tags
if nonWineOrigin != 'blank':
writeLines(templateB1bStart)
resultFile.write(nonWineOrigin)
writeLines(templateB1bEnd)
if price != 'blank':
writeLines(templateB1cStart)
resultFile.write(price)
resultFile.write('\n')
writeLines(templateB1cEnd)
#edit tags
if nonWineDescription != 'blank':
writeLines(templateB1dStart)
resultFile.write(nonWineDescription)
resultFile.write('\n')
writeLines(templateB1dEnd)
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function writes a by the glass wine item.
#
# Included are all associated attributes - description, origin, price, etc.
#--------------------------------------------------------------------------------------
def writeSingleWineByTheGlassInfo(firstLine, secondLine):
wineName = 'blank'
wineGrapes = 'blank'
wineDescription = 'blank'
wineOrigin = 'blank'
chilled = 'blank'
price = 'blank'
writeLines(template2C)
# If the line is separated by multiple blanks, assign wine info and price
split = splitBlank(firstLine)
if split != -1:
wineInfo = split[0]
price = split[1]
# Look for a hyphen in the wine info and split into wine name and grapes
split = splitHyphen(wineInfo)
#perhaps this needs a better variable name?
c = splitChilled(price)
if c != -1:
chilled = c[0]
price = c[1]
if split != -1:
wineName = split[0]
wineGrapes = split[1]
# Assing the following line the by the glass origin
if secondLine != 'blank':
wineOrigin = secondLine
if wineName != 'blank':
writeLines(template2D)
resultFile.write(wineName)
writeLines(template2E)
resultFile.write('\n')
if wineGrapes != 'blank':
writeLines(template2F)
resultFile.write(wineGrapes)
writeLines(template2G)
resultFile.write('\n')
if wineDescription != 'blank':
resultFile.write(wineDescription)
resultFile.write('\n')
if chilled != 'blank':
resultFile.write(chilled)
resultFile.write('\n')
if price != 'blank':
writeLines(template2H)
resultFile.write(price)
writeLines(template2I)
resultFile.write('\n')
if wineOrigin != 'blank':
writeLines(template2J)
resultFile.write(wineOrigin)
writeLines(template2K)
resultFile.write('\n')
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function writes a single bottle item.
#
# Included are all associated attributes - description, origin, price, etc.
#--------------------------------------------------------------------------------------
def writeSingleBottleInfo(firstLine, secondLine):
bottleInfo = 'blank'
bottleGrapes = 'blank'
bottleDescription = 'blank'
bottleOrigin = 'blank'
price = 'blank'
additionalInfo = 'blank'
# If the line is separated by multiple blanks, assign wine info and price
split = splitBlank(firstLine)
if split != -1:
bottleInfo = split[0]
priceInfo = split[1]
priceInfo = priceInfo.lstrip()
split = splitBlank(priceInfo)
if split != -1:
bottleOrigin = split[0]
price = split[1]
#Check for the rare instance of extra info about the wine ie. "(500ml)"
secondSplit = splitBlank(price)
if secondSplit != -1:
#What seemed to be bottleOrigin is actually additional info (rework this logic / variable names)
additionalInfo = bottleOrigin
bottleOrigin = secondSplit[0]
price = secondSplit[1]
else:
price = priceInfo
# Assing the following line the by the glass origin
if secondLine != 'blank':
bottleGrapeAndDescription = secondLine
# Look for a hyphen in the wine info and split into wine name and grapes
split = splitHyphen(bottleGrapeAndDescription)
if split != -1:
bottleGrapes = split[0]
bottleDescription = split[1]
if bottleInfo != 'blank':
writeLines(templateD3aStart)
resultFile.write(bottleInfo)
if additionalInfo != 'blank':
resultFile.write(" ")
resultFile.write(additionalInfo)
resultFile.write('\n')
writeLines(templateD3aEnd)
if price != 'blank':
writeLines(templateD3bStart)
resultFile.write(price)
writeLines(templateD3bEnd)
resultFile.write('\n')
if bottleOrigin != 'blank':
writeLines(templateD3cStart)
resultFile.write(bottleOrigin)
resultFile.write('\n')
writeLines(templateD3cEnd)
if bottleGrapes != 'blank':
writeLines(templateD3dStart)
resultFile.write(bottleGrapes)
resultFile.write('\n')
writeLines(templateD3dEnd)
if bottleDescription != 'blank':
writeLines(templateD3eStart)
resultFile.write(bottleDescription)
resultFile.write('\n')
writeLines(templateD3eEnd)
#--------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This function writes a by the glass wine item.
#
# Included are all associated attributes - description, origin, price, etc.
#--------------------------------------------------------------------------------------
def writeFoodInfo(firstLine, secondLine):
foodName = 'blank'
foodDescription = 'blank'
price = 'blank'
# If the line is separated by multiple blanks, assign wine info and price