grim/hggravatar

Parents 13a2db7b58db
Children 1edb76f6931b
make sure we put our files in the hg directory and don't make it configurable
--- a/hggravatar.py Thu Dec 20 01:21:31 2018 -0600
+++ b/hggravatar.py Thu Dec 20 01:44:41 2018 -0600
@@ -5,6 +5,7 @@
import json
import os
import os.path
+import shutil
from mercurial.i18n import _
from mercurial import (
@@ -16,6 +17,8 @@
)
from mercurial.utils import stringutil
+_CACHE_DIR = '.hg/cache/gravatar'
+
urlreq = util.urlreq
urlencode = urlreq.urlencode
@@ -42,13 +45,15 @@
# we handle everything in the callback closure so nothing to do here
continue
+ path = os.path.join(repo.root, _CACHE_DIR)
+
try:
- os.makedirs(opts.get('output'))
+ os.makedirs(path)
except os.error as err:
if err.errno != errno.EEXIST:
raise
- map_file = os.path.join(opts.get('output'), 'author_map')
+ map_file = os.path.join(path, 'author_map')
with open(map_file, 'w') as ofp:
json.dump(authors, ofp, indent=2)
@@ -94,7 +99,7 @@
ui.write('failed.\n')
continue
- with open(os.path.join(opts.get('output'), filename), 'w') as ofp:
+ with open(os.path.join(repo.root, _CACHE_DIR, filename), 'w') as ofp:
ofp.write(img.read())
img.close()
@@ -125,7 +130,6 @@
@command(
'gravatar',
[
- ('o', 'output', '.hg/cache/gravatar/', _('output directory'), _('DIR')),
('r', 'rating', '', _('rating'), _('RATING')),
('s', 'size', '', _('size'), _('SIZE')),
('t', 'theme', '', _('theme'), _('THEME')),