def _remote_info(repo, remote): OLD = False if OLD: remote_details = remote.repo.git.remote("get-url", remote.name, '--push') # TODO push into gitpython urls = [line for line in remote_details.split('\n')] else: urls = list(remote.urls) # urls = list(remote.urls) if len(urls) == 0: print('[git] WARNING: repo %r has no remote urls' % (repo,)) remote_info = None else: if len(urls) > 1: print('[git] WARNING: repo %r has multiple urls' % (repo,)) url = urls[0] url = url.replace('github.com:/', 'github.com:') remote_info = {} url_parts = re.split('[@/:]', url) # TODO: parse what format the url is in, ssh/http/https idx = util_list.listfind(url_parts, 'github.com') remote_info['name'] = remote.name remote_info['url'] = url if idx is not None: username = url_parts[idx + 1] remote_info['host'] = 'github' remote_info['username'] = username return remote_info
def db_to_dbdir(db, allow_newdir=False, extra_workdirs=[], use_sync=False): """ Implicitly gets dbdir. Searches for db inside of workdir """ work_dir = get_workdir() dbalias_dict = get_dbalias_dict() workdir_list = [] for extra_dir in extra_workdirs: if exists(extra_dir): workdir_list.append(extra_dir) if use_sync: sync_dir = join(work_dir, '../sync') if exists(sync_dir): workdir_list.append(sync_dir) workdir_list.append(work_dir) # TODO: Allow multiple workdirs # Check all of your work directories for the database for _dir in workdir_list: dbdir = realpath(join(_dir, db)) # Use db aliases if not exists(dbdir) and db.upper() in dbalias_dict: dbdir = join(_dir, dbalias_dict[db.upper()]) if exists(dbdir): break # Create the database if newdbs are allowed in the workdir #print('allow_newdir=%r' % allow_newdir) if allow_newdir: utool.ensuredir(dbdir, verbose=True) # Complain if the implicit dbdir does not exist if not exists(dbdir): print('!!!') print('[sysres] WARNING: db=%r not found in work_dir=%r' % (db, work_dir)) fname_list = os.listdir(work_dir) lower_list = [fname.lower() for fname in fname_list] index = util_list.listfind(lower_list, db.lower()) if index is not None: print('[sysres] WARNING: db capitalization seems to be off') if not utool.STRICT: print('[sysres] attempting to fix it') db = fname_list[index] dbdir = join(work_dir, db) print('[sysres] dbdir=%r' % dbdir) print('[sysres] db=%r' % db) if not exists(dbdir): msg = '[sysres!] ERROR: Database does not exist' print('<!!!>') print(msg) print('[sysres!] Here is a list of valid dbs: ' + utool.indentjoin(fname_list, '\n * ')) print('[sysres!] dbdir=%r' % dbdir) print('[sysres!] db=%r' % db) print('[sysres!] work_dir=%r' % work_dir) print('</!!!>') raise AssertionError(msg) print('!!!') return dbdir
def _remote_info(repo, remote): urls = list(remote.urls) if len(urls) == 0: print("[git] WARNING: repo %r has no remote urls" % (repo,)) remote_info = None else: if len(urls) > 1: print("[git] WARNING: repo %r has multiple urls" % (repo,)) url = urls[0] url = url.replace("github.com:/", "github.com:") remote_info = {} url_parts = re.split("[@/:]", url) # TODO: parse what format the url is in, ssh/http/https idx = util_list.listfind(url_parts, "github.com") remote_info["name"] = remote.name remote_info["url"] = url if idx is not None: username = url_parts[idx + 1] remote_info["host"] = "github" remote_info["username"] = username return remote_info
def _remote_info(repo, remote): urls = list(remote.urls) if len(urls) == 0: print('[git] WARNING: repo %r has no remote urls' % (repo,)) remote_info = None else: if len(urls) > 1: print('[git] WARNING: repo %r has multiple urls' % (repo,)) url = urls[0] url = url.replace('github.com:/', 'github.com:') remote_info = {} url_parts = re.split('[@/:]', url) # TODO: parse what format the url is in, ssh/http/https idx = util_list.listfind(url_parts, 'github.com') remote_info['name'] = remote.name remote_info['url'] = url if idx is not None: username = url_parts[idx + 1] remote_info['host'] = 'github' remote_info['username'] = username return remote_info
def db_to_dbdir(db, allow_newdir=False, extra_workdirs=[], use_sync=False): """ Implicitly gets dbdir. Searches for db inside of workdir """ if ut.VERBOSE: print('[sysres] db_to_dbdir: db=%r, allow_newdir=%r' % (db, allow_newdir)) work_dir = get_workdir() dbalias_dict = get_dbalias_dict() workdir_list = [] for extra_dir in extra_workdirs: if exists(extra_dir): workdir_list.append(extra_dir) if use_sync: sync_dir = join(work_dir, '../sync') if exists(sync_dir): workdir_list.append(sync_dir) workdir_list.append(work_dir) # TODO: Allow multiple workdirs # Check all of your work directories for the database for _dir in workdir_list: dbdir = realpath(join(_dir, db)) # Use db aliases if not exists(dbdir) and db.upper() in dbalias_dict: dbdir = join(_dir, dbalias_dict[db.upper()]) if exists(dbdir): break # Create the database if newdbs are allowed in the workdir #print('allow_newdir=%r' % allow_newdir) if allow_newdir: ut.ensuredir(dbdir, verbose=True) # Complain if the implicit dbdir does not exist if not exists(dbdir): print('!!!') print('[sysres] WARNING: db=%r not found in work_dir=%r' % (db, work_dir)) fname_list = os.listdir(work_dir) lower_list = [fname.lower() for fname in fname_list] index = util_list.listfind(lower_list, db.lower()) if index is not None: print('[sysres] WARNING: db capitalization seems to be off') if not ut.STRICT: print('[sysres] attempting to fix it') db = fname_list[index] dbdir = join(work_dir, db) print('[sysres] dbdir=%r' % dbdir) print('[sysres] db=%r' % db) if not exists(dbdir): msg = '[sysres!] ERROR: Database does not exist and allow_newdir=False' print('<!!!>') print(msg) print('[sysres!] Here is a list of valid dbs: ' + ut.indentjoin(sorted(fname_list), '\n * ')) print('[sysres!] dbdir=%r' % dbdir) print('[sysres!] db=%r' % db) print('[sysres!] work_dir=%r' % work_dir) print('</!!!>') raise AssertionError(msg) print('!!!') return dbdir