Permalink
Browse files

Rename target_path and target_dir to destination_*

  • Loading branch information...
sgkim126 committed May 6, 2014
1 parent dcd0152 commit d07ba2af198dfcfbb1d76b37ce440c76e54c8c53
Showing with 26 additions and 26 deletions.
  1. +10 −10 config/__init__.py
  2. +4 −4 config/bin.py
  3. +1 −1 config/git.py
  4. +6 −6 config/root.py
  5. +5 −5 config/xorg.py
@@ -14,18 +14,18 @@ def __init__(self, *targets):
def source_dir(self):
return os.path.abspath(os.path.curdir)
@abstractmethod
def target_dir(self):
def destination_dir(self):
return os.getenv('HOME')

@abstractmethod
def source_path(self, target):
return os.path.join(self.source_dir(), target)
@abstractmethod
def target_path(self, target):
return os.path.join(self.target_dir(), '.' + target)
def destination_path(self, target):
return os.path.join(self.destination_dir(), '.' + target)
@abstractmethod
def backup_path(self, target):
return os.path.join(self.target_dir(), target + '.backup')
return os.path.join(self.destination_dir(), target + '.backup')

@abstractmethod
def source_exists(self, target):
@@ -36,16 +36,16 @@ def source_exists(self, target):

@abstractmethod
def resolve_conflict(self, target):
if os.path.exists(self.target_path(target)):
target_path = self.target_path(target)
if os.path.exists(self.destination_path(target)):
destination_path = self.destination_path(target)
backup_path = self.backup_path(target)
print("ERROR: {0} is already exist.".format(target_path), file=sys.stderr)
print(" The old {0} will be moved to {1}".format(target_path, backup_path), file=sys.stderr)
shutil.move(target_path, backup_path)
print("ERROR: {0} is already exist.".format(destination_path), file=sys.stderr)
print(" The old {0} will be moved to {1}".format(destination_path, backup_path), file=sys.stderr)
shutil.move(destination_path, backup_path)
return True
@abstractmethod
def do(self, target):
os.symlink(self.source_path(target), self.target_path(target))
os.symlink(self.source_path(target), self.destination_path(target))
@abstractmethod
def pre(self):
pass
@@ -5,8 +5,8 @@
class ConfigBin(config.Config):
def source_dir(self):
return os.path.join(super().source_dir(), 'bin')
def target_dir(self):
return os.path.join(os.path.join(super().target_dir(), '.root'), 'bin')
def target_path(self, target):
return os.path.join(self.target_dir(), target)
def destination_dir(self):
return os.path.join(os.path.join(super().destination_dir(), '.root'), 'bin')
def destination_path(self, target):
return os.path.join(self.destination_dir(), target)

@@ -21,4 +21,4 @@ def post(self):
break
subprocess.call(['git', 'config', '--global', 'user.email', mail])
def do(self, target):
shutil.copy(self.source_path(target), self.target_path(target))
shutil.copy(self.source_path(target), self.destination_path(target))
@@ -6,15 +6,15 @@ class ConfigRoot(config.Config):
def make_if_not_exist(self, path):
if not os.path.exists(path):
os.mkdir(path)
def target_dir(self):
return os.path.join(super().target_dir(), '.root')
def target_path(self, target):
return os.path.join(self.target_dir(), target)
def destination_dir(self):
return os.path.join(super().destination_dir(), '.root')
def destination_path(self, target):
return os.path.join(self.destination_dir(), target)
def source_exists(self, target):
return True
def resolve_conflict(self, target):
return True
def pre(self):
self.make_if_not_exist(self.target_dir())
self.make_if_not_exist(self.destination_dir())
def do(self, target):
self.make_if_not_exist(self.target_path(target))
self.make_if_not_exist(self.destination_path(target))
@@ -6,11 +6,11 @@
class ConfigXorg(config.Config):
def source_dir(self):
return os.path.join(super().source_dir(), 'xorg')
def target_dir(self):
def destination_dir(self):
return '/usr/share/X11/xorg.conf.d/'
def target_path(self, target):
return os.path.join(self.target_dir(), '80-' + target)
def destination_path(self, target):
return os.path.join(self.destination_dir(), '80-' + target)
def backup_path(self, target):
return os.path.join(self.target_dir(), '90-' + target + '.backup')
return os.path.join(self.destination_dir(), '90-' + target + '.backup')
def do(self, target):
subprocess.call(['sudo', 'ln', '-s', self.source_path(target), self.target_path(target)])
subprocess.call(['sudo', 'ln', '-s', self.source_path(target), self.destination_path(target)])

0 comments on commit d07ba2a

Please sign in to comment.