repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.total_members_in_score_range | def total_members_in_score_range(self, min_score, max_score):
'''
Retrieve the total members in a given score range from the leaderboard.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score.
@return the total members in a given score range from the lea... | python | def total_members_in_score_range(self, min_score, max_score):
'''
Retrieve the total members in a given score range from the leaderboard.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score.
@return the total members in a given score range from the lea... | Retrieve the total members in a given score range from the leaderboard.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score.
@return the total members in a given score range from the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L392-L401 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.total_members_in_score_range_in | def total_members_in_score_range_in(
self, leaderboard_name, min_score, max_score):
'''
Retrieve the total members in a given score range from the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_s... | python | def total_members_in_score_range_in(
self, leaderboard_name, min_score, max_score):
'''
Retrieve the total members in a given score range from the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_s... | Retrieve the total members in a given score range from the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score.
@return the total members in a given score range from the named leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L403-L414 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.total_scores_in | def total_scores_in(self, leaderboard_name):
'''
Sum of scores for all members in the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@return Sum of scores for all members in the named leaderboard.
'''
return sum([leader[self.SCORE_KEY] for leader in ... | python | def total_scores_in(self, leaderboard_name):
'''
Sum of scores for all members in the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@return Sum of scores for all members in the named leaderboard.
'''
return sum([leader[self.SCORE_KEY] for leader in ... | Sum of scores for all members in the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@return Sum of scores for all members in the named leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L424-L431 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.rank_for_in | def rank_for_in(self, leaderboard_name, member):
'''
Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard.
'''
if se... | python | def rank_for_in(self, leaderboard_name, member):
'''
Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard.
'''
if se... | Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L462-L481 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.score_for_in | def score_for_in(self, leaderboard_name, member):
'''
Retrieve the score for a member in the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@param member [String] Member name.
@return the score for a member in the leaderboard or +None+ if the member is not i... | python | def score_for_in(self, leaderboard_name, member):
'''
Retrieve the score for a member in the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@param member [String] Member name.
@return the score for a member in the leaderboard or +None+ if the member is not i... | Retrieve the score for a member in the named leaderboard.
@param leaderboard_name Name of the leaderboard.
@param member [String] Member name.
@return the score for a member in the leaderboard or +None+ if the member is not in the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L492-L504 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.score_and_rank_for_in | def score_and_rank_for_in(self, leaderboard_name, member):
'''
Retrieve the score and rank for a member in the named leaderboard.
@param leaderboard_name [String]Name of the leaderboard.
@param member [String] Member name.
@return the score and rank for a member in the named lea... | python | def score_and_rank_for_in(self, leaderboard_name, member):
'''
Retrieve the score and rank for a member in the named leaderboard.
@param leaderboard_name [String]Name of the leaderboard.
@param member [String] Member name.
@return the score and rank for a member in the named lea... | Retrieve the score and rank for a member in the named leaderboard.
@param leaderboard_name [String]Name of the leaderboard.
@param member [String] Member name.
@return the score and rank for a member in the named leaderboard as a Hash. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L515-L527 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.change_score_for | def change_score_for(self, member, delta, member_data=None):
'''
Change the score for a member in the leaderboard by a score delta which can be positive or negative.
@param member [String] Member name.
@param delta [float] Score change.
@param member_data [String] Optional membe... | python | def change_score_for(self, member, delta, member_data=None):
'''
Change the score for a member in the leaderboard by a score delta which can be positive or negative.
@param member [String] Member name.
@param delta [float] Score change.
@param member_data [String] Optional membe... | Change the score for a member in the leaderboard by a score delta which can be positive or negative.
@param member [String] Member name.
@param delta [float] Score change.
@param member_data [String] Optional member data. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L529-L537 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.change_score_for_member_in | def change_score_for_member_in(self, leaderboard_name, member, delta, member_data=None):
'''
Change the score for a member in the named leaderboard by a delta which can be positive or negative.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.... | python | def change_score_for_member_in(self, leaderboard_name, member, delta, member_data=None):
'''
Change the score for a member in the named leaderboard by a delta which can be positive or negative.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.... | Change the score for a member in the named leaderboard by a delta which can be positive or negative.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param delta [float] Score change.
@param member_data [String] Optional member data. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L539-L555 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.remove_members_in_score_range | def remove_members_in_score_range(self, min_score, max_score):
'''
Remove members from the leaderboard in a given score range.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score.
'''
self.remove_members_in_score_range_in(
self.lead... | python | def remove_members_in_score_range(self, min_score, max_score):
'''
Remove members from the leaderboard in a given score range.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score.
'''
self.remove_members_in_score_range_in(
self.lead... | Remove members from the leaderboard in a given score range.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L557-L567 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.remove_members_in_score_range_in | def remove_members_in_score_range_in(
self, leaderboard_name, min_score, max_score):
'''
Remove members from the named leaderboard in a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_sco... | python | def remove_members_in_score_range_in(
self, leaderboard_name, min_score, max_score):
'''
Remove members from the named leaderboard in a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_sco... | Remove members from the named leaderboard in a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L569-L581 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.remove_members_outside_rank_in | def remove_members_outside_rank_in(self, leaderboard_name, rank):
'''
Remove members from the named leaderboard in a given rank range.
@param leaderboard_name [String] Name of the leaderboard.
@param rank [int] the rank (inclusive) which we should keep.
@return the total member ... | python | def remove_members_outside_rank_in(self, leaderboard_name, rank):
'''
Remove members from the named leaderboard in a given rank range.
@param leaderboard_name [String] Name of the leaderboard.
@param rank [int] the rank (inclusive) which we should keep.
@return the total member ... | Remove members from the named leaderboard in a given rank range.
@param leaderboard_name [String] Name of the leaderboard.
@param rank [int] the rank (inclusive) which we should keep.
@return the total member count which was removed. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L592-L606 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.page_for | def page_for(self, member, page_size=DEFAULT_PAGE_SIZE):
'''
Determine the page where a member falls in the leaderboard.
@param member [String] Member name.
@param page_size [int] Page size to be used in determining page location.
@return the page where a member falls in the lea... | python | def page_for(self, member, page_size=DEFAULT_PAGE_SIZE):
'''
Determine the page where a member falls in the leaderboard.
@param member [String] Member name.
@param page_size [int] Page size to be used in determining page location.
@return the page where a member falls in the lea... | Determine the page where a member falls in the leaderboard.
@param member [String] Member name.
@param page_size [int] Page size to be used in determining page location.
@return the page where a member falls in the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L608-L616 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.page_for_in | def page_for_in(self, leaderboard_name, member,
page_size=DEFAULT_PAGE_SIZE):
'''
Determine the page where a member falls in the named leaderboard.
@param leaderboard [String] Name of the leaderboard.
@param member [String] Member name.
@param page_size [int]... | python | def page_for_in(self, leaderboard_name, member,
page_size=DEFAULT_PAGE_SIZE):
'''
Determine the page where a member falls in the named leaderboard.
@param leaderboard [String] Name of the leaderboard.
@param member [String] Member name.
@param page_size [int]... | Determine the page where a member falls in the named leaderboard.
@param leaderboard [String] Name of the leaderboard.
@param member [String] Member name.
@param page_size [int] Page size to be used in determining page location.
@return the page where a member falls in the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L618-L643 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.percentile_for_in | def percentile_for_in(self, leaderboard_name, member):
'''
Retrieve the percentile for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the percentile for a member in the named leaderboard.
... | python | def percentile_for_in(self, leaderboard_name, member):
'''
Retrieve the percentile for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the percentile for a member in the named leaderboard.
... | Retrieve the percentile for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the percentile for a member in the named leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L654-L680 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.score_for_percentile_in | def score_for_percentile_in(self, leaderboard_name, percentile):
'''
Calculate the score for a given percentile value in the leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param percentile [float] Percentile value (0.0 to 100.0 inclusive).
@return the sc... | python | def score_for_percentile_in(self, leaderboard_name, percentile):
'''
Calculate the score for a given percentile value in the leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param percentile [float] Percentile value (0.0 to 100.0 inclusive).
@return the sc... | Calculate the score for a given percentile value in the leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param percentile [float] Percentile value (0.0 to 100.0 inclusive).
@return the score corresponding to the percentile argument. Return +None+ for arguments outside 0-1... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L691-L721 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.expire_leaderboard_for | def expire_leaderboard_for(self, leaderboard_name, seconds):
'''
Expire the given leaderboard in a set number of seconds. Do not use this with
leaderboards that utilize member data as there is no facility to cascade the
expiration out to the keys for the member data.
@param lead... | python | def expire_leaderboard_for(self, leaderboard_name, seconds):
'''
Expire the given leaderboard in a set number of seconds. Do not use this with
leaderboards that utilize member data as there is no facility to cascade the
expiration out to the keys for the member data.
@param lead... | Expire the given leaderboard in a set number of seconds. Do not use this with
leaderboards that utilize member data as there is no facility to cascade the
expiration out to the keys for the member data.
@param leaderboard_name [String] Name of the leaderboard.
@param seconds [int] Numbe... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L733-L745 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.leaders | def leaders(self, current_page, **options):
'''
Retrieve a page of leaders from the leaderboard.
@param current_page [int] Page to retrieve from the leaderboard.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders fro... | python | def leaders(self, current_page, **options):
'''
Retrieve a page of leaders from the leaderboard.
@param current_page [int] Page to retrieve from the leaderboard.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders fro... | Retrieve a page of leaders from the leaderboard.
@param current_page [int] Page to retrieve from the leaderboard.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders from the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L771-L779 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.leaders_in | def leaders_in(self, leaderboard_name, current_page, **options):
'''
Retrieve a page of leaders from the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param current_page [int] Page to retrieve from the named leaderboard.
@param options [Hash] Opti... | python | def leaders_in(self, leaderboard_name, current_page, **options):
'''
Retrieve a page of leaders from the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param current_page [int] Page to retrieve from the named leaderboard.
@param options [Hash] Opti... | Retrieve a page of leaders from the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param current_page [int] Page to retrieve from the named leaderboard.
@param options [Hash] Options to be used when retrieving the page from the named leaderboard.
@return a... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L781-L810 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.all_leaders_from | def all_leaders_from(self, leaderboard_name, **options):
'''
Retrieves all leaders from the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param options [Hash] Options to be used when retrieving the leaders from the named leaderboard.
@return the n... | python | def all_leaders_from(self, leaderboard_name, **options):
'''
Retrieves all leaders from the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param options [Hash] Options to be used when retrieving the leaders from the named leaderboard.
@return the n... | Retrieves all leaders from the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param options [Hash] Options to be used when retrieving the leaders from the named leaderboard.
@return the named leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L821-L832 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.members_from_score_range | def members_from_score_range(
self, minimum_score, maximum_score, **options):
'''
Retrieve members from the leaderboard within a given score range.
@param minimum_score [float] Minimum score (inclusive).
@param maximum_score [float] Maximum score (inclusive).
@param ... | python | def members_from_score_range(
self, minimum_score, maximum_score, **options):
'''
Retrieve members from the leaderboard within a given score range.
@param minimum_score [float] Minimum score (inclusive).
@param maximum_score [float] Maximum score (inclusive).
@param ... | Retrieve members from the leaderboard within a given score range.
@param minimum_score [float] Minimum score (inclusive).
@param maximum_score [float] Maximum score (inclusive).
@param options [Hash] Options to be used when retrieving the data from the leaderboard.
@return members from ... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L834-L845 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.members_from_score_range_in | def members_from_score_range_in(
self, leaderboard_name, minimum_score, maximum_score, **options):
'''
Retrieve members from the named leaderboard within a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param minimum_score [float] Minimum score... | python | def members_from_score_range_in(
self, leaderboard_name, minimum_score, maximum_score, **options):
'''
Retrieve members from the named leaderboard within a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param minimum_score [float] Minimum score... | Retrieve members from the named leaderboard within a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param minimum_score [float] Minimum score (inclusive).
@param maximum_score [float] Maximum score (inclusive).
@param options [Hash] Options to be used when... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L847-L870 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.members_from_rank_range | def members_from_rank_range(self, starting_rank, ending_rank, **options):
'''
Retrieve members from the leaderboard within a given rank range.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to... | python | def members_from_rank_range(self, starting_rank, ending_rank, **options):
'''
Retrieve members from the leaderboard within a given rank range.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to... | Retrieve members from the leaderboard within a given rank range.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to be used when retrieving the data from the leaderboard.
@return members from the leade... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L872-L882 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.members_from_rank_range_in | def members_from_rank_range_in(
self, leaderboard_name, starting_rank, ending_rank, **options):
'''
Retrieve members from the named leaderboard within a given rank range.
@param leaderboard_name [String] Name of the leaderboard.
@param starting_rank [int] Starting rank (incl... | python | def members_from_rank_range_in(
self, leaderboard_name, starting_rank, ending_rank, **options):
'''
Retrieve members from the named leaderboard within a given rank range.
@param leaderboard_name [String] Name of the leaderboard.
@param starting_rank [int] Starting rank (incl... | Retrieve members from the named leaderboard within a given rank range.
@param leaderboard_name [String] Name of the leaderboard.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to be used when retrievi... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L884-L918 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.top | def top(self, number, **options):
'''
Retrieve members from the leaderboard within a range from 1 to the number given.
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to be used when retrieving the data from the leaderboard.
@return number from t... | python | def top(self, number, **options):
'''
Retrieve members from the leaderboard within a range from 1 to the number given.
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to be used when retrieving the data from the leaderboard.
@return number from t... | Retrieve members from the leaderboard within a range from 1 to the number given.
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to be used when retrieving the data from the leaderboard.
@return number from the leaderboard that fall within the given rank range. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L920-L929 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.top_in | def top_in(self, leaderboard_name, number, **options):
'''
Retrieve members from the named leaderboard within a range from 1 to the number given.
@param leaderboard_name [String] Name of the leaderboard.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [i... | python | def top_in(self, leaderboard_name, number, **options):
'''
Retrieve members from the named leaderboard within a range from 1 to the number given.
@param leaderboard_name [String] Name of the leaderboard.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [i... | Retrieve members from the named leaderboard within a range from 1 to the number given.
@param leaderboard_name [String] Name of the leaderboard.
@param starting_rank [int] Starting rank (inclusive).
@param ending_rank [int] Ending rank (inclusive).
@param options [Hash] Options to be us... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L931-L942 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.member_at | def member_at(self, position, **options):
'''
Retrieve a member at the specified index from the leaderboard.
@param position [int] Position in leaderboard.
@param options [Hash] Options to be used when retrieving the member from the leaderboard.
@return a member from the leaderb... | python | def member_at(self, position, **options):
'''
Retrieve a member at the specified index from the leaderboard.
@param position [int] Position in leaderboard.
@param options [Hash] Options to be used when retrieving the member from the leaderboard.
@return a member from the leaderb... | Retrieve a member at the specified index from the leaderboard.
@param position [int] Position in leaderboard.
@param options [Hash] Options to be used when retrieving the member from the leaderboard.
@return a member from the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L944-L952 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.member_at_in | def member_at_in(self, leaderboard_name, position, **options):
'''
Retrieve a member at the specified index from the leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param position [int] Position in named leaderboard.
@param options [Hash] Options to be us... | python | def member_at_in(self, leaderboard_name, position, **options):
'''
Retrieve a member at the specified index from the leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param position [int] Position in named leaderboard.
@param options [Hash] Options to be us... | Retrieve a member at the specified index from the leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param position [int] Position in named leaderboard.
@param options [Hash] Options to be used when retrieving the member from the named leaderboard.
@return a page of... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L954-L973 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.around_me | def around_me(self, member, **options):
'''
Retrieve a page of leaders from the leaderboard around a given member.
@param member [String] Member name.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders from the leade... | python | def around_me(self, member, **options):
'''
Retrieve a page of leaders from the leaderboard around a given member.
@param member [String] Member name.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders from the leade... | Retrieve a page of leaders from the leaderboard around a given member.
@param member [String] Member name.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders from the leaderboard around a given member. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L975-L983 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.around_me_in | def around_me_in(self, leaderboard_name, member, **options):
'''
Retrieve a page of leaders from the named leaderboard around a given member.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param options [Hash] Options to be used wh... | python | def around_me_in(self, leaderboard_name, member, **options):
'''
Retrieve a page of leaders from the named leaderboard around a given member.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param options [Hash] Options to be used wh... | Retrieve a page of leaders from the named leaderboard around a given member.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param options [Hash] Options to be used when retrieving the page from the named leaderboard.
@return a page of lead... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L985-L1022 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.ranked_in_list | def ranked_in_list(self, members, **options):
'''
Retrieve a page of leaders from the leaderboard for a given list of members.
@param members [Array] Member names.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders f... | python | def ranked_in_list(self, members, **options):
'''
Retrieve a page of leaders from the leaderboard for a given list of members.
@param members [Array] Member names.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders f... | Retrieve a page of leaders from the leaderboard for a given list of members.
@param members [Array] Member names.
@param options [Hash] Options to be used when retrieving the page from the leaderboard.
@return a page of leaders from the leaderboard for a given list of members. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1024-L1033 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.ranked_in_list_in | def ranked_in_list_in(self, leaderboard_name, members, **options):
'''
Retrieve a page of leaders from the named leaderboard for a given list of members.
@param leaderboard_name [String] Name of the leaderboard.
@param members [Array] Member names.
@param options [Hash] Options ... | python | def ranked_in_list_in(self, leaderboard_name, members, **options):
'''
Retrieve a page of leaders from the named leaderboard for a given list of members.
@param leaderboard_name [String] Name of the leaderboard.
@param members [Array] Member names.
@param options [Hash] Options ... | Retrieve a page of leaders from the named leaderboard for a given list of members.
@param leaderboard_name [String] Name of the leaderboard.
@param members [Array] Member names.
@param options [Hash] Options to be used when retrieving the page from the named leaderboard.
@return a page ... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1035-L1095 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.merge_leaderboards | def merge_leaderboards(self, destination, keys, aggregate='SUM'):
'''
Merge leaderboards given by keys with this leaderboard into a named destination leaderboard.
@param destination [String] Destination leaderboard name.
@param keys [Array] Leaderboards to be merged with the current lea... | python | def merge_leaderboards(self, destination, keys, aggregate='SUM'):
'''
Merge leaderboards given by keys with this leaderboard into a named destination leaderboard.
@param destination [String] Destination leaderboard name.
@param keys [Array] Leaderboards to be merged with the current lea... | Merge leaderboards given by keys with this leaderboard into a named destination leaderboard.
@param destination [String] Destination leaderboard name.
@param keys [Array] Leaderboards to be merged with the current leaderboard.
@param options [Hash] Options for merging the leaderboards. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1097-L1106 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard.intersect_leaderboards | def intersect_leaderboards(self, destination, keys, aggregate='SUM'):
'''
Intersect leaderboards given by keys with this leaderboard into a named destination leaderboard.
@param destination [String] Destination leaderboard name.
@param keys [Array] Leaderboards to be merged with the cur... | python | def intersect_leaderboards(self, destination, keys, aggregate='SUM'):
'''
Intersect leaderboards given by keys with this leaderboard into a named destination leaderboard.
@param destination [String] Destination leaderboard name.
@param keys [Array] Leaderboards to be merged with the cur... | Intersect leaderboards given by keys with this leaderboard into a named destination leaderboard.
@param destination [String] Destination leaderboard name.
@param keys [Array] Leaderboards to be merged with the current leaderboard.
@param options [Hash] Options for intersecting the leaderboards. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1108-L1117 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard._member_data_key | def _member_data_key(self, leaderboard_name):
'''
Key for retrieving optional member data.
@param leaderboard_name [String] Name of the leaderboard.
@return a key in the form of +leaderboard_name:member_data+
'''
if self.global_member_data is False:
return '%... | python | def _member_data_key(self, leaderboard_name):
'''
Key for retrieving optional member data.
@param leaderboard_name [String] Name of the leaderboard.
@return a key in the form of +leaderboard_name:member_data+
'''
if self.global_member_data is False:
return '%... | Key for retrieving optional member data.
@param leaderboard_name [String] Name of the leaderboard.
@return a key in the form of +leaderboard_name:member_data+ | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1125-L1135 |
agoragames/leaderboard-python | leaderboard/leaderboard.py | Leaderboard._parse_raw_members | def _parse_raw_members(
self, leaderboard_name, members, members_only=False, **options):
'''
Parse the raw leaders data as returned from a given leader board query. Do associative
lookups with the member to rank, score and potentially sort the results.
@param leaderboard_nam... | python | def _parse_raw_members(
self, leaderboard_name, members, members_only=False, **options):
'''
Parse the raw leaders data as returned from a given leader board query. Do associative
lookups with the member to rank, score and potentially sort the results.
@param leaderboard_nam... | Parse the raw leaders data as returned from a given leader board query. Do associative
lookups with the member to rank, score and potentially sort the results.
@param leaderboard_name [String] Name of the leaderboard.
@param members [List] A list of members as returned from a sorted set range q... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/leaderboard.py#L1137-L1155 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.delete_leaderboard_named | def delete_leaderboard_named(self, leaderboard_name):
'''
Delete the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
'''
pipeline = self.redis_connection.pipeline()
pipeline.delete(leaderboard_name)
pipeline.delete(self._member_data_k... | python | def delete_leaderboard_named(self, leaderboard_name):
'''
Delete the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
'''
pipeline = self.redis_connection.pipeline()
pipeline.delete(leaderboard_name)
pipeline.delete(self._member_data_k... | Delete the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L33-L43 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.change_score_for_member_in | def change_score_for_member_in(self, leaderboard_name, member, delta, member_data=None):
'''
Change the score for a member in the named leaderboard by a delta which can be positive or negative.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.... | python | def change_score_for_member_in(self, leaderboard_name, member, delta, member_data=None):
'''
Change the score for a member in the named leaderboard by a delta which can be positive or negative.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.... | Change the score for a member in the named leaderboard by a delta which can be positive or negative.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param delta [float] Score change.
@param member_data [String] Optional member data. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L45-L76 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.rank_member_in | def rank_member_in(
self, leaderboard_name, member, score, member_data=None):
'''
Rank a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param score [float] Member score.
@param m... | python | def rank_member_in(
self, leaderboard_name, member, score, member_data=None):
'''
Rank a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param score [float] Member score.
@param m... | Rank a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@param score [float] Member score.
@param member_data [String] Optional member data. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L78-L110 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.rank_member_across | def rank_member_across(
self, leaderboards, member, score, member_data=None):
'''
Rank a member across multiple leaderboards.
@param leaderboards [Array] Leaderboard names.
@param member [String] Member name.
@param score [float] Member score.
@param member_d... | python | def rank_member_across(
self, leaderboards, member, score, member_data=None):
'''
Rank a member across multiple leaderboards.
@param leaderboards [Array] Leaderboard names.
@param member [String] Member name.
@param score [float] Member score.
@param member_d... | Rank a member across multiple leaderboards.
@param leaderboards [Array] Leaderboard names.
@param member [String] Member name.
@param score [float] Member score.
@param member_data [String] Optional member data. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L112-L123 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.rank_members_in | def rank_members_in(self, leaderboard_name, members_and_scores):
'''
Rank an array of members in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param members_and_scores [Array] Variable list of members and scores.
'''
for member, score ... | python | def rank_members_in(self, leaderboard_name, members_and_scores):
'''
Rank an array of members in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param members_and_scores [Array] Variable list of members and scores.
'''
for member, score ... | Rank an array of members in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param members_and_scores [Array] Variable list of members and scores. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L125-L133 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.remove_member_from | def remove_member_from(self, leaderboard_name, member):
'''
Remove the optional member data for a given member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
'''
member_score = None or self.redis_co... | python | def remove_member_from(self, leaderboard_name, member):
'''
Remove the optional member data for a given member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
'''
member_score = None or self.redis_co... | Remove the optional member data for a given member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L135-L153 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.rank_for_in | def rank_for_in(self, leaderboard_name, member):
'''
Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard.
'''
membe... | python | def rank_for_in(self, leaderboard_name, member):
'''
Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard.
'''
membe... | Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L155-L175 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.remove_members_in_score_range_in | def remove_members_in_score_range_in(
self, leaderboard_name, min_score, max_score):
'''
Remove members from the named leaderboard in a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_sco... | python | def remove_members_in_score_range_in(
self, leaderboard_name, min_score, max_score):
'''
Remove members from the named leaderboard in a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_sco... | Remove members from the named leaderboard in a given score range.
@param leaderboard_name [String] Name of the leaderboard.
@param min_score [float] Minimum score.
@param max_score [float] Maximum score. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L177-L195 |
agoragames/leaderboard-python | leaderboard/tie_ranking_leaderboard.py | TieRankingLeaderboard.expire_leaderboard_at_for | def expire_leaderboard_at_for(self, leaderboard_name, timestamp):
'''
Expire the given leaderboard at a specific UNIX timestamp. Do not use this with
leaderboards that utilize member data as there is no facility to cascade the
expiration out to the keys for the member data.
@par... | python | def expire_leaderboard_at_for(self, leaderboard_name, timestamp):
'''
Expire the given leaderboard at a specific UNIX timestamp. Do not use this with
leaderboards that utilize member data as there is no facility to cascade the
expiration out to the keys for the member data.
@par... | Expire the given leaderboard at a specific UNIX timestamp. Do not use this with
leaderboards that utilize member data as there is no facility to cascade the
expiration out to the keys for the member data.
@param leaderboard_name [String] Name of the leaderboard.
@param timestamp [int] U... | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/tie_ranking_leaderboard.py#L212-L226 |
agoragames/leaderboard-python | leaderboard/competition_ranking_leaderboard.py | CompetitionRankingLeaderboard.rank_for_in | def rank_for_in(self, leaderboard_name, member):
'''
Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard.
'''
membe... | python | def rank_for_in(self, leaderboard_name, member):
'''
Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard.
'''
membe... | Retrieve the rank for a member in the named leaderboard.
@param leaderboard_name [String] Name of the leaderboard.
@param member [String] Member name.
@return the rank for a member in the leaderboard. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/competition_ranking_leaderboard.py#L8-L28 |
agoragames/leaderboard-python | leaderboard/competition_ranking_leaderboard.py | CompetitionRankingLeaderboard.score_and_rank_for_in | def score_and_rank_for_in(self, leaderboard_name, member):
'''
Retrieve the score and rank for a member in the named leaderboard.
@param leaderboard_name [String]Name of the leaderboard.
@param member [String] Member name.
@return the score and rank for a member in the named lea... | python | def score_and_rank_for_in(self, leaderboard_name, member):
'''
Retrieve the score and rank for a member in the named leaderboard.
@param leaderboard_name [String]Name of the leaderboard.
@param member [String] Member name.
@return the score and rank for a member in the named lea... | Retrieve the score and rank for a member in the named leaderboard.
@param leaderboard_name [String]Name of the leaderboard.
@param member [String] Member name.
@return the score and rank for a member in the named leaderboard as a Hash. | https://github.com/agoragames/leaderboard-python/blob/ec309859b197a751ac0322374b36d134d8c5522f/leaderboard/competition_ranking_leaderboard.py#L30-L66 |
exoscale/cs | cs/client.py | check_key | def check_key(key, allowed):
"""
Validate that the specified key is allowed according the provided
list of patterns.
"""
if key in allowed:
return True
for pattern in allowed:
if fnmatch(key, pattern):
return True
return False | python | def check_key(key, allowed):
"""
Validate that the specified key is allowed according the provided
list of patterns.
"""
if key in allowed:
return True
for pattern in allowed:
if fnmatch(key, pattern):
return True
return False | Validate that the specified key is allowed according the provided
list of patterns. | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L78-L91 |
exoscale/cs | cs/client.py | cs_encode | def cs_encode(s):
"""Encode URI component like CloudStack would do before signing.
java.net.URLEncoder.encode(s).replace('+', '%20')
"""
if PY2 and isinstance(s, text_type):
s = s.encode("utf-8")
return quote(s, safe="*") | python | def cs_encode(s):
"""Encode URI component like CloudStack would do before signing.
java.net.URLEncoder.encode(s).replace('+', '%20')
"""
if PY2 and isinstance(s, text_type):
s = s.encode("utf-8")
return quote(s, safe="*") | Encode URI component like CloudStack would do before signing.
java.net.URLEncoder.encode(s).replace('+', '%20') | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L94-L101 |
exoscale/cs | cs/client.py | transform | def transform(params):
"""
Transforms an heterogeneous map of params into a CloudStack
ready mapping of parameter to values.
It handles lists and dicts.
>>> p = {"a": 1, "b": "foo", "c": ["eggs", "spam"], "d": {"key": "value"}}
>>> transform(p)
>>> print(p)
{'a': '1', 'b': 'foo', 'c': ... | python | def transform(params):
"""
Transforms an heterogeneous map of params into a CloudStack
ready mapping of parameter to values.
It handles lists and dicts.
>>> p = {"a": 1, "b": "foo", "c": ["eggs", "spam"], "d": {"key": "value"}}
>>> transform(p)
>>> print(p)
{'a': '1', 'b': 'foo', 'c': ... | Transforms an heterogeneous map of params into a CloudStack
ready mapping of parameter to values.
It handles lists and dicts.
>>> p = {"a": 1, "b": "foo", "c": ["eggs", "spam"], "d": {"key": "value"}}
>>> transform(p)
>>> print(p)
{'a': '1', 'b': 'foo', 'c': 'eggs,spam', 'd[0].key': 'value'} | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L104-L143 |
exoscale/cs | cs/client.py | read_config | def read_config(ini_group=None):
"""
Read the configuration from the environment, or config.
First it try to go for the environment, then it overrides
those with the cloudstack.ini file.
"""
env_conf = dict(DEFAULT_CONFIG)
for key in REQUIRED_CONFIG_KEYS.union(ALLOWED_CONFIG_KEYS):
... | python | def read_config(ini_group=None):
"""
Read the configuration from the environment, or config.
First it try to go for the environment, then it overrides
those with the cloudstack.ini file.
"""
env_conf = dict(DEFAULT_CONFIG)
for key in REQUIRED_CONFIG_KEYS.union(ALLOWED_CONFIG_KEYS):
... | Read the configuration from the environment, or config.
First it try to go for the environment, then it overrides
those with the cloudstack.ini file. | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L473-L513 |
exoscale/cs | cs/client.py | CloudStack._response_value | def _response_value(self, response, json=True):
"""Parses the HTTP response as a the cloudstack value.
It throws an exception if the server didn't answer with a 200.
"""
if json:
contentType = response.headers.get("Content-Type", "")
if not contentType.startswith... | python | def _response_value(self, response, json=True):
"""Parses the HTTP response as a the cloudstack value.
It throws an exception if the server didn't answer with a 200.
"""
if json:
contentType = response.headers.get("Content-Type", "")
if not contentType.startswith... | Parses the HTTP response as a the cloudstack value.
It throws an exception if the server didn't answer with a 200. | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L289-L332 |
exoscale/cs | cs/client.py | CloudStack._jobresult | def _jobresult(self, jobid, json=True, headers=None):
"""Poll the async job result.
To be run via in a Thread, the result is put within
the result list which is a hack.
"""
failures = 0
total_time = self.job_timeout or 2**30
remaining = timedelta(seconds=total_t... | python | def _jobresult(self, jobid, json=True, headers=None):
"""Poll the async job result.
To be run via in a Thread, the result is put within
the result list which is a hack.
"""
failures = 0
total_time = self.job_timeout or 2**30
remaining = timedelta(seconds=total_t... | Poll the async job result.
To be run via in a Thread, the result is put within
the result list which is a hack. | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L334-L414 |
exoscale/cs | cs/client.py | CloudStack._sign | def _sign(self, data):
"""
Compute a signature string according to the CloudStack
signature method (hmac/sha1).
"""
# Python2/3 urlencode aren't good enough for this task.
params = "&".join(
"=".join((key, cs_encode(value)))
for key, value in sort... | python | def _sign(self, data):
"""
Compute a signature string according to the CloudStack
signature method (hmac/sha1).
"""
# Python2/3 urlencode aren't good enough for this task.
params = "&".join(
"=".join((key, cs_encode(value)))
for key, value in sort... | Compute a signature string according to the CloudStack
signature method (hmac/sha1). | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/client.py#L416-L433 |
exoscale/cs | cs/__init__.py | _format_json | def _format_json(data, theme):
"""Pretty print a dict as a JSON, with colors if pygments is present."""
output = json.dumps(data, indent=2, sort_keys=True)
if pygments and sys.stdout.isatty():
style = get_style_by_name(theme)
formatter = Terminal256Formatter(style=style)
return pygm... | python | def _format_json(data, theme):
"""Pretty print a dict as a JSON, with colors if pygments is present."""
output = json.dumps(data, indent=2, sort_keys=True)
if pygments and sys.stdout.isatty():
style = get_style_by_name(theme)
formatter = Terminal256Formatter(style=style)
return pygm... | Pretty print a dict as a JSON, with colors if pygments is present. | https://github.com/exoscale/cs/blob/3a0b05559c1f9f3c5bda34920d4497dfd8b9290a/cs/__init__.py#L35-L44 |
nats-io/python-nats | nats/protocol/parser.py | Parser.parse | def parse(self, data=b''):
"""
Parses the wire protocol from NATS for the client
and dispatches the subscription callbacks.
"""
self.buf.extend(data)
while self.buf:
if self.state == AWAITING_CONTROL_LINE:
msg = MSG_RE.match(self.buf)
... | python | def parse(self, data=b''):
"""
Parses the wire protocol from NATS for the client
and dispatches the subscription callbacks.
"""
self.buf.extend(data)
while self.buf:
if self.state == AWAITING_CONTROL_LINE:
msg = MSG_RE.match(self.buf)
... | Parses the wire protocol from NATS for the client
and dispatches the subscription callbacks. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/protocol/parser.py#L74-L154 |
nats-io/python-nats | nats/io/client.py | Client.connect | def connect(self,
servers=["nats://127.0.0.1:4222"],
loop=None,
# 'io_loop' and 'loop' are the same, but we have
# both params to be consistent with asyncio client.
io_loop=None,
# Event Callbacks
error_cb=N... | python | def connect(self,
servers=["nats://127.0.0.1:4222"],
loop=None,
# 'io_loop' and 'loop' are the same, but we have
# both params to be consistent with asyncio client.
io_loop=None,
# Event Callbacks
error_cb=N... | Establishes a connection to a NATS server.
Examples:
# Configure pool of NATS servers.
nc = nats.io.client.Client()
yield nc.connect({ 'servers': ['nats://192.168.1.10:4222', 'nats://192.168.2.10:4222'] })
# User and pass are to be passed on the uri to authenticate.
... | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L206-L348 |
nats-io/python-nats | nats/io/client.py | Client._server_connect | def _server_connect(self, s):
"""
Sets up a TCP connection to the server.
"""
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.setblocking(0)
self._socket.settimeout(1.0)
if self.options["tcp_nodelay"]:
self._socket.setsoc... | python | def _server_connect(self, s):
"""
Sets up a TCP connection to the server.
"""
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self._socket.setblocking(0)
self._socket.settimeout(1.0)
if self.options["tcp_nodelay"]:
self._socket.setsoc... | Sets up a TCP connection to the server. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L351-L373 |
nats-io/python-nats | nats/io/client.py | Client.connect_command | def connect_command(self):
'''
Generates a JSON string with the params to be used
when sending CONNECT to the server.
->> CONNECT {"verbose": false, "pedantic": false, "lang": "python2" }
'''
options = {
"verbose": self.options["verbose"],
"ped... | python | def connect_command(self):
'''
Generates a JSON string with the params to be used
when sending CONNECT to the server.
->> CONNECT {"verbose": false, "pedantic": false, "lang": "python2" }
'''
options = {
"verbose": self.options["verbose"],
"ped... | Generates a JSON string with the params to be used
when sending CONNECT to the server.
->> CONNECT {"verbose": false, "pedantic": false, "lang": "python2" } | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L383-L418 |
nats-io/python-nats | nats/io/client.py | Client.send_command | def send_command(self, cmd, priority=False):
"""
Flushes a command to the server as a bytes payload.
"""
if priority:
self._pending.insert(0, cmd)
else:
self._pending.append(cmd)
self._pending_size += len(cmd)
if self._pending_size > DEFAU... | python | def send_command(self, cmd, priority=False):
"""
Flushes a command to the server as a bytes payload.
"""
if priority:
self._pending.insert(0, cmd)
else:
self._pending.append(cmd)
self._pending_size += len(cmd)
if self._pending_size > DEFAU... | Flushes a command to the server as a bytes payload. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L421-L432 |
nats-io/python-nats | nats/io/client.py | Client.publish_request | def publish_request(self, subject, reply, payload):
"""
Publishes a message tagging it with a reply subscription
which can be used by those receiving the message to respond:
->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5
->> MSG_PAYLOAD: world
<<- MSG hello 2 _... | python | def publish_request(self, subject, reply, payload):
"""
Publishes a message tagging it with a reply subscription
which can be used by those receiving the message to respond:
->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5
->> MSG_PAYLOAD: world
<<- MSG hello 2 _... | Publishes a message tagging it with a reply subscription
which can be used by those receiving the message to respond:
->> PUB hello _INBOX.2007314fe0fcb2cdc2a2914c1 5
->> MSG_PAYLOAD: world
<<- MSG hello 2 _INBOX.2007314fe0fcb2cdc2a2914c1 5 | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L465-L482 |
nats-io/python-nats | nats/io/client.py | Client._flush_timeout | def _flush_timeout(self, timeout):
"""
Takes a timeout and sets up a future which will return True
once the server responds back otherwise raise a TimeoutError.
"""
future = tornado.concurrent.Future()
yield self._send_ping(future)
try:
result = yield ... | python | def _flush_timeout(self, timeout):
"""
Takes a timeout and sets up a future which will return True
once the server responds back otherwise raise a TimeoutError.
"""
future = tornado.concurrent.Future()
yield self._send_ping(future)
try:
result = yield ... | Takes a timeout and sets up a future which will return True
once the server responds back otherwise raise a TimeoutError. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L495-L514 |
nats-io/python-nats | nats/io/client.py | Client.request | def request(self, subject, payload, timeout=0.5, expected=1, cb=None):
"""
Implements the request/response pattern via pub/sub using an
unique reply subject and an async subscription.
If cb is None, then it will wait and return a single message
using the new request/response sty... | python | def request(self, subject, payload, timeout=0.5, expected=1, cb=None):
"""
Implements the request/response pattern via pub/sub using an
unique reply subject and an async subscription.
If cb is None, then it will wait and return a single message
using the new request/response sty... | Implements the request/response pattern via pub/sub using an
unique reply subject and an async subscription.
If cb is None, then it will wait and return a single message
using the new request/response style that is less chatty over
the network.
->> SUB _INBOX.BF6zPVxvScfXGd4V... | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L517-L629 |
nats-io/python-nats | nats/io/client.py | Client.timed_request | def timed_request(self, subject, payload, timeout=0.5):
"""
Implements the request/response pattern via pub/sub
using an ephemeral subscription which will be published
with a limited interest of 1 reply returning the response
or raising a Timeout error.
->> SUB _INBOX.... | python | def timed_request(self, subject, payload, timeout=0.5):
"""
Implements the request/response pattern via pub/sub
using an ephemeral subscription which will be published
with a limited interest of 1 reply returning the response
or raising a Timeout error.
->> SUB _INBOX.... | Implements the request/response pattern via pub/sub
using an ephemeral subscription which will be published
with a limited interest of 1 reply returning the response
or raising a Timeout error.
->> SUB _INBOX.E9jM2HTirMXDMXPROSQmSd 90
->> UNSUB 90 1
->> PUB hello _... | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L632-L656 |
nats-io/python-nats | nats/io/client.py | Client.subscribe | def subscribe(
self,
subject="",
queue="",
cb=None,
future=None,
max_msgs=0,
is_async=False,
pending_msgs_limit=DEFAULT_SUB_PENDING_MSGS_LIMIT,
pending_bytes_limit=DEFAULT_SUB_PENDING_BYTES_LIMIT,
):
... | python | def subscribe(
self,
subject="",
queue="",
cb=None,
future=None,
max_msgs=0,
is_async=False,
pending_msgs_limit=DEFAULT_SUB_PENDING_MSGS_LIMIT,
pending_bytes_limit=DEFAULT_SUB_PENDING_BYTES_LIMIT,
):
... | Sends a SUB command to the server. Takes a queue parameter
which can be used in case of distributed queues or left empty
if it is not the case, and a callback that will be dispatched
message for processing them. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L659-L756 |
nats-io/python-nats | nats/io/client.py | Client.subscribe_async | def subscribe_async(self, subject, **kwargs):
"""
Schedules callback from subscription to be processed asynchronously
in the next iteration of the loop.
"""
kwargs["is_async"] = True
sid = yield self.subscribe(subject, **kwargs)
raise tornado.gen.Return(sid) | python | def subscribe_async(self, subject, **kwargs):
"""
Schedules callback from subscription to be processed asynchronously
in the next iteration of the loop.
"""
kwargs["is_async"] = True
sid = yield self.subscribe(subject, **kwargs)
raise tornado.gen.Return(sid) | Schedules callback from subscription to be processed asynchronously
in the next iteration of the loop. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L759-L766 |
nats-io/python-nats | nats/io/client.py | Client.unsubscribe | def unsubscribe(self, ssid, max_msgs=0):
"""
Takes a subscription sequence id and removes the subscription
from the client, optionally after receiving more than max_msgs,
and unsubscribes immediatedly.
"""
if self.is_closed:
raise ErrConnectionClosed
... | python | def unsubscribe(self, ssid, max_msgs=0):
"""
Takes a subscription sequence id and removes the subscription
from the client, optionally after receiving more than max_msgs,
and unsubscribes immediatedly.
"""
if self.is_closed:
raise ErrConnectionClosed
... | Takes a subscription sequence id and removes the subscription
from the client, optionally after receiving more than max_msgs,
and unsubscribes immediatedly. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L769-L795 |
nats-io/python-nats | nats/io/client.py | Client.auto_unsubscribe | def auto_unsubscribe(self, sid, limit=1):
"""
Sends an UNSUB command to the server. Unsubscribe is one of the basic building
blocks in order to be able to define request/response semantics via pub/sub
by announcing the server limited interest a priori.
"""
if self.is_dra... | python | def auto_unsubscribe(self, sid, limit=1):
"""
Sends an UNSUB command to the server. Unsubscribe is one of the basic building
blocks in order to be able to define request/response semantics via pub/sub
by announcing the server limited interest a priori.
"""
if self.is_dra... | Sends an UNSUB command to the server. Unsubscribe is one of the basic building
blocks in order to be able to define request/response semantics via pub/sub
by announcing the server limited interest a priori. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L812-L820 |
nats-io/python-nats | nats/io/client.py | Client._process_ping | def _process_ping(self):
"""
The server will be periodically sending a PING, and if the the client
does not reply a PONG back a number of times, it will close the connection
sending an `-ERR 'Stale Connection'` error.
"""
yield self.send_command(PONG_PROTO)
if sel... | python | def _process_ping(self):
"""
The server will be periodically sending a PING, and if the the client
does not reply a PONG back a number of times, it will close the connection
sending an `-ERR 'Stale Connection'` error.
"""
yield self.send_command(PONG_PROTO)
if sel... | The server will be periodically sending a PING, and if the the client
does not reply a PONG back a number of times, it will close the connection
sending an `-ERR 'Stale Connection'` error. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L833-L841 |
nats-io/python-nats | nats/io/client.py | Client._process_msg | def _process_msg(self, sid, subject, reply, data):
"""
Dispatches the received message to the stored subscription.
It first tries to detect whether the message should be
dispatched to a passed callback. In case there was not
a callback, then it tries to set the message into a fu... | python | def _process_msg(self, sid, subject, reply, data):
"""
Dispatches the received message to the stored subscription.
It first tries to detect whether the message should be
dispatched to a passed callback. In case there was not
a callback, then it tries to set the message into a fu... | Dispatches the received message to the stored subscription.
It first tries to detect whether the message should be
dispatched to a passed callback. In case there was not
a callback, then it tries to set the message into a future. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L863-L906 |
nats-io/python-nats | nats/io/client.py | Client._process_connect_init | def _process_connect_init(self):
"""
Handles the initial part of the NATS protocol, moving from
the (RE)CONNECTING to CONNECTED states when establishing
a connection with the server.
"""
# INFO {...}
line = yield self.io.read_until(_CRLF_, max_bytes=None)
... | python | def _process_connect_init(self):
"""
Handles the initial part of the NATS protocol, moving from
the (RE)CONNECTING to CONNECTED states when establishing
a connection with the server.
"""
# INFO {...}
line = yield self.io.read_until(_CRLF_, max_bytes=None)
... | Handles the initial part of the NATS protocol, moving from
the (RE)CONNECTING to CONNECTED states when establishing
a connection with the server. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L909-L981 |
nats-io/python-nats | nats/io/client.py | Client._process_info | def _process_info(self, info_line):
"""
Process INFO lines sent by the server to reconfigure client
with latest updates from cluster to enable server discovery.
"""
info = tornado.escape.json_decode(info_line.decode())
if 'connect_urls' in info:
if info['conn... | python | def _process_info(self, info_line):
"""
Process INFO lines sent by the server to reconfigure client
with latest updates from cluster to enable server discovery.
"""
info = tornado.escape.json_decode(info_line.decode())
if 'connect_urls' in info:
if info['conn... | Process INFO lines sent by the server to reconfigure client
with latest updates from cluster to enable server discovery. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L983-L1009 |
nats-io/python-nats | nats/io/client.py | Client._next_server | def _next_server(self):
"""
Chooses next available server to connect.
"""
if self.options["dont_randomize"]:
server = self._server_pool.pop(0)
self._server_pool.append(server)
else:
shuffle(self._server_pool)
s = None
for serve... | python | def _next_server(self):
"""
Chooses next available server to connect.
"""
if self.options["dont_randomize"]:
server = self._server_pool.pop(0)
self._server_pool.append(server)
else:
shuffle(self._server_pool)
s = None
for serve... | Chooses next available server to connect. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1011-L1029 |
nats-io/python-nats | nats/io/client.py | Client._process_op_err | def _process_op_err(self, err=None):
"""
Process errors which occured while reading/parsing the protocol.
It attempts to reconnect if `allow_reconnect' is enabled.
"""
if self.is_connecting or self.is_closed or self.is_reconnecting:
return
if self.options["al... | python | def _process_op_err(self, err=None):
"""
Process errors which occured while reading/parsing the protocol.
It attempts to reconnect if `allow_reconnect' is enabled.
"""
if self.is_connecting or self.is_closed or self.is_reconnecting:
return
if self.options["al... | Process errors which occured while reading/parsing the protocol.
It attempts to reconnect if `allow_reconnect' is enabled. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1056-L1071 |
nats-io/python-nats | nats/io/client.py | Client._select_next_server | def _select_next_server(self):
"""
Looks up in the server pool for an available server
and attempts to connect.
"""
# Continue trying to connect until there is an available server
# or bail in case there are no more available servers.
while True:
if l... | python | def _select_next_server(self):
"""
Looks up in the server pool for an available server
and attempts to connect.
"""
# Continue trying to connect until there is an available server
# or bail in case there are no more available servers.
while True:
if l... | Looks up in the server pool for an available server
and attempts to connect. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1177-L1216 |
nats-io/python-nats | nats/io/client.py | Client._close | def _close(self, status, do_callbacks=True):
"""
Takes the status on which it should leave the connection
and an optional boolean parameter to dispatch the disconnected
and close callbacks if there are any.
"""
if self.is_closed:
self._status = status
... | python | def _close(self, status, do_callbacks=True):
"""
Takes the status on which it should leave the connection
and an optional boolean parameter to dispatch the disconnected
and close callbacks if there are any.
"""
if self.is_closed:
self._status = status
... | Takes the status on which it should leave the connection
and an optional boolean parameter to dispatch the disconnected
and close callbacks if there are any. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1227-L1257 |
nats-io/python-nats | nats/io/client.py | Client.drain | def drain(self, sid=None):
"""
Drain will put a connection into a drain state. All subscriptions will
immediately be put into a drain state. Upon completion, the publishers
will be drained and can not publish any additional messages. Upon draining
of the publishers, the connectio... | python | def drain(self, sid=None):
"""
Drain will put a connection into a drain state. All subscriptions will
immediately be put into a drain state. Upon completion, the publishers
will be drained and can not publish any additional messages. Upon draining
of the publishers, the connectio... | Drain will put a connection into a drain state. All subscriptions will
immediately be put into a drain state. Upon completion, the publishers
will be drained and can not publish any additional messages. Upon draining
of the publishers, the connection will be closed. Use the `closed_cb'
o... | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1260-L1305 |
nats-io/python-nats | nats/io/client.py | Client._process_err | def _process_err(self, err=None):
"""
Stores the last received error from the server and dispatches the error callback.
"""
self.stats['errors_received'] += 1
if err == "'Authorization Violation'":
self._err = ErrAuthorization
elif err == "'Slow Consumer'":
... | python | def _process_err(self, err=None):
"""
Stores the last received error from the server and dispatches the error callback.
"""
self.stats['errors_received'] += 1
if err == "'Authorization Violation'":
self._err = ErrAuthorization
elif err == "'Slow Consumer'":
... | Stores the last received error from the server and dispatches the error callback. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1338-L1354 |
nats-io/python-nats | nats/io/client.py | Client._read_loop | def _read_loop(self, data=''):
"""
Read loop for gathering bytes from the server in a buffer
of maximum MAX_CONTROL_LINE_SIZE, then received bytes are streamed
to the parsing callback for processing.
"""
while True:
if not self.is_connected or self.is_connecti... | python | def _read_loop(self, data=''):
"""
Read loop for gathering bytes from the server in a buffer
of maximum MAX_CONTROL_LINE_SIZE, then received bytes are streamed
to the parsing callback for processing.
"""
while True:
if not self.is_connected or self.is_connecti... | Read loop for gathering bytes from the server in a buffer
of maximum MAX_CONTROL_LINE_SIZE, then received bytes are streamed
to the parsing callback for processing. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1391-L1410 |
nats-io/python-nats | nats/io/client.py | Client._flusher_loop | def _flusher_loop(self):
"""
Coroutine which continuously tries to consume pending commands
and then flushes them to the socket.
"""
while True:
pending = []
pending_size = 0
try:
# Block and wait for the flusher to be kicked
... | python | def _flusher_loop(self):
"""
Coroutine which continuously tries to consume pending commands
and then flushes them to the socket.
"""
while True:
pending = []
pending_size = 0
try:
# Block and wait for the flusher to be kicked
... | Coroutine which continuously tries to consume pending commands
and then flushes them to the socket. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1413-L1444 |
nats-io/python-nats | nats/io/client.py | Client._end_flusher_loop | def _end_flusher_loop(self):
"""
Let flusher_loop coroutine quit - useful when disconnecting.
"""
if not self.is_connected or self.is_connecting or self.io.closed():
if self._flush_queue is not None and self._flush_queue.empty():
self._flush_pending(check_conn... | python | def _end_flusher_loop(self):
"""
Let flusher_loop coroutine quit - useful when disconnecting.
"""
if not self.is_connected or self.is_connecting or self.io.closed():
if self._flush_queue is not None and self._flush_queue.empty():
self._flush_pending(check_conn... | Let flusher_loop coroutine quit - useful when disconnecting. | https://github.com/nats-io/python-nats/blob/4a409319c409e7e55ce8377b64b406375c5f455b/nats/io/client.py#L1447-L1454 |
Scout24/yamlreader | src/main/python/yamlreader/yamlreader.py | data_merge | def data_merge(a, b):
"""merges b into a and return merged result
based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge
and extended to also merge arrays and to replace the content of keys with the same name
NOTE: tuples and arbitrary objects are not handled as i... | python | def data_merge(a, b):
"""merges b into a and return merged result
based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge
and extended to also merge arrays and to replace the content of keys with the same name
NOTE: tuples and arbitrary objects are not handled as i... | merges b into a and return merged result
based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge
and extended to also merge arrays and to replace the content of keys with the same name
NOTE: tuples and arbitrary objects are not handled as it is totally ambiguous what s... | https://github.com/Scout24/yamlreader/blob/31b1adc8391447f7eca56755cb467e3cf34da631/src/main/python/yamlreader/yamlreader.py#L24-L59 |
Scout24/yamlreader | src/main/python/yamlreader/yamlreader.py | yaml_load | def yaml_load(source, defaultdata=NO_DEFAULT):
"""merge YAML data from files found in source
Always returns a dict. The YAML files are expected to contain some kind of
key:value structures, possibly deeply nested. When merging, lists are
appended and dict keys are replaced. The YAML files are read with... | python | def yaml_load(source, defaultdata=NO_DEFAULT):
"""merge YAML data from files found in source
Always returns a dict. The YAML files are expected to contain some kind of
key:value structures, possibly deeply nested. When merging, lists are
appended and dict keys are replaced. The YAML files are read with... | merge YAML data from files found in source
Always returns a dict. The YAML files are expected to contain some kind of
key:value structures, possibly deeply nested. When merging, lists are
appended and dict keys are replaced. The YAML files are read with the
yaml.safe_load function.
source can be a... | https://github.com/Scout24/yamlreader/blob/31b1adc8391447f7eca56755cb467e3cf34da631/src/main/python/yamlreader/yamlreader.py#L62-L117 |
MaayanLab/clustergrammer-py | clustergrammer/__init__.py | Network.widget | def widget(self, which_viz='viz'):
'''
Generate a widget visualization using the widget. The export_viz_to_widget
method passes the visualization JSON to the instantiated widget, which is
returned and visualized on the front-end.
'''
if hasattr(self, 'widget_class') == True:
self.widget_in... | python | def widget(self, which_viz='viz'):
'''
Generate a widget visualization using the widget. The export_viz_to_widget
method passes the visualization JSON to the instantiated widget, which is
returned and visualized on the front-end.
'''
if hasattr(self, 'widget_class') == True:
self.widget_in... | Generate a widget visualization using the widget. The export_viz_to_widget
method passes the visualization JSON to the instantiated widget, which is
returned and visualized on the front-end. | https://github.com/MaayanLab/clustergrammer-py/blob/c7c98c9910db7c296d513fa4a32f271b54b89fdd/clustergrammer/__init__.py#L203-L215 |
seatgeek/businesstime | businesstime/__init__.py | BusinessTime.iterdays | def iterdays(self, d1, d2):
"""
Date iterator returning dates in d1 <= x < d2
"""
curr = datetime.datetime.combine(d1, datetime.time())
end = datetime.datetime.combine(d2, datetime.time())
if d1.date() == d2.date():
yield curr
return
while ... | python | def iterdays(self, d1, d2):
"""
Date iterator returning dates in d1 <= x < d2
"""
curr = datetime.datetime.combine(d1, datetime.time())
end = datetime.datetime.combine(d2, datetime.time())
if d1.date() == d2.date():
yield curr
return
while ... | Date iterator returning dates in d1 <= x < d2 | https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/__init__.py#L59-L70 |
seatgeek/businesstime | businesstime/__init__.py | BusinessTime.iterweekdays | def iterweekdays(self, d1, d2):
"""
Date iterator returning dates in d1 <= x < d2, excluding weekends
"""
for dt in self.iterdays(d1, d2):
if not self.isweekend(dt):
yield dt | python | def iterweekdays(self, d1, d2):
"""
Date iterator returning dates in d1 <= x < d2, excluding weekends
"""
for dt in self.iterdays(d1, d2):
if not self.isweekend(dt):
yield dt | Date iterator returning dates in d1 <= x < d2, excluding weekends | https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/__init__.py#L72-L78 |
seatgeek/businesstime | businesstime/__init__.py | BusinessTime.iterbusinessdays | def iterbusinessdays(self, d1, d2):
"""
Date iterator returning dates in d1 <= x < d2, excluding weekends and holidays
"""
assert d2 >= d1
if d1.date() == d2.date() and d2.time() < self.business_hours[0]:
return
first = True
for dt in self.iterdays(d1,... | python | def iterbusinessdays(self, d1, d2):
"""
Date iterator returning dates in d1 <= x < d2, excluding weekends and holidays
"""
assert d2 >= d1
if d1.date() == d2.date() and d2.time() < self.business_hours[0]:
return
first = True
for dt in self.iterdays(d1,... | Date iterator returning dates in d1 <= x < d2, excluding weekends and holidays | https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/__init__.py#L80-L94 |
seatgeek/businesstime | businesstime/__init__.py | BusinessTime.businesstimedelta | def businesstimedelta(self, d1, d2):
"""
Returns a datetime.timedelta with the number of full business days
and business time between d1 and d2
"""
if d1 > d2:
d1, d2, timedelta_direction = d2, d1, -1
else:
timedelta_direction = 1
business... | python | def businesstimedelta(self, d1, d2):
"""
Returns a datetime.timedelta with the number of full business days
and business time between d1 and d2
"""
if d1 > d2:
d1, d2, timedelta_direction = d2, d1, -1
else:
timedelta_direction = 1
business... | Returns a datetime.timedelta with the number of full business days
and business time between d1 and d2 | https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/__init__.py#L127-L178 |
seatgeek/businesstime | businesstime/__init__.py | BusinessTime.businesstime_hours | def businesstime_hours(self, d1, d2):
"""
Returns a datetime.timedelta of business hours between d1 and d2,
based on the length of the businessday
"""
open_hours = self.open_hours.seconds / 3600
btd = self.businesstimedelta(d1, d2)
btd_hours = btd.seconds / 3600
... | python | def businesstime_hours(self, d1, d2):
"""
Returns a datetime.timedelta of business hours between d1 and d2,
based on the length of the businessday
"""
open_hours = self.open_hours.seconds / 3600
btd = self.businesstimedelta(d1, d2)
btd_hours = btd.seconds / 3600
... | Returns a datetime.timedelta of business hours between d1 and d2,
based on the length of the businessday | https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/__init__.py#L180-L188 |
seatgeek/businesstime | businesstime/holidays/usa.py | USFederalHolidays._day_rule_matches | def _day_rule_matches(self, rule, dt):
"""
Day-of-month-specific US federal holidays that fall on Sat or Sun are
observed on Fri or Mon respectively. Note that this method considers
both the actual holiday and the day of observance to be holidays.
"""
if dt.weekday() == 4... | python | def _day_rule_matches(self, rule, dt):
"""
Day-of-month-specific US federal holidays that fall on Sat or Sun are
observed on Fri or Mon respectively. Note that this method considers
both the actual holiday and the day of observance to be holidays.
"""
if dt.weekday() == 4... | Day-of-month-specific US federal holidays that fall on Sat or Sun are
observed on Fri or Mon respectively. Note that this method considers
both the actual holiday and the day of observance to be holidays. | https://github.com/seatgeek/businesstime/blob/3f3efd8aed7fc98539c54543bc05ab83587bb180/businesstime/holidays/usa.py#L27-L41 |
repobee/repobee-plug | repobee_plug/exthooks.py | CloneHook.act_on_cloned_repo | def act_on_cloned_repo(self, path: Union[str, pathlib.Path],
api) -> Optional[HookResult]:
"""Do something with a cloned repo.
Args:
path: Path to the repo.
api: An instance of :py:class:`repobee.github_api.GitHubAPI`.
Returns:
opt... | python | def act_on_cloned_repo(self, path: Union[str, pathlib.Path],
api) -> Optional[HookResult]:
"""Do something with a cloned repo.
Args:
path: Path to the repo.
api: An instance of :py:class:`repobee.github_api.GitHubAPI`.
Returns:
opt... | Do something with a cloned repo.
Args:
path: Path to the repo.
api: An instance of :py:class:`repobee.github_api.GitHubAPI`.
Returns:
optionally returns a HookResult namedtuple for reporting the
outcome of the hook. May also return None, in which case no... | https://github.com/repobee/repobee-plug/blob/5ebaac02c69fce90aea73f9c3c4b3e15d34d1eb7/repobee_plug/exthooks.py#L26-L38 |
repobee/repobee-plug | repobee_plug/corehooks.py | PeerReviewHook.generate_review_allocations | def generate_review_allocations(
self, master_repo_name: str, students: Iterable[str],
num_reviews: int,
review_team_name_function: Callable[[str, str], str]
) -> Mapping[str, List[str]]:
"""Generate a (peer_review_team -> reviewers) mapping for each student
repos... | python | def generate_review_allocations(
self, master_repo_name: str, students: Iterable[str],
num_reviews: int,
review_team_name_function: Callable[[str, str], str]
) -> Mapping[str, List[str]]:
"""Generate a (peer_review_team -> reviewers) mapping for each student
repos... | Generate a (peer_review_team -> reviewers) mapping for each student
repository (i.e. <student>-<master_repo_name>), where len(reviewers) =
num_reviews.
review_team_name_function should be used to generate review team names.
It should be called like:
.. code-block:: python
... | https://github.com/repobee/repobee-plug/blob/5ebaac02c69fce90aea73f9c3c4b3e15d34d1eb7/repobee_plug/corehooks.py#L23-L54 |
pickleshare/pickleshare | pickleshare.py | PickleShareDB.hset | def hset(self, hashroot, key, value):
""" hashed set """
hroot = self.root / hashroot
if not hroot.is_dir():
hroot.mkdir()
hfile = hroot / gethashfile(key)
d = self.get(hfile, {})
d.update( {key : value})
self[hfile] = d | python | def hset(self, hashroot, key, value):
""" hashed set """
hroot = self.root / hashroot
if not hroot.is_dir():
hroot.mkdir()
hfile = hroot / gethashfile(key)
d = self.get(hfile, {})
d.update( {key : value})
self[hfile] = d | hashed set | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L125-L133 |
pickleshare/pickleshare | pickleshare.py | PickleShareDB.hget | def hget(self, hashroot, key, default = _sentinel, fast_only = True):
""" hashed get """
hroot = self.root / hashroot
hfile = hroot / gethashfile(key)
d = self.get(hfile, _sentinel )
#print "got dict",d,"from",hfile
if d is _sentinel:
if fast_only:
... | python | def hget(self, hashroot, key, default = _sentinel, fast_only = True):
""" hashed get """
hroot = self.root / hashroot
hfile = hroot / gethashfile(key)
d = self.get(hfile, _sentinel )
#print "got dict",d,"from",hfile
if d is _sentinel:
if fast_only:
... | hashed get | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L137-L154 |
pickleshare/pickleshare | pickleshare.py | PickleShareDB.hcompress | def hcompress(self, hashroot):
""" Compress category 'hashroot', so hset is fast again
hget will fail if fast_only is True for compressed items (that were
hset before hcompress).
"""
hfiles = self.keys(hashroot + "/*")
all = {}
for f in hfiles:
# pri... | python | def hcompress(self, hashroot):
""" Compress category 'hashroot', so hset is fast again
hget will fail if fast_only is True for compressed items (that were
hset before hcompress).
"""
hfiles = self.keys(hashroot + "/*")
all = {}
for f in hfiles:
# pri... | Compress category 'hashroot', so hset is fast again
hget will fail if fast_only is True for compressed items (that were
hset before hcompress). | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L179-L198 |
pickleshare/pickleshare | pickleshare.py | PickleShareDB.keys | def keys(self, globpat = None):
""" All keys in DB, or all keys matching a glob"""
if globpat is None:
files = self.root.rglob('*')
else:
files = self.root.glob(globpat)
return [self._normalized(p) for p in files if p.is_file()] | python | def keys(self, globpat = None):
""" All keys in DB, or all keys matching a glob"""
if globpat is None:
files = self.root.rglob('*')
else:
files = self.root.glob(globpat)
return [self._normalized(p) for p in files if p.is_file()] | All keys in DB, or all keys matching a glob | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L217-L224 |
pickleshare/pickleshare | pickleshare.py | PickleShareDB.uncache | def uncache(self,*items):
""" Removes all, or specified items from cache
Use this after reading a large amount of large objects
to free up memory, when you won't be needing the objects
for a while.
"""
if not items:
self.cache = {}
for it in items:
... | python | def uncache(self,*items):
""" Removes all, or specified items from cache
Use this after reading a large amount of large objects
to free up memory, when you won't be needing the objects
for a while.
"""
if not items:
self.cache = {}
for it in items:
... | Removes all, or specified items from cache
Use this after reading a large amount of large objects
to free up memory, when you won't be needing the objects
for a while. | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L232-L243 |
pickleshare/pickleshare | pickleshare.py | PickleShareDB.waitget | def waitget(self,key, maxwaittime = 60 ):
""" Wait (poll) for a key to get a value
Will wait for `maxwaittime` seconds before raising a KeyError.
The call exits normally if the `key` field in db gets a value
within the timeout period.
Use this for synchronizing different proces... | python | def waitget(self,key, maxwaittime = 60 ):
""" Wait (poll) for a key to get a value
Will wait for `maxwaittime` seconds before raising a KeyError.
The call exits normally if the `key` field in db gets a value
within the timeout period.
Use this for synchronizing different proces... | Wait (poll) for a key to get a value
Will wait for `maxwaittime` seconds before raising a KeyError.
The call exits normally if the `key` field in db gets a value
within the timeout period.
Use this for synchronizing different processes or for ensuring
that an unfortunately time... | https://github.com/pickleshare/pickleshare/blob/f7950a9a359774c0190abde8da729b1810bdf3f4/pickleshare.py#L245-L275 |
openstack/hacking | hacking/checks/comments.py | hacking_todo_format | def hacking_todo_format(physical_line, tokens):
"""Check for 'TODO()'.
OpenStack HACKING guide recommendation for TODO:
Include your name with TODOs as in "# TODO(termie)"
Okay: # TODO(sdague)
H101: # TODO fail
H101: # TODO
H101: # TODO (jogo) fail
Okay: TODO = 5
"""
# TODO(jog... | python | def hacking_todo_format(physical_line, tokens):
"""Check for 'TODO()'.
OpenStack HACKING guide recommendation for TODO:
Include your name with TODOs as in "# TODO(termie)"
Okay: # TODO(sdague)
H101: # TODO fail
H101: # TODO
H101: # TODO (jogo) fail
Okay: TODO = 5
"""
# TODO(jog... | Check for 'TODO()'.
OpenStack HACKING guide recommendation for TODO:
Include your name with TODOs as in "# TODO(termie)"
Okay: # TODO(sdague)
H101: # TODO fail
H101: # TODO
H101: # TODO (jogo) fail
Okay: TODO = 5 | https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/checks/comments.py#L24-L46 |
openstack/hacking | hacking/checks/comments.py | hacking_has_license | def hacking_has_license(physical_line, filename, lines, line_number):
"""Check for Apache 2.0 license.
H102 license header not found
"""
# don't work about init files for now
# TODO(sdague): enforce license in init file if it's not empty of content
license_found = False
# skip files that a... | python | def hacking_has_license(physical_line, filename, lines, line_number):
"""Check for Apache 2.0 license.
H102 license header not found
"""
# don't work about init files for now
# TODO(sdague): enforce license in init file if it's not empty of content
license_found = False
# skip files that a... | Check for Apache 2.0 license.
H102 license header not found | https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/checks/comments.py#L50-L71 |
openstack/hacking | hacking/checks/comments.py | hacking_has_correct_license | def hacking_has_correct_license(physical_line, filename, lines, line_number):
"""Check for Apache 2.0 license.
H103 header does not match Apache 2.0 License notice
"""
# don't work about init files for now
# TODO(sdague): enforce license in init file if it's not empty of content
# skip files t... | python | def hacking_has_correct_license(physical_line, filename, lines, line_number):
"""Check for Apache 2.0 license.
H103 header does not match Apache 2.0 License notice
"""
# don't work about init files for now
# TODO(sdague): enforce license in init file if it's not empty of content
# skip files t... | Check for Apache 2.0 license.
H103 header does not match Apache 2.0 License notice | https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/checks/comments.py#L75-L93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.