diff --git a/pagure/lib/link.py b/pagure/lib/link.py index 8749439..5236478 100644 --- a/pagure/lib/link.py +++ b/pagure/lib/link.py @@ -19,19 +19,25 @@ import pagure.exceptions FIXES = [ re.compile(r'(?:.*\s+)?fixe?[sd]?:?\s*?#(\d+)', re.I), - re.compile(r'(?:.*\s+)?fixe?[sd]?:?\s*?https?://.*/(\w+)/(?:issue|pull-request)/(\d+)', re.I), + re.compile( + r'(?:.*\s+)?fixe?[sd]?:?\s*?https?://.*/(\w+)' + '/(?:issue|pull-request)/(\d+)', re.I), re.compile(r'(?:.*\s+)?merge?[sd]?:?\s*?#(\d+)', re.I), - re.compile(r'(?:.*\s+)?merge?[sd]?:?\s*?https?://.*/(\w+)/(?:issue|pull-request)/(\d+)', re.I), + re.compile( + r'(?:.*\s+)?merge?[sd]?:?\s*?https?://.*/(\w+)' + '/(?:issue|pull-request)/(\d+)', re.I), re.compile(r'(?:.*\s+)?close?[sd]?:?\s*?#(\d+)', re.I), - re.compile(r'(?:.*\s+)?close?[sd]?:?\s*?https?://.*/(\w+)/(?:issue|pull-request)/(\d+)', re.I), + re.compile( + r'(?:.*\s+)?close?[sd]?:?\s*?https?://.*/(\w+)' + '/(?:issue|pull-request)/(\d+)', re.I), ] RELATES = [ re.compile(r'(?:.*\s+)?relate[sd]?:?\s*?(?:to)?\s*?#(\d+)', re.I), re.compile(r'(?:.*\s+)?relate[sd]?:?\s?#(\d+)', re.I), re.compile( - r'(?:.*\s+)?relate[sd]?:?\s*?(?:to)?\s*?https?://.*/(\w+)/issue/(\d+)', - re.I), + r'(?:.*\s+)?relate[sd]?:?\s*?(?:to)?\s*?' + 'https?://.*/(\w+)/issue/(\d+)', re.I), ] diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 25d7752..ba2b0da 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -106,7 +106,8 @@ def create_default_status(session, acls=None): """ Insert the defaults status in the status tables. """ - for status in ['Open', 'Invalid', 'Insufficient data', 'Fixed', 'Duplicate']: + statuses = ['Open', 'Invalid', 'Insufficient data', 'Fixed', 'Duplicate'] + for status in statuses: ticket_stat = StatusIssue(status=status) session.add(ticket_stat) try: @@ -478,7 +479,6 @@ class Project(BASE): Issue.private == False ).count() - def to_json(self, public=False, api=False): ''' Return a representation of the project as JSON. ''' @@ -633,7 +633,10 @@ class Issue(BASE): def user_comments(self): ''' Return user comments only, filter it from notifications ''' - return [comment for comment in self.comments if not comment.notification] + return [ + comment + for comment in self.comments + if not comment.notification] def to_json(self, public=False, with_comments=True): ''' Returns a dictionary representation of the issue. @@ -773,8 +776,10 @@ class IssueComment(BASE): 'parent': self.parent_id, 'date_created': self.date_created.strftime('%s'), 'user': self.user.to_json(public=public), - 'edited_on': self.edited_on.strftime('%s') if self.edited_on else None, - 'editor': self.editor.to_json(public=public) if self.editor_id else None, + 'edited_on': self.edited_on.strftime('%s') + if self.edited_on else None, + 'editor': self.editor.to_json(public=public) + if self.editor_id else None, 'notification': self.notification, } return output @@ -1033,7 +1038,10 @@ class PullRequest(BASE): def user_comments(self): ''' Return user comments only, filter it from notifications ''' - return [comment for comment in self.comments if not comment.notification] + return [ + comment + for comment in self.comments + if not comment.notification] def to_json(self, public=False, api=False, with_comments=True): ''' Returns a dictionnary representation of the pull-request. @@ -1173,8 +1181,10 @@ class PullRequestComment(BASE): 'parent': self.parent_id, 'date_created': self.date_created.strftime('%s'), 'user': self.user.to_json(public=public), - 'edited_on': self.edited_on.strftime('%s') if self.edited_on else None, - 'editor': self.editor.to_json(public=public) if self.editor_id else None, + 'edited_on': self.edited_on.strftime('%s') + if self.edited_on else None, + 'editor': self.editor.to_json(public=public) + if self.editor_id else None, 'notification': self.notification, } @@ -1349,10 +1359,8 @@ class ProjectGroup(BASE): primary_key=True) # Constraints - __table_args__ = ( - sa.UniqueConstraint( - 'project_id', 'group_id'), - ) + __table_args__ = (sa.UniqueConstraint('project_id', 'group_id'),) + class Watcher(BASE): """ Stores the user of a projects. diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index 6c789ce..3b85667 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -194,14 +194,17 @@ def send_email(text, subject, to_mail, subject_tag = 'Pagure' if pagure.APP.config['SMTP_SSL']: - smtp = smtplib.SMTP_SSL(pagure.APP.config['SMTP_SERVER'], pagure.APP.config['SMTP_PORT']) + smtp = smtplib.SMTP_SSL( + pagure.APP.config['SMTP_SERVER'], pagure.APP.config['SMTP_PORT']) else: - smtp = smtplib.SMTP(pagure.APP.config['SMTP_SERVER'], pagure.APP.config['SMTP_PORT']) + smtp = smtplib.SMTP( + pagure.APP.config['SMTP_SERVER'], pagure.APP.config['SMTP_PORT']) for mailto in to_mail.split(','): msg = MIMEText(text.encode('utf-8'), 'plain', 'utf-8') msg['Subject'] = '[%s] %s' % (subject_tag, subject) - from_email = pagure.APP.config.get('FROM_EMAIL', 'pagure@fedoraproject.org') + from_email = pagure.APP.config.get( + 'FROM_EMAIL', 'pagure@fedoraproject.org') msg['From'] = from_email if mail_id: @@ -224,8 +227,12 @@ def send_email(text, subject, to_mail, mhash.hexdigest(), pagure.APP.config['DOMAIN_EMAIL_NOTIFICATIONS']) try: - if pagure.APP.config['SMTP_USERNAME'] and pagure.APP.config['SMTP_PASSWORD']: - smtp.login(pagure.APP.config['SMTP_USERNAME'], pagure.APP.config['SMTP_PASSWORD']) + if pagure.APP.config['SMTP_USERNAME'] \ + and pagure.APP.config['SMTP_PASSWORD']: + smtp.login( + pagure.APP.config['SMTP_USERNAME'], + pagure.APP.config['SMTP_PASSWORD'] + ) smtp.sendmail( from_email,