Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_commit_dt(text):
return isoparse(text.rsplit(':', 1)[0]).replace(second=0, microsecond=0)
def _get_commit_dt(repo_dir, commit_hash, **kw):
kw.setdefault('env', {})['TZ'] = 'UTC'
kw['cwd'] = repo_dir
proc_res = run_cap(['git', 'show', '-s', '--format=%cd', '--date=format-local:%Y-%m-%dT%H:%M:%S', commit_hash], **kw)
date_text = proc_res.stdout.strip()
return isoparse(date_text)
def _get_project_repo_info_map(project_list, repo_dir):
ret = OrderedDict()
for project in project_list:
target_repo_dir = os.path.join(repo_dir, project.name_slug)
if not os.path.isdir(target_repo_dir):
print_err('project %s repo directory not found at: %r' % (project.name, target_repo_dir))
continue
pull_date_path = target_repo_dir + '/.apatite_last_pulled'
with open(pull_date_path, 'r') as f:
last_pulled_bytes = f.read()
try:
last_pulled = isoparse(last_pulled_bytes)
except (TypeError, ValueError):
print_err('project %s had unreadable pull date at: %r' % (project.name, pull_date_path))
continue
ret[project] = (target_repo_dir, last_pulled)
return ret
def _get_commit_dt(repo_dir, commit_hash, **kw):
kw.setdefault('env', {})['TZ'] = 'UTC'
kw['cwd'] = repo_dir
proc_res = run_cap(['git', 'show', '-s', '--format=%cd', '--date=format-local:%Y-%m-%dT%H:%M:%S', commit_hash], **kw)
date_text = proc_res.stdout.strip()
return isoparse(date_text)
def _date_param(text):
text = text.strip()
if text.startswith('-'):
td = parse_timedelta(text)
dt = datetime.datetime.utcnow() + td # adding a negative
return dt
dt = isoparse(text)
return dt
def _date_param(text):
text = text.strip()
if text.startswith('-'):
td = parse_timedelta(text)
dt = datetime.datetime.utcnow() + td # adding a negative
return dt
dt = isoparse(text)
return dt
def _get_project_repo_info_map(project_list, repo_dir):
ret = OrderedDict()
for project in project_list:
target_repo_dir = os.path.join(repo_dir, project.name_slug)
if not os.path.isdir(target_repo_dir):
print_err('project %s repo directory not found at: %r' % (project.name, target_repo_dir))
continue
pull_date_path = target_repo_dir + '/.apatite_last_pulled'
with open(pull_date_path, 'r') as f:
last_pulled_bytes = f.read()
try:
last_pulled = isoparse(last_pulled_bytes)
except (TypeError, ValueError):
print_err('project %s had unreadable pull date at: %r' % (project.name, pull_date_path))
continue
ret[project] = (target_repo_dir, last_pulled)
return ret