repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
MisterY/pydatum | pydatum/datum.py | Datum.set_day | def set_day(self, day: int) -> datetime:
""" Sets the day value """
self.value = self.value.replace(day=day)
return self.value | python | def set_day(self, day: int) -> datetime:
""" Sets the day value """
self.value = self.value.replace(day=day)
return self.value | [
"def",
"set_day",
"(",
"self",
",",
"day",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
".",
"replace",
"(",
"day",
"=",
"day",
")",
"return",
"self",
".",
"value"
] | Sets the day value | [
"Sets",
"the",
"day",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L146-L149 | train | 58,700 |
MisterY/pydatum | pydatum/datum.py | Datum.set_value | def set_value(self, value: datetime):
""" Sets the current value """
assert isinstance(value, datetime)
self.value = value | python | def set_value(self, value: datetime):
""" Sets the current value """
assert isinstance(value, datetime)
self.value = value | [
"def",
"set_value",
"(",
"self",
",",
"value",
":",
"datetime",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"datetime",
")",
"self",
".",
"value",
"=",
"value"
] | Sets the current value | [
"Sets",
"the",
"current",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L151-L155 | train | 58,701 |
MisterY/pydatum | pydatum/datum.py | Datum.start_of_day | def start_of_day(self) -> datetime:
""" Returns start of day """
self.value = datetime(self.value.year, self.value.month, self.value.day)
return self.value | python | def start_of_day(self) -> datetime:
""" Returns start of day """
self.value = datetime(self.value.year, self.value.month, self.value.day)
return self.value | [
"def",
"start_of_day",
"(",
"self",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"datetime",
"(",
"self",
".",
"value",
".",
"year",
",",
"self",
".",
"value",
".",
"month",
",",
"self",
".",
"value",
".",
"day",
")",
"return",
"self",
".... | Returns start of day | [
"Returns",
"start",
"of",
"day"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L157-L160 | train | 58,702 |
MisterY/pydatum | pydatum/datum.py | Datum.subtract_days | def subtract_days(self, days: int) -> datetime:
""" Subtracts dates from the given value """
self.value = self.value - relativedelta(days=days)
return self.value | python | def subtract_days(self, days: int) -> datetime:
""" Subtracts dates from the given value """
self.value = self.value - relativedelta(days=days)
return self.value | [
"def",
"subtract_days",
"(",
"self",
",",
"days",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"-",
"relativedelta",
"(",
"days",
"=",
"days",
")",
"return",
"self",
".",
"value"
] | Subtracts dates from the given value | [
"Subtracts",
"dates",
"from",
"the",
"given",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L162-L165 | train | 58,703 |
MisterY/pydatum | pydatum/datum.py | Datum.subtract_weeks | def subtract_weeks(self, weeks: int) -> datetime:
""" Subtracts number of weeks from the current value """
self.value = self.value - timedelta(weeks=weeks)
return self.value | python | def subtract_weeks(self, weeks: int) -> datetime:
""" Subtracts number of weeks from the current value """
self.value = self.value - timedelta(weeks=weeks)
return self.value | [
"def",
"subtract_weeks",
"(",
"self",
",",
"weeks",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"-",
"timedelta",
"(",
"weeks",
"=",
"weeks",
")",
"return",
"self",
".",
"value"
] | Subtracts number of weeks from the current value | [
"Subtracts",
"number",
"of",
"weeks",
"from",
"the",
"current",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L167-L170 | train | 58,704 |
MisterY/pydatum | pydatum/datum.py | Datum.subtract_months | def subtract_months(self, months: int) -> datetime:
""" Subtracts a number of months from the current value """
self.value = self.value - relativedelta(months=months)
return self.value | python | def subtract_months(self, months: int) -> datetime:
""" Subtracts a number of months from the current value """
self.value = self.value - relativedelta(months=months)
return self.value | [
"def",
"subtract_months",
"(",
"self",
",",
"months",
":",
"int",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"self",
".",
"value",
"-",
"relativedelta",
"(",
"months",
"=",
"months",
")",
"return",
"self",
".",
"value"
] | Subtracts a number of months from the current value | [
"Subtracts",
"a",
"number",
"of",
"months",
"from",
"the",
"current",
"value"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L172-L175 | train | 58,705 |
MisterY/pydatum | pydatum/datum.py | Datum.yesterday | def yesterday(self) -> datetime:
""" Set the value to yesterday """
self.value = datetime.today() - timedelta(days=1)
return self.value | python | def yesterday(self) -> datetime:
""" Set the value to yesterday """
self.value = datetime.today() - timedelta(days=1)
return self.value | [
"def",
"yesterday",
"(",
"self",
")",
"->",
"datetime",
":",
"self",
".",
"value",
"=",
"datetime",
".",
"today",
"(",
")",
"-",
"timedelta",
"(",
"days",
"=",
"1",
")",
"return",
"self",
".",
"value"
] | Set the value to yesterday | [
"Set",
"the",
"value",
"to",
"yesterday"
] | 4b39f43040e31a95bcf219603b6429078a9ba3c2 | https://github.com/MisterY/pydatum/blob/4b39f43040e31a95bcf219603b6429078a9ba3c2/pydatum/datum.py#L218-L221 | train | 58,706 |
hsdp/python-dropsonde | dropsonde/util.py | get_uuid_string | def get_uuid_string(low=None, high=None, **x):
"""This method parses a UUID protobuf message type from its component
'high' and 'low' longs into a standard formatted UUID string
Args:
x (dict): containing keys, 'low' and 'high' corresponding to the UUID
protobuf message type
Return... | python | def get_uuid_string(low=None, high=None, **x):
"""This method parses a UUID protobuf message type from its component
'high' and 'low' longs into a standard formatted UUID string
Args:
x (dict): containing keys, 'low' and 'high' corresponding to the UUID
protobuf message type
Return... | [
"def",
"get_uuid_string",
"(",
"low",
"=",
"None",
",",
"high",
"=",
"None",
",",
"*",
"*",
"x",
")",
":",
"if",
"low",
"is",
"None",
"or",
"high",
"is",
"None",
":",
"return",
"None",
"x",
"=",
"''",
".",
"join",
"(",
"[",
"parse_part",
"(",
"... | This method parses a UUID protobuf message type from its component
'high' and 'low' longs into a standard formatted UUID string
Args:
x (dict): containing keys, 'low' and 'high' corresponding to the UUID
protobuf message type
Returns:
str: UUID formatted string | [
"This",
"method",
"parses",
"a",
"UUID",
"protobuf",
"message",
"type",
"from",
"its",
"component",
"high",
"and",
"low",
"longs",
"into",
"a",
"standard",
"formatted",
"UUID",
"string"
] | e72680a3139cbb5ee4910ce1bbc2ccbaa227fb07 | https://github.com/hsdp/python-dropsonde/blob/e72680a3139cbb5ee4910ce1bbc2ccbaa227fb07/dropsonde/util.py#L25-L39 | train | 58,707 |
Tommos0/pyzenodo | pyzenodo/zenodo.py | Zenodo.search | def search(self, search):
"""search Zenodo record for string `search`
:param search: string to search
:return: Record[] results
"""
search = search.replace('/', ' ') # zenodo can't handle '/' in search query
params = {'q': search}
return self._get_records(params... | python | def search(self, search):
"""search Zenodo record for string `search`
:param search: string to search
:return: Record[] results
"""
search = search.replace('/', ' ') # zenodo can't handle '/' in search query
params = {'q': search}
return self._get_records(params... | [
"def",
"search",
"(",
"self",
",",
"search",
")",
":",
"search",
"=",
"search",
".",
"replace",
"(",
"'/'",
",",
"' '",
")",
"# zenodo can't handle '/' in search query",
"params",
"=",
"{",
"'q'",
":",
"search",
"}",
"return",
"self",
".",
"_get_records",
... | search Zenodo record for string `search`
:param search: string to search
:return: Record[] results | [
"search",
"Zenodo",
"record",
"for",
"string",
"search"
] | 1d68a9346fc7f7558d006175cbb1fa5c928e6e66 | https://github.com/Tommos0/pyzenodo/blob/1d68a9346fc7f7558d006175cbb1fa5c928e6e66/pyzenodo/zenodo.py#L75-L83 | train | 58,708 |
vicalloy/lbutils | lbutils/views.py | qdict_get_list | def qdict_get_list(qdict, k):
"""
get list from QueryDict and remove blank date from list.
"""
pks = qdict.getlist(k)
return [e for e in pks if e] | python | def qdict_get_list(qdict, k):
"""
get list from QueryDict and remove blank date from list.
"""
pks = qdict.getlist(k)
return [e for e in pks if e] | [
"def",
"qdict_get_list",
"(",
"qdict",
",",
"k",
")",
":",
"pks",
"=",
"qdict",
".",
"getlist",
"(",
"k",
")",
"return",
"[",
"e",
"for",
"e",
"in",
"pks",
"if",
"e",
"]"
] | get list from QueryDict and remove blank date from list. | [
"get",
"list",
"from",
"QueryDict",
"and",
"remove",
"blank",
"date",
"from",
"list",
"."
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/views.py#L20-L25 | train | 58,709 |
vicalloy/lbutils | lbutils/views.py | request_get_next | def request_get_next(request, default_next):
"""
get next url form request
order: POST.next GET.next HTTP_REFERER, default_next
"""
next_url = request.POST.get('next')\
or request.GET.get('next')\
or request.META.get('HTTP_REFERER')\
or default_next
return next_url | python | def request_get_next(request, default_next):
"""
get next url form request
order: POST.next GET.next HTTP_REFERER, default_next
"""
next_url = request.POST.get('next')\
or request.GET.get('next')\
or request.META.get('HTTP_REFERER')\
or default_next
return next_url | [
"def",
"request_get_next",
"(",
"request",
",",
"default_next",
")",
":",
"next_url",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'next'",
")",
"or",
"request",
".",
"GET",
".",
"get",
"(",
"'next'",
")",
"or",
"request",
".",
"META",
".",
"get",
... | get next url form request
order: POST.next GET.next HTTP_REFERER, default_next | [
"get",
"next",
"url",
"form",
"request"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/views.py#L28-L38 | train | 58,710 |
foobarbecue/afterflight | afterflight/logbrowse/views.py | upload_progress | def upload_progress(request):
"""
AJAX view adapted from django-progressbarupload
Return the upload progress and total length values
"""
if 'X-Progress-ID' in request.GET:
progress_id = request.GET['X-Progress-ID']
elif 'X-Progress-ID' in request.META:
progress_id = request.META... | python | def upload_progress(request):
"""
AJAX view adapted from django-progressbarupload
Return the upload progress and total length values
"""
if 'X-Progress-ID' in request.GET:
progress_id = request.GET['X-Progress-ID']
elif 'X-Progress-ID' in request.META:
progress_id = request.META... | [
"def",
"upload_progress",
"(",
"request",
")",
":",
"if",
"'X-Progress-ID'",
"in",
"request",
".",
"GET",
":",
"progress_id",
"=",
"request",
".",
"GET",
"[",
"'X-Progress-ID'",
"]",
"elif",
"'X-Progress-ID'",
"in",
"request",
".",
"META",
":",
"progress_id",
... | AJAX view adapted from django-progressbarupload
Return the upload progress and total length values | [
"AJAX",
"view",
"adapted",
"from",
"django",
"-",
"progressbarupload"
] | 7085f719593f88999dce93f35caec5f15d2991b6 | https://github.com/foobarbecue/afterflight/blob/7085f719593f88999dce93f35caec5f15d2991b6/afterflight/logbrowse/views.py#L40-L58 | train | 58,711 |
MisanthropicBit/colorise | colorise/BaseColorManager.py | BaseColorManager.set_color | def set_color(self, fg=None, bg=None, intensify=False, target=sys.stdout):
"""Set foreground- and background colors and intensity."""
raise NotImplementedError | python | def set_color(self, fg=None, bg=None, intensify=False, target=sys.stdout):
"""Set foreground- and background colors and intensity."""
raise NotImplementedError | [
"def",
"set_color",
"(",
"self",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"intensify",
"=",
"False",
",",
"target",
"=",
"sys",
".",
"stdout",
")",
":",
"raise",
"NotImplementedError"
] | Set foreground- and background colors and intensity. | [
"Set",
"foreground",
"-",
"and",
"background",
"colors",
"and",
"intensity",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/BaseColorManager.py#L34-L36 | train | 58,712 |
helixyte/everest | everest/repositories/memory/cache.py | EntityCache.add | def add(self, entity):
"""
Adds the given entity to this cache.
:param entity: Entity to add.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises ValueError: If the ID of the entity to add is ``None``
(unless the `allow_none_id` constructor a... | python | def add(self, entity):
"""
Adds the given entity to this cache.
:param entity: Entity to add.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises ValueError: If the ID of the entity to add is ``None``
(unless the `allow_none_id` constructor a... | [
"def",
"add",
"(",
"self",
",",
"entity",
")",
":",
"do_append",
"=",
"self",
".",
"__check_new",
"(",
"entity",
")",
"if",
"do_append",
":",
"self",
".",
"__entities",
".",
"append",
"(",
"entity",
")"
] | Adds the given entity to this cache.
:param entity: Entity to add.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises ValueError: If the ID of the entity to add is ``None``
(unless the `allow_none_id` constructor argument was set). | [
"Adds",
"the",
"given",
"entity",
"to",
"this",
"cache",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L75-L86 | train | 58,713 |
helixyte/everest | everest/repositories/memory/cache.py | EntityCache.remove | def remove(self, entity):
"""
Removes the given entity from this cache.
:param entity: Entity to remove.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises KeyError: If the given entity is not in this cache.
:raises ValueError: If the ID of th... | python | def remove(self, entity):
"""
Removes the given entity from this cache.
:param entity: Entity to remove.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises KeyError: If the given entity is not in this cache.
:raises ValueError: If the ID of th... | [
"def",
"remove",
"(",
"self",
",",
"entity",
")",
":",
"self",
".",
"__id_map",
".",
"pop",
"(",
"entity",
".",
"id",
",",
"None",
")",
"self",
".",
"__slug_map",
".",
"pop",
"(",
"entity",
".",
"slug",
",",
"None",
")",
"self",
".",
"__entities",
... | Removes the given entity from this cache.
:param entity: Entity to remove.
:type entity: Object implementing :class:`everest.interfaces.IEntity`.
:raises KeyError: If the given entity is not in this cache.
:raises ValueError: If the ID of the given entity is `None`. | [
"Removes",
"the",
"given",
"entity",
"from",
"this",
"cache",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L88-L99 | train | 58,714 |
helixyte/everest | everest/repositories/memory/cache.py | EntityCache.retrieve | def retrieve(self, filter_expression=None,
order_expression=None, slice_key=None):
"""
Retrieve entities from this cache, possibly after filtering, ordering
and slicing.
"""
ents = iter(self.__entities)
if not filter_expression is None:
ents =... | python | def retrieve(self, filter_expression=None,
order_expression=None, slice_key=None):
"""
Retrieve entities from this cache, possibly after filtering, ordering
and slicing.
"""
ents = iter(self.__entities)
if not filter_expression is None:
ents =... | [
"def",
"retrieve",
"(",
"self",
",",
"filter_expression",
"=",
"None",
",",
"order_expression",
"=",
"None",
",",
"slice_key",
"=",
"None",
")",
":",
"ents",
"=",
"iter",
"(",
"self",
".",
"__entities",
")",
"if",
"not",
"filter_expression",
"is",
"None",
... | Retrieve entities from this cache, possibly after filtering, ordering
and slicing. | [
"Retrieve",
"entities",
"from",
"this",
"cache",
"possibly",
"after",
"filtering",
"ordering",
"and",
"slicing",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/memory/cache.py#L118-L133 | train | 58,715 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | extract_user_keywords_generator | def extract_user_keywords_generator(twitter_lists_gen, lemmatizing="wordnet"):
"""
Based on the user-related lists I have downloaded, annotate the users.
Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
- lemmatizing: A string conta... | python | def extract_user_keywords_generator(twitter_lists_gen, lemmatizing="wordnet"):
"""
Based on the user-related lists I have downloaded, annotate the users.
Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
- lemmatizing: A string conta... | [
"def",
"extract_user_keywords_generator",
"(",
"twitter_lists_gen",
",",
"lemmatizing",
"=",
"\"wordnet\"",
")",
":",
"####################################################################################################################",
"# Extract keywords serially.",
"#####################... | Based on the user-related lists I have downloaded, annotate the users.
Inputs: - twitter_lists_gen: A python generator that yields a user Twitter id and a generator of Twitter lists.
- lemmatizing: A string containing one of the following: "porter", "snowball" or "wordnet".
Yields: - user_twitter_... | [
"Based",
"on",
"the",
"user",
"-",
"related",
"lists",
"I",
"have",
"downloaded",
"annotate",
"the",
"users",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L21-L51 | train | 58,716 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | form_user_label_matrix | def form_user_label_matrix(user_twitter_list_keywords_gen, id_to_node, max_number_of_labels):
"""
Forms the user-label matrix to be used in multi-label classification.
Input: - user_twitter_list_keywords_gen:
- id_to_node: A Twitter id to node map as a python dictionary.
Outputs: - use... | python | def form_user_label_matrix(user_twitter_list_keywords_gen, id_to_node, max_number_of_labels):
"""
Forms the user-label matrix to be used in multi-label classification.
Input: - user_twitter_list_keywords_gen:
- id_to_node: A Twitter id to node map as a python dictionary.
Outputs: - use... | [
"def",
"form_user_label_matrix",
"(",
"user_twitter_list_keywords_gen",
",",
"id_to_node",
",",
"max_number_of_labels",
")",
":",
"user_label_matrix",
",",
"annotated_nodes",
",",
"label_to_lemma",
",",
"node_to_lemma_tokeywordbag",
"=",
"form_user_term_matrix",
"(",
"user_tw... | Forms the user-label matrix to be used in multi-label classification.
Input: - user_twitter_list_keywords_gen:
- id_to_node: A Twitter id to node map as a python dictionary.
Outputs: - user_label_matrix: A user-to-label matrix in scipy sparse matrix format.
- annotated_nodes: A nu... | [
"Forms",
"the",
"user",
"-",
"label",
"matrix",
"to",
"be",
"used",
"in",
"multi",
"-",
"label",
"classification",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L54-L81 | train | 58,717 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | form_user_term_matrix | def form_user_term_matrix(user_twitter_list_keywords_gen, id_to_node, lemma_set=None, keyword_to_topic_manual=None):
"""
Forms a user-term matrix.
Input: - user_twitter_list_keywords_gen: A python generator that yields a user Twitter id and a bag-of-words.
- id_to_node: A Twitter id to node... | python | def form_user_term_matrix(user_twitter_list_keywords_gen, id_to_node, lemma_set=None, keyword_to_topic_manual=None):
"""
Forms a user-term matrix.
Input: - user_twitter_list_keywords_gen: A python generator that yields a user Twitter id and a bag-of-words.
- id_to_node: A Twitter id to node... | [
"def",
"form_user_term_matrix",
"(",
"user_twitter_list_keywords_gen",
",",
"id_to_node",
",",
"lemma_set",
"=",
"None",
",",
"keyword_to_topic_manual",
"=",
"None",
")",
":",
"# Prepare for iteration.",
"term_to_attribute",
"=",
"dict",
"(",
")",
"user_term_matrix_row",
... | Forms a user-term matrix.
Input: - user_twitter_list_keywords_gen: A python generator that yields a user Twitter id and a bag-of-words.
- id_to_node: A Twitter id to node map as a python dictionary.
- lemma_set: For the labelling, we use only lemmas in this set. Default: None
Outp... | [
"Forms",
"a",
"user",
"-",
"term",
"matrix",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L107-L196 | train | 58,718 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | fetch_twitter_lists_for_user_ids_generator | def fetch_twitter_lists_for_user_ids_generator(twitter_app_key,
twitter_app_secret,
user_id_list):
"""
Collects at most 500 Twitter lists for each user from an input list of Twitter user ids.
Inputs: - twitter_app... | python | def fetch_twitter_lists_for_user_ids_generator(twitter_app_key,
twitter_app_secret,
user_id_list):
"""
Collects at most 500 Twitter lists for each user from an input list of Twitter user ids.
Inputs: - twitter_app... | [
"def",
"fetch_twitter_lists_for_user_ids_generator",
"(",
"twitter_app_key",
",",
"twitter_app_secret",
",",
"user_id_list",
")",
":",
"####################################################################################################################",
"# Log into my application.",
"######... | Collects at most 500 Twitter lists for each user from an input list of Twitter user ids.
Inputs: - twitter_app_key: What is says on the tin.
- twitter_app_secret: Ditto.
- user_id_list: A python list of Twitter user ids.
Yields: - user_twitter_id: A Twitter user id.
- twitt... | [
"Collects",
"at",
"most",
"500",
"Twitter",
"lists",
"for",
"each",
"user",
"from",
"an",
"input",
"list",
"of",
"Twitter",
"user",
"ids",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L493-L540 | train | 58,719 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | decide_which_users_to_annotate | def decide_which_users_to_annotate(centrality_vector,
number_to_annotate,
already_annotated,
node_to_id):
"""
Sorts a centrality vector and returns the Twitter user ids that are to be annotated.
Inputs:... | python | def decide_which_users_to_annotate(centrality_vector,
number_to_annotate,
already_annotated,
node_to_id):
"""
Sorts a centrality vector and returns the Twitter user ids that are to be annotated.
Inputs:... | [
"def",
"decide_which_users_to_annotate",
"(",
"centrality_vector",
",",
"number_to_annotate",
",",
"already_annotated",
",",
"node_to_id",
")",
":",
"# Sort the centrality vector according to decreasing centrality.",
"centrality_vector",
"=",
"np",
".",
"asarray",
"(",
"central... | Sorts a centrality vector and returns the Twitter user ids that are to be annotated.
Inputs: - centrality_vector: A numpy array vector, that contains the centrality values for all users.
- number_to_annotate: The number of users to annotate.
- already_annotated: A python set of user twitter... | [
"Sorts",
"a",
"centrality",
"vector",
"and",
"returns",
"the",
"Twitter",
"user",
"ids",
"that",
"are",
"to",
"be",
"annotated",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L543-L580 | train | 58,720 |
MKLab-ITI/reveal-user-annotation | reveal_user_annotation/twitter/user_annotate.py | on_demand_annotation | def on_demand_annotation(twitter_app_key, twitter_app_secret, user_twitter_id):
"""
A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this.
"""
##################################################################################################################... | python | def on_demand_annotation(twitter_app_key, twitter_app_secret, user_twitter_id):
"""
A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this.
"""
##################################################################################################################... | [
"def",
"on_demand_annotation",
"(",
"twitter_app_key",
",",
"twitter_app_secret",
",",
"user_twitter_id",
")",
":",
"####################################################################################################################",
"# Log into my application",
"##########################... | A service that leverages twitter lists for on-demand annotation of popular users.
TODO: Do this. | [
"A",
"service",
"that",
"leverages",
"twitter",
"lists",
"for",
"on",
"-",
"demand",
"annotation",
"of",
"popular",
"users",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/twitter/user_annotate.py#L583-L599 | train | 58,721 |
helixyte/everest | everest/resources/utils.py | get_member_class | def get_member_class(resource):
"""
Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
reg = get_current_registry()
if IInterfac... | python | def get_member_class(resource):
"""
Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
reg = get_current_registry()
if IInterfac... | [
"def",
"get_member_class",
"(",
"resource",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"if",
"IInterface",
"in",
"provided_by",
"(",
"resource",
")",
":",
"member_class",
"=",
"reg",
".",
"getUtility",
"(",
"resource",
",",
"name",
"=",
"'member... | Returns the registered member class for the given resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface. | [
"Returns",
"the",
"registered",
"member",
"class",
"for",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L57-L71 | train | 58,722 |
helixyte/everest | everest/resources/utils.py | get_collection_class | def get_collection_class(resource):
"""
Returns the registered collection resource class for the given marker
interface or member resource class or instance.
:param rc: registered resource
:type rc: class implementing or instance providing or subclass of
a registered resource interface.
... | python | def get_collection_class(resource):
"""
Returns the registered collection resource class for the given marker
interface or member resource class or instance.
:param rc: registered resource
:type rc: class implementing or instance providing or subclass of
a registered resource interface.
... | [
"def",
"get_collection_class",
"(",
"resource",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"if",
"IInterface",
"in",
"provided_by",
"(",
"resource",
")",
":",
"coll_class",
"=",
"reg",
".",
"getUtility",
"(",
"resource",
",",
"name",
"=",
"'coll... | Returns the registered collection resource class for the given marker
interface or member resource class or instance.
:param rc: registered resource
:type rc: class implementing or instance providing or subclass of
a registered resource interface. | [
"Returns",
"the",
"registered",
"collection",
"resource",
"class",
"for",
"the",
"given",
"marker",
"interface",
"or",
"member",
"resource",
"class",
"or",
"instance",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L74-L89 | train | 58,723 |
helixyte/everest | everest/resources/utils.py | as_member | def as_member(entity, parent=None):
"""
Adapts an object to a location aware member resource.
:param entity: a domain object for which a resource adapter has been
registered
:type entity: an object implementing
:class:`everest.entities.interfaces.IEntity`
:param parent: optional par... | python | def as_member(entity, parent=None):
"""
Adapts an object to a location aware member resource.
:param entity: a domain object for which a resource adapter has been
registered
:type entity: an object implementing
:class:`everest.entities.interfaces.IEntity`
:param parent: optional par... | [
"def",
"as_member",
"(",
"entity",
",",
"parent",
"=",
"None",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"rc",
"=",
"reg",
".",
"getAdapter",
"(",
"entity",
",",
"IMemberResource",
")",
"if",
"not",
"parent",
"is",
"None",
":",
"rc",
".",... | Adapts an object to a location aware member resource.
:param entity: a domain object for which a resource adapter has been
registered
:type entity: an object implementing
:class:`everest.entities.interfaces.IEntity`
:param parent: optional parent collection resource to make the new member
... | [
"Adapts",
"an",
"object",
"to",
"a",
"location",
"aware",
"member",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L103-L122 | train | 58,724 |
helixyte/everest | everest/resources/utils.py | get_resource_url | def get_resource_url(resource):
"""
Returns the URL for the given resource.
"""
path = model_path(resource)
parsed = list(urlparse.urlparse(path))
parsed[1] = ""
return urlparse.urlunparse(parsed) | python | def get_resource_url(resource):
"""
Returns the URL for the given resource.
"""
path = model_path(resource)
parsed = list(urlparse.urlparse(path))
parsed[1] = ""
return urlparse.urlunparse(parsed) | [
"def",
"get_resource_url",
"(",
"resource",
")",
":",
"path",
"=",
"model_path",
"(",
"resource",
")",
"parsed",
"=",
"list",
"(",
"urlparse",
".",
"urlparse",
"(",
"path",
")",
")",
"parsed",
"[",
"1",
"]",
"=",
"\"\"",
"return",
"urlparse",
".",
"url... | Returns the URL for the given resource. | [
"Returns",
"the",
"URL",
"for",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L136-L143 | train | 58,725 |
helixyte/everest | everest/resources/utils.py | get_registered_collection_resources | def get_registered_collection_resources():
"""
Returns a list of all registered collection resource classes.
"""
reg = get_current_registry()
return [util.component
for util in reg.registeredUtilities()
if util.name == 'collection-class'] | python | def get_registered_collection_resources():
"""
Returns a list of all registered collection resource classes.
"""
reg = get_current_registry()
return [util.component
for util in reg.registeredUtilities()
if util.name == 'collection-class'] | [
"def",
"get_registered_collection_resources",
"(",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"return",
"[",
"util",
".",
"component",
"for",
"util",
"in",
"reg",
".",
"registeredUtilities",
"(",
")",
"if",
"util",
".",
"name",
"==",
"'collection-... | Returns a list of all registered collection resource classes. | [
"Returns",
"a",
"list",
"of",
"all",
"registered",
"collection",
"resource",
"classes",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L176-L183 | train | 58,726 |
helixyte/everest | everest/resources/utils.py | resource_to_url | def resource_to_url(resource, request=None, quote=False):
"""
Converts the given resource to a URL.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
:param bool quote: If set, the URL returned will be quoted.
"""
... | python | def resource_to_url(resource, request=None, quote=False):
"""
Converts the given resource to a URL.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
:param bool quote: If set, the URL returned will be quoted.
"""
... | [
"def",
"resource_to_url",
"(",
"resource",
",",
"request",
"=",
"None",
",",
"quote",
"=",
"False",
")",
":",
"if",
"request",
"is",
"None",
":",
"request",
"=",
"get_current_request",
"(",
")",
"# cnv = request.registry.getAdapter(request, IResourceUrlConverter)",... | Converts the given resource to a URL.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
:param bool quote: If set, the URL returned will be quoted. | [
"Converts",
"the",
"given",
"resource",
"to",
"a",
"URL",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L197-L210 | train | 58,727 |
helixyte/everest | everest/resources/utils.py | url_to_resource | def url_to_resource(url, request=None):
"""
Converts the given URL to a resource.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
"""
if request is None:
request = get_current_request()
# cnv = request.... | python | def url_to_resource(url, request=None):
"""
Converts the given URL to a resource.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used.
"""
if request is None:
request = get_current_request()
# cnv = request.... | [
"def",
"url_to_resource",
"(",
"url",
",",
"request",
"=",
"None",
")",
":",
"if",
"request",
"is",
"None",
":",
"request",
"=",
"get_current_request",
"(",
")",
"# cnv = request.registry.getAdapter(request, IResourceUrlConverter)",
"reg",
"=",
"get_current_registry"... | Converts the given URL to a resource.
:param request: Request object (required for the host name part of the
URL). If this is not given, the current request is used. | [
"Converts",
"the",
"given",
"URL",
"to",
"a",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/utils.py#L213-L225 | train | 58,728 |
helixyte/everest | everest/entities/utils.py | get_entity_class | def get_entity_class(resource):
"""
Returns the entity class registered for the given registered resource.
:param resource: registered resource
:type collection: class implementing or instance providing a registered
resource interface.
:return: entity class
(class implementing `ever... | python | def get_entity_class(resource):
"""
Returns the entity class registered for the given registered resource.
:param resource: registered resource
:type collection: class implementing or instance providing a registered
resource interface.
:return: entity class
(class implementing `ever... | [
"def",
"get_entity_class",
"(",
"resource",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"if",
"IInterface",
"in",
"provided_by",
"(",
"resource",
")",
":",
"ent_cls",
"=",
"reg",
".",
"getUtility",
"(",
"resource",
",",
"name",
"=",
"'entity-clas... | Returns the entity class registered for the given registered resource.
:param resource: registered resource
:type collection: class implementing or instance providing a registered
resource interface.
:return: entity class
(class implementing `everest.entities.interfaces.IEntity`) | [
"Returns",
"the",
"entity",
"class",
"registered",
"for",
"the",
"given",
"registered",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/entities/utils.py#L37-L52 | train | 58,729 |
ponty/confduino | confduino/examples/board.py | install_board_with_programmer | def install_board_with_programmer(mcu,
programmer,
f_cpu=16000000,
core='arduino',
replace_existing=False,
):
"""install board with programmer."""... | python | def install_board_with_programmer(mcu,
programmer,
f_cpu=16000000,
core='arduino',
replace_existing=False,
):
"""install board with programmer."""... | [
"def",
"install_board_with_programmer",
"(",
"mcu",
",",
"programmer",
",",
"f_cpu",
"=",
"16000000",
",",
"core",
"=",
"'arduino'",
",",
"replace_existing",
"=",
"False",
",",
")",
":",
"bunch",
"=",
"AutoBunch",
"(",
")",
"board_id",
"=",
"'{mcu}_{f_cpu}_{pr... | install board with programmer. | [
"install",
"board",
"with",
"programmer",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/board.py#L17-L40 | train | 58,730 |
agrc/agrc.python | agrc/logging.py | Logger.logMsg | def logMsg(self, msg, printMsg=True):
"""
logs a message and prints it to the screen
"""
time = datetime.datetime.now().strftime('%I:%M %p')
self.log = '{0}\n{1} | {2}'.format(self.log, time, msg)
if printMsg:
print msg
if self.addLogsToArcpyMessages:... | python | def logMsg(self, msg, printMsg=True):
"""
logs a message and prints it to the screen
"""
time = datetime.datetime.now().strftime('%I:%M %p')
self.log = '{0}\n{1} | {2}'.format(self.log, time, msg)
if printMsg:
print msg
if self.addLogsToArcpyMessages:... | [
"def",
"logMsg",
"(",
"self",
",",
"msg",
",",
"printMsg",
"=",
"True",
")",
":",
"time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%I:%M %p'",
")",
"self",
".",
"log",
"=",
"'{0}\\n{1} | {2}'",
".",
"format",
"(... | logs a message and prints it to the screen | [
"logs",
"a",
"message",
"and",
"prints",
"it",
"to",
"the",
"screen"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L26-L37 | train | 58,731 |
agrc/agrc.python | agrc/logging.py | Logger.logGPMsg | def logGPMsg(self, printMsg=True):
"""
logs the arcpy messages and prints them to the screen
"""
from arcpy import GetMessages
msgs = GetMessages()
try:
self.logMsg(msgs, printMsg)
except:
self.logMsg('error getting arcpy message', printMs... | python | def logGPMsg(self, printMsg=True):
"""
logs the arcpy messages and prints them to the screen
"""
from arcpy import GetMessages
msgs = GetMessages()
try:
self.logMsg(msgs, printMsg)
except:
self.logMsg('error getting arcpy message', printMs... | [
"def",
"logGPMsg",
"(",
"self",
",",
"printMsg",
"=",
"True",
")",
":",
"from",
"arcpy",
"import",
"GetMessages",
"msgs",
"=",
"GetMessages",
"(",
")",
"try",
":",
"self",
".",
"logMsg",
"(",
"msgs",
",",
"printMsg",
")",
"except",
":",
"self",
".",
... | logs the arcpy messages and prints them to the screen | [
"logs",
"the",
"arcpy",
"messages",
"and",
"prints",
"them",
"to",
"the",
"screen"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L39-L49 | train | 58,732 |
agrc/agrc.python | agrc/logging.py | Logger.writeLogToFile | def writeLogToFile(self):
"""
writes the log to a
"""
if not os.path.exists(self.logFolder):
os.mkdir(self.logFolder)
with open(self.logFile, mode='a') as f:
f.write('\n\n' + self.log) | python | def writeLogToFile(self):
"""
writes the log to a
"""
if not os.path.exists(self.logFolder):
os.mkdir(self.logFolder)
with open(self.logFile, mode='a') as f:
f.write('\n\n' + self.log) | [
"def",
"writeLogToFile",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"logFolder",
")",
":",
"os",
".",
"mkdir",
"(",
"self",
".",
"logFolder",
")",
"with",
"open",
"(",
"self",
".",
"logFile",
",",
"mode"... | writes the log to a | [
"writes",
"the",
"log",
"to",
"a"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L51-L59 | train | 58,733 |
agrc/agrc.python | agrc/logging.py | Logger.logError | def logError(self):
"""
gets traceback info and logs it
"""
# got from http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Error_handling_with_Python
import traceback
self.logMsg('ERROR!!!')
errMsg = traceback.format_exc()
self.logMsg(errMsg)
... | python | def logError(self):
"""
gets traceback info and logs it
"""
# got from http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Error_handling_with_Python
import traceback
self.logMsg('ERROR!!!')
errMsg = traceback.format_exc()
self.logMsg(errMsg)
... | [
"def",
"logError",
"(",
"self",
")",
":",
"# got from http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Error_handling_with_Python",
"import",
"traceback",
"self",
".",
"logMsg",
"(",
"'ERROR!!!'",
")",
"errMsg",
"=",
"traceback",
".",
"format_exc",
"(",
")",
... | gets traceback info and logs it | [
"gets",
"traceback",
"info",
"and",
"logs",
"it"
] | be427e919bd4cdd6f19524b7f7fe18882429c25b | https://github.com/agrc/agrc.python/blob/be427e919bd4cdd6f19524b7f7fe18882429c25b/agrc/logging.py#L61-L71 | train | 58,734 |
kstrauser/giphycat | giphycat/giphycat.py | get_random_giphy | def get_random_giphy(phrase):
"""Return the URL of a random GIF related to the phrase, if possible"""
with warnings.catch_warnings():
warnings.simplefilter('ignore')
giphy = giphypop.Giphy()
results = giphy.search_list(phrase=phrase, limit=100)
if not results:
raise ValueError... | python | def get_random_giphy(phrase):
"""Return the URL of a random GIF related to the phrase, if possible"""
with warnings.catch_warnings():
warnings.simplefilter('ignore')
giphy = giphypop.Giphy()
results = giphy.search_list(phrase=phrase, limit=100)
if not results:
raise ValueError... | [
"def",
"get_random_giphy",
"(",
"phrase",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"'ignore'",
")",
"giphy",
"=",
"giphypop",
".",
"Giphy",
"(",
")",
"results",
"=",
"giphy",
".",
"search_lis... | Return the URL of a random GIF related to the phrase, if possible | [
"Return",
"the",
"URL",
"of",
"a",
"random",
"GIF",
"related",
"to",
"the",
"phrase",
"if",
"possible"
] | c7c060dc0fc370d7253650e32ee93fde215621a8 | https://github.com/kstrauser/giphycat/blob/c7c060dc0fc370d7253650e32ee93fde215621a8/giphycat/giphycat.py#L14-L26 | train | 58,735 |
kstrauser/giphycat | giphycat/giphycat.py | handle_command_line | def handle_command_line():
"""Display an image for the phrase in sys.argv, if possible"""
phrase = ' '.join(sys.argv[1:]) or 'random'
try:
giphy = get_random_giphy(phrase)
except ValueError:
sys.stderr.write('Unable to find any GIFs for {!r}\n'.format(phrase))
sys.exit(1)
d... | python | def handle_command_line():
"""Display an image for the phrase in sys.argv, if possible"""
phrase = ' '.join(sys.argv[1:]) or 'random'
try:
giphy = get_random_giphy(phrase)
except ValueError:
sys.stderr.write('Unable to find any GIFs for {!r}\n'.format(phrase))
sys.exit(1)
d... | [
"def",
"handle_command_line",
"(",
")",
":",
"phrase",
"=",
"' '",
".",
"join",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"or",
"'random'",
"try",
":",
"giphy",
"=",
"get_random_giphy",
"(",
"phrase",
")",
"except",
"ValueError",
":",
"sys",
... | Display an image for the phrase in sys.argv, if possible | [
"Display",
"an",
"image",
"for",
"the",
"phrase",
"in",
"sys",
".",
"argv",
"if",
"possible"
] | c7c060dc0fc370d7253650e32ee93fde215621a8 | https://github.com/kstrauser/giphycat/blob/c7c060dc0fc370d7253650e32ee93fde215621a8/giphycat/giphycat.py#L39-L49 | train | 58,736 |
erikvw/django-collect-offline-files | django_collect_offline_files/apps.py | AppConfig.make_required_folders | def make_required_folders(self):
"""Makes all folders declared in the config if they
do not exist.
"""
for folder in [
self.pending_folder,
self.usb_incoming_folder,
self.outgoing_folder,
self.incoming_folder,
self.archive_folde... | python | def make_required_folders(self):
"""Makes all folders declared in the config if they
do not exist.
"""
for folder in [
self.pending_folder,
self.usb_incoming_folder,
self.outgoing_folder,
self.incoming_folder,
self.archive_folde... | [
"def",
"make_required_folders",
"(",
"self",
")",
":",
"for",
"folder",
"in",
"[",
"self",
".",
"pending_folder",
",",
"self",
".",
"usb_incoming_folder",
",",
"self",
".",
"outgoing_folder",
",",
"self",
".",
"incoming_folder",
",",
"self",
".",
"archive_fold... | Makes all folders declared in the config if they
do not exist. | [
"Makes",
"all",
"folders",
"declared",
"in",
"the",
"config",
"if",
"they",
"do",
"not",
"exist",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/apps.py#L31-L45 | train | 58,737 |
dariusbakunas/rawdisk | rawdisk/plugins/filesystems/hfs_plus/hfs_plus_volume.py | HfsPlusVolume.load | def load(self, filename, offset):
"""Loads HFS+ volume information"""
try:
self.offset = offset
self.fd = open(filename, 'rb')
# 1024 - temporary, need to find out actual volume header size
self.fd.seek(self.offset + VOLUME_HEADER_OFFSET)
data ... | python | def load(self, filename, offset):
"""Loads HFS+ volume information"""
try:
self.offset = offset
self.fd = open(filename, 'rb')
# 1024 - temporary, need to find out actual volume header size
self.fd.seek(self.offset + VOLUME_HEADER_OFFSET)
data ... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"offset",
")",
":",
"try",
":",
"self",
".",
"offset",
"=",
"offset",
"self",
".",
"fd",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"# 1024 - temporary, need to find out actual volume header size",
"self",... | Loads HFS+ volume information | [
"Loads",
"HFS",
"+",
"volume",
"information"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/hfs_plus/hfs_plus_volume.py#L42-L54 | train | 58,738 |
rossdylan/sham | sham/machine/__init__.py | VirtualMachine.get_interfaces | def get_interfaces(self):
"""
Return a list of sham.network.interfaces.NetworkInterface
describing all the interfaces this VM has
"""
interfaces = self.xml.find('devices').iter('interface')
iobjs = []
for interface in interfaces:
_type = interface.attr... | python | def get_interfaces(self):
"""
Return a list of sham.network.interfaces.NetworkInterface
describing all the interfaces this VM has
"""
interfaces = self.xml.find('devices').iter('interface')
iobjs = []
for interface in interfaces:
_type = interface.attr... | [
"def",
"get_interfaces",
"(",
"self",
")",
":",
"interfaces",
"=",
"self",
".",
"xml",
".",
"find",
"(",
"'devices'",
")",
".",
"iter",
"(",
"'interface'",
")",
"iobjs",
"=",
"[",
"]",
"for",
"interface",
"in",
"interfaces",
":",
"_type",
"=",
"interfa... | Return a list of sham.network.interfaces.NetworkInterface
describing all the interfaces this VM has | [
"Return",
"a",
"list",
"of",
"sham",
".",
"network",
".",
"interfaces",
".",
"NetworkInterface",
"describing",
"all",
"the",
"interfaces",
"this",
"VM",
"has"
] | d938ae3da43814c3c45ae95b6116bd87282c8691 | https://github.com/rossdylan/sham/blob/d938ae3da43814c3c45ae95b6116bd87282c8691/sham/machine/__init__.py#L51-L64 | train | 58,739 |
rossdylan/sham | sham/machine/__init__.py | VirtualMachine.get_disks | def get_disks(self):
"""
Return a list of all the Disks attached to this VM
The disks are returned in a sham.storage.volumes.Volume
object
"""
disks = [disk for disk in self.xml.iter('disk')]
disk_objs = []
for disk in disks:
source = disk.find... | python | def get_disks(self):
"""
Return a list of all the Disks attached to this VM
The disks are returned in a sham.storage.volumes.Volume
object
"""
disks = [disk for disk in self.xml.iter('disk')]
disk_objs = []
for disk in disks:
source = disk.find... | [
"def",
"get_disks",
"(",
"self",
")",
":",
"disks",
"=",
"[",
"disk",
"for",
"disk",
"in",
"self",
".",
"xml",
".",
"iter",
"(",
"'disk'",
")",
"]",
"disk_objs",
"=",
"[",
"]",
"for",
"disk",
"in",
"disks",
":",
"source",
"=",
"disk",
".",
"find"... | Return a list of all the Disks attached to this VM
The disks are returned in a sham.storage.volumes.Volume
object | [
"Return",
"a",
"list",
"of",
"all",
"the",
"Disks",
"attached",
"to",
"this",
"VM",
"The",
"disks",
"are",
"returned",
"in",
"a",
"sham",
".",
"storage",
".",
"volumes",
".",
"Volume",
"object"
] | d938ae3da43814c3c45ae95b6116bd87282c8691 | https://github.com/rossdylan/sham/blob/d938ae3da43814c3c45ae95b6116bd87282c8691/sham/machine/__init__.py#L66-L81 | train | 58,740 |
rossdylan/sham | sham/machine/__init__.py | VirtualMachine.delete | def delete(self):
"""
Delete this VM, and remove all its disks
"""
disks = self.get_disks()
self.domain.undefine()
for disk in disks:
disk.wipe()
disk.delete() | python | def delete(self):
"""
Delete this VM, and remove all its disks
"""
disks = self.get_disks()
self.domain.undefine()
for disk in disks:
disk.wipe()
disk.delete() | [
"def",
"delete",
"(",
"self",
")",
":",
"disks",
"=",
"self",
".",
"get_disks",
"(",
")",
"self",
".",
"domain",
".",
"undefine",
"(",
")",
"for",
"disk",
"in",
"disks",
":",
"disk",
".",
"wipe",
"(",
")",
"disk",
".",
"delete",
"(",
")"
] | Delete this VM, and remove all its disks | [
"Delete",
"this",
"VM",
"and",
"remove",
"all",
"its",
"disks"
] | d938ae3da43814c3c45ae95b6116bd87282c8691 | https://github.com/rossdylan/sham/blob/d938ae3da43814c3c45ae95b6116bd87282c8691/sham/machine/__init__.py#L83-L91 | train | 58,741 |
rossdylan/sham | sham/machine/__init__.py | VirtualMachine.to_dict | def to_dict(self):
"""
Return the values contained in this object as a dict
"""
return {'domain_type': self.domain_type,
'max_memory': self.max_memory,
'current_memory': self.current_memory,
'num_cpus': self.num_cpus,
'runni... | python | def to_dict(self):
"""
Return the values contained in this object as a dict
"""
return {'domain_type': self.domain_type,
'max_memory': self.max_memory,
'current_memory': self.current_memory,
'num_cpus': self.num_cpus,
'runni... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'domain_type'",
":",
"self",
".",
"domain_type",
",",
"'max_memory'",
":",
"self",
".",
"max_memory",
",",
"'current_memory'",
":",
"self",
".",
"current_memory",
",",
"'num_cpus'",
":",
"self",
".",
... | Return the values contained in this object as a dict | [
"Return",
"the",
"values",
"contained",
"in",
"this",
"object",
"as",
"a",
"dict"
] | d938ae3da43814c3c45ae95b6116bd87282c8691 | https://github.com/rossdylan/sham/blob/d938ae3da43814c3c45ae95b6116bd87282c8691/sham/machine/__init__.py#L125-L135 | train | 58,742 |
yougov/vr.common | vr/common/repo.py | guess_url_vcs | def guess_url_vcs(url):
"""
Given a url, try to guess what kind of VCS it's for. Return None if we
can't make a good guess.
"""
parsed = urllib.parse.urlsplit(url)
if parsed.scheme in ('git', 'svn'):
return parsed.scheme
elif parsed.path.endswith('.git'):
return 'git'
e... | python | def guess_url_vcs(url):
"""
Given a url, try to guess what kind of VCS it's for. Return None if we
can't make a good guess.
"""
parsed = urllib.parse.urlsplit(url)
if parsed.scheme in ('git', 'svn'):
return parsed.scheme
elif parsed.path.endswith('.git'):
return 'git'
e... | [
"def",
"guess_url_vcs",
"(",
"url",
")",
":",
"parsed",
"=",
"urllib",
".",
"parse",
".",
"urlsplit",
"(",
"url",
")",
"if",
"parsed",
".",
"scheme",
"in",
"(",
"'git'",
",",
"'svn'",
")",
":",
"return",
"parsed",
".",
"scheme",
"elif",
"parsed",
"."... | Given a url, try to guess what kind of VCS it's for. Return None if we
can't make a good guess. | [
"Given",
"a",
"url",
"try",
"to",
"guess",
"what",
"kind",
"of",
"VCS",
"it",
"s",
"for",
".",
"Return",
"None",
"if",
"we",
"can",
"t",
"make",
"a",
"good",
"guess",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/repo.py#L18-L39 | train | 58,743 |
yougov/vr.common | vr/common/repo.py | guess_folder_vcs | def guess_folder_vcs(folder):
"""
Given a path for a folder on the local filesystem, see what kind of vcs
repo it is, if any.
"""
try:
contents = os.listdir(folder)
vcs_folders = ['.git', '.hg', '.svn']
found = next((x for x in vcs_folders if x in contents), None)
# C... | python | def guess_folder_vcs(folder):
"""
Given a path for a folder on the local filesystem, see what kind of vcs
repo it is, if any.
"""
try:
contents = os.listdir(folder)
vcs_folders = ['.git', '.hg', '.svn']
found = next((x for x in vcs_folders if x in contents), None)
# C... | [
"def",
"guess_folder_vcs",
"(",
"folder",
")",
":",
"try",
":",
"contents",
"=",
"os",
".",
"listdir",
"(",
"folder",
")",
"vcs_folders",
"=",
"[",
"'.git'",
",",
"'.hg'",
",",
"'.svn'",
"]",
"found",
"=",
"next",
"(",
"(",
"x",
"for",
"x",
"in",
"... | Given a path for a folder on the local filesystem, see what kind of vcs
repo it is, if any. | [
"Given",
"a",
"path",
"for",
"a",
"folder",
"on",
"the",
"local",
"filesystem",
"see",
"what",
"kind",
"of",
"vcs",
"repo",
"it",
"is",
"if",
"any",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/repo.py#L42-L54 | train | 58,744 |
yougov/vr.common | vr/common/repo.py | basename | def basename(url):
"""
Return the name of the folder that you'd get if you cloned 'url' into the
current working directory.
"""
# It's easy to accidentally have whitespace on the beginning or end of the
# url.
url = url.strip()
url, _sep, _fragment = url.partition('#')
# Remove trai... | python | def basename(url):
"""
Return the name of the folder that you'd get if you cloned 'url' into the
current working directory.
"""
# It's easy to accidentally have whitespace on the beginning or end of the
# url.
url = url.strip()
url, _sep, _fragment = url.partition('#')
# Remove trai... | [
"def",
"basename",
"(",
"url",
")",
":",
"# It's easy to accidentally have whitespace on the beginning or end of the",
"# url.",
"url",
"=",
"url",
".",
"strip",
"(",
")",
"url",
",",
"_sep",
",",
"_fragment",
"=",
"url",
".",
"partition",
"(",
"'#'",
")",
"# Re... | Return the name of the folder that you'd get if you cloned 'url' into the
current working directory. | [
"Return",
"the",
"name",
"of",
"the",
"folder",
"that",
"you",
"d",
"get",
"if",
"you",
"cloned",
"url",
"into",
"the",
"current",
"working",
"directory",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/repo.py#L169-L183 | train | 58,745 |
yougov/vr.common | vr/common/repo.py | Repo.get_url | def get_url(self):
"""
Assuming that the repo has been cloned locally, get its default
upstream URL.
"""
cmd = {
'hg': 'hg paths default',
'git': 'git config --local --get remote.origin.url',
}[self.vcs_type]
with chdir(self.folder):
... | python | def get_url(self):
"""
Assuming that the repo has been cloned locally, get its default
upstream URL.
"""
cmd = {
'hg': 'hg paths default',
'git': 'git config --local --get remote.origin.url',
}[self.vcs_type]
with chdir(self.folder):
... | [
"def",
"get_url",
"(",
"self",
")",
":",
"cmd",
"=",
"{",
"'hg'",
":",
"'hg paths default'",
",",
"'git'",
":",
"'git config --local --get remote.origin.url'",
",",
"}",
"[",
"self",
".",
"vcs_type",
"]",
"with",
"chdir",
"(",
"self",
".",
"folder",
")",
"... | Assuming that the repo has been cloned locally, get its default
upstream URL. | [
"Assuming",
"that",
"the",
"repo",
"has",
"been",
"cloned",
"locally",
"get",
"its",
"default",
"upstream",
"URL",
"."
] | ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4 | https://github.com/yougov/vr.common/blob/ca8ed0c50ba873fc51fdfeeaa25d3b8ec1b54eb4/vr/common/repo.py#L90-L101 | train | 58,746 |
callowayproject/Calloway | calloway/apps/django_ext/templatetags/fb.py | fburl | def fburl(parser, token):
"""
Returns an absolute URL matching given view with its parameters.
This is a way to define links that aren't tied to a particular URL
configuration::
{% url path.to.some_view arg1,arg2,name1=value1 %}
The first argument is a path to a view. It can be an absolut... | python | def fburl(parser, token):
"""
Returns an absolute URL matching given view with its parameters.
This is a way to define links that aren't tied to a particular URL
configuration::
{% url path.to.some_view arg1,arg2,name1=value1 %}
The first argument is a path to a view. It can be an absolut... | [
"def",
"fburl",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"contents",
".",
"split",
"(",
"' '",
")",
"if",
"len",
"(",
"bits",
")",
"<",
"2",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"\"'%s' takes at least one ar... | Returns an absolute URL matching given view with its parameters.
This is a way to define links that aren't tied to a particular URL
configuration::
{% url path.to.some_view arg1,arg2,name1=value1 %}
The first argument is a path to a view. It can be an absolute python path
or just ``app_name.v... | [
"Returns",
"an",
"absolute",
"URL",
"matching",
"given",
"view",
"with",
"its",
"parameters",
"."
] | d22e98d41fbd298ab6393ba7bd84a75528be9f81 | https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/templatetags/fb.py#L43-L97 | train | 58,747 |
Jarn/jarn.mkrelease | jarn/mkrelease/chdir.py | chdir | def chdir(method):
"""Decorator executing method in directory 'dir'.
"""
def wrapper(self, dir, *args, **kw):
dirstack = ChdirStack()
dirstack.push(dir)
try:
return method(self, dir, *args, **kw)
finally:
dirstack.pop()
return functools.wraps(meth... | python | def chdir(method):
"""Decorator executing method in directory 'dir'.
"""
def wrapper(self, dir, *args, **kw):
dirstack = ChdirStack()
dirstack.push(dir)
try:
return method(self, dir, *args, **kw)
finally:
dirstack.pop()
return functools.wraps(meth... | [
"def",
"chdir",
"(",
"method",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"dir",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"dirstack",
"=",
"ChdirStack",
"(",
")",
"dirstack",
".",
"push",
"(",
"dir",
")",
"try",
":",
"return",
"method"... | Decorator executing method in directory 'dir'. | [
"Decorator",
"executing",
"method",
"in",
"directory",
"dir",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/chdir.py#L27-L38 | train | 58,748 |
Jarn/jarn.mkrelease | jarn/mkrelease/chdir.py | ChdirStack.push | def push(self, dir):
"""Push cwd on stack and change to 'dir'.
"""
self.stack.append(os.getcwd())
os.chdir(dir or os.getcwd()) | python | def push(self, dir):
"""Push cwd on stack and change to 'dir'.
"""
self.stack.append(os.getcwd())
os.chdir(dir or os.getcwd()) | [
"def",
"push",
"(",
"self",
",",
"dir",
")",
":",
"self",
".",
"stack",
".",
"append",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"os",
".",
"chdir",
"(",
"dir",
"or",
"os",
".",
"getcwd",
"(",
")",
")"
] | Push cwd on stack and change to 'dir'. | [
"Push",
"cwd",
"on",
"stack",
"and",
"change",
"to",
"dir",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/chdir.py#L14-L18 | train | 58,749 |
Jarn/jarn.mkrelease | jarn/mkrelease/chdir.py | ChdirStack.pop | def pop(self):
"""Pop dir off stack and change to it.
"""
if len(self.stack):
os.chdir(self.stack.pop()) | python | def pop(self):
"""Pop dir off stack and change to it.
"""
if len(self.stack):
os.chdir(self.stack.pop()) | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"stack",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"stack",
".",
"pop",
"(",
")",
")"
] | Pop dir off stack and change to it. | [
"Pop",
"dir",
"off",
"stack",
"and",
"change",
"to",
"it",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/chdir.py#L20-L24 | train | 58,750 |
helixyte/everest | everest/traversal.py | DataTraversalProxy.get_matching | def get_matching(self, source_id):
"""
Returns a matching target object for the given source ID.
"""
value = self._accessor.get_by_id(source_id)
if not value is None:
reg = get_current_registry()
prx_fac = reg.getUtility(IDataTraversalProxyFactory)
... | python | def get_matching(self, source_id):
"""
Returns a matching target object for the given source ID.
"""
value = self._accessor.get_by_id(source_id)
if not value is None:
reg = get_current_registry()
prx_fac = reg.getUtility(IDataTraversalProxyFactory)
... | [
"def",
"get_matching",
"(",
"self",
",",
"source_id",
")",
":",
"value",
"=",
"self",
".",
"_accessor",
".",
"get_by_id",
"(",
"source_id",
")",
"if",
"not",
"value",
"is",
"None",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"prx_fac",
"=",
"reg",... | Returns a matching target object for the given source ID. | [
"Returns",
"a",
"matching",
"target",
"object",
"for",
"the",
"given",
"source",
"ID",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversal.py#L125-L139 | train | 58,751 |
helixyte/everest | everest/traversal.py | DataTraversalProxy.update_attribute_value_items | def update_attribute_value_items(self):
"""
Returns an iterator of items for an attribute value map to use for
an UPDATE operation.
The iterator ignores collection attributes as these are processed
implicitly by the traversal algorithm.
:returns: iterator yielding tuple... | python | def update_attribute_value_items(self):
"""
Returns an iterator of items for an attribute value map to use for
an UPDATE operation.
The iterator ignores collection attributes as these are processed
implicitly by the traversal algorithm.
:returns: iterator yielding tuple... | [
"def",
"update_attribute_value_items",
"(",
"self",
")",
":",
"for",
"attr",
"in",
"self",
".",
"_attribute_iterator",
"(",
")",
":",
"if",
"attr",
".",
"kind",
"!=",
"RESOURCE_ATTRIBUTE_KINDS",
".",
"COLLECTION",
":",
"try",
":",
"attr_val",
"=",
"self",
".... | Returns an iterator of items for an attribute value map to use for
an UPDATE operation.
The iterator ignores collection attributes as these are processed
implicitly by the traversal algorithm.
:returns: iterator yielding tuples with objects implementing
:class:`everest.resour... | [
"Returns",
"an",
"iterator",
"of",
"items",
"for",
"an",
"attribute",
"value",
"map",
"to",
"use",
"for",
"an",
"UPDATE",
"operation",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversal.py#L142-L161 | train | 58,752 |
helixyte/everest | everest/traversal.py | ConvertingDataTraversalProxyMixin.get_entity | def get_entity(self):
"""
Returns the entity converted from the proxied data.
"""
if self._accessor is None:
if self.__converted_entity is None:
self.__converted_entity = self._convert_to_entity()
else:
# If we have an accessor, we can get ... | python | def get_entity(self):
"""
Returns the entity converted from the proxied data.
"""
if self._accessor is None:
if self.__converted_entity is None:
self.__converted_entity = self._convert_to_entity()
else:
# If we have an accessor, we can get ... | [
"def",
"get_entity",
"(",
"self",
")",
":",
"if",
"self",
".",
"_accessor",
"is",
"None",
":",
"if",
"self",
".",
"__converted_entity",
"is",
"None",
":",
"self",
".",
"__converted_entity",
"=",
"self",
".",
"_convert_to_entity",
"(",
")",
"else",
":",
"... | Returns the entity converted from the proxied data. | [
"Returns",
"the",
"entity",
"converted",
"from",
"the",
"proxied",
"data",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversal.py#L350-L363 | train | 58,753 |
helixyte/everest | everest/traversal.py | SourceTargetDataTreeTraverser.make_traverser | def make_traverser(cls, source_data, target_data, relation_operation,
accessor=None, manage_back_references=True):
"""
Factory method to create a tree traverser depending on the input
source and target data combination.
:param source_data: Source data.
:pa... | python | def make_traverser(cls, source_data, target_data, relation_operation,
accessor=None, manage_back_references=True):
"""
Factory method to create a tree traverser depending on the input
source and target data combination.
:param source_data: Source data.
:pa... | [
"def",
"make_traverser",
"(",
"cls",
",",
"source_data",
",",
"target_data",
",",
"relation_operation",
",",
"accessor",
"=",
"None",
",",
"manage_back_references",
"=",
"True",
")",
":",
"reg",
"=",
"get_current_registry",
"(",
")",
"prx_fac",
"=",
"reg",
"."... | Factory method to create a tree traverser depending on the input
source and target data combination.
:param source_data: Source data.
:param target_target: Target data.
:param str relation_operation: Relation operation. On of the constants
defined in :class:`everest.constants.... | [
"Factory",
"method",
"to",
"create",
"a",
"tree",
"traverser",
"depending",
"on",
"the",
"input",
"source",
"and",
"target",
"data",
"combination",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/traversal.py#L408-L494 | train | 58,754 |
andy29485/embypy | embypy/emby.py | Emby.info | async def info(self, obj_id=None):
'''Get info about object id
|coro|
Parameters
----------
obj_id : str, list
if not provided, server info is retured(as a dict).
Otherwise, an object with that id is returned
(or objects if `obj_id` is a list).
'''
if obj_id:
try:
... | python | async def info(self, obj_id=None):
'''Get info about object id
|coro|
Parameters
----------
obj_id : str, list
if not provided, server info is retured(as a dict).
Otherwise, an object with that id is returned
(or objects if `obj_id` is a list).
'''
if obj_id:
try:
... | [
"async",
"def",
"info",
"(",
"self",
",",
"obj_id",
"=",
"None",
")",
":",
"if",
"obj_id",
":",
"try",
":",
"return",
"await",
"self",
".",
"process",
"(",
"obj_id",
")",
"except",
"JSONDecodeError",
":",
"raise",
"LookupError",
"(",
"'Error object with th... | Get info about object id
|coro|
Parameters
----------
obj_id : str, list
if not provided, server info is retured(as a dict).
Otherwise, an object with that id is returned
(or objects if `obj_id` is a list). | [
"Get",
"info",
"about",
"object",
"id"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/emby.py#L39-L57 | train | 58,755 |
andy29485/embypy | embypy/emby.py | Emby.search | async def search(self, query,
sort_map = {'BoxSet':0,'Series':1,'Movie':2,'Audio':3,'Person':4},
strict_sort = False):
'''Sends a search request to emby, returns results
|coro|
Parameters
----------
query : str
the search string to send to emby
sort_map : dict
... | python | async def search(self, query,
sort_map = {'BoxSet':0,'Series':1,'Movie':2,'Audio':3,'Person':4},
strict_sort = False):
'''Sends a search request to emby, returns results
|coro|
Parameters
----------
query : str
the search string to send to emby
sort_map : dict
... | [
"async",
"def",
"search",
"(",
"self",
",",
"query",
",",
"sort_map",
"=",
"{",
"'BoxSet'",
":",
"0",
",",
"'Series'",
":",
"1",
",",
"'Movie'",
":",
"2",
",",
"'Audio'",
":",
"3",
",",
"'Person'",
":",
"4",
"}",
",",
"strict_sort",
"=",
"False",
... | Sends a search request to emby, returns results
|coro|
Parameters
----------
query : str
the search string to send to emby
sort_map : dict
is a dict of strings to ints. Strings should be item types, and
the ints are the priority of those types(for sorting).
lower valued(0) ... | [
"Sends",
"a",
"search",
"request",
"to",
"emby",
"returns",
"results"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/emby.py#L64-L101 | train | 58,756 |
andy29485/embypy | embypy/emby.py | Emby.nextUp | async def nextUp(self, userId=None):
'''returns list of items marked as `next up`
|coro|
Parameters
----------
userId : str
if provided, then the list returned is
the one that that use will see.
Returns
-------
list
the itmes that will appear as next up
(for us... | python | async def nextUp(self, userId=None):
'''returns list of items marked as `next up`
|coro|
Parameters
----------
userId : str
if provided, then the list returned is
the one that that use will see.
Returns
-------
list
the itmes that will appear as next up
(for us... | [
"async",
"def",
"nextUp",
"(",
"self",
",",
"userId",
"=",
"None",
")",
":",
"json",
"=",
"await",
"self",
".",
"connector",
".",
"getJson",
"(",
"'/Shows/NextUp'",
",",
"pass_uid",
"=",
"True",
",",
"remote",
"=",
"False",
",",
"userId",
"=",
"userId"... | returns list of items marked as `next up`
|coro|
Parameters
----------
userId : str
if provided, then the list returned is
the one that that use will see.
Returns
-------
list
the itmes that will appear as next up
(for user if id was given) | [
"returns",
"list",
"of",
"items",
"marked",
"as",
"next",
"up"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/emby.py#L137-L159 | train | 58,757 |
andy29485/embypy | embypy/emby.py | Emby.update | async def update(self):
'''
reload all cached information
|coro|
Notes
-----
This is a slow process, and will remove the cache before updating.
Thus it is recomended to use the `*_force` properties, which will
only update the cache after data is retrived.
'''
keys = self.extras... | python | async def update(self):
'''
reload all cached information
|coro|
Notes
-----
This is a slow process, and will remove the cache before updating.
Thus it is recomended to use the `*_force` properties, which will
only update the cache after data is retrived.
'''
keys = self.extras... | [
"async",
"def",
"update",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"extras",
".",
"keys",
"(",
")",
"self",
".",
"extras",
"=",
"{",
"}",
"for",
"key",
"in",
"keys",
":",
"try",
":",
"func",
"=",
"getattr",
"(",
"self",
",",
"key",
",",... | reload all cached information
|coro|
Notes
-----
This is a slow process, and will remove the cache before updating.
Thus it is recomended to use the `*_force` properties, which will
only update the cache after data is retrived. | [
"reload",
"all",
"cached",
"information"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/emby.py#L165-L185 | train | 58,758 |
andy29485/embypy | embypy/emby.py | Emby.create_playlist | async def create_playlist(self, name, *songs):
'''create a new playlist
|coro|
Parameters
----------
name : str
name of new playlist
songs : array_like
list of song ids to add to playlist
'''
data = {'Name': name}
ids = [i.id for i in (await self.process(songs))]
i... | python | async def create_playlist(self, name, *songs):
'''create a new playlist
|coro|
Parameters
----------
name : str
name of new playlist
songs : array_like
list of song ids to add to playlist
'''
data = {'Name': name}
ids = [i.id for i in (await self.process(songs))]
i... | [
"async",
"def",
"create_playlist",
"(",
"self",
",",
"name",
",",
"*",
"songs",
")",
":",
"data",
"=",
"{",
"'Name'",
":",
"name",
"}",
"ids",
"=",
"[",
"i",
".",
"id",
"for",
"i",
"in",
"(",
"await",
"self",
".",
"process",
"(",
"songs",
")",
... | create a new playlist
|coro|
Parameters
----------
name : str
name of new playlist
songs : array_like
list of song ids to add to playlist | [
"create",
"a",
"new",
"playlist"
] | cde658d380965caaf4789d4d182d045b0346797b | https://github.com/andy29485/embypy/blob/cde658d380965caaf4789d4d182d045b0346797b/embypy/emby.py#L190-L213 | train | 58,759 |
helixyte/everest | everest/plugins.py | PluginManager.load_all | def load_all(self, group):
"""
Loads all plugins advertising entry points with the given group name.
The specified plugin needs to be a callable that accepts the everest
configurator as single argument.
"""
for ep in iter_entry_points(group=group):
plugin = ep... | python | def load_all(self, group):
"""
Loads all plugins advertising entry points with the given group name.
The specified plugin needs to be a callable that accepts the everest
configurator as single argument.
"""
for ep in iter_entry_points(group=group):
plugin = ep... | [
"def",
"load_all",
"(",
"self",
",",
"group",
")",
":",
"for",
"ep",
"in",
"iter_entry_points",
"(",
"group",
"=",
"group",
")",
":",
"plugin",
"=",
"ep",
".",
"load",
"(",
")",
"plugin",
"(",
"self",
".",
"__config",
")"
] | Loads all plugins advertising entry points with the given group name.
The specified plugin needs to be a callable that accepts the everest
configurator as single argument. | [
"Loads",
"all",
"plugins",
"advertising",
"entry",
"points",
"with",
"the",
"given",
"group",
"name",
".",
"The",
"specified",
"plugin",
"needs",
"to",
"be",
"a",
"callable",
"that",
"accepts",
"the",
"everest",
"configurator",
"as",
"single",
"argument",
"."
... | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/plugins.py#L32-L40 | train | 58,760 |
ponty/confduino | confduino/examples/remove_libraries.py | gui | def gui():
"""remove libraries by GUI."""
sel = psidialogs.multi_choice(libraries(),
'select libraries to remove from %s!' % libraries_dir(),
title='remove boards')
print('%s selected' % sel)
if sel:
if psidialogs.ask_yes_no('... | python | def gui():
"""remove libraries by GUI."""
sel = psidialogs.multi_choice(libraries(),
'select libraries to remove from %s!' % libraries_dir(),
title='remove boards')
print('%s selected' % sel)
if sel:
if psidialogs.ask_yes_no('... | [
"def",
"gui",
"(",
")",
":",
"sel",
"=",
"psidialogs",
".",
"multi_choice",
"(",
"libraries",
"(",
")",
",",
"'select libraries to remove from %s!'",
"%",
"libraries_dir",
"(",
")",
",",
"title",
"=",
"'remove boards'",
")",
"print",
"(",
"'%s selected'",
"%",... | remove libraries by GUI. | [
"remove",
"libraries",
"by",
"GUI",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/remove_libraries.py#L8-L20 | train | 58,761 |
mamrhein/specification | specification/_extd_ast_expr.py | src2ast | def src2ast(src: str) -> Expression:
"""Return ast.Expression created from source code given in `src`."""
try:
return ast.parse(src, mode='eval')
except SyntaxError:
raise ValueError("Not a valid expression.") from None | python | def src2ast(src: str) -> Expression:
"""Return ast.Expression created from source code given in `src`."""
try:
return ast.parse(src, mode='eval')
except SyntaxError:
raise ValueError("Not a valid expression.") from None | [
"def",
"src2ast",
"(",
"src",
":",
"str",
")",
"->",
"Expression",
":",
"try",
":",
"return",
"ast",
".",
"parse",
"(",
"src",
",",
"mode",
"=",
"'eval'",
")",
"except",
"SyntaxError",
":",
"raise",
"ValueError",
"(",
"\"Not a valid expression.\"",
")",
... | Return ast.Expression created from source code given in `src`. | [
"Return",
"ast",
".",
"Expression",
"created",
"from",
"source",
"code",
"given",
"in",
"src",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L533-L538 | train | 58,762 |
mamrhein/specification | specification/_extd_ast_expr.py | names | def names(expr: AST) -> Set[str]:
"""Names of globals in `expr`."""
nodes = [node for node in ast.walk(expr) if isinstance(node, ast.Name)]
loaded = {node.id for node in nodes if isinstance(node.ctx, ast.Load)}
stored = {node.id for node in nodes if isinstance(node.ctx, ast.Store)}
return loaded - s... | python | def names(expr: AST) -> Set[str]:
"""Names of globals in `expr`."""
nodes = [node for node in ast.walk(expr) if isinstance(node, ast.Name)]
loaded = {node.id for node in nodes if isinstance(node.ctx, ast.Load)}
stored = {node.id for node in nodes if isinstance(node.ctx, ast.Store)}
return loaded - s... | [
"def",
"names",
"(",
"expr",
":",
"AST",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"nodes",
"=",
"[",
"node",
"for",
"node",
"in",
"ast",
".",
"walk",
"(",
"expr",
")",
"if",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Name",
")",
"]",
"loaded",... | Names of globals in `expr`. | [
"Names",
"of",
"globals",
"in",
"expr",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L546-L551 | train | 58,763 |
mamrhein/specification | specification/_extd_ast_expr.py | replace_name | def replace_name(expr: AST, old_name: str, new_name: str) -> AST:
"""Replace all Name nodes named `old_name` with nodes named `new_name`."""
return _NameReplacer(old_name, new_name).visit(deepcopy(expr)) | python | def replace_name(expr: AST, old_name: str, new_name: str) -> AST:
"""Replace all Name nodes named `old_name` with nodes named `new_name`."""
return _NameReplacer(old_name, new_name).visit(deepcopy(expr)) | [
"def",
"replace_name",
"(",
"expr",
":",
"AST",
",",
"old_name",
":",
"str",
",",
"new_name",
":",
"str",
")",
"->",
"AST",
":",
"return",
"_NameReplacer",
"(",
"old_name",
",",
"new_name",
")",
".",
"visit",
"(",
"deepcopy",
"(",
"expr",
")",
")"
] | Replace all Name nodes named `old_name` with nodes named `new_name`. | [
"Replace",
"all",
"Name",
"nodes",
"named",
"old_name",
"with",
"nodes",
"named",
"new_name",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L567-L569 | train | 58,764 |
mamrhein/specification | specification/_extd_ast_expr.py | Negation | def Negation(expr: Expression) -> Expression:
"""Return expression which is the negation of `expr`."""
expr = Expression(_negate(expr.body))
return ast.fix_missing_locations(expr) | python | def Negation(expr: Expression) -> Expression:
"""Return expression which is the negation of `expr`."""
expr = Expression(_negate(expr.body))
return ast.fix_missing_locations(expr) | [
"def",
"Negation",
"(",
"expr",
":",
"Expression",
")",
"->",
"Expression",
":",
"expr",
"=",
"Expression",
"(",
"_negate",
"(",
"expr",
".",
"body",
")",
")",
"return",
"ast",
".",
"fix_missing_locations",
"(",
"expr",
")"
] | Return expression which is the negation of `expr`. | [
"Return",
"expression",
"which",
"is",
"the",
"negation",
"of",
"expr",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L615-L618 | train | 58,765 |
mamrhein/specification | specification/_extd_ast_expr.py | Conjunction | def Conjunction(expr1: Expression, expr2: Expression) -> Expression:
"""Return expression which is the conjunction of `expr1` and `expr2`."""
expr = Expression(ast.BoolOp(ast.And(), [expr1.body, expr2.body]))
return ast.fix_missing_locations(expr) | python | def Conjunction(expr1: Expression, expr2: Expression) -> Expression:
"""Return expression which is the conjunction of `expr1` and `expr2`."""
expr = Expression(ast.BoolOp(ast.And(), [expr1.body, expr2.body]))
return ast.fix_missing_locations(expr) | [
"def",
"Conjunction",
"(",
"expr1",
":",
"Expression",
",",
"expr2",
":",
"Expression",
")",
"->",
"Expression",
":",
"expr",
"=",
"Expression",
"(",
"ast",
".",
"BoolOp",
"(",
"ast",
".",
"And",
"(",
")",
",",
"[",
"expr1",
".",
"body",
",",
"expr2"... | Return expression which is the conjunction of `expr1` and `expr2`. | [
"Return",
"expression",
"which",
"is",
"the",
"conjunction",
"of",
"expr1",
"and",
"expr2",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L621-L624 | train | 58,766 |
mamrhein/specification | specification/_extd_ast_expr.py | Disjunction | def Disjunction(expr1: Expression, expr2: Expression) -> Expression:
"""Return expression which is the disjunction of `expr1` and `expr2`."""
expr = Expression(ast.BoolOp(ast.Or(), [expr1.body, expr2.body]))
return ast.fix_missing_locations(expr) | python | def Disjunction(expr1: Expression, expr2: Expression) -> Expression:
"""Return expression which is the disjunction of `expr1` and `expr2`."""
expr = Expression(ast.BoolOp(ast.Or(), [expr1.body, expr2.body]))
return ast.fix_missing_locations(expr) | [
"def",
"Disjunction",
"(",
"expr1",
":",
"Expression",
",",
"expr2",
":",
"Expression",
")",
"->",
"Expression",
":",
"expr",
"=",
"Expression",
"(",
"ast",
".",
"BoolOp",
"(",
"ast",
".",
"Or",
"(",
")",
",",
"[",
"expr1",
".",
"body",
",",
"expr2",... | Return expression which is the disjunction of `expr1` and `expr2`. | [
"Return",
"expression",
"which",
"is",
"the",
"disjunction",
"of",
"expr1",
"and",
"expr2",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L627-L630 | train | 58,767 |
mamrhein/specification | specification/_extd_ast_expr.py | Contradiction | def Contradiction(expr1: Expression, expr2: Expression) -> Expression:
"""Return expression which is the contradiction of `expr1` and `expr2`."""
expr = Disjunction(Conjunction(expr1, Negation(expr2)),
Conjunction(Negation(expr1), expr2))
return ast.fix_missing_locations(expr) | python | def Contradiction(expr1: Expression, expr2: Expression) -> Expression:
"""Return expression which is the contradiction of `expr1` and `expr2`."""
expr = Disjunction(Conjunction(expr1, Negation(expr2)),
Conjunction(Negation(expr1), expr2))
return ast.fix_missing_locations(expr) | [
"def",
"Contradiction",
"(",
"expr1",
":",
"Expression",
",",
"expr2",
":",
"Expression",
")",
"->",
"Expression",
":",
"expr",
"=",
"Disjunction",
"(",
"Conjunction",
"(",
"expr1",
",",
"Negation",
"(",
"expr2",
")",
")",
",",
"Conjunction",
"(",
"Negatio... | Return expression which is the contradiction of `expr1` and `expr2`. | [
"Return",
"expression",
"which",
"is",
"the",
"contradiction",
"of",
"expr1",
"and",
"expr2",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L633-L637 | train | 58,768 |
mamrhein/specification | specification/_extd_ast_expr.py | OpBindingManager.diff_binding | def diff_binding(self) -> int:
"""Return the difference betweens the binding levels of the current
and the previous operator.
"""
try:
prev_op, prev_op_binding = self.nested_ops[-2]
except IndexError:
prev_op, prev_op_binding = None, 0
try:
... | python | def diff_binding(self) -> int:
"""Return the difference betweens the binding levels of the current
and the previous operator.
"""
try:
prev_op, prev_op_binding = self.nested_ops[-2]
except IndexError:
prev_op, prev_op_binding = None, 0
try:
... | [
"def",
"diff_binding",
"(",
"self",
")",
"->",
"int",
":",
"try",
":",
"prev_op",
",",
"prev_op_binding",
"=",
"self",
".",
"nested_ops",
"[",
"-",
"2",
"]",
"except",
"IndexError",
":",
"prev_op",
",",
"prev_op_binding",
"=",
"None",
",",
"0",
"try",
... | Return the difference betweens the binding levels of the current
and the previous operator. | [
"Return",
"the",
"difference",
"betweens",
"the",
"binding",
"levels",
"of",
"the",
"current",
"and",
"the",
"previous",
"operator",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L90-L106 | train | 58,769 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.wrap_expr | def wrap_expr(self, src: str, dfltChaining: bool) -> str:
"""Wrap `src` in parentheses if neccessary."""
diff_binding = self.op_man.diff_binding()
if diff_binding < 0 or diff_binding == 0 and not dfltChaining:
return self.parenthesize(src)
else:
return src | python | def wrap_expr(self, src: str, dfltChaining: bool) -> str:
"""Wrap `src` in parentheses if neccessary."""
diff_binding = self.op_man.diff_binding()
if diff_binding < 0 or diff_binding == 0 and not dfltChaining:
return self.parenthesize(src)
else:
return src | [
"def",
"wrap_expr",
"(",
"self",
",",
"src",
":",
"str",
",",
"dfltChaining",
":",
"bool",
")",
"->",
"str",
":",
"diff_binding",
"=",
"self",
".",
"op_man",
".",
"diff_binding",
"(",
")",
"if",
"diff_binding",
"<",
"0",
"or",
"diff_binding",
"==",
"0"... | Wrap `src` in parentheses if neccessary. | [
"Wrap",
"src",
"in",
"parentheses",
"if",
"neccessary",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L124-L130 | train | 58,770 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit | def visit(self, node: AST, dfltChaining: bool = True) -> str:
"""Process `node` by dispatching to a handler."""
# print(node.__class__.__name__)
if node is None:
return ''
if isinstance(node, ast.Expression):
return self.visit(node.body)
# dispatch to spec... | python | def visit(self, node: AST, dfltChaining: bool = True) -> str:
"""Process `node` by dispatching to a handler."""
# print(node.__class__.__name__)
if node is None:
return ''
if isinstance(node, ast.Expression):
return self.visit(node.body)
# dispatch to spec... | [
"def",
"visit",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"# print(node.__class__.__name__)",
"if",
"node",
"is",
"None",
":",
"return",
"''",
"if",
"isinstance",
"(",
"node",
",",
"ast",
... | Process `node` by dispatching to a handler. | [
"Process",
"node",
"by",
"dispatching",
"to",
"a",
"handler",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L134-L144 | train | 58,771 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.generic_visit | def generic_visit(self, node: AST, dfltChaining: bool = True) -> str:
"""Default handler, called if no explicit visitor function exists for
a node.
"""
for field, value in ast.iter_fields(node):
if isinstance(value, list):
for item in value:
... | python | def generic_visit(self, node: AST, dfltChaining: bool = True) -> str:
"""Default handler, called if no explicit visitor function exists for
a node.
"""
for field, value in ast.iter_fields(node):
if isinstance(value, list):
for item in value:
... | [
"def",
"generic_visit",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"for",
"field",
",",
"value",
"in",
"ast",
".",
"iter_fields",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"value"... | Default handler, called if no explicit visitor function exists for
a node. | [
"Default",
"handler",
"called",
"if",
"no",
"explicit",
"visitor",
"function",
"exists",
"for",
"a",
"node",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L146-L156 | train | 58,772 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_NameConstant | def visit_NameConstant(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s name as string."""
return str(node.value) | python | def visit_NameConstant(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s name as string."""
return str(node.value) | [
"def",
"visit_NameConstant",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"str",
"(",
"node",
".",
"value",
")"
] | Return `node`s name as string. | [
"Return",
"node",
"s",
"name",
"as",
"string",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L163-L165 | train | 58,773 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Num | def visit_Num(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s number as string."""
return str(node.n) | python | def visit_Num(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s number as string."""
return str(node.n) | [
"def",
"visit_Num",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"str",
"(",
"node",
".",
"n",
")"
] | Return `node`s number as string. | [
"Return",
"node",
"s",
"number",
"as",
"string",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L167-L169 | train | 58,774 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Str | def visit_Str(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s string representation."""
return repr(node.s) | python | def visit_Str(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s string representation."""
return repr(node.s) | [
"def",
"visit_Str",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"repr",
"(",
"node",
".",
"s",
")"
] | Return `node`s string representation. | [
"Return",
"node",
"s",
"string",
"representation",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L171-L173 | train | 58,775 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_FormattedValue | def visit_FormattedValue(self, node: AST,
dfltChaining: bool = True) -> str:
"""Return `node`s value formatted according to its format spec."""
format_spec = node.format_spec
return f"{{{self.visit(node.value)}" \
f"{self.CONV_MAP.get(node.conversion, ... | python | def visit_FormattedValue(self, node: AST,
dfltChaining: bool = True) -> str:
"""Return `node`s value formatted according to its format spec."""
format_spec = node.format_spec
return f"{{{self.visit(node.value)}" \
f"{self.CONV_MAP.get(node.conversion, ... | [
"def",
"visit_FormattedValue",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"format_spec",
"=",
"node",
".",
"format_spec",
"return",
"f\"{{{self.visit(node.value)}\"",
"f\"{self.CONV_MAP.get(node.conver... | Return `node`s value formatted according to its format spec. | [
"Return",
"node",
"s",
"value",
"formatted",
"according",
"to",
"its",
"format",
"spec",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L177-L183 | train | 58,776 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Tuple | def visit_Tuple(self, node: AST, dfltChaining: bool = True) -> str:
"""Return tuple representation of `node`s elements."""
elems = (self.visit(elt) for elt in node.elts)
return f"({', '.join(elems)}{')' if len(node.elts) != 1 else ',)'}" | python | def visit_Tuple(self, node: AST, dfltChaining: bool = True) -> str:
"""Return tuple representation of `node`s elements."""
elems = (self.visit(elt) for elt in node.elts)
return f"({', '.join(elems)}{')' if len(node.elts) != 1 else ',)'}" | [
"def",
"visit_Tuple",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"elems",
"=",
"(",
"self",
".",
"visit",
"(",
"elt",
")",
"for",
"elt",
"in",
"node",
".",
"elts",
")",
"return",
"f... | Return tuple representation of `node`s elements. | [
"Return",
"tuple",
"representation",
"of",
"node",
"s",
"elements",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L205-L208 | train | 58,777 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Set | def visit_Set(self, node: AST, dfltChaining: bool = True) -> str:
"""Return set representation of `node`s elements."""
return '{' + ', '.join([self.visit(elt) for elt in node.elts]) + '}' | python | def visit_Set(self, node: AST, dfltChaining: bool = True) -> str:
"""Return set representation of `node`s elements."""
return '{' + ', '.join([self.visit(elt) for elt in node.elts]) + '}' | [
"def",
"visit_Set",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"'{'",
"+",
"', '",
".",
"join",
"(",
"[",
"self",
".",
"visit",
"(",
"elt",
")",
"for",
"elt",
"in",
"node"... | Return set representation of `node`s elements. | [
"Return",
"set",
"representation",
"of",
"node",
"s",
"elements",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L210-L212 | train | 58,778 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Dict | def visit_Dict(self, node: AST, dfltChaining: bool = True) -> str:
"""Return dict representation of `node`s elements."""
items = (': '.join((self.visit(key), self.visit(value)))
for key, value in zip(node.keys, node.values))
return f"{{{', '.join(items)}}}" | python | def visit_Dict(self, node: AST, dfltChaining: bool = True) -> str:
"""Return dict representation of `node`s elements."""
items = (': '.join((self.visit(key), self.visit(value)))
for key, value in zip(node.keys, node.values))
return f"{{{', '.join(items)}}}" | [
"def",
"visit_Dict",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"items",
"=",
"(",
"': '",
".",
"join",
"(",
"(",
"self",
".",
"visit",
"(",
"key",
")",
",",
"self",
".",
"visit",
... | Return dict representation of `node`s elements. | [
"Return",
"dict",
"representation",
"of",
"node",
"s",
"elements",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L214-L218 | train | 58,779 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Name | def visit_Name(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s id."""
return node.id | python | def visit_Name(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s id."""
return node.id | [
"def",
"visit_Name",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"node",
".",
"id"
] | Return `node`s id. | [
"Return",
"node",
"s",
"id",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L226-L228 | train | 58,780 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Starred | def visit_Starred(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of starred expresssion."""
with self.op_man(node):
return f"*{self.visit(node.value)}" | python | def visit_Starred(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of starred expresssion."""
with self.op_man(node):
return f"*{self.visit(node.value)}" | [
"def",
"visit_Starred",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"with",
"self",
".",
"op_man",
"(",
"node",
")",
":",
"return",
"f\"*{self.visit(node.value)}\""
] | Return representation of starred expresssion. | [
"Return",
"representation",
"of",
"starred",
"expresssion",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L230-L233 | train | 58,781 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Expr | def visit_Expr(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of nested expression."""
return self.visit(node.value) | python | def visit_Expr(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of nested expression."""
return self.visit(node.value) | [
"def",
"visit_Expr",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"self",
".",
"visit",
"(",
"node",
".",
"value",
")"
] | Return representation of nested expression. | [
"Return",
"representation",
"of",
"nested",
"expression",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L236-L238 | train | 58,782 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_UnaryOp | def visit_UnaryOp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of `node`s operator and operand."""
op = node.op
with self.op_man(op):
return self.visit(op) + self.visit(node.operand) | python | def visit_UnaryOp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of `node`s operator and operand."""
op = node.op
with self.op_man(op):
return self.visit(op) + self.visit(node.operand) | [
"def",
"visit_UnaryOp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"op",
"=",
"node",
".",
"op",
"with",
"self",
".",
"op_man",
"(",
"op",
")",
":",
"return",
"self",
".",
"visit",
... | Return representation of `node`s operator and operand. | [
"Return",
"representation",
"of",
"node",
"s",
"operator",
"and",
"operand",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L242-L246 | train | 58,783 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Div | def visit_Div(self, node: AST, dfltChaining: bool = True) -> str:
"""Return division sign."""
return '/' if self.compact else ' / ' | python | def visit_Div(self, node: AST, dfltChaining: bool = True) -> str:
"""Return division sign."""
return '/' if self.compact else ' / ' | [
"def",
"visit_Div",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"'/'",
"if",
"self",
".",
"compact",
"else",
"' / '"
] | Return division sign. | [
"Return",
"division",
"sign",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L293-L295 | train | 58,784 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Compare | def visit_Compare(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s operators and operands as inlined expression."""
# all comparison operators have the same precedence,
# we just take the first one as representative
first_op = node.ops[0]
with self.op_man(fir... | python | def visit_Compare(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s operators and operands as inlined expression."""
# all comparison operators have the same precedence,
# we just take the first one as representative
first_op = node.ops[0]
with self.op_man(fir... | [
"def",
"visit_Compare",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"# all comparison operators have the same precedence,",
"# we just take the first one as representative",
"first_op",
"=",
"node",
".",
... | Return `node`s operators and operands as inlined expression. | [
"Return",
"node",
"s",
"operators",
"and",
"operands",
"as",
"inlined",
"expression",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L350-L360 | train | 58,785 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_keyword | def visit_keyword(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of `node` as keyword arg."""
arg = node.arg
if arg is None:
return f"**{self.visit(node.value)}"
else:
return f"{arg}={self.visit(node.value)}" | python | def visit_keyword(self, node: AST, dfltChaining: bool = True) -> str:
"""Return representation of `node` as keyword arg."""
arg = node.arg
if arg is None:
return f"**{self.visit(node.value)}"
else:
return f"{arg}={self.visit(node.value)}" | [
"def",
"visit_keyword",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"arg",
"=",
"node",
".",
"arg",
"if",
"arg",
"is",
"None",
":",
"return",
"f\"**{self.visit(node.value)}\"",
"else",
":",
... | Return representation of `node` as keyword arg. | [
"Return",
"representation",
"of",
"node",
"as",
"keyword",
"arg",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L404-L410 | train | 58,786 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Call | def visit_Call(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as function call."""
args = node.args
try:
kwds = node.keywords
except AttributeError:
kwds = []
self.compact = True
args_src = (self.visit(arg) for... | python | def visit_Call(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as function call."""
args = node.args
try:
kwds = node.keywords
except AttributeError:
kwds = []
self.compact = True
args_src = (self.visit(arg) for... | [
"def",
"visit_Call",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"args",
"=",
"node",
".",
"args",
"try",
":",
"kwds",
"=",
"node",
".",
"keywords",
"except",
"AttributeError",
":",
"kwd... | Return `node`s representation as function call. | [
"Return",
"node",
"s",
"representation",
"as",
"function",
"call",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L412-L425 | train | 58,787 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_arguments | def visit_arguments(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as argument list."""
args = node.args
dflts = node.defaults
vararg = node.vararg
kwargs = node.kwonlyargs
kwdflts = node.kw_defaults
kwarg = node.kwarg
... | python | def visit_arguments(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as argument list."""
args = node.args
dflts = node.defaults
vararg = node.vararg
kwargs = node.kwonlyargs
kwdflts = node.kw_defaults
kwarg = node.kwarg
... | [
"def",
"visit_arguments",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"args",
"=",
"node",
".",
"args",
"dflts",
"=",
"node",
".",
"defaults",
"vararg",
"=",
"node",
".",
"vararg",
"kwar... | Return `node`s representation as argument list. | [
"Return",
"node",
"s",
"representation",
"as",
"argument",
"list",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L429-L450 | train | 58,788 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Lambda | def visit_Lambda(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as lambda expression."""
with self.op_man(node):
src = f"lambda {self.visit(node.args)}: {self.visit(node.body)}"
return self.wrap_expr(src, dfltChaining) | python | def visit_Lambda(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as lambda expression."""
with self.op_man(node):
src = f"lambda {self.visit(node.args)}: {self.visit(node.body)}"
return self.wrap_expr(src, dfltChaining) | [
"def",
"visit_Lambda",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"with",
"self",
".",
"op_man",
"(",
"node",
")",
":",
"src",
"=",
"f\"lambda {self.visit(node.args)}: {self.visit(node.body)}\"",... | Return `node`s representation as lambda expression. | [
"Return",
"node",
"s",
"representation",
"as",
"lambda",
"expression",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L452-L456 | train | 58,789 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_IfExp | def visit_IfExp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as ... if ... else ... expression."""
with self.op_man(node):
src = " if ".join((self.visit(node.body, dfltChaining=False),
" else ".join((self.visit(node.test)... | python | def visit_IfExp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as ... if ... else ... expression."""
with self.op_man(node):
src = " if ".join((self.visit(node.body, dfltChaining=False),
" else ".join((self.visit(node.test)... | [
"def",
"visit_IfExp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"with",
"self",
".",
"op_man",
"(",
"node",
")",
":",
"src",
"=",
"\" if \"",
".",
"join",
"(",
"(",
"self",
".",
"v... | Return `node`s representation as ... if ... else ... expression. | [
"Return",
"node",
"s",
"representation",
"as",
"...",
"if",
"...",
"else",
"...",
"expression",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L460-L466 | train | 58,790 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Attribute | def visit_Attribute(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as attribute access."""
return '.'.join((self.visit(node.value), node.attr)) | python | def visit_Attribute(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as attribute access."""
return '.'.join((self.visit(node.value), node.attr)) | [
"def",
"visit_Attribute",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"'.'",
".",
"join",
"(",
"(",
"self",
".",
"visit",
"(",
"node",
".",
"value",
")",
",",
"node",
".",
... | Return `node`s representation as attribute access. | [
"Return",
"node",
"s",
"representation",
"as",
"attribute",
"access",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L470-L472 | train | 58,791 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_Slice | def visit_Slice(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as slice."""
elems = [self.visit(node.lower), self.visit(node.upper)]
if node.step is not None:
elems.append(self.visit(node.step))
return ':'.join(elems) | python | def visit_Slice(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as slice."""
elems = [self.visit(node.lower), self.visit(node.upper)]
if node.step is not None:
elems.append(self.visit(node.step))
return ':'.join(elems) | [
"def",
"visit_Slice",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"elems",
"=",
"[",
"self",
".",
"visit",
"(",
"node",
".",
"lower",
")",
",",
"self",
".",
"visit",
"(",
"node",
"."... | Return `node`s representation as slice. | [
"Return",
"node",
"s",
"representation",
"as",
"slice",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L484-L489 | train | 58,792 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_ExtSlice | def visit_ExtSlice(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as extended slice."""
return ', '.join((self.visit(dim) for dim in node.dims)) | python | def visit_ExtSlice(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as extended slice."""
return ', '.join((self.visit(dim) for dim in node.dims)) | [
"def",
"visit_ExtSlice",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"', '",
".",
"join",
"(",
"(",
"self",
".",
"visit",
"(",
"dim",
")",
"for",
"dim",
"in",
"node",
".",
... | Return `node`s representation as extended slice. | [
"Return",
"node",
"s",
"representation",
"as",
"extended",
"slice",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L491-L493 | train | 58,793 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_comprehension | def visit_comprehension(self, node: AST,
dfltChaining: bool = True) -> str:
"""Return `node`s representation as comprehension."""
target = node.target
try:
elts = target.elts # we have a tuple of names
except AttributeError:
na... | python | def visit_comprehension(self, node: AST,
dfltChaining: bool = True) -> str:
"""Return `node`s representation as comprehension."""
target = node.target
try:
elts = target.elts # we have a tuple of names
except AttributeError:
na... | [
"def",
"visit_comprehension",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"target",
"=",
"node",
".",
"target",
"try",
":",
"elts",
"=",
"target",
".",
"elts",
"# we have a tuple of names",
... | Return `node`s representation as comprehension. | [
"Return",
"node",
"s",
"representation",
"as",
"comprehension",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L497-L510 | train | 58,794 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_ListComp | def visit_ListComp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as list comprehension."""
return f"[{self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)}]" | python | def visit_ListComp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as list comprehension."""
return f"[{self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)}]" | [
"def",
"visit_ListComp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"f\"[{self.visit(node.elt)} \"",
"f\"{' '.join(self.visit(gen) for gen in node.generators)}]\""
] | Return `node`s representation as list comprehension. | [
"Return",
"node",
"s",
"representation",
"as",
"list",
"comprehension",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L512-L515 | train | 58,795 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_SetComp | def visit_SetComp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as set comprehension."""
return f"{{{self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)}}}" | python | def visit_SetComp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as set comprehension."""
return f"{{{self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)}}}" | [
"def",
"visit_SetComp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"f\"{{{self.visit(node.elt)} \"",
"f\"{' '.join(self.visit(gen) for gen in node.generators)}}}\""
] | Return `node`s representation as set comprehension. | [
"Return",
"node",
"s",
"representation",
"as",
"set",
"comprehension",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L517-L520 | train | 58,796 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_DictComp | def visit_DictComp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as dict comprehension."""
return f"{{{self.visit(node.key)}: {self.visit(node.value)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)}}}" | python | def visit_DictComp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as dict comprehension."""
return f"{{{self.visit(node.key)}: {self.visit(node.value)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)}}}" | [
"def",
"visit_DictComp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"f\"{{{self.visit(node.key)}: {self.visit(node.value)} \"",
"f\"{' '.join(self.visit(gen) for gen in node.generators)}}}\""
] | Return `node`s representation as dict comprehension. | [
"Return",
"node",
"s",
"representation",
"as",
"dict",
"comprehension",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L522-L525 | train | 58,797 |
mamrhein/specification | specification/_extd_ast_expr.py | SourceGenerator.visit_GeneratorExp | def visit_GeneratorExp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as generator expression."""
return f"({self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)})" | python | def visit_GeneratorExp(self, node: AST, dfltChaining: bool = True) -> str:
"""Return `node`s representation as generator expression."""
return f"({self.visit(node.elt)} " \
f"{' '.join(self.visit(gen) for gen in node.generators)})" | [
"def",
"visit_GeneratorExp",
"(",
"self",
",",
"node",
":",
"AST",
",",
"dfltChaining",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"f\"({self.visit(node.elt)} \"",
"f\"{' '.join(self.visit(gen) for gen in node.generators)})\""
] | Return `node`s representation as generator expression. | [
"Return",
"node",
"s",
"representation",
"as",
"generator",
"expression",
"."
] | a4c09a0d286cda7a04e8a189f12e23edd97f64ea | https://github.com/mamrhein/specification/blob/a4c09a0d286cda7a04e8a189f12e23edd97f64ea/specification/_extd_ast_expr.py#L527-L530 | train | 58,798 |
SeattleTestbed/seash | pyreadline/lineeditor/lineobj.py | TextLine.visible_line_width | def visible_line_width(self, position = Point):
"""Return the visible width of the text in line buffer up to position."""
extra_char_width = len([ None for c in self[:position].line_buffer if 0x2013 <= ord(c) <= 0xFFFD])
return len(self[:position].quoted_text()) + self[:position].line_buffer.... | python | def visible_line_width(self, position = Point):
"""Return the visible width of the text in line buffer up to position."""
extra_char_width = len([ None for c in self[:position].line_buffer if 0x2013 <= ord(c) <= 0xFFFD])
return len(self[:position].quoted_text()) + self[:position].line_buffer.... | [
"def",
"visible_line_width",
"(",
"self",
",",
"position",
"=",
"Point",
")",
":",
"extra_char_width",
"=",
"len",
"(",
"[",
"None",
"for",
"c",
"in",
"self",
"[",
":",
"position",
"]",
".",
"line_buffer",
"if",
"0x2013",
"<=",
"ord",
"(",
"c",
")",
... | Return the visible width of the text in line buffer up to position. | [
"Return",
"the",
"visible",
"width",
"of",
"the",
"text",
"in",
"line",
"buffer",
"up",
"to",
"position",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/lineobj.py#L243-L246 | train | 58,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.