diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-06-04 17:30:31 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-06-04 17:30:31 +0200 |
commit | 6fbb69306c0e14bacb8dcb92a89af27d3d5d631f (patch) | |
tree | 4a6e0c14b412315c13cc4ac6466f4888644195a3 /lib/git/odb/utils.py | |
parent | 25dca42bac17d511b7e2ebdd9d1d679e7626db5f (diff) | |
parent | e746f96bcc29238b79118123028ca170adc4ff0f (diff) | |
download | gitpython-6fbb69306c0e14bacb8dcb92a89af27d3d5d631f.tar.gz |
Merge branch 'odb'
Conflicts:
lib/git/cmd.py
Diffstat (limited to 'lib/git/odb/utils.py')
-rw-r--r-- | lib/git/odb/utils.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/git/odb/utils.py b/lib/git/odb/utils.py new file mode 100644 index 00000000..6863e97b --- /dev/null +++ b/lib/git/odb/utils.py @@ -0,0 +1,38 @@ +import binascii +import os +import errno + +#{ Routines + +hex_to_bin = binascii.a2b_hex +bin_to_hex = binascii.b2a_hex + +def to_hex_sha(sha): + """:return: hexified version of sha""" + if len(sha) == 40: + return sha + return bin_to_hex(sha) + +def to_bin_sha(sha): + if len(sha) == 20: + return sha + return hex_to_bin(sha) + +# errors +ENOENT = errno.ENOENT + +# os shortcuts +exists = os.path.exists +mkdir = os.mkdir +isdir = os.path.isdir +rename = os.rename +dirname = os.path.dirname +join = os.path.join +read = os.read +write = os.write +close = os.close + + +#} END Routines + + |