summaryrefslogtreecommitdiffstats
path: root/combox/file.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-03-19 22:42:26 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-03-19 22:42:26 -0400
commit7dbd4907a7b351bcc022a55068449c987d1754df (patch)
tree9bfb278bc71628941df838f3b2f1e0b1d9b89f43 /combox/file.py
parent1f5e33f6607f44419935715fdd8b87cefede2950 (diff)
new function combox.file.node_paths: returns the abs. path of shards/directories in node directories.
modified: combox/file.py modified: tests/file_test.py
Diffstat (limited to 'combox/file.py')
-rw-r--r--combox/file.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/combox/file.py b/combox/file.py
index d42d099..2f18823 100644
--- a/combox/file.py
+++ b/combox/file.py
@@ -93,6 +93,34 @@ def node_path(cb_path, config, isfile):
return file_node_path
+def node_paths(cb_path, config, isfile):
+ """Returns list of abs. path of file (in node dir.) the cb_path.
+
+ If cb_path is a file, it returns a list of abs. path names of
+ shards of the file in the node directories.
+
+ isfile: True if cb_path is a file
+ """
+
+ n_paths = []
+ nodes = get_nodedirs(config)
+ rel_path = relative_path(cb_path, config)
+
+ if isfile:
+ shard_no = 0
+ for node in nodes:
+ file_shard = '%s.shard%d' % (rel_path, shard_no)
+ n_path = path.join(node, file_shard)
+ n_paths.append(n_path)
+ shard_no += 1
+ else:
+ for node in nodes:
+ n_path = path.join(node, rel_path)
+ n_paths.append(n_path)
+
+ return n_paths
+
+
def mk_nodedir(directory, config):
"""
Creates directory `directory' inside the nodes.