Created
December 16, 2016 22:11
-
-
Save Gee19/c8491e96aa1ac5609cc59f6f3e6ac57f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def insert_after(self, the_list, after, items_to_insert): | |
after_obj = next((i for i in the_list if | |
getattr(i, 'id', None) == after or getattr(i, 'name', | |
None) == after)) | |
for item in reversed(items_to_insert): | |
try: | |
the_list.insert(the_list.index(after_obj) + 1, item) | |
except ValueError as exc: | |
raise IntegrationPluginException( | |
"Item doesn't exist in the list: {0}".format(exc.message)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment