Skip to content

Commit

Permalink
Remove syntax incompatible with python 2 (#1374)
Browse files Browse the repository at this point in the history
* Remove syntax incompatible with python 2

* Add py27 as one of black's target versions

---------

Co-authored-by: Gonchik Tsymzhitov <[email protected]>
  • Loading branch information
HoussemNasri and gonchik authored Jan 8, 2025
1 parent ecf109f commit c258ed1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,9 +1468,8 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50,
for attachment in attachments:
file_name = attachment["title"] or attachment["id"] # Use attachment ID if title is unavailable
download_link = self.url + attachment["_links"]["download"]

# Fetch the file content
response = self._session.get(download_link)
response = self._session.get(str(download_link))
response.raise_for_status() # Raise error if request fails

if to_memory:
Expand All @@ -1488,7 +1487,6 @@ def download_attachments_from_page(self, page_id, path=None, start=0, limit=50,
return downloaded_files
else:
return {"attachments_downloaded": len(attachments), "path": path}

except NotADirectoryError:
raise FileNotFoundError("The directory '{path}' does not exist.".format(path=path))
except PermissionError:
Expand Down
6 changes: 3 additions & 3 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ def download_attachments_from_issue(self, issue, path=None, cloud=True):
path = os.getcwd()
issue_id = self.issue(issue, fields="id")["id"]
if cloud:
url = self.url + "/secure/issueAttachments/%s.zip" % (issue_id)
url = self.url + "/secure/issueAttachments/{}.zip".format(issue_id)
else:
url = self.url + "/secure/attachmentzip/%s.zip" % (issue_id)
url = self.url + "/secure/attachmentzip/{}.zip".format(issue_id)
response = self._session.get(url)
attachment_name = "%s_attachments.zip" % (issue_id)
attachment_name = "{}_attachments.zip".format(issue_id)
file_path = os.path.join(path, attachment_name)
# if Jira issue doesn't have any attachments _session.get request response will return 22 bytes of PKzip format
file_size = sum(len(chunk) for chunk in response.iter_content(8196))
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ commands = pylint {[base]linting_targets}

[testenv:black]
basepython = python3
target-version = ["py37"]
target-version = ["py27", "py37"]
skip_install = true
deps = black
commands = black --check --diff {[base]linting_targets} --exclude __pycache__
Expand Down

0 comments on commit c258ed1

Please sign in to comment.