summaryrefslogtreecommitdiffstats
path: root/combox/file.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-02-19 15:47:46 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-02-19 15:47:46 -0500
commitdb00e9be8e7740d0cf8a6ebbf6abca06bea58774 (patch)
treef2fe40b6de3a6c7a9d1bc4d4d54891ad3637b417 /combox/file.py
parentcaf90af84206d5df203747d2b5410aa33997c990 (diff)
modded combox.file.relative_path function.
Now the function is rigged up to return path relative to both combox directory and node directory. Corresponding test for this function is at tests.file_test module. modified: combox/file.py modified: tests/file_test.py
Diffstat (limited to 'combox/file.py')
-rw-r--r--combox/file.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/combox/file.py b/combox/file.py
index 0eb08b3..e6d4000 100644
--- a/combox/file.py
+++ b/combox/file.py
@@ -26,8 +26,14 @@ from glob import glob
from combox.config import get_nodedirs
-def relative_path(p, config):
- """Returns the relative path to the `p' w. r. t combox directory.
+def relative_path(p, config, comboxd=True):
+ """Returns the relative path to the `p' w. r. t combox or node directory.
+
+ If `comboxd' is True, the relative path is w. r. t combox
+ directory.
+
+ If `comboxd' is False, the relative path is w. r. t node
+ directory.
p: path to a directory or file.
@@ -35,9 +41,12 @@ def relative_path(p, config):
combox.
"""
- combox_dir = '%s/' % config['combox_dir']
+ if comboxd:
+ directory = '%s/' % config['combox_dir']
+ else:
+ directory = '%s/' % get_nodedirs(config)[0]
- return p.partition(combox_dir)[2]
+ return p.partition(directory)[2]
def mk_nodedir(directory, config):