11import requests
22from bs4 import BeautifulSoup
33
4- class Issue :
54
6- def __init__ (self , username : str , repository_name :str , issue_number :int ):
5+ class Issue :
6+ def __init__ (self , username : str , repository_name : str , issue_number : int ):
77 self .username = username
88 self .repository = repository_name
99 self .issue_number = issue_number
1010
1111 def __scrape_page (self ):
12- data = requests .get (f"https://github.com/{ self .username } /{ self .repository } /issues/{ self .issue_number } " )
13- data = BeautifulSoup (data .text ,"html.parser" )
12+ data = requests .get (
13+ f"https://github.com/{ self .username } /{ self .repository } /issues/{ self .issue_number } "
14+ )
15+ data = BeautifulSoup (data .text , "html.parser" )
1416 return data
15-
17+
1618 def assignees (self ):
1719 """
1820 Fetch list of assignees
1921 """
2022 data = self .__scrape_page ()
2123 try :
22- assignees_body = data .find (' span' , class_ = ' css-truncate js-issue-assignees' )
24+ assignees_body = data .find (" span" , class_ = " css-truncate js-issue-assignees" )
2325 assignees = []
24- for assignee in assignees_body .find_all ('a' , class_ = 'assignee Link--primary css-truncate-target width-fit' ):
25- assignees .append (assignee .text .replace ('\n ' ,'' ).strip ())
26+ for assignee in assignees_body .find_all (
27+ "a" , class_ = "assignee Link--primary css-truncate-target width-fit"
28+ ):
29+ assignees .append (assignee .text .replace ("\n " , "" ).strip ())
2630 return assignees
2731 except :
2832 message = "No assignees found"
@@ -34,8 +38,10 @@ def labels(self):
3438 """
3539 data = self .__scrape_page ()
3640 try :
37- labelsDiv = data .find (class_ = "js-issue-labels d-flex flex-wrap" )
38- allLabelsHtml = labelsDiv .find_all (class_ = "css-truncate css-truncate-target width-fit" )
41+ labelsDiv = data .find (class_ = "js-issue-labels d-flex flex-wrap" )
42+ allLabelsHtml = labelsDiv .find_all (
43+ class_ = "css-truncate css-truncate-target width-fit"
44+ )
3945 allLabels = []
4046 for label in allLabelsHtml :
4147 allLabels .append (label .text )
@@ -44,36 +50,34 @@ def labels(self):
4450 message = "No label found"
4551 return message
4652
47-
4853 def opened_by (self ):
4954 """
5055 Fetch the name of the user, who opened the issue
5156 """
5257 data = self .__scrape_page ()
53- author_name = data .find ('a' , class_ = ' author text-bold Link--secondary' ).text
58+ author_name = data .find ("a" , class_ = " author text-bold Link--secondary" ).text
5459 return author_name
5560
56-
5761 def title (self ):
5862 """
5963 Fetch title of the issue
6064 """
6165 data = self .__scrape_page ()
6266 try :
63- title_body = data .find (' bdi' , class_ = "js-issue-title markdown-title" )
67+ title_body = data .find (" bdi" , class_ = "js-issue-title markdown-title" )
6468 title = title_body .text .strip ()
6569 return title
6670 except :
6771 message = "No title found"
6872 return message
69-
73+
7074 def opened_at (self ):
7175 """
7276 Returns a string containing the time when the issue was opened in ISO format
7377 """
7478 try :
7579 data = self .__scrape_page ()
76- return data .find (' relative-time' ).text
80+ return data .find (" relative-time" ).text
7781 except :
7882 message = "Unable to fetch time"
7983 return message
@@ -84,7 +88,9 @@ def is_milestone(self):
8488 """
8589 data = self .__scrape_page ()
8690 try :
87- milestone = data .find ('a' , class_ = 'Link--secondary mt-1 d-block text-bold css-truncate' ).text .strip ()
91+ milestone = data .find (
92+ "a" , class_ = "Link--secondary mt-1 d-block text-bold css-truncate"
93+ ).text .strip ()
8894 return milestone
8995 except :
9096 message = "No milestone"
0 commit comments