Skip to content

Commit

Permalink
fix use of LinkType.make method and dashes/underscores in enum names
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Nov 14, 2016
1 parent 6114ef1 commit 8ee1a09
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions conda/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class LinkType(Enum):
# LINK_SOFT: 'soft-link',
# LINK_COPY: 'copy',
# }
hard_link = 1
soft_link = 2
hardlink = 1
softlink = 2
copy = 3
directory = 4

Expand Down
2 changes: 1 addition & 1 deletion conda/core/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, prefix, index, dist):
self.dist = dist
self.package_info = None # set in the link method

def link(self, requested_link_type=LinkType.hard_link):
def link(self, requested_link_type=LinkType.hardlink):
log.debug("linking package %s with link type %s", self.dist, requested_link_type)
self.extracted_package_dir = is_extracted(self.dist)
assert self.extracted_package_dir is not None
Expand Down
8 changes: 4 additions & 4 deletions conda/gateways/disk/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def try_hard_link(pkgs_dir, prefix, dist):
try:
if not isdir(prefix):
makedirs(prefix)
link(src, dst, LinkType.hard_link)
link(src, dst, LinkType.hardlink)
# Some file systems (at least BeeGFS) do not support hard-links
# between files in different directories. Depending on the
# file system configuration, a symbolic link may be created
Expand Down Expand Up @@ -191,19 +191,19 @@ def win_soft_link(src, dst):
raise CondaOSError('win32 soft link failed')


def link(src, dst, link_type=LinkType.hard_link):
def link(src, dst, link_type=LinkType.hardlink):
if exists(dst):
if context.force:
log.info("file exists, but clobbering: %r" % dst)
rm_rf(dst)
else:
raise ClobberError(dst, src, link_type)
if link_type == LinkType.hard_link:
if link_type == LinkType.hardlink:
if on_win:
win_hard_link(src, dst)
else:
os.link(src, dst)
elif link_type == LinkType.soft_link:
elif link_type == LinkType.softlink:
if on_win:
win_soft_link(src, dst)
else:
Expand Down
4 changes: 2 additions & 2 deletions conda/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def RM_FETCHED_CMD(state, arg):
def split_linkarg(arg):
"""Return tuple(dist, linktype)"""
parts = arg.split()
return (parts[0], int(LinkType.hard_link if len(parts) < 2 else parts[1]))
return (parts[0], int(LinkType.hardlink if len(parts) < 2 else parts[1]))


def LINK_CMD(state, arg):
dist, lt = split_linkarg(arg)
dist, lt = Dist(dist), LinkType.make(lt)
dist, lt = Dist(dist), LinkType(lt)
log.debug("=======> LINKING %s <=======", dist)
installer = get_package_installer(state['prefix'], state['index'], dist)
installer.link(lt)
Expand Down
6 changes: 3 additions & 3 deletions conda/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def explicit(specs, prefix, verbose=False, force_extract=True, index_args=None,
if context.always_copy:
lt = LinkType.copy
elif context.always_softlink:
lt = LinkType.soft_link
lt = LinkType.softlink
elif try_hard_link(fetched_dir, prefix, dist):
lt = LinkType.hard_link
lt = LinkType.hardlink
elif context.allow_softlinks and not on_win:
lt = LinkType.soft_link
lt = LinkType.softlink
else:
lt = LinkType.copy
actions[LINK].append('%s %d' % (dist, lt))
Expand Down
10 changes: 5 additions & 5 deletions conda/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def channel_filt(s):
if features[pkg][0]:
oldfmt[pkg] += ' [{features[0]:<%s}]' % maxoldfeatures

lt = LinkType(linktypes.get(pkg, LinkType.hard_link))
lt = '' if lt == LinkType.hard_link else (' (%s)' % lt)
lt = LinkType(linktypes.get(pkg, LinkType.hardlink))
lt = '' if lt == LinkType.hardlink else (' (%s)' % lt)
if pkg in removed or pkg in new:
oldfmt[pkg] += lt
continue
Expand Down Expand Up @@ -363,11 +363,11 @@ def ensure_linked_actions(dists, prefix, index=None, force=False,
if context.always_copy or always_copy:
lt = LinkType.copy
elif context.always_softlink:
lt = LinkType.soft_link
lt = LinkType.softlink
elif try_hard_link(fetched_dir, prefix, dist):
lt = LinkType.hard_link
lt = LinkType.hardlink
elif context.allow_softlinks and not on_win:
lt = LinkType.soft_link
lt = LinkType.softlink
else:
lt = LinkType.copy

Expand Down

0 comments on commit 8ee1a09

Please sign in to comment.