Skip to content

[yeb] type-convert checksum and patch values#1826

Merged
boegel merged 6 commits intoeasybuilders:developfrom
Caylo:yeb-type-checksums
Jul 5, 2016
Merged

[yeb] type-convert checksum and patch values#1826
boegel merged 6 commits intoeasybuilders:developfrom
Caylo:yeb-type-checksums

Conversation

@Caylo
Copy link
Copy Markdown
Contributor

@Caylo Caylo commented Jun 30, 2016

(to use in yeb, simply replace tuples by lists)

@Caylo Caylo changed the title [.yeb] type-convert checksum and patch values [yeb] type-convert checksum and patch values Jun 30, 2016
Comment thread easybuild/framework/easyconfig/types.py Outdated
return [to_dependency(dep) for dep in dep_list]

def to_checksums(checksums):
if not isinstance(checksums[0], list):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the [0]?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this is needed either, it looks wrong to only consider the 1st element.

@boegel
Copy link
Copy Markdown
Member

boegel commented Jul 4, 2016

(open/close to trigger Travis)

@boegel boegel closed this Jul 4, 2016
@boegel boegel reopened this Jul 4, 2016
@boegel boegel added this to the v2.9.0 milestone Jul 4, 2016
Comment thread easybuild/framework/easyconfig/types.py Outdated
CHECKSUMS = (list, as_hashable({'elem_types': [STRING_OR_TUPLE_LIST]}))

CHECKABLE_TYPES = [CHECKSUMS, DEPENDENCIES, DEPENDENCY_DICT, NAME_VERSION_DICT, SANITY_CHECK_PATHS_DICT,
STRING_OR_TUPLE_LIST, TUPLE_OF_STRINGS]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit-picking: fix indent to align with line above

Comment thread easybuild/framework/easyconfig/types.py Outdated
if not any(isinstance(checksum, list) for checksum in checksums):
return to_list_of_strings_and_tuples(checksums)
else:
return [to_list_of_strings_and_tuples(cs) for cs in checksums]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

positive logic (and a docstring) makes this easier to comprehend:

def to_checksums(checksums):
    """Ensure correct element types for list of checksums: convert each element to a tuple."""
    if all(isinstance(cs, basestring) for cs in checksums):
        # if all elements are strings, we convert each individual element to a tuple
        res = [to_list_of_strings_and_tuples(cs) for cs in checksums]
    else:
        res = to_list_of_strings_and_tuples(checksums)

    return res

(do check my comment/docstring, I may confuse between list/tuple...)

@boegel boegel modified the milestones: v2.9.0, v2.8.2 Jul 4, 2016
@boegel
Copy link
Copy Markdown
Member

boegel commented Jul 5, 2016

Going in, thanks @Caylo!

@boegel boegel merged commit 3f966d9 into easybuilders:develop Jul 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants