Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions bin/ghar
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright (C) 2010 Brandon Philips <brandon@ifup.org>
#
Expand Down Expand Up @@ -29,7 +29,7 @@ import re
try: # Assume Python3
from urllib import parse
except ImportError: # Support Python2
from urlparse import urlparse
from urllib.parse import urlparse
import subprocess
from stat import *

Expand Down Expand Up @@ -148,9 +148,9 @@ class Repo:
found_one = False
for f in l:
# global .gitconfig as a config is OK but not .git/ or .gitignore
if re.match("^\.git(ignore|modules)?$", f) or re.match("^README.*$", f) or re.match("^\.travis.yml", f):
if re.match(r"^\.git(ignore|modules)?$", f) or re.match(r"^README.*$", f) or re.match(r"^\.travis.yml", f):
self.ls.remove(f)
elif re.match("^\..+$", f):
elif re.match(r"^\..+$", f):
found_one = True
if found_one: return True
return False
Expand Down Expand Up @@ -191,16 +191,16 @@ class Repo:
dir_links = []
ls = os.listdir(path)
for fname in ls:
if re.match('^\.git\/?$', fname):
if re.match(r'^\.git\/?$', fname):
continue
link = Link(os.path.join(path, fname), base=self.path)
ok, link_status = link.status()
if link_status == "directory":
new_path = os.path.join(path, fname)
dir_links += self.list_directory_links(new_path)
elif link_status.startswith("link to "):
print ("Linking %s to %s: can't handle non-ghar symlinks." %
(link, os.path.join(path, fname)))
print(("Linking %s to %s: can't handle non-ghar symlinks." %
(link, os.path.join(path, fname))))
else:
dir_links.append(Link(os.path.join(path, fname), base=self.path, ignore=self.ignore))
return dir_links
Expand Down Expand Up @@ -258,14 +258,14 @@ argp_add.set_defaults(func=add)
def _git_subcommand(args, action):
pull_repos = repos
if args.repos:
pull_repos = filter(lambda x: str(x) in args.repos, repos)
pull_repos = [x for x in repos if str(x) in args.repos]

for r in pull_repos:
try:
status, string = getattr(r, action)()
print ("%s: %s" % (str(r), string))
print(("%s: %s" % (str(r), string)))
except NoGitException as e:
print ("%s is not a git repo" % str(r))
print(("%s is not a git repo" % str(r)))
return 0

argp_pull = argp_sub.add_parser('pull', help='pull all or a few repos')
Expand All @@ -285,25 +285,25 @@ argp_status.set_defaults(func=status)
def _link_subcommand(args, action, error_msg):
pull_repos = repos
if args.repos:
pull_repos = filter(lambda x: str(x) in args.repos, repos)
pull_repos = [x for x in repos if str(x) in args.repos]

for repo in pull_repos:
if not repo.has_git():
print ("%s: not a git repo" % str(repo))
print(("%s: not a git repo" % str(repo)))
elif len(repo.links) <= 0:
print ("%s: has no dotfiles" % str(repo))
print(("%s: has no dotfiles" % str(repo)))
else:
success = True
ret = []


print (repo.basename)
print((repo.basename))
for l in repo.links:
stat, string = getattr(l, action)()
if stat == False: success = False
print (" %s\t%s" % (string, str(l)))
print((" %s\t%s" % (string, str(l))))
if not success:
print (error_msg % str(repo))
print((error_msg % str(repo)))


argp_install = argp_sub.add_parser('install', help="install symlinks")
Expand Down