Commit 0eaef195 authored by pavan kumar.siligam's avatar pavan kumar.siligam

auto version the metadata file when applicable

parent da3079e0
......@@ -14,9 +14,10 @@ import posixpath
import re
import datetime
import json
import shlex
from collections import OrderedDict
from netCDF4 import Dataset
from subprocess import Popen, PIPE
from subprocess import Popen, PIPE, check_output
from contextlib import contextmanager
......@@ -177,7 +178,18 @@ def meta_load(filename):
def meta_save(filename, collection):
with open(filename, "w") as fid:
json.dump(collection, fid, indent=INDENT)
dirname = os.path.dirname(filename)
fname = os.path.basename(filename)
gitrepo = os.path.join(dirname, ".git")
if os.path.exists(gitrepo):
current_dir = os.getcwd()
with temporary_change_dir(os.chdir, current_dir, dirname):
cmd_add = shlex.split("git add {}".format(fname))
cmd_commit = shlex.split('git commit -m "{!s}"'.format(datetime.datetime.now()))
o = check_output(cmd_add)
o = check_output(cmd_commit)
if o:
print('GIT {}: updated {}'.format(' '.join(o.split()[:2])), fname)
def meta_append(collection, entry):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment