Skip to content

Commit

Permalink
Merge pull request #203 from metno/issue201_get_folder_name
Browse files Browse the repository at this point in the history
make a function to find folder name in file archive
  • Loading branch information
johtoblan authored Oct 11, 2023
2 parents 4b3ce55 + 6de6454 commit b57ac51
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dmci/distributors/file_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
logger = logging.getLogger(__name__)


def get_folder_names(fileUUID):
lvlA = "arch_%s" % fileUUID.hex[7]
lvlB = "arch_%s" % fileUUID.hex[6]
lvlC = "arch_%s" % fileUUID.hex[5]

return lvlA, lvlB, lvlC


class FileDist(Distributor):

def __init__(self, cmd, xml_file=None, metadata_UUID=None, **kwargs):
Expand Down Expand Up @@ -134,9 +142,7 @@ def _delete_from_archive(self):

def _make_full_path(self, fileUUID):
"""Make the file name and path for a file with a given uuid."""
lvlA = "arch_%s" % fileUUID.hex[7]
lvlB = "arch_%s" % fileUUID.hex[6]
lvlC = "arch_%s" % fileUUID.hex[5]
lvlA, lvlB, lvlC = get_folder_names(fileUUID)

fileName = str(fileUUID) + ".xml"
archPath = os.path.join(self._conf.file_archive_path, lvlA, lvlB, lvlC)
Expand Down

0 comments on commit b57ac51

Please sign in to comment.