from .pathmapper import ArvPathMapper, trim_listing
from .arvtool import ArvadosCommandTool, set_cluster_target
from ._version import __version__
+from .util import common_prefix
from .perf import Perf
drop_ids(d[field])
-def common_prefix(firstfile, all_files):
- n = 0
- allmatch = True
- if not firstfile:
- return ""
-
- while allmatch and n < len(firstfile)-1:
- n += 1
- for f in all_files:
- if len(f)-1 < n:
- n -= 1
- allmatch = False
- break
- if f[n] != firstfile[n]:
- allmatch = False
- break
-
- while n > 0 and firstfile[n] != "/":
- n -= 1
-
- if firstfile[n] == "/":
- n += 1
-
- return firstfile[:n]
-
-
def upload_workflow(arvRunner, tool, job_order, project_uuid,
runtimeContext,
uuid=None,
raise e
return current_container
+
+
+def common_prefix(firstfile, all_files):
+ common_parts = firstfile.split('/')
+ common_parts[-1] = ''
+ for f in all_files:
+ f_parts = f.split('/')
+ for index, (a, b) in enumerate(zip(common_parts, f_parts)):
+ if a != b:
+ common_parts = common_parts[:index + 1]
+ common_parts[-1] = ''
+ break
+ if not any(common_parts):
+ break
+ return '/'.join(common_parts)
from arvados_cwl.util import *
from arvados.errors import ApiError
-from arvados_cwl.arvworkflow import common_prefix
+from arvados_cwl.util import common_prefix
class MockDateTime(datetime.datetime):
@classmethod