# Path: dgitcore/helper.py
# class cd:
#     """Context manager for changing the current working directory"""
#     def __init__(self, newPath):
#         self.newPath = os.path.expanduser(newPath)
# 
#     def __enter__(self):
#         self.savedPath = os.getcwd()
#         os.chdir(self.newPath)
# 
#     def __exit__(self, etype, value, traceback):
#         os.chdir(self.savedPath)
# 
# Path: dgitcore/plugins/instrumentation.py
# class InstrumentationBase(object):
#     """
#     Pre-computed patterns
#     """
#     def __init__(self, name, version, description, supported=[]):
#         self.enable = 'y'
#         self.name = name
#         self.version = version
#         self.description = description
#         self.support = supported + [name]
#         self.initialize()
# 
#     def initialize(self):
#         return
# 
#     def config(self, what='get', params=None):
#         return
# 
# Path: dgitcore/config.py
# def get_config():
#     if config is None:
#         init()
#     return config


import os, sys
import json
import messytables
import subprocess
from dgitcore.helper import cd
from dgitcore.plugins.instrumentation import InstrumentationBase
from dgitcore.config import get_config
        output = run(cmd)
        return {'remote.origin.url': output.strip()}

def executable_commit(filename,
                      what=['commit', 'username', 'useremail', 'date']):
    mapping = {
        'commit': '%H',
        'username': '%cn',
        'useremail': '%ce',
        'date': '%cd'
    }

    missing = [mapping[w] for w in what if w not in mapping]
    if len(missing) > 0:
        print("Cannot gather commit attributes of executable", missing)
        raise Exception("Invalid specification")

    codes = ",".join([mapping[w] for w in what if w in mapping])

    with cd(os.path.dirname(filename)):
        cmd = 'git log -n 1  --date=iso --pretty="%s" -- %s ' %(codes, filename)
        output = run(cmd)
        output = output.strip()
        output = output.split(",")
        return {what[i]: output[i] for i in range(len(what))}

    return {}

def executable_repopath(filename):


# Path: dgitcore/helper.py
# class cd:
#     """Context manager for changing the current working directory"""
#     def __init__(self, newPath):
#         self.newPath = os.path.expanduser(newPath)
# 
#     def __enter__(self):
#         self.savedPath = os.getcwd()
#         os.chdir(self.newPath)
# 
#     def __exit__(self, etype, value, traceback):
#         os.chdir(self.savedPath)
# 
# Path: dgitcore/plugins/instrumentation.py
# class InstrumentationBase(object):
#     """
#     Pre-computed patterns
#     """
#     def __init__(self, name, version, description, supported=[]):
#         self.enable = 'y'
#         self.name = name
#         self.version = version
#         self.description = description
#         self.support = supported + [name]
#         self.initialize()
# 
#     def initialize(self):
#         return
# 
#     def config(self, what='get', params=None):
#         return
# 
# Path: dgitcore/config.py
# def get_config():
#     if config is None:
#         init()
#     return config


# Path: dgitcore/contrib/instrumentations/executable.py
import os, sys
import json
import messytables
import subprocess
from dgitcore.helper import cd
from dgitcore.plugins.instrumentation import InstrumentationBase
from dgitcore.config import get_config

        output = run(cmd)
        return {'remote.origin.url': output.strip()}

def executable_commit(filename,
                      what=['commit', 'username', 'useremail', 'date']):
    mapping = {
        'commit': '%H',
        'username': '%cn',
        'useremail': '%ce',
        'date': '%cd'
    }

    missing = [mapping[w] for w in what if w not in mapping]
    if len(missing) > 0:
        print("Cannot gather commit attributes of executable", missing)
        raise Exception("Invalid specification")

    codes = ",".join([mapping[w] for w in what if w in mapping])

    with cd(os.path.dirname(filename)):
        cmd = 'git log -n 1  --date=iso --pretty="%s" -- %s ' %(codes, filename)
        output = run(cmd)
        output = output.strip()
        output = output.split(",")
        return {what[i]: output[i] for i in range(len(what))}

    return {}

def executable_repopath(filename):


    with cd(os.path.dirname(filename)):