Hidayatmahar commited on
Commit
d02b4fa
·
verified ·
1 Parent(s): 7346b3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +199 -65
app.py CHANGED
@@ -4,81 +4,215 @@ from reportlab.lib.styles import getSampleStyleSheet
4
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
5
  from reportlab.lib.units import inch
6
 
7
- # Function to generate PDF
8
- def create_bail_application_pdf(filename, court_name, bail_application_no, applicant_name, applicant_details, crime_no, police_station, section, date, advocate_name):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  doc = SimpleDocTemplate(filename, pagesize=letter)
10
  styles = getSampleStyleSheet()
11
  story = []
12
 
13
  # Add content to the PDF
14
- story.append(Paragraph(court_name, styles['Heading1']))
15
- story.append(Spacer(1, 0.2 * inch))
16
- story.append(Paragraph(bail_application_no, styles['Heading2']))
17
- story.append(Spacer(1, 0.2 * inch))
18
- story.append(Paragraph(applicant_name, styles['Normal']))
19
- story.append(Paragraph(applicant_details, styles['Normal']))
20
- story.append(Spacer(1, 0.2 * inch))
21
- story.append(Paragraph("<b>Versus</b>", styles['Normal']))
22
- story.append(Paragraph("The State", styles['Normal']))
23
- story.append(Spacer(1, 0.2 * inch))
24
- story.append(Paragraph(f"<b>{crime_no}</b>", styles['Normal']))
25
- story.append(Paragraph(f"<b>{police_station}</b>", styles['Normal']))
26
- story.append(Paragraph(f"<b>{section}</b>", styles['Normal']))
27
- story.append(Spacer(1, 0.2 * inch))
28
- story.append(Paragraph("<b>BAIL APPLICATION UNDER SECTION 497 CR.PC.</b>", styles['Heading2']))
29
- story.append(Spacer(1, 0.2 * inch))
30
- story.append(Paragraph("It is submitted and prayed on behalf of the above-named applicant/accused that this Honorable Court may kindly be pleased to grant him post-arrest bail in the above crime, on consideration of the following facts and grounds: -", styles['Normal']))
31
- story.append(Spacer(1, 0.2 * inch))
32
- story.append(Paragraph("<b>F A C T S</b>", styles['Heading2']))
33
- story.append(Paragraph("That brief facts of the prosecution story are that complainant SIP Din Muhammad Malik posted at of Police Station A-section, lodged the instant FIR on 10-04-2024 at 1900 hours, contents whereof are as under; -", styles['Normal']))
34
- story.append(Spacer(1, 0.2 * inch))
35
- story.append(Paragraph("<b>G R O U N D S</b>", styles['Heading2']))
36
- story.append(Paragraph("1. That, there are no reasonable grounds to believe that the applicant/accused has committed the alleged offence with which he stands charged.", styles['Normal']))
37
- story.append(Paragraph("2. That, the story narrated in the F.I.R. is false, absurd, concocted one, unbelievable and outcome of malice.", styles['Normal']))
38
- story.append(Spacer(1, 0.2 * inch))
39
- story.append(Paragraph(f"Kotri. Dated: -{date}. {advocate_name}.", styles['Normal']))
40
- story.append(Spacer(1, 0.2 * inch))
41
- story.append(Paragraph("<b>C E R T I F I C A T E</b>", styles['Heading2']))
42
- story.append(Paragraph("In view of Honorable Supreme Court decision dated 22.01.2014 passed in Cr. Rev. Petition No.8-L & 10-L of 2013, this is to certify that prior to this bail application, no bail application of the present accused, and co-accused has been filed before this Honorable Court in the above-mentioned crime. In case the facts mentioned in the certificate/statement is found incorrect, I shall be personally held responsible with all its consequences.", styles['Normal']))
43
- story.append(Spacer(1, 0.2 * inch))
44
- story.append(Paragraph(f"Hyderabad. Dated: -{date}. {advocate_name}.", styles['Normal']))
45
-
46
- # Build the PDF
47
  doc.build(story)
48
 
49
  # Streamlit App
50
- st.title("Bail Application PDF Generator")
51
 
52
  # Input fields
53
- court_name = st.text_input("Court Name", "IN THE CONSUMER 10th JUDICIAL MAGISTRATE AND CIVIL JUDGE HYDERABAD")
54
- bail_application_no = st.text_input("Bail Application No.", "Criminal Bail Application No. 12345 of 2024")
55
- applicant_name = st.text_input("Applicant Name", "Adnan S/o Chand Muhammad")
56
- applicant_details = st.text_input("Applicant Details", "Muslim, adult, by caste Shaikh, R/o Latifabad, Hyderabad")
57
- crime_no = st.text_input("Crime No.", "Crime No. 102 of 2024")
58
- police_station = st.text_input("Police Station", "P.S. A-Section")
59
- section = st.text_input("Section", "U/S 3/4 PEHO")
60
- date = st.text_input("Date", "07-2024")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  advocate_name = st.text_input("Advocate Name", "ADVOCATE FOR APPLICANT/ACCUSED")
 
62
 
63
- # Generate PDF button
64
- if st.button("Generate PDF"):
65
- filename = "bail_application.pdf"
66
- create_bail_application_pdf(
67
- filename,
68
- court_name,
69
- bail_application_no,
70
- applicant_name,
71
- applicant_details,
72
- crime_no,
73
- police_station,
74
- section,
75
- date,
76
- advocate_name
77
  )
78
- st.success("PDF generated successfully!")
79
- st.download_button(
80
- label="Download PDF",
81
- data=open(filename, "rb").read(),
82
- file_name=filename,
83
- mime="application/pdf"
84
- )
 
 
 
 
4
  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
5
  from reportlab.lib.units import inch
6
 
7
+ # Function to generate the bail application text
8
+ def generate_bail_application(
9
+ court_name, bail_application_number, applicant_name, applicant_father_name, applicant_caste,
10
+ applicant_address, crime_number, crime_section, police_station, complainant_name,
11
+ complainant_father_name, car_details, incident_date, fir_date, illegal_act_date,
12
+ section_491_date, case_references, advocate_name, application_date
13
+ ):
14
+ template = f"""
15
+ **IN THE COURT OF {court_name.upper()}.**
16
+
17
+ **Criminal Bail Application No. {bail_application_number} of 2024.**
18
+
19
+ **{applicant_name} S/o {applicant_father_name}** Adult, Muslim,
20
+ By caste {applicant_caste}
21
+ R/o {applicant_address}..................................**........Applicant(s)/Accused.**
22
+
23
+ **Versus**
24
+
25
+ The State...........................................................**Respondent.**
26
+
27
+ -----------------------------------------------------------------------
28
+ **Crime No. {crime_number} of 2024**
29
+ -----------------------------------------------------------------------
30
+ **U/S {crime_section} PPC**
31
+
32
+ **P.S; {police_station}, Hyderabad.**
33
+ -----------------------------------------------------------------------
34
+
35
+ **BAIL APPLICATION UNDER SECTION 497 CR.PC.**
36
+
37
+ It is submitted and prayed on behalf of the above-named
38
+ applicant/accused that this Honorable Court may kindly be pleased to
39
+ grant him post-arrest bail in the above crime, on consideration of the
40
+ following facts and grounds: -
41
+
42
+ **F A C T S.**
43
+
44
+ Brief facts of prosecution case as narrated in the F.I.R lodged by
45
+ complainant {complainant_name} S/o {complainant_father_name}, are that I, live at the above
46
+ mentioned address and I have a {car_details} for my
47
+ personal use which I usually park outside my house. On dated {incident_date},
48
+ I parked as usually outside my house, at 1700 evening for the sake of
49
+ check of car I found car's bonnet opened and battery of AGS company has
50
+ been stolen which we tried a lot to search but we could not find any
51
+ information.
52
+
53
+ Hence I request at PS that an unknown thief has stolen a battery from my
54
+ car.
55
+
56
+ > **GROUNDS**
57
+
58
+ 1. That, there are no reasonable grounds to believe that the
59
+ applicant/accused has committed the alleged offence with which he
60
+ stands charged.
61
+
62
+ 2. That, the applicant is law abiding citizen and doing labor in
63
+ Hyderabad and for earning his livehood by working on daily wages.
64
+
65
+ 3. That, the allegations leveled in the FIR are concerned, they are
66
+ quite ill motivated, baseless, unwarranted and are based on
67
+ ill-founded facts, owing to some personal grudge and vendetta.
68
+
69
+ 4. That, the FIR has been lodged with mala fide intention merely to
70
+ harass and get gratification from applicant's family. That, the said
71
+ FIR was lodged on **{fir_date}** and the occurrence is shown on
72
+ **{incident_date}**, such delay of two months indicates premeditated act
73
+ of complainant just to falsely apprehended and prosecute innocent
74
+ applicant.
75
+
76
+ 5. That, the real facts of the case are entirely different from the
77
+ contents of FIR, as on the dated {illegal_act_date}, **at about 11.00 PM
78
+ Hours; night time** the SHO of PS {police_station} along with his
79
+ subordinate staff forcibly entered in house and spread terror by
80
+ searching house without any prior permission, they made ingress
81
+ without due care of Parda/modesity of woman house; applicant and
82
+ other family members requested them to tell reason for such sudden
83
+ and terror acts but said SHO and his subordinate staff did not
84
+ bother and listen to pay any heed and forcibly taken the
85
+ applicant/accused and while issuing threats of dire consequences.
86
+
87
+ 6. That, against above such illegal act, on dated {section_491_date}, the
88
+ sister of said applicant/accused had also filed an application under
89
+ section 491 Cr.P.C as to produce detenuee from illegal detention,
90
+ however, despite of compliance, Police nominated said
91
+ applicant/accused in this fabricated FIR.
92
+
93
+ 7. That, neither the applicant/accused has committed the alleged
94
+ offense nor he has any nexus with alleged offense directly or
95
+ indirectly, hence his false implication cannot be ruled out.
96
+
97
+ 8. That, the applicant/accused is confined in jail and is no more
98
+ required to ploce for further investigation, therefore his further
99
+ detention in jail will serve no purpose.
100
+
101
+ 9. That, the offence under which the applicant/accused is charged does
102
+ not fall within the Prohibitory clause of S. 497, Cr.P.C. hence the
103
+ grant of bail is rule and refusal is an exception in such like cases
104
+ and no exceptional ground appeared in the case to withheld the bail.
105
+
106
+ 10. That, neither the name of applicant/accused is shown in said FIR,
107
+ nor any incriminating have been recovered from the possession of
108
+ applicant/accused.
109
+
110
+ 11. That, the case of present applicant does not come within the
111
+ exception as provided in case of **{case_references[0]}** reported in **{case_references[1]}**
112
+ and **{case_references[2]} V/S The State reported in {case_references[3]}**.
113
+
114
+ 12. That, the Honourable High Court Karachi had also held against the
115
+ impugned order of learned Ist Additional Sessions Judge, Karachi
116
+ West in case of **{case_references[4]} alias Waja (Applicant) V/S The
117
+ State**, reported in **{case_references[5]}** , that Merely
118
+ registration of the case would not disentitle the accused from the
119
+ concession of bail.
120
+
121
+ 13. That, the deeper appreciation of the evidence is not permissible
122
+ while deciding a bail application and same is to be decided on basis
123
+ of the tentative assessment of the material available on the record.
124
+ On tentative assessment of the material available in this case it
125
+ appears that case of applicant requires further inquiry.
126
+
127
+ 14. That, in the light of above grounds the case of the applicant/
128
+ accused requires further probe as contemplated in Section 497
129
+ Cr.P.C. for further enquiry.
130
+
131
+ 15. That, the law for the purpose of bail cannot be stretched in favour
132
+ of prosecution and if any benefit of doubt arises even at the bail
133
+ stage, it must go to the accused.
134
+
135
+ 16. That, the bail should not be refused as a punishment, the principle
136
+ based on natural justice is that any possible wrong at the bail
137
+ stage could be cured at the time of final judgment by convicting the
138
+ accused if he is found guilty but any wrong committed by refusing
139
+ bail and putting him into jail custody could not be cured if he is
140
+ found innocent.
141
+
142
+ 17. That, the further law points and grounds will be raised/ agitated at
143
+ the time of hearing of this bail application with permission of this
144
+ Honorable Court.
145
+
146
+ 18. That, there is no likelihood of ascendance or tampering with
147
+ prosecution evidence.
148
+
149
+ 19. That, the applicant/accused is ready to furnish reasonable surety to
150
+ the satisfaction of the Honorable Court.
151
+
152
+ > That, the grant of prayer would meet the ends of justice.
153
+
154
+ **HYDERABAD**
155
+
156
+ **Dated: {application_date}. ADVOCATE FOR APPLICANT/ACCUSED.**
157
+ """
158
+ return template
159
+
160
+ # Function to create PDF
161
+ def create_bail_application_pdf(filename, content):
162
  doc = SimpleDocTemplate(filename, pagesize=letter)
163
  styles = getSampleStyleSheet()
164
  story = []
165
 
166
  # Add content to the PDF
167
+ story.append(Paragraph(content, styles['Normal']))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  doc.build(story)
169
 
170
  # Streamlit App
171
+ st.title("Bail Application Generator")
172
 
173
  # Input fields
174
+ court_name = st.text_input("Court Name", "VIIITH JUDICIAL MAGISTRATE, HYDERABAD")
175
+ bail_application_number = st.text_input("Bail Application Number", "156")
176
+ applicant_name = st.text_input("Applicant Name", "Ayaz Gul")
177
+ applicant_father_name = st.text_input("Applicant's Father Name", "Lal Gul")
178
+ applicant_caste = st.text_input("Applicant's Caste", "Mari Baloch")
179
+ applicant_address = st.text_input("Applicant's Address", "Mohallah Mir Fateh Colony Hussainabad District Hyderabad")
180
+ crime_number = st.text_input("Crime Number", "156")
181
+ crime_section = st.text_input("Crime Section", "379")
182
+ police_station = st.text_input("Police Station", "Hussainabad")
183
+ complainant_name = st.text_input("Complainant Name", "Faiz Ullah")
184
+ complainant_father_name = st.text_input("Complainant's Father Name", "Ubedullah")
185
+ car_details = st.text_input("Car Details", "Mehran car registered No. AZS; 909")
186
+ incident_date = st.text_input("Incident Date", "27-06-2024")
187
+ fir_date = st.text_input("FIR Date", "15.09.2024")
188
+ illegal_act_date = st.text_input("Illegal Act Date", "14.09.2024")
189
+ section_491_date = st.text_input("Section 491 Date", "20.09.2024")
190
+ case_references = [
191
+ st.text_input("Case Reference 1", "Tariq Bahir"),
192
+ st.text_input("Case Reference 2", "PLD 1995 SC 34"),
193
+ st.text_input("Case Reference 3", "Muhammad Eden"),
194
+ st.text_input("Case Reference 4", "2022 PcrLJ 143"),
195
+ st.text_input("Case Reference 5", "Muhammad Nizam"),
196
+ st.text_input("Case Reference 6", "Cr.Bail application 1179/2024"),
197
+ ]
198
  advocate_name = st.text_input("Advocate Name", "ADVOCATE FOR APPLICANT/ACCUSED")
199
+ application_date = st.text_input("Application Date", "10-10-2024")
200
 
201
+ # Generate Bail Application
202
+ if st.button("Generate Bail Application"):
203
+ bail_application = generate_bail_application(
204
+ court_name, bail_application_number, applicant_name, applicant_father_name, applicant_caste,
205
+ applicant_address, crime_number, crime_section, police_station, complainant_name,
206
+ complainant_father_name, car_details, incident_date, fir_date, illegal_act_date,
207
+ section_491_date, case_references, advocate_name, application_date
 
 
 
 
 
 
 
208
  )
209
+
210
+ # Display the generated application
211
+ st.markdown(bail_application)
212
+
213
+ # Create and download PDF
214
+ pdf_filename = "bail_application.pdf"
215
+ create_bail_application_pdf(pdf_filename, bail_application)
216
+
217
+ with open(pdf_filename, "rb") as f:
218
+ st.download_button("Download PDF", f, file_name=pdf_filename)