-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pilot 4734: distinguish project folders and name folders when listing (…
…#133) * add [p] prefix for project folder when listing items under project * group itemprefix class with itemtype class * add double quotation when item name contains space * change enum type PROJECTFOLDER to SHAREDFOLDER * bumpup versions --------- Co-authored-by: zhiren <zzhan@indocresearch.org>
- Loading branch information
Showing
9 changed files
with
76 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (C) 2023-2024 Indoc Systems | ||
# | ||
# Contact Indoc Systems for any questions regarding the use of this source code. | ||
|
||
from enum import Enum | ||
|
||
|
||
class ItemType(str, Enum): | ||
"""The class to reflect the type of item in database.""" | ||
|
||
FILE = 'file' | ||
Folder = 'folder' | ||
NAMEFOLDER = 'name_folder' | ||
SHAREDFOLDER = 'project_folder' | ||
|
||
@classmethod | ||
def get_type_from_keyword(self, keyword: str): | ||
"""The function will return the type of the item based on the keyword. | ||
- name folder will have keyword 'namefolder' as input | ||
- project folder will not have any keyword | ||
""" | ||
|
||
alternative_mapping = { | ||
'projectfolder': self.SHAREDFOLDER, | ||
} | ||
|
||
return alternative_mapping.get(keyword, self.NAMEFOLDER) | ||
|
||
def get_prefix_by_type(self) -> str: | ||
"""Get the prefix for the folder type.""" | ||
|
||
prefix = { | ||
self.NAMEFOLDER: '', | ||
self.SHAREDFOLDER: 'shared/', | ||
} | ||
|
||
return prefix.get(self.value, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8b37666
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.
Coverage Report