Commits

Anonymous committed e935ae6

Adding get_dir command to hornet.file

  • Participants
  • Parent commits 073b4da

Comments (0)

Files changed (2)

File src/hornet/file.py

     'dir/file.csv'
     """
     return os.path.join(*args)
+
+
+def get_dir(filename):
+    """Get the absolute path to the directory in which *filename*
+    exists.
+    
+    >>> get_dir(__file__)
+    """
+    return os.path.dirname(os.path.abspath(filename))

File tests/test_file.py

 def test_join_multiple():
     expected = os.path.join('a', 'b', 'c')
     assert join('a','b', 'c') == expected
+
+def test_get_dir():
+    assert get_dir(__file__) == os.path.dirname(os.path.abspath(__file__))