Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix SFTP default values #309

Merged
merged 2 commits into from
Oct 13, 2022
Merged

fix SFTP default values #309

merged 2 commits into from
Oct 13, 2022

Conversation

CaptainOfHacks
Copy link
Collaborator

No description provided.

@swarmia
Copy link

swarmia bot commented Oct 13, 2022

✅  Linked to Bug TED-835 · Fix notice_publisher import timeout

@CaptainOfHacks CaptainOfHacks merged commit e911a06 into main Oct 13, 2022
@CaptainOfHacks CaptainOfHacks deleted the feature/TED-835 branch October 13, 2022 19:00
@sonarcloud
Copy link

sonarcloud bot commented Oct 13, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@kaleanych kaleanych left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comments

@@ -44,14 +44,14 @@ def disconnect(self):
def __del__(self):
self.disconnect()

def publish(self, source_path, remote_path) -> bool:
def publish(self, source_path: str, remote_path: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

"""
Publish file_content to the sftp server remote path.
"""
self.connection.put(source_path, remote_path)
return True

def remove(self, remote_path) -> bool:
def remove(self, remote_path: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

"""
This function publishes the METS manifestation for a Notice in Cellar.
"""

publisher = publisher if publisher else SFTPPublisher()
remote_folder_path = remote_folder_path if remote_folder_path else config.SFTP_PATH
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing default for parameter for this?
The same thing with more code.
I think it's clearer (if you still like this way) to write:
remote_folder_path = remote_folder_path or config.SFTP_PATH

VIVA non strict typed programming languages 😁

@@ -25,7 +26,7 @@ def publish_notice(notice: Notice, publisher: SFTPPublisherABC = SFTPPublisher()
source_file.write(package_content)
try:
publisher.connect()
if publisher.publish(source_path=pathlib.Path(source_file.name),
if publisher.publish(source_path=str(pathlib.Path(source_file.name)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str(pathlib.Path(strValue))
Just put source_file.name

"""
This function publishes the METS manifestation for a Notice in Cellar.
"""

publisher = publisher if publisher else SFTPPublisher()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as below:
use
a = a or b
Instead of
a = a if a else b

The same thing, but I think "or" version is more clear. Both are good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants