Skip to content

Commit

Permalink
Make getPathFromDomain OS-agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed May 1, 2024
1 parent 0adf64c commit 04f715c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/hl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import numpy as np
import unittest as ut
from platform import system


# Check if non-ascii filenames are supported
Expand Down Expand Up @@ -242,18 +243,25 @@ def getPathFromDomain(self, domain):
E.g. "mytest.h5pyd_test.hdfgroup.org" to
"/org/hdfgroup/h5pyd_test/mytest
"""
if domain.find('/') > -1:
if (domain.find('/') > -1) or (domain.find(':') > -1):
# looks like the domain already is specified as a path
return domain

names = domain.split('.')
names.reverse()
path = '/'

# strip empty names
names = [name for name in names if name]

path = os.path.abspath(os.sep)

for name in names:
if name:
path += name
path += '/'
path = path[:-1] # strip trailing slash
path = os.path.join(path, name)

# strip trailing slash
if path[-1] == os.sep:
path = path[:-1]

return path

def is_hsds(self, id=None):
Expand Down

0 comments on commit 04f715c

Please sign in to comment.