Skip to content

Commit

Permalink
Pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
devcurmudgeon committed Jul 3, 2016
1 parent 29c8430 commit 6c2dc60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ybd/morphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ def _tidy_and_insert_recursively(self, dn):
dn['contents'] = dn.get('contents', [])

if type(dn.get('chunks', [])) is not list:
log('DEFINITIONS', 'WARNING: %s chunks must be list\n' % dn['path'],
log('DEFINITIONS', 'WARNING: %s chunks must be list:' % dn['path'],
dn.get('chunks', []), exit=True)

if type(dn.get('strata', [])) is not list:
log('DEFINITIONS', 'WARNING: %s strata must be list\n' % dn['path'],
log('DEFINITIONS', 'WARNING: %s strata must be list:' % dn['path'],
dn.get('strata', []), exit=True)

dn['contents'] += dn.pop('chunks', []) + dn.pop('strata', [])
Expand Down
29 changes: 15 additions & 14 deletions ybd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,46 @@ def set_mtime_recursively(root, set_time=default_magic_timestamp):

# relative_symlink_target()
# @root: The staging area root location
# @symlink: The location of the symlink in the staging area (including the root path)
# @symlink: Location of the symlink in staging area (including the root path)
# @target: The symbolic link target, which may be an absolute path
#
# If @target is an absolute path, a relative path from the symbolic link location
# will be returned, otherwise if @target is a relative path, it will be return
# unchanged.
# If @target is an absolute path, a relative path from the symbolic link
# location will be returned, otherwise if @target is a relative path, it will
# be returned unchanged.
#
def relative_symlink_target(root, symlink, target):
'''Resolves a relative symbolic link target if the target is an absolute path
'''Resolves a relative symbolic link target if target is an absolute path
This is is necessary when staging files into a staging area, otherwise we
can either get errors for non-existant paths on the host filesystem or
even worse, if we are running as super user we can end up silently overwriting
files on the build host.
even worse, if we are running as super user we can end up silently
overwriting files on the build host.
'''

if os.path.isabs (target):
if os.path.isabs(target):

# First fix the input a little, the symlink itself must not have a
# trailing slash, otherwise we fail to remove the symlink filename
# from it's directory components in os.path.split()
#
# The absolute target filename must have it's leading separator
# removed, otherwise os.path.join() will discard the prefix
symlink = symlink.rstrip (os.path.sep)
target = target.lstrip (os.path.sep)
symlink = symlink.rstrip(os.path.sep)
target = target.lstrip(os.path.sep)

# We want a relative path from the directory in which symlink
# is located, not from the symlink itself.
symlinkdir, unused = os.path.split (symlink)
symlinkdir, unused = os.path.split(symlink)

# Create a full path to the target including the leading staging directory
fulltarget = os.path.join (root, target)
# Create a full path to the target, including the leading staging
# directory
fulltarget = os.path.join(root, target)

# now get the relative path from the directory where the symlink
# is located within the staging root, to the target within the same
# staging root
newtarget = os.path.relpath (fulltarget, symlinkdir)
newtarget = os.path.relpath(fulltarget, symlinkdir)

return newtarget
else:
Expand Down

0 comments on commit 6c2dc60

Please sign in to comment.