Add law_base utility.
@@ -5,8 +5,8 @@ Helpful utility functions.
"""
-__all__ = ["printerr", "abort", "colored", "query_choice", "multi_match", "make_list", "flatten",
- "which"]
+__all__ = ["law_base", "printerr", "abort", "colored", "query_choice", "multi_match", "make_list",
+ "flatten", "which"]
import os
@@ -18,6 +18,14 @@ import fnmatch
import six
+def law_base(*paths):
+ """
+ Returns the law installation directory, optionally joined with *paths*.
+ """
+ base = os.path.dirname(os.path.abspath(__file__))
+ return os.path.join(base, *paths)
+
+
def printerr(*args, **kwargs):
""" printerr(*args, flush=False)
Same as *print*, but outputs to stderr. If *flush* is *True*, stderr is flushed after printing.
