-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
✅ Linked to Bug TED-835 · Fix notice_publisher import timeout |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)), |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
No description provided.