id int32 0 252k | 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 list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
47,200 | troeger/opensubmit | executor/opensubmitexec/running.py | RunningProgram.expect_end | def expect_end(self):
"""Wait for the running program to finish.
Returns:
A tuple with the exit code, as reported by the operating system, and the output produced.
"""
logger.debug("Waiting for termination of '{0}'".format(self.name))
try:
# Make sure we ... | python | def expect_end(self):
"""Wait for the running program to finish.
Returns:
A tuple with the exit code, as reported by the operating system, and the output produced.
"""
logger.debug("Waiting for termination of '{0}'".format(self.name))
try:
# Make sure we ... | [
"def",
"expect_end",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Waiting for termination of '{0}'\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"try",
":",
"# Make sure we fetch the last output bytes.",
"# Recommendation from the pexpect docs.",
"sel... | Wait for the running program to finish.
Returns:
A tuple with the exit code, as reported by the operating system, and the output produced. | [
"Wait",
"for",
"the",
"running",
"program",
"to",
"finish",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L159-L182 |
47,201 | troeger/opensubmit | executor/opensubmitexec/running.py | RunningProgram.expect_exitstatus | def expect_exitstatus(self, exit_status):
"""Wait for the running program to finish and expect some exit status.
Args:
exit_status (int): The expected exit status.
Raises:
WrongExitStatusException: The produced exit status is not the expected one.
"""
s... | python | def expect_exitstatus(self, exit_status):
"""Wait for the running program to finish and expect some exit status.
Args:
exit_status (int): The expected exit status.
Raises:
WrongExitStatusException: The produced exit status is not the expected one.
"""
s... | [
"def",
"expect_exitstatus",
"(",
"self",
",",
"exit_status",
")",
":",
"self",
".",
"expect_end",
"(",
")",
"logger",
".",
"debug",
"(",
"\"Checking exit status of '{0}', output so far: {1}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"get_outp... | Wait for the running program to finish and expect some exit status.
Args:
exit_status (int): The expected exit status.
Raises:
WrongExitStatusException: The produced exit status is not the expected one. | [
"Wait",
"for",
"the",
"running",
"program",
"to",
"finish",
"and",
"expect",
"some",
"exit",
"status",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L184-L205 |
47,202 | idlesign/django-sitemessage | sitemessage/views.py | unsubscribe | def unsubscribe(request, message_id, dispatch_id, hashed, redirect_to=None):
"""Handles unsubscribe request.
:param Request request:
:param int message_id:
:param int dispatch_id:
:param str hashed:
:param str redirect_to:
:return:
"""
return _generic_view(
'handle_unsubscri... | python | def unsubscribe(request, message_id, dispatch_id, hashed, redirect_to=None):
"""Handles unsubscribe request.
:param Request request:
:param int message_id:
:param int dispatch_id:
:param str hashed:
:param str redirect_to:
:return:
"""
return _generic_view(
'handle_unsubscri... | [
"def",
"unsubscribe",
"(",
"request",
",",
"message_id",
",",
"dispatch_id",
",",
"hashed",
",",
"redirect_to",
"=",
"None",
")",
":",
"return",
"_generic_view",
"(",
"'handle_unsubscribe_request'",
",",
"sig_unsubscribe_failed",
",",
"request",
",",
"message_id",
... | Handles unsubscribe request.
:param Request request:
:param int message_id:
:param int dispatch_id:
:param str hashed:
:param str redirect_to:
:return: | [
"Handles",
"unsubscribe",
"request",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/views.py#L47-L60 |
47,203 | idlesign/django-sitemessage | sitemessage/views.py | mark_read | def mark_read(request, message_id, dispatch_id, hashed, redirect_to=None):
"""Handles mark message as read request.
:param Request request:
:param int message_id:
:param int dispatch_id:
:param str hashed:
:param str redirect_to:
:return:
"""
if redirect_to is None:
redirect... | python | def mark_read(request, message_id, dispatch_id, hashed, redirect_to=None):
"""Handles mark message as read request.
:param Request request:
:param int message_id:
:param int dispatch_id:
:param str hashed:
:param str redirect_to:
:return:
"""
if redirect_to is None:
redirect... | [
"def",
"mark_read",
"(",
"request",
",",
"message_id",
",",
"dispatch_id",
",",
"hashed",
",",
"redirect_to",
"=",
"None",
")",
":",
"if",
"redirect_to",
"is",
"None",
":",
"redirect_to",
"=",
"get_static_url",
"(",
"'img/sitemessage/blank.png'",
")",
"return",
... | Handles mark message as read request.
:param Request request:
:param int message_id:
:param int dispatch_id:
:param str hashed:
:param str redirect_to:
:return: | [
"Handles",
"mark",
"message",
"as",
"read",
"request",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/views.py#L63-L79 |
47,204 | idlesign/django-sitemessage | sitemessage/toolbox.py | schedule_messages | def schedule_messages(messages, recipients=None, sender=None, priority=None):
"""Schedules a message or messages.
:param MessageBase|str|list messages: str or MessageBase heir or list - use str to create PlainTextMessage.
:param list|None recipients: recipients addresses or Django User model heir instances... | python | def schedule_messages(messages, recipients=None, sender=None, priority=None):
"""Schedules a message or messages.
:param MessageBase|str|list messages: str or MessageBase heir or list - use str to create PlainTextMessage.
:param list|None recipients: recipients addresses or Django User model heir instances... | [
"def",
"schedule_messages",
"(",
"messages",
",",
"recipients",
"=",
"None",
",",
"sender",
"=",
"None",
",",
"priority",
"=",
"None",
")",
":",
"if",
"not",
"is_iterable",
"(",
"messages",
")",
":",
"messages",
"=",
"(",
"messages",
",",
")",
"results",... | Schedules a message or messages.
:param MessageBase|str|list messages: str or MessageBase heir or list - use str to create PlainTextMessage.
:param list|None recipients: recipients addresses or Django User model heir instances
If `None` Dispatches should be created before send using `prepare_dispatches... | [
"Schedules",
"a",
"message",
"or",
"messages",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/toolbox.py#L30-L54 |
47,205 | idlesign/django-sitemessage | sitemessage/toolbox.py | send_scheduled_messages | def send_scheduled_messages(priority=None, ignore_unknown_messengers=False, ignore_unknown_message_types=False):
"""Sends scheduled messages.
:param int, None priority: number to limit sending message by this priority.
:param bool ignore_unknown_messengers: to silence UnknownMessengerError
:param bool ... | python | def send_scheduled_messages(priority=None, ignore_unknown_messengers=False, ignore_unknown_message_types=False):
"""Sends scheduled messages.
:param int, None priority: number to limit sending message by this priority.
:param bool ignore_unknown_messengers: to silence UnknownMessengerError
:param bool ... | [
"def",
"send_scheduled_messages",
"(",
"priority",
"=",
"None",
",",
"ignore_unknown_messengers",
"=",
"False",
",",
"ignore_unknown_message_types",
"=",
"False",
")",
":",
"dispatches_by_messengers",
"=",
"Dispatch",
".",
"group_by_messengers",
"(",
"Dispatch",
".",
... | Sends scheduled messages.
:param int, None priority: number to limit sending message by this priority.
:param bool ignore_unknown_messengers: to silence UnknownMessengerError
:param bool ignore_unknown_message_types: to silence UnknownMessageTypeError
:raises UnknownMessengerError:
:raises UnknownM... | [
"Sends",
"scheduled",
"messages",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/toolbox.py#L57-L75 |
47,206 | idlesign/django-sitemessage | sitemessage/toolbox.py | check_undelivered | def check_undelivered(to=None):
"""Sends a notification email if any undelivered dispatches.
Returns undelivered (failed) dispatches count.
:param str|unicode to: Recipient address. If not set Django ADMINS setting is used.
:rtype: int
"""
failed_count = Dispatch.objects.filter(dispatch_statu... | python | def check_undelivered(to=None):
"""Sends a notification email if any undelivered dispatches.
Returns undelivered (failed) dispatches count.
:param str|unicode to: Recipient address. If not set Django ADMINS setting is used.
:rtype: int
"""
failed_count = Dispatch.objects.filter(dispatch_statu... | [
"def",
"check_undelivered",
"(",
"to",
"=",
"None",
")",
":",
"failed_count",
"=",
"Dispatch",
".",
"objects",
".",
"filter",
"(",
"dispatch_status",
"=",
"Dispatch",
".",
"DISPATCH_STATUS_FAILED",
")",
".",
"count",
"(",
")",
"if",
"failed_count",
":",
"fro... | Sends a notification email if any undelivered dispatches.
Returns undelivered (failed) dispatches count.
:param str|unicode to: Recipient address. If not set Django ADMINS setting is used.
:rtype: int | [
"Sends",
"a",
"notification",
"email",
"if",
"any",
"undelivered",
"dispatches",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/toolbox.py#L89-L122 |
47,207 | idlesign/django-sitemessage | sitemessage/toolbox.py | prepare_dispatches | def prepare_dispatches():
"""Automatically creates dispatches for messages without them.
:return: list of Dispatch
:rtype: list
"""
dispatches = []
target_messages = Message.get_without_dispatches()
cache = {}
for message_model in target_messages:
if message_model.cls not in ... | python | def prepare_dispatches():
"""Automatically creates dispatches for messages without them.
:return: list of Dispatch
:rtype: list
"""
dispatches = []
target_messages = Message.get_without_dispatches()
cache = {}
for message_model in target_messages:
if message_model.cls not in ... | [
"def",
"prepare_dispatches",
"(",
")",
":",
"dispatches",
"=",
"[",
"]",
"target_messages",
"=",
"Message",
".",
"get_without_dispatches",
"(",
")",
"cache",
"=",
"{",
"}",
"for",
"message_model",
"in",
"target_messages",
":",
"if",
"message_model",
".",
"cls"... | Automatically creates dispatches for messages without them.
:return: list of Dispatch
:rtype: list | [
"Automatically",
"creates",
"dispatches",
"for",
"messages",
"without",
"them",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/toolbox.py#L160-L182 |
47,208 | idlesign/django-sitemessage | sitemessage/toolbox.py | get_user_preferences_for_ui | def get_user_preferences_for_ui(user, message_filter=None, messenger_filter=None, new_messengers_titles=None):
"""Returns a two element tuple with user subscription preferences to render in UI.
Message types with the same titles are merged into one row.
First element:
A list of messengers titles.
... | python | def get_user_preferences_for_ui(user, message_filter=None, messenger_filter=None, new_messengers_titles=None):
"""Returns a two element tuple with user subscription preferences to render in UI.
Message types with the same titles are merged into one row.
First element:
A list of messengers titles.
... | [
"def",
"get_user_preferences_for_ui",
"(",
"user",
",",
"message_filter",
"=",
"None",
",",
"messenger_filter",
"=",
"None",
",",
"new_messengers_titles",
"=",
"None",
")",
":",
"if",
"new_messengers_titles",
"is",
"None",
":",
"new_messengers_titles",
"=",
"{",
"... | Returns a two element tuple with user subscription preferences to render in UI.
Message types with the same titles are merged into one row.
First element:
A list of messengers titles.
Second element:
User preferences dictionary indexed by message type titles.
Preferences (dictiona... | [
"Returns",
"a",
"two",
"element",
"tuple",
"with",
"user",
"subscription",
"preferences",
"to",
"render",
"in",
"UI",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/toolbox.py#L185-L263 |
47,209 | idlesign/django-sitemessage | sitemessage/toolbox.py | set_user_preferences_from_request | def set_user_preferences_from_request(request):
"""Sets user subscription preferences using data from a request.
Expects data sent by form built with `sitemessage_prefs_table` template tag.
:param request:
:rtype: bool
:return: Flag, whether prefs were found in the request.
"""
prefs = []
... | python | def set_user_preferences_from_request(request):
"""Sets user subscription preferences using data from a request.
Expects data sent by form built with `sitemessage_prefs_table` template tag.
:param request:
:rtype: bool
:return: Flag, whether prefs were found in the request.
"""
prefs = []
... | [
"def",
"set_user_preferences_from_request",
"(",
"request",
")",
":",
"prefs",
"=",
"[",
"]",
"for",
"pref",
"in",
"request",
".",
"POST",
".",
"getlist",
"(",
"_PREF_POST_KEY",
")",
":",
"message_alias",
",",
"messenger_alias",
"=",
"pref",
".",
"split",
"(... | Sets user subscription preferences using data from a request.
Expects data sent by form built with `sitemessage_prefs_table` template tag.
:param request:
:rtype: bool
:return: Flag, whether prefs were found in the request. | [
"Sets",
"user",
"subscription",
"preferences",
"using",
"data",
"from",
"a",
"request",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/toolbox.py#L266-L292 |
47,210 | troeger/opensubmit | web/opensubmit/admin/gradingscheme.py | GradingSchemeAdmin.formfield_for_dbfield | def formfield_for_dbfield(self, db_field, **kwargs):
''' Offer only gradings that are not used by other schemes, which means they are used by this scheme or not at all.'''
if db_field.name == "gradings":
request=kwargs['request']
try:
#TODO: MockRequst object fro... | python | def formfield_for_dbfield(self, db_field, **kwargs):
''' Offer only gradings that are not used by other schemes, which means they are used by this scheme or not at all.'''
if db_field.name == "gradings":
request=kwargs['request']
try:
#TODO: MockRequst object fro... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"db_field",
".",
"name",
"==",
"\"gradings\"",
":",
"request",
"=",
"kwargs",
"[",
"'request'",
"]",
"try",
":",
"#TODO: MockRequst object from unit test does... | Offer only gradings that are not used by other schemes, which means they are used by this scheme or not at all. | [
"Offer",
"only",
"gradings",
"that",
"are",
"not",
"used",
"by",
"other",
"schemes",
"which",
"means",
"they",
"are",
"used",
"by",
"this",
"scheme",
"or",
"not",
"at",
"all",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/gradingscheme.py#L36-L48 |
47,211 | umich-brcf-bioinf/Connor | connor/consam/bamtag.py | build_bam_tags | def build_bam_tags():
'''builds the list of BAM tags to be added to output BAMs'''
#pylint: disable=unused-argument
def _combine_filters(fam, paired_align, align):
filters = [x.filter_value for x in [fam, align] if x and x.filter_value]
if filters:
return ";".join(filters).replac... | python | def build_bam_tags():
'''builds the list of BAM tags to be added to output BAMs'''
#pylint: disable=unused-argument
def _combine_filters(fam, paired_align, align):
filters = [x.filter_value for x in [fam, align] if x and x.filter_value]
if filters:
return ";".join(filters).replac... | [
"def",
"build_bam_tags",
"(",
")",
":",
"#pylint: disable=unused-argument",
"def",
"_combine_filters",
"(",
"fam",
",",
"paired_align",
",",
"align",
")",
":",
"filters",
"=",
"[",
"x",
".",
"filter_value",
"for",
"x",
"in",
"[",
"fam",
",",
"align",
"]",
... | builds the list of BAM tags to be added to output BAMs | [
"builds",
"the",
"list",
"of",
"BAM",
"tags",
"to",
"be",
"added",
"to",
"output",
"BAMs"
] | b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13 | https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/consam/bamtag.py#L41-L76 |
47,212 | praekelt/django-livechat | livechat/context_processors.py | current_livechat | def current_livechat(request):
"""
Checks if a live chat is currently on the go, and add it to the request
context.
This is to allow the AskMAMA URL in the top-navigation to be redirected to
the live chat object view consistently, and to make it available to the
views and tags that depends on i... | python | def current_livechat(request):
"""
Checks if a live chat is currently on the go, and add it to the request
context.
This is to allow the AskMAMA URL in the top-navigation to be redirected to
the live chat object view consistently, and to make it available to the
views and tags that depends on i... | [
"def",
"current_livechat",
"(",
"request",
")",
":",
"result",
"=",
"{",
"}",
"livechat",
"=",
"LiveChat",
".",
"chat_finder",
".",
"get_current_live_chat",
"(",
")",
"if",
"livechat",
":",
"result",
"[",
"'live_chat'",
"]",
"=",
"{",
"}",
"result",
"[",
... | Checks if a live chat is currently on the go, and add it to the request
context.
This is to allow the AskMAMA URL in the top-navigation to be redirected to
the live chat object view consistently, and to make it available to the
views and tags that depends on it. | [
"Checks",
"if",
"a",
"live",
"chat",
"is",
"currently",
"on",
"the",
"go",
"and",
"add",
"it",
"to",
"the",
"request",
"context",
"."
] | 22d86fb4219e5af6c83e0542aa30e5ea54e71d26 | https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/context_processors.py#L4-L21 |
47,213 | troeger/opensubmit | web/opensubmit/models/submissionfile.py | upload_path | def upload_path(instance, filename):
'''
Sanitize the user-provided file name, add timestamp for uniqness.
'''
filename = filename.replace(" ", "_")
filename = unicodedata.normalize('NFKD', filename).lower()
return os.path.join(str(timezone.now().date().isoformat()), filename) | python | def upload_path(instance, filename):
'''
Sanitize the user-provided file name, add timestamp for uniqness.
'''
filename = filename.replace(" ", "_")
filename = unicodedata.normalize('NFKD', filename).lower()
return os.path.join(str(timezone.now().date().isoformat()), filename) | [
"def",
"upload_path",
"(",
"instance",
",",
"filename",
")",
":",
"filename",
"=",
"filename",
".",
"replace",
"(",
"\" \"",
",",
"\"_\"",
")",
"filename",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"filename",
")",
".",
"lower",
"(",
")",... | Sanitize the user-provided file name, add timestamp for uniqness. | [
"Sanitize",
"the",
"user",
"-",
"provided",
"file",
"name",
"add",
"timestamp",
"for",
"uniqness",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submissionfile.py#L17-L24 |
47,214 | troeger/opensubmit | web/opensubmit/models/submissionfile.py | SubmissionFile.is_archive | def is_archive(self):
'''
Determines if the attachment is an archive.
'''
try:
if zipfile.is_zipfile(self.attachment.path) or tarfile.is_tarfile(self.attachment.path):
return True
except Exception:
pass
return False | python | def is_archive(self):
'''
Determines if the attachment is an archive.
'''
try:
if zipfile.is_zipfile(self.attachment.path) or tarfile.is_tarfile(self.attachment.path):
return True
except Exception:
pass
return False | [
"def",
"is_archive",
"(",
"self",
")",
":",
"try",
":",
"if",
"zipfile",
".",
"is_zipfile",
"(",
"self",
".",
"attachment",
".",
"path",
")",
"or",
"tarfile",
".",
"is_tarfile",
"(",
"self",
".",
"attachment",
".",
"path",
")",
":",
"return",
"True",
... | Determines if the attachment is an archive. | [
"Determines",
"if",
"the",
"attachment",
"is",
"an",
"archive",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submissionfile.py#L141-L150 |
47,215 | troeger/opensubmit | web/opensubmit/social/passthrough.py | PassThroughAuth.get_user_details | def get_user_details(self, response):
""" Complete with additional information from session, as available. """
result = {
'id': response['id'],
'username': response.get('username', None),
'email': response.get('email', None),
'first_name': response.get('fi... | python | def get_user_details(self, response):
""" Complete with additional information from session, as available. """
result = {
'id': response['id'],
'username': response.get('username', None),
'email': response.get('email', None),
'first_name': response.get('fi... | [
"def",
"get_user_details",
"(",
"self",
",",
"response",
")",
":",
"result",
"=",
"{",
"'id'",
":",
"response",
"[",
"'id'",
"]",
",",
"'username'",
":",
"response",
".",
"get",
"(",
"'username'",
",",
"None",
")",
",",
"'email'",
":",
"response",
".",... | Complete with additional information from session, as available. | [
"Complete",
"with",
"additional",
"information",
"from",
"session",
"as",
"available",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/social/passthrough.py#L48-L60 |
47,216 | umich-brcf-bioinf/Connor | connor/consam/readers.py | paired_reader_from_bamfile | def paired_reader_from_bamfile(args,
log,
usage_logger,
annotated_writer):
'''Given a BAM file, return a generator that yields filtered, paired reads'''
total_aligns = pysamwrapper.total_align_count(args.input_bam)
... | python | def paired_reader_from_bamfile(args,
log,
usage_logger,
annotated_writer):
'''Given a BAM file, return a generator that yields filtered, paired reads'''
total_aligns = pysamwrapper.total_align_count(args.input_bam)
... | [
"def",
"paired_reader_from_bamfile",
"(",
"args",
",",
"log",
",",
"usage_logger",
",",
"annotated_writer",
")",
":",
"total_aligns",
"=",
"pysamwrapper",
".",
"total_align_count",
"(",
"args",
".",
"input_bam",
")",
"bamfile_generator",
"=",
"_bamfile_generator",
"... | Given a BAM file, return a generator that yields filtered, paired reads | [
"Given",
"a",
"BAM",
"file",
"return",
"a",
"generator",
"that",
"yields",
"filtered",
"paired",
"reads"
] | b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13 | https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/consam/readers.py#L112-L124 |
47,217 | troeger/opensubmit | executor/opensubmitexec/hostinfo.py | opencl | def opencl():
'''
Determine some system information about the installed OpenCL device.
'''
result = []
try:
import pyopencl as ocl
for plt in ocl.get_platforms():
result.append("Platform: " + platform.name)
for device in plt.get_devices():
... | python | def opencl():
'''
Determine some system information about the installed OpenCL device.
'''
result = []
try:
import pyopencl as ocl
for plt in ocl.get_platforms():
result.append("Platform: " + platform.name)
for device in plt.get_devices():
... | [
"def",
"opencl",
"(",
")",
":",
"result",
"=",
"[",
"]",
"try",
":",
"import",
"pyopencl",
"as",
"ocl",
"for",
"plt",
"in",
"ocl",
".",
"get_platforms",
"(",
")",
":",
"result",
".",
"append",
"(",
"\"Platform: \"",
"+",
"platform",
".",
"name",
")",... | Determine some system information about the installed OpenCL device. | [
"Determine",
"some",
"system",
"information",
"about",
"the",
"installed",
"OpenCL",
"device",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/hostinfo.py#L34-L55 |
47,218 | troeger/opensubmit | executor/opensubmitexec/hostinfo.py | all_host_infos | def all_host_infos():
'''
Summarize all host information.
'''
output = []
output.append(["Operating system", os()])
output.append(["CPUID information", cpu()])
output.append(["CC information", compiler()])
output.append(["JDK information", from_cmd("java -version")])
output.appen... | python | def all_host_infos():
'''
Summarize all host information.
'''
output = []
output.append(["Operating system", os()])
output.append(["CPUID information", cpu()])
output.append(["CC information", compiler()])
output.append(["JDK information", from_cmd("java -version")])
output.appen... | [
"def",
"all_host_infos",
"(",
")",
":",
"output",
"=",
"[",
"]",
"output",
".",
"append",
"(",
"[",
"\"Operating system\"",
",",
"os",
"(",
")",
"]",
")",
"output",
".",
"append",
"(",
"[",
"\"CPUID information\"",
",",
"cpu",
"(",
")",
"]",
")",
"ou... | Summarize all host information. | [
"Summarize",
"all",
"host",
"information",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/hostinfo.py#L82-L99 |
47,219 | umich-brcf-bioinf/Connor | connor/family.py | CoordinateFamilyHolder._completed_families | def _completed_families(self, reference_name, rightmost_boundary):
'''returns one or more families whose end < rightmost boundary'''
in_progress = self._right_coords_in_progress[reference_name]
while len(in_progress):
right_coord = in_progress[0]
if right_coord < rightmos... | python | def _completed_families(self, reference_name, rightmost_boundary):
'''returns one or more families whose end < rightmost boundary'''
in_progress = self._right_coords_in_progress[reference_name]
while len(in_progress):
right_coord = in_progress[0]
if right_coord < rightmos... | [
"def",
"_completed_families",
"(",
"self",
",",
"reference_name",
",",
"rightmost_boundary",
")",
":",
"in_progress",
"=",
"self",
".",
"_right_coords_in_progress",
"[",
"reference_name",
"]",
"while",
"len",
"(",
"in_progress",
")",
":",
"right_coord",
"=",
"in_p... | returns one or more families whose end < rightmost boundary | [
"returns",
"one",
"or",
"more",
"families",
"whose",
"end",
"<",
"rightmost",
"boundary"
] | b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13 | https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/family.py#L164-L178 |
47,220 | troeger/opensubmit | web/opensubmit/mails.py | inform_student | def inform_student(submission, request, state):
'''
Create an email message for the student,
based on the given submission state.
Sending eMails on validation completion does
not work, since this may have been triggered
by the admin.
'''
details_url = request.build_absolute_uri(reverse(... | python | def inform_student(submission, request, state):
'''
Create an email message for the student,
based on the given submission state.
Sending eMails on validation completion does
not work, since this may have been triggered
by the admin.
'''
details_url = request.build_absolute_uri(reverse(... | [
"def",
"inform_student",
"(",
"submission",
",",
"request",
",",
"state",
")",
":",
"details_url",
"=",
"request",
".",
"build_absolute_uri",
"(",
"reverse",
"(",
"'details'",
",",
"args",
"=",
"(",
"submission",
".",
"pk",
",",
")",
")",
")",
"if",
"sta... | Create an email message for the student,
based on the given submission state.
Sending eMails on validation completion does
not work, since this may have been triggered
by the admin. | [
"Create",
"an",
"email",
"message",
"for",
"the",
"student",
"based",
"on",
"the",
"given",
"submission",
"state",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/mails.py#L40-L80 |
47,221 | troeger/opensubmit | web/opensubmit/models/course.py | Course.graded_submissions | def graded_submissions(self):
'''
Queryset for the graded submissions, which are worth closing.
'''
qs = self._valid_submissions().filter(state__in=[Submission.GRADED])
return qs | python | def graded_submissions(self):
'''
Queryset for the graded submissions, which are worth closing.
'''
qs = self._valid_submissions().filter(state__in=[Submission.GRADED])
return qs | [
"def",
"graded_submissions",
"(",
"self",
")",
":",
"qs",
"=",
"self",
".",
"_valid_submissions",
"(",
")",
".",
"filter",
"(",
"state__in",
"=",
"[",
"Submission",
".",
"GRADED",
"]",
")",
"return",
"qs"
] | Queryset for the graded submissions, which are worth closing. | [
"Queryset",
"for",
"the",
"graded",
"submissions",
"which",
"are",
"worth",
"closing",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/course.py#L67-L72 |
47,222 | troeger/opensubmit | web/opensubmit/models/course.py | Course.authors | def authors(self):
'''
Queryset for all distinct authors this course had so far. Important for statistics.
Note that this may be different from the list of people being registered for the course,
f.e. when they submit something and the leave the course.
'''
qs... | python | def authors(self):
'''
Queryset for all distinct authors this course had so far. Important for statistics.
Note that this may be different from the list of people being registered for the course,
f.e. when they submit something and the leave the course.
'''
qs... | [
"def",
"authors",
"(",
"self",
")",
":",
"qs",
"=",
"self",
".",
"_valid_submissions",
"(",
")",
".",
"values_list",
"(",
"'authors'",
",",
"flat",
"=",
"True",
")",
".",
"distinct",
"(",
")",
"return",
"qs"
] | Queryset for all distinct authors this course had so far. Important for statistics.
Note that this may be different from the list of people being registered for the course,
f.e. when they submit something and the leave the course. | [
"Queryset",
"for",
"all",
"distinct",
"authors",
"this",
"course",
"had",
"so",
"far",
".",
"Important",
"for",
"statistics",
".",
"Note",
"that",
"this",
"may",
"be",
"different",
"from",
"the",
"list",
"of",
"people",
"being",
"registered",
"for",
"the",
... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/course.py#L85-L92 |
47,223 | troeger/opensubmit | web/opensubmit/signalhandlers.py | post_user_login | def post_user_login(sender, request, user, **kwargs):
"""
Create a profile for the user, when missing.
Make sure that all neccessary user groups exist and have the right permissions.
We need that automatism for people not calling the configure tool,
admin rights for admins after the ... | python | def post_user_login(sender, request, user, **kwargs):
"""
Create a profile for the user, when missing.
Make sure that all neccessary user groups exist and have the right permissions.
We need that automatism for people not calling the configure tool,
admin rights for admins after the ... | [
"def",
"post_user_login",
"(",
"sender",
",",
"request",
",",
"user",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"\"Running post-processing for user login.\"",
")",
"# Users created by social login or admins have no profile.",
"# We fix that during thei... | Create a profile for the user, when missing.
Make sure that all neccessary user groups exist and have the right permissions.
We need that automatism for people not calling the configure tool,
admin rights for admins after the first login, and similar cases. | [
"Create",
"a",
"profile",
"for",
"the",
"user",
"when",
"missing",
".",
"Make",
"sure",
"that",
"all",
"neccessary",
"user",
"groups",
"exist",
"and",
"have",
"the",
"right",
"permissions",
".",
"We",
"need",
"that",
"automatism",
"for",
"people",
"not",
"... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/signalhandlers.py#L17-L34 |
47,224 | troeger/opensubmit | web/opensubmit/signalhandlers.py | submissionfile_post_save | def submissionfile_post_save(sender, instance, signal, created, **kwargs):
'''
Update MD5 field for newly uploaded files.
'''
if created:
logger.debug("Running post-processing for new submission file.")
instance.md5 = instance.attachment_md5()
instance.save() | python | def submissionfile_post_save(sender, instance, signal, created, **kwargs):
'''
Update MD5 field for newly uploaded files.
'''
if created:
logger.debug("Running post-processing for new submission file.")
instance.md5 = instance.attachment_md5()
instance.save() | [
"def",
"submissionfile_post_save",
"(",
"sender",
",",
"instance",
",",
"signal",
",",
"created",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"created",
":",
"logger",
".",
"debug",
"(",
"\"Running post-processing for new submission file.\"",
")",
"instance",
".",
... | Update MD5 field for newly uploaded files. | [
"Update",
"MD5",
"field",
"for",
"newly",
"uploaded",
"files",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/signalhandlers.py#L38-L45 |
47,225 | troeger/opensubmit | web/opensubmit/signalhandlers.py | submission_post_save | def submission_post_save(sender, instance, **kwargs):
''' Several sanity checks after we got a valid submission object.'''
logger.debug("Running post-processing for submission")
# Make the submitter an author
if instance.submitter not in instance.authors.all():
instance.authors.add(instance.subm... | python | def submission_post_save(sender, instance, **kwargs):
''' Several sanity checks after we got a valid submission object.'''
logger.debug("Running post-processing for submission")
# Make the submitter an author
if instance.submitter not in instance.authors.all():
instance.authors.add(instance.subm... | [
"def",
"submission_post_save",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"\"Running post-processing for submission\"",
")",
"# Make the submitter an author",
"if",
"instance",
".",
"submitter",
"not",
"in",
"inst... | Several sanity checks after we got a valid submission object. | [
"Several",
"sanity",
"checks",
"after",
"we",
"got",
"a",
"valid",
"submission",
"object",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/signalhandlers.py#L49-L67 |
47,226 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.get_subscribers | def get_subscribers(cls, active_only=True):
"""Returns a list of Recipient objects subscribed for this message type.
:param bool active_only: Flag whether
:return:
"""
subscribers_raw = Subscription.get_for_message_cls(cls.alias)
subscribers = []
for subscriber ... | python | def get_subscribers(cls, active_only=True):
"""Returns a list of Recipient objects subscribed for this message type.
:param bool active_only: Flag whether
:return:
"""
subscribers_raw = Subscription.get_for_message_cls(cls.alias)
subscribers = []
for subscriber ... | [
"def",
"get_subscribers",
"(",
"cls",
",",
"active_only",
"=",
"True",
")",
":",
"subscribers_raw",
"=",
"Subscription",
".",
"get_for_message_cls",
"(",
"cls",
".",
"alias",
")",
"subscribers",
"=",
"[",
"]",
"for",
"subscriber",
"in",
"subscribers_raw",
":",... | Returns a list of Recipient objects subscribed for this message type.
:param bool active_only: Flag whether
:return: | [
"Returns",
"a",
"list",
"of",
"Recipient",
"objects",
"subscribed",
"for",
"this",
"message",
"type",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L127-L155 |
47,227 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase._get_url | def _get_url(cls, name, message_model, dispatch_model):
"""Returns a common pattern sitemessage URL.
:param str name: URL name
:param Message message_model:
:param Dispatch|None dispatch_model:
:return:
"""
global APP_URLS_ATTACHED
url = ''
if d... | python | def _get_url(cls, name, message_model, dispatch_model):
"""Returns a common pattern sitemessage URL.
:param str name: URL name
:param Message message_model:
:param Dispatch|None dispatch_model:
:return:
"""
global APP_URLS_ATTACHED
url = ''
if d... | [
"def",
"_get_url",
"(",
"cls",
",",
"name",
",",
"message_model",
",",
"dispatch_model",
")",
":",
"global",
"APP_URLS_ATTACHED",
"url",
"=",
"''",
"if",
"dispatch_model",
"is",
"None",
":",
"return",
"url",
"if",
"APP_URLS_ATTACHED",
"!=",
"False",
":",
"# ... | Returns a common pattern sitemessage URL.
:param str name: URL name
:param Message message_model:
:param Dispatch|None dispatch_model:
:return: | [
"Returns",
"a",
"common",
"pattern",
"sitemessage",
"URL",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L188-L214 |
47,228 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.handle_unsubscribe_request | def handle_unsubscribe_request(cls, request, message, dispatch, hash_is_valid, redirect_to):
"""Handles user subscription cancelling request.
:param Request request: Request instance
:param Message message: Message model instance
:param Dispatch dispatch: Dispatch model instance
... | python | def handle_unsubscribe_request(cls, request, message, dispatch, hash_is_valid, redirect_to):
"""Handles user subscription cancelling request.
:param Request request: Request instance
:param Message message: Message model instance
:param Dispatch dispatch: Dispatch model instance
... | [
"def",
"handle_unsubscribe_request",
"(",
"cls",
",",
"request",
",",
"message",
",",
"dispatch",
",",
"hash_is_valid",
",",
"redirect_to",
")",
":",
"if",
"hash_is_valid",
":",
"Subscription",
".",
"cancel",
"(",
"dispatch",
".",
"recipient_id",
"or",
"dispatch... | Handles user subscription cancelling request.
:param Request request: Request instance
:param Message message: Message model instance
:param Dispatch dispatch: Dispatch model instance
:param bool hash_is_valid: Flag indicating that user supplied request signature is correct
:par... | [
"Handles",
"user",
"subscription",
"cancelling",
"request",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L217-L237 |
47,229 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.handle_mark_read_request | def handle_mark_read_request(cls, request, message, dispatch, hash_is_valid, redirect_to):
"""Handles a request to mark a message as read.
:param Request request: Request instance
:param Message message: Message model instance
:param Dispatch dispatch: Dispatch model instance
:p... | python | def handle_mark_read_request(cls, request, message, dispatch, hash_is_valid, redirect_to):
"""Handles a request to mark a message as read.
:param Request request: Request instance
:param Message message: Message model instance
:param Dispatch dispatch: Dispatch model instance
:p... | [
"def",
"handle_mark_read_request",
"(",
"cls",
",",
"request",
",",
"message",
",",
"dispatch",
",",
"hash_is_valid",
",",
"redirect_to",
")",
":",
"if",
"hash_is_valid",
":",
"dispatch",
".",
"mark_read",
"(",
")",
"dispatch",
".",
"save",
"(",
")",
"signal... | Handles a request to mark a message as read.
:param Request request: Request instance
:param Message message: Message model instance
:param Dispatch dispatch: Dispatch model instance
:param bool hash_is_valid: Flag indicating that user supplied request signature is correct
:para... | [
"Handles",
"a",
"request",
"to",
"mark",
"a",
"message",
"as",
"read",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L240-L259 |
47,230 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.get_template | def get_template(cls, message, messenger):
"""Get a template path to compile a message.
1. `tpl` field of message context;
2. `template` field of message class;
3. deduced from message, messenger data and `template_ext` message type field
(e.g. `sitemessage/messages/plain__sm... | python | def get_template(cls, message, messenger):
"""Get a template path to compile a message.
1. `tpl` field of message context;
2. `template` field of message class;
3. deduced from message, messenger data and `template_ext` message type field
(e.g. `sitemessage/messages/plain__sm... | [
"def",
"get_template",
"(",
"cls",
",",
"message",
",",
"messenger",
")",
":",
"template",
"=",
"message",
".",
"context",
".",
"get",
"(",
"'tpl'",
",",
"None",
")",
"if",
"template",
":",
"# Template name is taken from message context.",
"return",
"template",
... | Get a template path to compile a message.
1. `tpl` field of message context;
2. `template` field of message class;
3. deduced from message, messenger data and `template_ext` message type field
(e.g. `sitemessage/messages/plain__smtp.txt` for `plain` message type).
:param Mes... | [
"Get",
"a",
"template",
"path",
"to",
"compile",
"a",
"message",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L262-L284 |
47,231 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.compile | def compile(cls, message, messenger, dispatch=None):
"""Compiles and returns a message text.
Considers `use_tpl` field from message context to decide whether
template compilation is used.
Otherwise a SIMPLE_TEXT_ID field from message context is used as message contents.
:param... | python | def compile(cls, message, messenger, dispatch=None):
"""Compiles and returns a message text.
Considers `use_tpl` field from message context to decide whether
template compilation is used.
Otherwise a SIMPLE_TEXT_ID field from message context is used as message contents.
:param... | [
"def",
"compile",
"(",
"cls",
",",
"message",
",",
"messenger",
",",
"dispatch",
"=",
"None",
")",
":",
"if",
"message",
".",
"context",
".",
"get",
"(",
"'use_tpl'",
",",
"False",
")",
":",
"context",
"=",
"message",
".",
"context",
"context",
".",
... | Compiles and returns a message text.
Considers `use_tpl` field from message context to decide whether
template compilation is used.
Otherwise a SIMPLE_TEXT_ID field from message context is used as message contents.
:param Message message: model instance
:param MessengerBase me... | [
"Compiles",
"and",
"returns",
"a",
"message",
"text",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L287-L312 |
47,232 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.update_context | def update_context(cls, base_context, str_or_dict, template_path=None):
"""Helper method to structure initial message context data.
NOTE: updates `base_context` inplace.
:param dict base_context: context dict to update
:param dict, str str_or_dict: text representing a message, or a dic... | python | def update_context(cls, base_context, str_or_dict, template_path=None):
"""Helper method to structure initial message context data.
NOTE: updates `base_context` inplace.
:param dict base_context: context dict to update
:param dict, str str_or_dict: text representing a message, or a dic... | [
"def",
"update_context",
"(",
"cls",
",",
"base_context",
",",
"str_or_dict",
",",
"template_path",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"str_or_dict",
",",
"dict",
")",
":",
"base_context",
".",
"update",
"(",
"str_or_dict",
")",
"base_context",
... | Helper method to structure initial message context data.
NOTE: updates `base_context` inplace.
:param dict base_context: context dict to update
:param dict, str str_or_dict: text representing a message, or a dict to be placed into message context.
:param str template_path: template pat... | [
"Helper",
"method",
"to",
"structure",
"initial",
"message",
"context",
"data",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L327-L345 |
47,233 | idlesign/django-sitemessage | sitemessage/messages/base.py | MessageBase.prepare_dispatches | def prepare_dispatches(cls, message, recipients=None):
"""Creates Dispatch models for a given message and return them.
:param Message message: Message model instance
:param list|None recipients: A list or Recipient objects
:return: list of created Dispatch models
:rtype: list
... | python | def prepare_dispatches(cls, message, recipients=None):
"""Creates Dispatch models for a given message and return them.
:param Message message: Message model instance
:param list|None recipients: A list or Recipient objects
:return: list of created Dispatch models
:rtype: list
... | [
"def",
"prepare_dispatches",
"(",
"cls",
",",
"message",
",",
"recipients",
"=",
"None",
")",
":",
"return",
"Dispatch",
".",
"create",
"(",
"message",
",",
"recipients",
"or",
"cls",
".",
"get_subscribers",
"(",
")",
")"
] | Creates Dispatch models for a given message and return them.
:param Message message: Message model instance
:param list|None recipients: A list or Recipient objects
:return: list of created Dispatch models
:rtype: list | [
"Creates",
"Dispatch",
"models",
"for",
"a",
"given",
"message",
"and",
"return",
"them",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/base.py#L348-L356 |
47,234 | idlesign/django-sitemessage | sitemessage/messengers/facebook.py | FacebookMessenger.get_page_access_token | def get_page_access_token(self, app_id, app_secret, user_token):
"""Returns a dictionary of never expired page token indexed by page names.
:param str app_id: Application ID
:param str app_secret: Application secret
:param str user_token: User short-lived token
:rtype: dict
... | python | def get_page_access_token(self, app_id, app_secret, user_token):
"""Returns a dictionary of never expired page token indexed by page names.
:param str app_id: Application ID
:param str app_secret: Application secret
:param str user_token: User short-lived token
:rtype: dict
... | [
"def",
"get_page_access_token",
"(",
"self",
",",
"app_id",
",",
"app_secret",
",",
"user_token",
")",
":",
"url_extend",
"=",
"(",
"self",
".",
"_url_base",
"+",
"'/oauth/access_token?grant_type=fb_exchange_token&'",
"'client_id=%(app_id)s&client_secret=%(app_secret)s&fb_exc... | Returns a dictionary of never expired page token indexed by page names.
:param str app_id: Application ID
:param str app_secret: Application secret
:param str user_token: User short-lived token
:rtype: dict | [
"Returns",
"a",
"dictionary",
"of",
"never",
"expired",
"page",
"token",
"indexed",
"by",
"page",
"names",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/facebook.py#L53-L75 |
47,235 | troeger/opensubmit | executor/opensubmitexec/filesystem.py | create_working_dir | def create_working_dir(config, prefix):
'''
Create a fresh temporary directory, based on the fiven prefix.
Returns the new path.
'''
# Fetch base directory from executor configuration
basepath = config.get("Execution", "directory")
if not prefix:
prefix = 'opensubmit'
f... | python | def create_working_dir(config, prefix):
'''
Create a fresh temporary directory, based on the fiven prefix.
Returns the new path.
'''
# Fetch base directory from executor configuration
basepath = config.get("Execution", "directory")
if not prefix:
prefix = 'opensubmit'
f... | [
"def",
"create_working_dir",
"(",
"config",
",",
"prefix",
")",
":",
"# Fetch base directory from executor configuration",
"basepath",
"=",
"config",
".",
"get",
"(",
"\"Execution\"",
",",
"\"directory\"",
")",
"if",
"not",
"prefix",
":",
"prefix",
"=",
"'opensubmit... | Create a fresh temporary directory, based on the fiven prefix.
Returns the new path. | [
"Create",
"a",
"fresh",
"temporary",
"directory",
"based",
"on",
"the",
"fiven",
"prefix",
".",
"Returns",
"the",
"new",
"path",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/filesystem.py#L119-L135 |
47,236 | troeger/opensubmit | executor/opensubmitexec/filesystem.py | prepare_working_directory | def prepare_working_directory(job, submission_path, validator_path):
'''
Based on two downloaded files in the working directory,
the student submission and the validation package,
the working directory is prepared.
We unpack student submission first, so that teacher files overwrite
them in case... | python | def prepare_working_directory(job, submission_path, validator_path):
'''
Based on two downloaded files in the working directory,
the student submission and the validation package,
the working directory is prepared.
We unpack student submission first, so that teacher files overwrite
them in case... | [
"def",
"prepare_working_directory",
"(",
"job",
",",
"submission_path",
",",
"validator_path",
")",
":",
"# Safeguard for fail-fast in disk full scenarios on the executor",
"dusage",
"=",
"shutil",
".",
"disk_usage",
"(",
"job",
".",
"working_dir",
")",
"if",
"dusage",
... | Based on two downloaded files in the working directory,
the student submission and the validation package,
the working directory is prepared.
We unpack student submission first, so that teacher files overwrite
them in case.
When the student submission is a single directory, we change the
worki... | [
"Based",
"on",
"two",
"downloaded",
"files",
"in",
"the",
"working",
"directory",
"the",
"student",
"submission",
"and",
"the",
"validation",
"package",
"the",
"working",
"directory",
"is",
"prepared",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/filesystem.py#L138-L218 |
47,237 | troeger/opensubmit | web/opensubmit/cmdline.py | django_admin | def django_admin(args):
'''
Run something like it would be done through Django's manage.py.
'''
from django.core.management import execute_from_command_line
from django.core.exceptions import ImproperlyConfigured
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "opensubmit.settings")
try:... | python | def django_admin(args):
'''
Run something like it would be done through Django's manage.py.
'''
from django.core.management import execute_from_command_line
from django.core.exceptions import ImproperlyConfigured
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "opensubmit.settings")
try:... | [
"def",
"django_admin",
"(",
"args",
")",
":",
"from",
"django",
".",
"core",
".",
"management",
"import",
"execute_from_command_line",
"from",
"django",
".",
"core",
".",
"exceptions",
"import",
"ImproperlyConfigured",
"os",
".",
"environ",
".",
"setdefault",
"(... | Run something like it would be done through Django's manage.py. | [
"Run",
"something",
"like",
"it",
"would",
"be",
"done",
"through",
"Django",
"s",
"manage",
".",
"py",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L97-L108 |
47,238 | troeger/opensubmit | web/opensubmit/cmdline.py | check_path | def check_path(file_path):
'''
Checks if the directories for this path exist, and creates them in case.
'''
directory = os.path.dirname(file_path)
if directory != '':
if not os.path.exists(directory):
os.makedirs(directory, 0o775) | python | def check_path(file_path):
'''
Checks if the directories for this path exist, and creates them in case.
'''
directory = os.path.dirname(file_path)
if directory != '':
if not os.path.exists(directory):
os.makedirs(directory, 0o775) | [
"def",
"check_path",
"(",
"file_path",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"file_path",
")",
"if",
"directory",
"!=",
"''",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"directory",
")",
":",
"os",
".",
"... | Checks if the directories for this path exist, and creates them in case. | [
"Checks",
"if",
"the",
"directories",
"for",
"this",
"path",
"exist",
"and",
"creates",
"them",
"in",
"case",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L151-L158 |
47,239 | troeger/opensubmit | web/opensubmit/cmdline.py | check_file | def check_file(filepath):
'''
- Checks if the parent directories for this path exist.
- Checks that the file exists.
- Donates the file to the web server user.
TODO: This is Debian / Ubuntu specific.
'''
check_path(filepath)
if not os.path.exists(filepath):
print... | python | def check_file(filepath):
'''
- Checks if the parent directories for this path exist.
- Checks that the file exists.
- Donates the file to the web server user.
TODO: This is Debian / Ubuntu specific.
'''
check_path(filepath)
if not os.path.exists(filepath):
print... | [
"def",
"check_file",
"(",
"filepath",
")",
":",
"check_path",
"(",
"filepath",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"print",
"(",
"\"WARNING: File does not exist. Creating it: %s\"",
"%",
"filepath",
")",
"open",
"(",
... | - Checks if the parent directories for this path exist.
- Checks that the file exists.
- Donates the file to the web server user.
TODO: This is Debian / Ubuntu specific. | [
"-",
"Checks",
"if",
"the",
"parent",
"directories",
"for",
"this",
"path",
"exist",
".",
"-",
"Checks",
"that",
"the",
"file",
"exists",
".",
"-",
"Donates",
"the",
"file",
"to",
"the",
"web",
"server",
"user",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L161-L180 |
47,240 | troeger/opensubmit | web/opensubmit/cmdline.py | check_web_config_consistency | def check_web_config_consistency(config):
'''
Check the web application config file for consistency.
'''
login_conf_deps = {
'LOGIN_TWITTER_OAUTH_KEY': ['LOGIN_TWITTER_OAUTH_SECRET'],
'LOGIN_GOOGLE_OAUTH_KEY': ['LOGIN_GOOGLE_OAUTH_SECRET'],
'LOGIN_GITHUB_OAUTH_KEY': ['LOGIN_G... | python | def check_web_config_consistency(config):
'''
Check the web application config file for consistency.
'''
login_conf_deps = {
'LOGIN_TWITTER_OAUTH_KEY': ['LOGIN_TWITTER_OAUTH_SECRET'],
'LOGIN_GOOGLE_OAUTH_KEY': ['LOGIN_GOOGLE_OAUTH_SECRET'],
'LOGIN_GITHUB_OAUTH_KEY': ['LOGIN_G... | [
"def",
"check_web_config_consistency",
"(",
"config",
")",
":",
"login_conf_deps",
"=",
"{",
"'LOGIN_TWITTER_OAUTH_KEY'",
":",
"[",
"'LOGIN_TWITTER_OAUTH_SECRET'",
"]",
",",
"'LOGIN_GOOGLE_OAUTH_KEY'",
":",
"[",
"'LOGIN_GOOGLE_OAUTH_SECRET'",
"]",
",",
"'LOGIN_GITHUB_OAUTH_... | Check the web application config file for consistency. | [
"Check",
"the",
"web",
"application",
"config",
"file",
"for",
"consistency",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L183-L226 |
47,241 | troeger/opensubmit | web/opensubmit/cmdline.py | check_web_config | def check_web_config(config_fname):
'''
Try to load the Django settings.
If this does not work, than settings file does not exist.
Returns:
Loaded configuration, or None.
'''
print("Looking for config file at {0} ...".format(config_fname))
config = RawConfigParser()
... | python | def check_web_config(config_fname):
'''
Try to load the Django settings.
If this does not work, than settings file does not exist.
Returns:
Loaded configuration, or None.
'''
print("Looking for config file at {0} ...".format(config_fname))
config = RawConfigParser()
... | [
"def",
"check_web_config",
"(",
"config_fname",
")",
":",
"print",
"(",
"\"Looking for config file at {0} ...\"",
".",
"format",
"(",
"config_fname",
")",
")",
"config",
"=",
"RawConfigParser",
"(",
")",
"try",
":",
"config",
".",
"readfp",
"(",
"open",
"(",
"... | Try to load the Django settings.
If this does not work, than settings file does not exist.
Returns:
Loaded configuration, or None. | [
"Try",
"to",
"load",
"the",
"Django",
"settings",
".",
"If",
"this",
"does",
"not",
"work",
"than",
"settings",
"file",
"does",
"not",
"exist",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L229-L244 |
47,242 | nitely/kua | kua/routes.py | normalize_url | def normalize_url(url: str) -> str:
"""
Remove leading and trailing slashes from a URL
:param url: URL
:return: URL with no leading and trailing slashes
:private:
"""
if url.startswith('/'):
url = url[1:]
if url.endswith('/'):
url = url[:-1]
return url | python | def normalize_url(url: str) -> str:
"""
Remove leading and trailing slashes from a URL
:param url: URL
:return: URL with no leading and trailing slashes
:private:
"""
if url.startswith('/'):
url = url[1:]
if url.endswith('/'):
url = url[:-1]
return url | [
"def",
"normalize_url",
"(",
"url",
":",
"str",
")",
"->",
"str",
":",
"if",
"url",
".",
"startswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
"1",
":",
"]",
"if",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
":... | Remove leading and trailing slashes from a URL
:param url: URL
:return: URL with no leading and trailing slashes
:private: | [
"Remove",
"leading",
"and",
"trailing",
"slashes",
"from",
"a",
"URL"
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L38-L53 |
47,243 | nitely/kua | kua/routes.py | _unwrap | def _unwrap(variable_parts: VariablePartsType):
"""
Yield URL parts. The given parts are usually in reverse order.
"""
curr_parts = variable_parts
var_any = []
while curr_parts:
curr_parts, (var_type, part) = curr_parts
if var_type == Routes._VAR_ANY_NODE:
var_any.a... | python | def _unwrap(variable_parts: VariablePartsType):
"""
Yield URL parts. The given parts are usually in reverse order.
"""
curr_parts = variable_parts
var_any = []
while curr_parts:
curr_parts, (var_type, part) = curr_parts
if var_type == Routes._VAR_ANY_NODE:
var_any.a... | [
"def",
"_unwrap",
"(",
"variable_parts",
":",
"VariablePartsType",
")",
":",
"curr_parts",
"=",
"variable_parts",
"var_any",
"=",
"[",
"]",
"while",
"curr_parts",
":",
"curr_parts",
",",
"(",
"var_type",
",",
"part",
")",
"=",
"curr_parts",
"if",
"var_type",
... | Yield URL parts. The given parts are usually in reverse order. | [
"Yield",
"URL",
"parts",
".",
"The",
"given",
"parts",
"are",
"usually",
"in",
"reverse",
"order",
"."
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L56-L87 |
47,244 | nitely/kua | kua/routes.py | make_params | def make_params(
key_parts: Sequence[str],
variable_parts: VariablePartsType) -> Dict[str, Union[str, Tuple[str]]]:
"""
Map keys to variables. This map\
URL-pattern variables to\
a URL related parts
:param key_parts: A list of URL parts
:param variable_parts: A linked-list\
... | python | def make_params(
key_parts: Sequence[str],
variable_parts: VariablePartsType) -> Dict[str, Union[str, Tuple[str]]]:
"""
Map keys to variables. This map\
URL-pattern variables to\
a URL related parts
:param key_parts: A list of URL parts
:param variable_parts: A linked-list\
... | [
"def",
"make_params",
"(",
"key_parts",
":",
"Sequence",
"[",
"str",
"]",
",",
"variable_parts",
":",
"VariablePartsType",
")",
"->",
"Dict",
"[",
"str",
",",
"Union",
"[",
"str",
",",
"Tuple",
"[",
"str",
"]",
"]",
"]",
":",
"# The unwrapped variable part... | Map keys to variables. This map\
URL-pattern variables to\
a URL related parts
:param key_parts: A list of URL parts
:param variable_parts: A linked-list\
(ala nested tuples) of URL parts
:return: The param dict with the values\
assigned to the keys
:private: | [
"Map",
"keys",
"to",
"variables",
".",
"This",
"map",
"\\",
"URL",
"-",
"pattern",
"variables",
"to",
"\\",
"a",
"URL",
"related",
"parts"
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L90-L109 |
47,245 | nitely/kua | kua/routes.py | Routes._deconstruct_url | def _deconstruct_url(self, url: str) -> List[str]:
"""
Split a regular URL into parts
:param url: A normalized URL
:return: Parts of the URL
:raises kua.routes.RouteError: \
If the depth of the URL exceeds\
the max depth of the deepest\
registered pattern... | python | def _deconstruct_url(self, url: str) -> List[str]:
"""
Split a regular URL into parts
:param url: A normalized URL
:return: Parts of the URL
:raises kua.routes.RouteError: \
If the depth of the URL exceeds\
the max depth of the deepest\
registered pattern... | [
"def",
"_deconstruct_url",
"(",
"self",
",",
"url",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"parts",
"=",
"url",
".",
"split",
"(",
"'/'",
",",
"self",
".",
"_max_depth",
"+",
"1",
")",
"if",
"depth_of",
"(",
"parts",
")",
">",
"self... | Split a regular URL into parts
:param url: A normalized URL
:return: Parts of the URL
:raises kua.routes.RouteError: \
If the depth of the URL exceeds\
the max depth of the deepest\
registered pattern
:private: | [
"Split",
"a",
"regular",
"URL",
"into",
"parts"
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L213-L231 |
47,246 | nitely/kua | kua/routes.py | Routes._match | def _match(self, parts: Sequence[str]) -> RouteResolved:
"""
Match URL parts to a registered pattern.
This function is basically where all\
the CPU-heavy work is done.
:param parts: URL parts
:return: Matched route
:raises kua.routes.RouteError: If there is no m... | python | def _match(self, parts: Sequence[str]) -> RouteResolved:
"""
Match URL parts to a registered pattern.
This function is basically where all\
the CPU-heavy work is done.
:param parts: URL parts
:return: Matched route
:raises kua.routes.RouteError: If there is no m... | [
"def",
"_match",
"(",
"self",
",",
"parts",
":",
"Sequence",
"[",
"str",
"]",
")",
"->",
"RouteResolved",
":",
"route_match",
"=",
"None",
"# type: RouteResolved",
"route_variable_parts",
"=",
"tuple",
"(",
")",
"# type: VariablePartsType",
"# (route_partial, variab... | Match URL parts to a registered pattern.
This function is basically where all\
the CPU-heavy work is done.
:param parts: URL parts
:return: Matched route
:raises kua.routes.RouteError: If there is no match
:private: | [
"Match",
"URL",
"parts",
"to",
"a",
"registered",
"pattern",
"."
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L233-L300 |
47,247 | nitely/kua | kua/routes.py | Routes.match | def match(self, url: str) -> RouteResolved:
"""
Match a URL to a registered pattern.
:param url: URL
:return: Matched route
:raises kua.RouteError: If there is no match
"""
url = normalize_url(url)
parts = self._deconstruct_url(url)
return self._m... | python | def match(self, url: str) -> RouteResolved:
"""
Match a URL to a registered pattern.
:param url: URL
:return: Matched route
:raises kua.RouteError: If there is no match
"""
url = normalize_url(url)
parts = self._deconstruct_url(url)
return self._m... | [
"def",
"match",
"(",
"self",
",",
"url",
":",
"str",
")",
"->",
"RouteResolved",
":",
"url",
"=",
"normalize_url",
"(",
"url",
")",
"parts",
"=",
"self",
".",
"_deconstruct_url",
"(",
"url",
")",
"return",
"self",
".",
"_match",
"(",
"parts",
")"
] | Match a URL to a registered pattern.
:param url: URL
:return: Matched route
:raises kua.RouteError: If there is no match | [
"Match",
"a",
"URL",
"to",
"a",
"registered",
"pattern",
"."
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L302-L312 |
47,248 | nitely/kua | kua/routes.py | Routes.add | def add(self, url: str, anything: Any) -> None:
"""
Register a URL pattern into\
the routes for later matching.
It's possible to attach any kind of\
object to the pattern for later\
retrieving. A dict with methods and callbacks,\
for example. Anything really.
... | python | def add(self, url: str, anything: Any) -> None:
"""
Register a URL pattern into\
the routes for later matching.
It's possible to attach any kind of\
object to the pattern for later\
retrieving. A dict with methods and callbacks,\
for example. Anything really.
... | [
"def",
"add",
"(",
"self",
",",
"url",
":",
"str",
",",
"anything",
":",
"Any",
")",
"->",
"None",
":",
"url",
"=",
"normalize_url",
"(",
"url",
")",
"parts",
"=",
"url",
".",
"split",
"(",
"'/'",
")",
"curr_partial_routes",
"=",
"self",
".",
"_rou... | Register a URL pattern into\
the routes for later matching.
It's possible to attach any kind of\
object to the pattern for later\
retrieving. A dict with methods and callbacks,\
for example. Anything really.
Registration order does not matter.\
Adding a URL firs... | [
"Register",
"a",
"URL",
"pattern",
"into",
"\\",
"the",
"routes",
"for",
"later",
"matching",
"."
] | 6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6 | https://github.com/nitely/kua/blob/6ffc9d0426e87a34cf8c3f8e7aedac6d35e59cb6/kua/routes.py#L314-L352 |
47,249 | idlesign/django-sitemessage | sitemessage/utils.py | get_site_url | def get_site_url():
"""Returns a URL for current site.
:rtype: str|unicode
"""
site_url = getattr(_THREAD_LOCAL, _THREAD_SITE_URL, None)
if site_url is None:
site_url = SITE_URL or get_site_url_()
setattr(_THREAD_LOCAL, _THREAD_SITE_URL, site_url)
return site_url | python | def get_site_url():
"""Returns a URL for current site.
:rtype: str|unicode
"""
site_url = getattr(_THREAD_LOCAL, _THREAD_SITE_URL, None)
if site_url is None:
site_url = SITE_URL or get_site_url_()
setattr(_THREAD_LOCAL, _THREAD_SITE_URL, site_url)
return site_url | [
"def",
"get_site_url",
"(",
")",
":",
"site_url",
"=",
"getattr",
"(",
"_THREAD_LOCAL",
",",
"_THREAD_SITE_URL",
",",
"None",
")",
"if",
"site_url",
"is",
"None",
":",
"site_url",
"=",
"SITE_URL",
"or",
"get_site_url_",
"(",
")",
"setattr",
"(",
"_THREAD_LOC... | Returns a URL for current site.
:rtype: str|unicode | [
"Returns",
"a",
"URL",
"for",
"current",
"site",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/utils.py#L31-L42 |
47,250 | idlesign/django-sitemessage | sitemessage/utils.py | get_message_type_for_app | def get_message_type_for_app(app_name, default_message_type_alias):
"""Returns a registered message type object for a given application.
Supposed to be used by reusable applications authors,
to get message type objects which may be overridden by project authors
using `override_message_type_for_app`.
... | python | def get_message_type_for_app(app_name, default_message_type_alias):
"""Returns a registered message type object for a given application.
Supposed to be used by reusable applications authors,
to get message type objects which may be overridden by project authors
using `override_message_type_for_app`.
... | [
"def",
"get_message_type_for_app",
"(",
"app_name",
",",
"default_message_type_alias",
")",
":",
"message_type",
"=",
"default_message_type_alias",
"try",
":",
"message_type",
"=",
"_MESSAGES_FOR_APPS",
"[",
"app_name",
"]",
"[",
"message_type",
"]",
"except",
"KeyError... | Returns a registered message type object for a given application.
Supposed to be used by reusable applications authors,
to get message type objects which may be overridden by project authors
using `override_message_type_for_app`.
:param str|unicode app_name:
:param str|unicode default_message_type... | [
"Returns",
"a",
"registered",
"message",
"type",
"object",
"for",
"a",
"given",
"application",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/utils.py#L45-L64 |
47,251 | idlesign/django-sitemessage | sitemessage/utils.py | recipients | def recipients(messenger, addresses):
"""Structures recipients data.
:param str|unicode, MessageBase messenger: MessengerBase heir
:param list[str|unicode]|str|unicode addresses: recipients addresses or Django User
model heir instances (NOTE: if supported by a messenger)
:return: list of Recip... | python | def recipients(messenger, addresses):
"""Structures recipients data.
:param str|unicode, MessageBase messenger: MessengerBase heir
:param list[str|unicode]|str|unicode addresses: recipients addresses or Django User
model heir instances (NOTE: if supported by a messenger)
:return: list of Recip... | [
"def",
"recipients",
"(",
"messenger",
",",
"addresses",
")",
":",
"if",
"isinstance",
"(",
"messenger",
",",
"six",
".",
"string_types",
")",
":",
"messenger",
"=",
"get_registered_messenger_object",
"(",
"messenger",
")",
"return",
"messenger",
".",
"_structur... | Structures recipients data.
:param str|unicode, MessageBase messenger: MessengerBase heir
:param list[str|unicode]|str|unicode addresses: recipients addresses or Django User
model heir instances (NOTE: if supported by a messenger)
:return: list of Recipient
:rtype: list[Recipient] | [
"Structures",
"recipients",
"data",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/utils.py#L183-L196 |
47,252 | praekelt/django-livechat | livechat/models.py | LiveChatManager.upcoming_live_chat | def upcoming_live_chat(self):
"""
Find any upcoming or current live chat to advertise on the home page or
live chat page.
These are LiveChat's with primary category of 'ask-mama' and category
of 'live-chat'. The Chat date must be less than 5 days away, or
happening now.
... | python | def upcoming_live_chat(self):
"""
Find any upcoming or current live chat to advertise on the home page or
live chat page.
These are LiveChat's with primary category of 'ask-mama' and category
of 'live-chat'. The Chat date must be less than 5 days away, or
happening now.
... | [
"def",
"upcoming_live_chat",
"(",
"self",
")",
":",
"chat",
"=",
"None",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"lcqs",
"=",
"self",
".",
"get_query_set",
"(",
")",
"lcqs",
"=",
"lcqs",
".",
"filter",
"(",
"chat_ends_at__gte",
"=",
"now",
")",
... | Find any upcoming or current live chat to advertise on the home page or
live chat page.
These are LiveChat's with primary category of 'ask-mama' and category
of 'live-chat'. The Chat date must be less than 5 days away, or
happening now. | [
"Find",
"any",
"upcoming",
"or",
"current",
"live",
"chat",
"to",
"advertise",
"on",
"the",
"home",
"page",
"or",
"live",
"chat",
"page",
".",
"These",
"are",
"LiveChat",
"s",
"with",
"primary",
"category",
"of",
"ask",
"-",
"mama",
"and",
"category",
"o... | 22d86fb4219e5af6c83e0542aa30e5ea54e71d26 | https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/models.py#L22-L52 |
47,253 | praekelt/django-livechat | livechat/models.py | LiveChatManager.get_current_live_chat | def get_current_live_chat(self):
""" Check if there is a live chat on the go, so that we should take
over the AskMAMA page with the live chat.
"""
now = datetime.now()
chat = self.upcoming_live_chat()
if chat and chat.is_in_progress():
return chat
... | python | def get_current_live_chat(self):
""" Check if there is a live chat on the go, so that we should take
over the AskMAMA page with the live chat.
"""
now = datetime.now()
chat = self.upcoming_live_chat()
if chat and chat.is_in_progress():
return chat
... | [
"def",
"get_current_live_chat",
"(",
"self",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"chat",
"=",
"self",
".",
"upcoming_live_chat",
"(",
")",
"if",
"chat",
"and",
"chat",
".",
"is_in_progress",
"(",
")",
":",
"return",
"chat",
"return",
... | Check if there is a live chat on the go, so that we should take
over the AskMAMA page with the live chat. | [
"Check",
"if",
"there",
"is",
"a",
"live",
"chat",
"on",
"the",
"go",
"so",
"that",
"we",
"should",
"take",
"over",
"the",
"AskMAMA",
"page",
"with",
"the",
"live",
"chat",
"."
] | 22d86fb4219e5af6c83e0542aa30e5ea54e71d26 | https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/models.py#L54-L62 |
47,254 | praekelt/django-livechat | livechat/models.py | LiveChatManager.get_last_live_chat | def get_last_live_chat(self):
""" Check if there is a live chat that ended in the last 3 days, and
return it. We will display a link to it on the articles page.
"""
now = datetime.now()
lcqs = self.get_query_set()
lcqs = lcqs.filter(
chat_ends_at__lte=now... | python | def get_last_live_chat(self):
""" Check if there is a live chat that ended in the last 3 days, and
return it. We will display a link to it on the articles page.
"""
now = datetime.now()
lcqs = self.get_query_set()
lcqs = lcqs.filter(
chat_ends_at__lte=now... | [
"def",
"get_last_live_chat",
"(",
"self",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"lcqs",
"=",
"self",
".",
"get_query_set",
"(",
")",
"lcqs",
"=",
"lcqs",
".",
"filter",
"(",
"chat_ends_at__lte",
"=",
"now",
",",
")",
".",
"order_by",
... | Check if there is a live chat that ended in the last 3 days, and
return it. We will display a link to it on the articles page. | [
"Check",
"if",
"there",
"is",
"a",
"live",
"chat",
"that",
"ended",
"in",
"the",
"last",
"3",
"days",
"and",
"return",
"it",
".",
"We",
"will",
"display",
"a",
"link",
"to",
"it",
"on",
"the",
"articles",
"page",
"."
] | 22d86fb4219e5af6c83e0542aa30e5ea54e71d26 | https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/models.py#L64-L77 |
47,255 | praekelt/django-livechat | livechat/models.py | LiveChat.comment_set | def comment_set(self):
""" Get the comments that have been submitted for the chat
"""
ct = ContentType.objects.get_for_model(self.__class__)
qs = Comment.objects.filter(
content_type=ct,
object_pk=self.pk)
qs = qs.exclude(is_removed=True)
qs = qs.o... | python | def comment_set(self):
""" Get the comments that have been submitted for the chat
"""
ct = ContentType.objects.get_for_model(self.__class__)
qs = Comment.objects.filter(
content_type=ct,
object_pk=self.pk)
qs = qs.exclude(is_removed=True)
qs = qs.o... | [
"def",
"comment_set",
"(",
"self",
")",
":",
"ct",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
".",
"__class__",
")",
"qs",
"=",
"Comment",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"ct",
",",
"object_pk",
"=",
... | Get the comments that have been submitted for the chat | [
"Get",
"the",
"comments",
"that",
"have",
"been",
"submitted",
"for",
"the",
"chat"
] | 22d86fb4219e5af6c83e0542aa30e5ea54e71d26 | https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/models.py#L136-L145 |
47,256 | idlesign/django-sitemessage | sitemessage/models.py | _get_dispatches | def _get_dispatches(filter_kwargs):
"""Simplified version. Not distributed friendly."""
dispatches = Dispatch.objects.prefetch_related('message').filter(
**filter_kwargs
).order_by('-message__time_created')
return list(dispatches) | python | def _get_dispatches(filter_kwargs):
"""Simplified version. Not distributed friendly."""
dispatches = Dispatch.objects.prefetch_related('message').filter(
**filter_kwargs
).order_by('-message__time_created')
return list(dispatches) | [
"def",
"_get_dispatches",
"(",
"filter_kwargs",
")",
":",
"dispatches",
"=",
"Dispatch",
".",
"objects",
".",
"prefetch_related",
"(",
"'message'",
")",
".",
"filter",
"(",
"*",
"*",
"filter_kwargs",
")",
".",
"order_by",
"(",
"'-message__time_created'",
")",
... | Simplified version. Not distributed friendly. | [
"Simplified",
"version",
".",
"Not",
"distributed",
"friendly",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/models.py#L21-L28 |
47,257 | idlesign/django-sitemessage | sitemessage/models.py | _get_dispatches_for_update | def _get_dispatches_for_update(filter_kwargs):
"""Distributed friendly version using ``select for update``."""
dispatches = Dispatch.objects.prefetch_related('message').filter(
**filter_kwargs
).select_for_update(
**GET_DISPATCHES_ARGS[1]
).order_by('-message__time_created')
try:... | python | def _get_dispatches_for_update(filter_kwargs):
"""Distributed friendly version using ``select for update``."""
dispatches = Dispatch.objects.prefetch_related('message').filter(
**filter_kwargs
).select_for_update(
**GET_DISPATCHES_ARGS[1]
).order_by('-message__time_created')
try:... | [
"def",
"_get_dispatches_for_update",
"(",
"filter_kwargs",
")",
":",
"dispatches",
"=",
"Dispatch",
".",
"objects",
".",
"prefetch_related",
"(",
"'message'",
")",
".",
"filter",
"(",
"*",
"*",
"filter_kwargs",
")",
".",
"select_for_update",
"(",
"*",
"*",
"GE... | Distributed friendly version using ``select for update``. | [
"Distributed",
"friendly",
"version",
"using",
"select",
"for",
"update",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/models.py#L31-L51 |
47,258 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.author_list | def author_list(self):
''' The list of authors als text, for admin submission list overview.'''
author_list = [self.submitter] + \
[author for author in self.authors.all().exclude(pk=self.submitter.pk)]
return ",\n".join([author.get_full_name() for author in author_list]) | python | def author_list(self):
''' The list of authors als text, for admin submission list overview.'''
author_list = [self.submitter] + \
[author for author in self.authors.all().exclude(pk=self.submitter.pk)]
return ",\n".join([author.get_full_name() for author in author_list]) | [
"def",
"author_list",
"(",
"self",
")",
":",
"author_list",
"=",
"[",
"self",
".",
"submitter",
"]",
"+",
"[",
"author",
"for",
"author",
"in",
"self",
".",
"authors",
".",
"all",
"(",
")",
".",
"exclude",
"(",
"pk",
"=",
"self",
".",
"submitter",
... | The list of authors als text, for admin submission list overview. | [
"The",
"list",
"of",
"authors",
"als",
"text",
"for",
"admin",
"submission",
"list",
"overview",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L276-L280 |
47,259 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.grading_status_text | def grading_status_text(self):
'''
A rendering of the grading that is an answer on the question
"Is grading finished?".
Used in duplicate view and submission list on the teacher backend.
'''
if self.assignment.is_graded():
if self.is_grading_finished():
... | python | def grading_status_text(self):
'''
A rendering of the grading that is an answer on the question
"Is grading finished?".
Used in duplicate view and submission list on the teacher backend.
'''
if self.assignment.is_graded():
if self.is_grading_finished():
... | [
"def",
"grading_status_text",
"(",
"self",
")",
":",
"if",
"self",
".",
"assignment",
".",
"is_graded",
"(",
")",
":",
"if",
"self",
".",
"is_grading_finished",
"(",
")",
":",
"return",
"str",
"(",
"'Yes ({0})'",
".",
"format",
"(",
"self",
".",
"grading... | A rendering of the grading that is an answer on the question
"Is grading finished?".
Used in duplicate view and submission list on the teacher backend. | [
"A",
"rendering",
"of",
"the",
"grading",
"that",
"is",
"an",
"answer",
"on",
"the",
"question",
"Is",
"grading",
"finished?",
".",
"Used",
"in",
"duplicate",
"view",
"and",
"submission",
"list",
"on",
"the",
"teacher",
"backend",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L288-L300 |
47,260 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.grading_value_text | def grading_value_text(self):
'''
A rendering of the grading that is an answer to the question
"What is the grade?".
'''
if self.assignment.is_graded():
if self.is_grading_finished():
return str(self.grading)
else:
return st... | python | def grading_value_text(self):
'''
A rendering of the grading that is an answer to the question
"What is the grade?".
'''
if self.assignment.is_graded():
if self.is_grading_finished():
return str(self.grading)
else:
return st... | [
"def",
"grading_value_text",
"(",
"self",
")",
":",
"if",
"self",
".",
"assignment",
".",
"is_graded",
"(",
")",
":",
"if",
"self",
".",
"is_grading_finished",
"(",
")",
":",
"return",
"str",
"(",
"self",
".",
"grading",
")",
"else",
":",
"return",
"st... | A rendering of the grading that is an answer to the question
"What is the grade?". | [
"A",
"rendering",
"of",
"the",
"grading",
"that",
"is",
"an",
"answer",
"to",
"the",
"question",
"What",
"is",
"the",
"grade?",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L316-L330 |
47,261 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.grading_means_passed | def grading_means_passed(self):
'''
Information if the given grading means passed.
Non-graded assignments are always passed.
'''
if self.assignment.is_graded():
if self.grading and self.grading.means_passed:
return True
else:
... | python | def grading_means_passed(self):
'''
Information if the given grading means passed.
Non-graded assignments are always passed.
'''
if self.assignment.is_graded():
if self.grading and self.grading.means_passed:
return True
else:
... | [
"def",
"grading_means_passed",
"(",
"self",
")",
":",
"if",
"self",
".",
"assignment",
".",
"is_graded",
"(",
")",
":",
"if",
"self",
".",
"grading",
"and",
"self",
".",
"grading",
".",
"means_passed",
":",
"return",
"True",
"else",
":",
"return",
"False... | Information if the given grading means passed.
Non-graded assignments are always passed. | [
"Information",
"if",
"the",
"given",
"grading",
"means",
"passed",
".",
"Non",
"-",
"graded",
"assignments",
"are",
"always",
"passed",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L332-L343 |
47,262 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.can_modify | def can_modify(self, user=None):
"""Determines whether the submission can be modified.
Returns a boolean value.
The 'user' parameter is optional and additionally checks whether
the given user is authorized to perform these actions.
This function checks the submission states and ... | python | def can_modify(self, user=None):
"""Determines whether the submission can be modified.
Returns a boolean value.
The 'user' parameter is optional and additionally checks whether
the given user is authorized to perform these actions.
This function checks the submission states and ... | [
"def",
"can_modify",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"# The user must be authorized to commit these actions.",
"if",
"user",
"and",
"not",
"self",
".",
"user_can_modify",
"(",
"user",
")",
":",
"#self.log('DEBUG', \"Submission cannot be modified, user is ... | Determines whether the submission can be modified.
Returns a boolean value.
The 'user' parameter is optional and additionally checks whether
the given user is authorized to perform these actions.
This function checks the submission states and assignment deadlines. | [
"Determines",
"whether",
"the",
"submission",
"can",
"be",
"modified",
".",
"Returns",
"a",
"boolean",
"value",
".",
"The",
"user",
"parameter",
"is",
"optional",
"and",
"additionally",
"checks",
"whether",
"the",
"given",
"user",
"is",
"authorized",
"to",
"pe... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L361-L420 |
47,263 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.can_reupload | def can_reupload(self, user=None):
"""Determines whether a submission can be re-uploaded.
Returns a boolean value.
Requires: can_modify.
Re-uploads are allowed only when test executions have failed."""
# Re-uploads are allowed only when test executions have failed.
if ... | python | def can_reupload(self, user=None):
"""Determines whether a submission can be re-uploaded.
Returns a boolean value.
Requires: can_modify.
Re-uploads are allowed only when test executions have failed."""
# Re-uploads are allowed only when test executions have failed.
if ... | [
"def",
"can_reupload",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"# Re-uploads are allowed only when test executions have failed.",
"if",
"self",
".",
"state",
"not",
"in",
"(",
"self",
".",
"TEST_VALIDITY_FAILED",
",",
"self",
".",
"TEST_FULL_FAILED",
")",
... | Determines whether a submission can be re-uploaded.
Returns a boolean value.
Requires: can_modify.
Re-uploads are allowed only when test executions have failed. | [
"Determines",
"whether",
"a",
"submission",
"can",
"be",
"re",
"-",
"uploaded",
".",
"Returns",
"a",
"boolean",
"value",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L431-L447 |
47,264 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.get_initial_state | def get_initial_state(self):
'''
Return first state for this submission after upload,
which depends on the kind of assignment.
'''
if not self.assignment.attachment_is_tested():
return Submission.SUBMITTED
else:
if self.assignment.attachmen... | python | def get_initial_state(self):
'''
Return first state for this submission after upload,
which depends on the kind of assignment.
'''
if not self.assignment.attachment_is_tested():
return Submission.SUBMITTED
else:
if self.assignment.attachmen... | [
"def",
"get_initial_state",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"assignment",
".",
"attachment_is_tested",
"(",
")",
":",
"return",
"Submission",
".",
"SUBMITTED",
"else",
":",
"if",
"self",
".",
"assignment",
".",
"attachment_test_validity",
":",... | Return first state for this submission after upload,
which depends on the kind of assignment. | [
"Return",
"first",
"state",
"for",
"this",
"submission",
"after",
"upload",
"which",
"depends",
"on",
"the",
"kind",
"of",
"assignment",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L473-L484 |
47,265 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.info_file | def info_file(self, delete=True):
'''
Prepares an open temporary file with information about the submission.
Closing it will delete it, which must be considered by the caller.
This file is not readable, since the tempfile library wants either readable or writable files.
... | python | def info_file(self, delete=True):
'''
Prepares an open temporary file with information about the submission.
Closing it will delete it, which must be considered by the caller.
This file is not readable, since the tempfile library wants either readable or writable files.
... | [
"def",
"info_file",
"(",
"self",
",",
"delete",
"=",
"True",
")",
":",
"info",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"'wt'",
",",
"encoding",
"=",
"'utf-8'",
",",
"delete",
"=",
"delete",
")",
"info",
".",
"write",
"(",
"\"Submi... | Prepares an open temporary file with information about the submission.
Closing it will delete it, which must be considered by the caller.
This file is not readable, since the tempfile library wants either readable or writable files. | [
"Prepares",
"an",
"open",
"temporary",
"file",
"with",
"information",
"about",
"the",
"submission",
".",
"Closing",
"it",
"will",
"delete",
"it",
"which",
"must",
"be",
"considered",
"by",
"the",
"caller",
".",
"This",
"file",
"is",
"not",
"readable",
"since... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L561-L588 |
47,266 | troeger/opensubmit | web/opensubmit/models/submission.py | Submission.copy_file_upload | def copy_file_upload(self, targetdir):
'''
Copies the currently valid file upload into the given directory.
If possible, the content is un-archived in the target directory.
'''
assert(self.file_upload)
# unpack student data to temporary directory
# os.chro... | python | def copy_file_upload(self, targetdir):
'''
Copies the currently valid file upload into the given directory.
If possible, the content is un-archived in the target directory.
'''
assert(self.file_upload)
# unpack student data to temporary directory
# os.chro... | [
"def",
"copy_file_upload",
"(",
"self",
",",
"targetdir",
")",
":",
"assert",
"(",
"self",
".",
"file_upload",
")",
"# unpack student data to temporary directory",
"# os.chroot is not working with tarfile support",
"tempdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"... | Copies the currently valid file upload into the given directory.
If possible, the content is un-archived in the target directory. | [
"Copies",
"the",
"currently",
"valid",
"file",
"upload",
"into",
"the",
"given",
"directory",
".",
"If",
"possible",
"the",
"content",
"is",
"un",
"-",
"archived",
"in",
"the",
"target",
"directory",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/submission.py#L590-L619 |
47,267 | idlesign/django-sitemessage | sitemessage/messengers/telegram.py | TelegramMessenger._send_command | def _send_command(self, method_name, data=None):
"""Sends a command to API.
:param str method_name:
:param dict data:
:return:
"""
try:
response = self.lib.post(self._tpl_url % {'token': self.auth_token, 'method': method_name}, data=data)
json = r... | python | def _send_command(self, method_name, data=None):
"""Sends a command to API.
:param str method_name:
:param dict data:
:return:
"""
try:
response = self.lib.post(self._tpl_url % {'token': self.auth_token, 'method': method_name}, data=data)
json = r... | [
"def",
"_send_command",
"(",
"self",
",",
"method_name",
",",
"data",
"=",
"None",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"lib",
".",
"post",
"(",
"self",
".",
"_tpl_url",
"%",
"{",
"'token'",
":",
"self",
".",
"auth_token",
",",
"'metho... | Sends a command to API.
:param str method_name:
:param dict data:
:return: | [
"Sends",
"a",
"command",
"to",
"API",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/telegram.py#L85-L102 |
47,268 | troeger/opensubmit | web/opensubmit/admin/submissionfile.py | SubmissionFileAdmin.get_queryset | def get_queryset(self, request):
''' Restrict the listed submission files for the current user.'''
qs = super(SubmissionFileAdmin, self).get_queryset(request)
if request.user.is_superuser:
return qs
else:
return qs.filter(Q(submissions__assignment__course__tutors_... | python | def get_queryset(self, request):
''' Restrict the listed submission files for the current user.'''
qs = super(SubmissionFileAdmin, self).get_queryset(request)
if request.user.is_superuser:
return qs
else:
return qs.filter(Q(submissions__assignment__course__tutors_... | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"super",
"(",
"SubmissionFileAdmin",
",",
"self",
")",
".",
"get_queryset",
"(",
"request",
")",
"if",
"request",
".",
"user",
".",
"is_superuser",
":",
"return",
"qs",
"else",
":",... | Restrict the listed submission files for the current user. | [
"Restrict",
"the",
"listed",
"submission",
"files",
"for",
"the",
"current",
"user",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submissionfile.py#L22-L28 |
47,269 | idlesign/django-sitemessage | sitemessage/messages/__init__.py | register_builtin_message_types | def register_builtin_message_types():
"""Registers the built-in message types."""
from .plain import PlainTextMessage
from .email import EmailTextMessage, EmailHtmlMessage
register_message_types(PlainTextMessage, EmailTextMessage, EmailHtmlMessage) | python | def register_builtin_message_types():
"""Registers the built-in message types."""
from .plain import PlainTextMessage
from .email import EmailTextMessage, EmailHtmlMessage
register_message_types(PlainTextMessage, EmailTextMessage, EmailHtmlMessage) | [
"def",
"register_builtin_message_types",
"(",
")",
":",
"from",
".",
"plain",
"import",
"PlainTextMessage",
"from",
".",
"email",
"import",
"EmailTextMessage",
",",
"EmailHtmlMessage",
"register_message_types",
"(",
"PlainTextMessage",
",",
"EmailTextMessage",
",",
"Ema... | Registers the built-in message types. | [
"Registers",
"the",
"built",
"-",
"in",
"message",
"types",
"."
] | 25b179b798370354c5988042ec209e255d23793f | https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messages/__init__.py#L4-L8 |
47,270 | troeger/opensubmit | web/opensubmit/admin/assignment.py | view_links | def view_links(obj):
''' Link to performance data and duplicate overview.'''
result=format_html('')
result+=format_html('<a href="%s" style="white-space: nowrap">Show duplicates</a><br/>'%reverse('duplicates', args=(obj.pk,)))
result+=format_html('<a href="%s" style="white-space: nowrap">Show submission... | python | def view_links(obj):
''' Link to performance data and duplicate overview.'''
result=format_html('')
result+=format_html('<a href="%s" style="white-space: nowrap">Show duplicates</a><br/>'%reverse('duplicates', args=(obj.pk,)))
result+=format_html('<a href="%s" style="white-space: nowrap">Show submission... | [
"def",
"view_links",
"(",
"obj",
")",
":",
"result",
"=",
"format_html",
"(",
"''",
")",
"result",
"+=",
"format_html",
"(",
"'<a href=\"%s\" style=\"white-space: nowrap\">Show duplicates</a><br/>'",
"%",
"reverse",
"(",
"'duplicates'",
",",
"args",
"=",
"(",
"obj",... | Link to performance data and duplicate overview. | [
"Link",
"to",
"performance",
"data",
"and",
"duplicate",
"overview",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/assignment.py#L117-L123 |
47,271 | troeger/opensubmit | web/opensubmit/admin/assignment.py | AssignmentAdminForm.clean | def clean(self):
'''
Check if such an assignment configuration makes sense, and reject it otherwise.
This mainly relates to interdependencies between the different fields, since
single field constraints are already clatified by the Django model configuration.
'''
... | python | def clean(self):
'''
Check if such an assignment configuration makes sense, and reject it otherwise.
This mainly relates to interdependencies between the different fields, since
single field constraints are already clatified by the Django model configuration.
'''
... | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
"AssignmentAdminForm",
",",
"self",
")",
".",
"clean",
"(",
")",
"d",
"=",
"defaultdict",
"(",
"lambda",
":",
"False",
")",
"d",
".",
"update",
"(",
"self",
".",
"cleaned_data",
")",
"# Having valida... | Check if such an assignment configuration makes sense, and reject it otherwise.
This mainly relates to interdependencies between the different fields, since
single field constraints are already clatified by the Django model configuration. | [
"Check",
"if",
"such",
"an",
"assignment",
"configuration",
"makes",
"sense",
"and",
"reject",
"it",
"otherwise",
".",
"This",
"mainly",
"relates",
"to",
"interdependencies",
"between",
"the",
"different",
"fields",
"since",
"single",
"field",
"constraints",
"are"... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/assignment.py#L66-L93 |
47,272 | troeger/opensubmit | web/opensubmit/admin/assignment.py | AssignmentAdmin.get_queryset | def get_queryset(self, request):
''' Restrict the listed assignments for the current user.'''
qs = super(AssignmentAdmin, self).get_queryset(request)
if not request.user.is_superuser:
qs = qs.filter(course__active=True).filter(Q(course__tutors__pk=request.user.pk) | Q(course__owner=r... | python | def get_queryset(self, request):
''' Restrict the listed assignments for the current user.'''
qs = super(AssignmentAdmin, self).get_queryset(request)
if not request.user.is_superuser:
qs = qs.filter(course__active=True).filter(Q(course__tutors__pk=request.user.pk) | Q(course__owner=r... | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"super",
"(",
"AssignmentAdmin",
",",
"self",
")",
".",
"get_queryset",
"(",
"request",
")",
"if",
"not",
"request",
".",
"user",
".",
"is_superuser",
":",
"qs",
"=",
"qs",
".",
... | Restrict the listed assignments for the current user. | [
"Restrict",
"the",
"listed",
"assignments",
"for",
"the",
"current",
"user",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/assignment.py#L150-L155 |
47,273 | troeger/opensubmit | web/opensubmit/social/env.py | ServerEnvAuth.get_user_details | def get_user_details(self, response):
""" Complete with additional information from environment, as available. """
result = {
'username': response[self.ENV_USERNAME],
'email': response.get(self.ENV_EMAIL, None),
'first_name': response.get(self.ENV_FIRST_NAME, None),
... | python | def get_user_details(self, response):
""" Complete with additional information from environment, as available. """
result = {
'username': response[self.ENV_USERNAME],
'email': response.get(self.ENV_EMAIL, None),
'first_name': response.get(self.ENV_FIRST_NAME, None),
... | [
"def",
"get_user_details",
"(",
"self",
",",
"response",
")",
":",
"result",
"=",
"{",
"'username'",
":",
"response",
"[",
"self",
".",
"ENV_USERNAME",
"]",
",",
"'email'",
":",
"response",
".",
"get",
"(",
"self",
".",
"ENV_EMAIL",
",",
"None",
")",
"... | Complete with additional information from environment, as available. | [
"Complete",
"with",
"additional",
"information",
"from",
"environment",
"as",
"available",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/social/env.py#L47-L58 |
47,274 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.file_link | def file_link(self, instance):
'''
Renders the link to the student upload file.
'''
sfile = instance.file_upload
if not sfile:
return mark_safe('No file submitted by student.')
else:
return mark_safe('<a href="%s">%s</a><br/>(<a href="%s" targe... | python | def file_link(self, instance):
'''
Renders the link to the student upload file.
'''
sfile = instance.file_upload
if not sfile:
return mark_safe('No file submitted by student.')
else:
return mark_safe('<a href="%s">%s</a><br/>(<a href="%s" targe... | [
"def",
"file_link",
"(",
"self",
",",
"instance",
")",
":",
"sfile",
"=",
"instance",
".",
"file_upload",
"if",
"not",
"sfile",
":",
"return",
"mark_safe",
"(",
"'No file submitted by student.'",
")",
"else",
":",
"return",
"mark_safe",
"(",
"'<a href=\"%s\">%s<... | Renders the link to the student upload file. | [
"Renders",
"the",
"link",
"to",
"the",
"student",
"upload",
"file",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L153-L161 |
47,275 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.get_queryset | def get_queryset(self, request):
''' Restrict the listed submission for the current user.'''
qs = super(SubmissionAdmin, self).get_queryset(request)
if request.user.is_superuser:
return qs
else:
return qs.filter(Q(assignment__course__tutors__pk=request.user.pk) | ... | python | def get_queryset(self, request):
''' Restrict the listed submission for the current user.'''
qs = super(SubmissionAdmin, self).get_queryset(request)
if request.user.is_superuser:
return qs
else:
return qs.filter(Q(assignment__course__tutors__pk=request.user.pk) | ... | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"super",
"(",
"SubmissionAdmin",
",",
"self",
")",
".",
"get_queryset",
"(",
"request",
")",
"if",
"request",
".",
"user",
".",
"is_superuser",
":",
"return",
"qs",
"else",
":",
"... | Restrict the listed submission for the current user. | [
"Restrict",
"the",
"listed",
"submission",
"for",
"the",
"current",
"user",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L202-L208 |
47,276 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.formfield_for_dbfield | def formfield_for_dbfield(self, db_field, **kwargs):
''' Offer grading choices from the assignment definition as potential form
field values for 'grading'.
When no object is given in the form, the this is a new manual submission
'''
if db_field.name == "grading":
... | python | def formfield_for_dbfield(self, db_field, **kwargs):
''' Offer grading choices from the assignment definition as potential form
field values for 'grading'.
When no object is given in the form, the this is a new manual submission
'''
if db_field.name == "grading":
... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"db_field",
".",
"name",
"==",
"\"grading\"",
":",
"submurl",
"=",
"kwargs",
"[",
"'request'",
"]",
".",
"path",
"try",
":",
"# Does not work on new submis... | Offer grading choices from the assignment definition as potential form
field values for 'grading'.
When no object is given in the form, the this is a new manual submission | [
"Offer",
"grading",
"choices",
"from",
"the",
"assignment",
"definition",
"as",
"potential",
"form",
"field",
"values",
"for",
"grading",
".",
"When",
"no",
"object",
"is",
"given",
"in",
"the",
"form",
"the",
"this",
"is",
"a",
"new",
"manual",
"submission"... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L224-L238 |
47,277 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.save_model | def save_model(self, request, obj, form, change):
''' Our custom addition to the view
adds an easy radio button choice for the new state. This is meant to be for tutors.
We need to peel this choice from the form data and set the state accordingly.
The radio buttons have no de... | python | def save_model(self, request, obj, form, change):
''' Our custom addition to the view
adds an easy radio button choice for the new state. This is meant to be for tutors.
We need to peel this choice from the form data and set the state accordingly.
The radio buttons have no de... | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"if",
"'newstate'",
"in",
"request",
".",
"POST",
":",
"if",
"request",
".",
"POST",
"[",
"'newstate'",
"]",
"==",
"'finished'",
":",
"obj",
".",
"sta... | Our custom addition to the view
adds an easy radio button choice for the new state. This is meant to be for tutors.
We need to peel this choice from the form data and set the state accordingly.
The radio buttons have no default, so that we can keep the existing state
if t... | [
"Our",
"custom",
"addition",
"to",
"the",
"view",
"adds",
"an",
"easy",
"radio",
"button",
"choice",
"for",
"the",
"new",
"state",
".",
"This",
"is",
"meant",
"to",
"be",
"for",
"tutors",
".",
"We",
"need",
"to",
"peel",
"this",
"choice",
"from",
"the"... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L240-L253 |
47,278 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.setGradingNotFinishedStateAction | def setGradingNotFinishedStateAction(self, request, queryset):
'''
Set all marked submissions to "grading not finished".
This is intended to support grading corrections on a larger scale.
'''
for subm in queryset:
subm.state = Submission.GRADING_IN_PROGRESS
... | python | def setGradingNotFinishedStateAction(self, request, queryset):
'''
Set all marked submissions to "grading not finished".
This is intended to support grading corrections on a larger scale.
'''
for subm in queryset:
subm.state = Submission.GRADING_IN_PROGRESS
... | [
"def",
"setGradingNotFinishedStateAction",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"for",
"subm",
"in",
"queryset",
":",
"subm",
".",
"state",
"=",
"Submission",
".",
"GRADING_IN_PROGRESS",
"subm",
".",
"save",
"(",
")"
] | Set all marked submissions to "grading not finished".
This is intended to support grading corrections on a larger scale. | [
"Set",
"all",
"marked",
"submissions",
"to",
"grading",
"not",
"finished",
".",
"This",
"is",
"intended",
"to",
"support",
"grading",
"corrections",
"on",
"a",
"larger",
"scale",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L261-L268 |
47,279 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.setGradingFinishedStateAction | def setGradingFinishedStateAction(self, request, queryset):
'''
Set all marked submissions to "grading finished".
This is intended to support grading corrections on a larger scale.
'''
for subm in queryset:
subm.state = Submission.GRADED
subm.save(... | python | def setGradingFinishedStateAction(self, request, queryset):
'''
Set all marked submissions to "grading finished".
This is intended to support grading corrections on a larger scale.
'''
for subm in queryset:
subm.state = Submission.GRADED
subm.save(... | [
"def",
"setGradingFinishedStateAction",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"for",
"subm",
"in",
"queryset",
":",
"subm",
".",
"state",
"=",
"Submission",
".",
"GRADED",
"subm",
".",
"save",
"(",
")"
] | Set all marked submissions to "grading finished".
This is intended to support grading corrections on a larger scale. | [
"Set",
"all",
"marked",
"submissions",
"to",
"grading",
"finished",
".",
"This",
"is",
"intended",
"to",
"support",
"grading",
"corrections",
"on",
"a",
"larger",
"scale",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L271-L278 |
47,280 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.closeAndNotifyAction | def closeAndNotifyAction(self, request, queryset):
''' Close all submissions were the tutor sayed that the grading is finished,
and inform the student. CLosing only graded submissions is a safeguard,
since backend users tend to checkbox-mark all submissions without thinking.
'''
... | python | def closeAndNotifyAction(self, request, queryset):
''' Close all submissions were the tutor sayed that the grading is finished,
and inform the student. CLosing only graded submissions is a safeguard,
since backend users tend to checkbox-mark all submissions without thinking.
'''
... | [
"def",
"closeAndNotifyAction",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"mails",
"=",
"[",
"]",
"qs",
"=",
"queryset",
".",
"filter",
"(",
"Q",
"(",
"state",
"=",
"Submission",
".",
"GRADED",
")",
")",
"for",
"subm",
"in",
"qs",
":",
... | Close all submissions were the tutor sayed that the grading is finished,
and inform the student. CLosing only graded submissions is a safeguard,
since backend users tend to checkbox-mark all submissions without thinking. | [
"Close",
"all",
"submissions",
"were",
"the",
"tutor",
"sayed",
"that",
"the",
"grading",
"is",
"finished",
"and",
"inform",
"the",
"student",
".",
"CLosing",
"only",
"graded",
"submissions",
"is",
"a",
"safeguard",
"since",
"backend",
"users",
"tend",
"to",
... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L304-L320 |
47,281 | troeger/opensubmit | web/opensubmit/admin/submission.py | SubmissionAdmin.downloadArchiveAction | def downloadArchiveAction(self, request, queryset):
'''
Download selected submissions as archive, for targeted correction.
'''
output = io.BytesIO()
z = zipfile.ZipFile(output, 'w')
for sub in queryset:
sub.add_to_zipfile(z)
z.close()
# go ba... | python | def downloadArchiveAction(self, request, queryset):
'''
Download selected submissions as archive, for targeted correction.
'''
output = io.BytesIO()
z = zipfile.ZipFile(output, 'w')
for sub in queryset:
sub.add_to_zipfile(z)
z.close()
# go ba... | [
"def",
"downloadArchiveAction",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"output",
"=",
"io",
".",
"BytesIO",
"(",
")",
"z",
"=",
"zipfile",
".",
"ZipFile",
"(",
"output",
",",
"'w'",
")",
"for",
"sub",
"in",
"queryset",
":",
"sub",
".... | Download selected submissions as archive, for targeted correction. | [
"Download",
"selected",
"submissions",
"as",
"archive",
"for",
"targeted",
"correction",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/submission.py#L332-L348 |
47,282 | troeger/opensubmit | web/opensubmit/models/assignment.py | Assignment.directory_name_with_course | def directory_name_with_course(self):
''' The assignment name in a format that is suitable for a directory name. '''
coursename = self.course.directory_name()
assignmentname = self.title.replace(" ", "_").replace("\\", "_").replace(",","").lower()
return coursename + os.sep + assignment... | python | def directory_name_with_course(self):
''' The assignment name in a format that is suitable for a directory name. '''
coursename = self.course.directory_name()
assignmentname = self.title.replace(" ", "_").replace("\\", "_").replace(",","").lower()
return coursename + os.sep + assignment... | [
"def",
"directory_name_with_course",
"(",
"self",
")",
":",
"coursename",
"=",
"self",
".",
"course",
".",
"directory_name",
"(",
")",
"assignmentname",
"=",
"self",
".",
"title",
".",
"replace",
"(",
"\" \"",
",",
"\"_\"",
")",
".",
"replace",
"(",
"\"\\\... | The assignment name in a format that is suitable for a directory name. | [
"The",
"assignment",
"name",
"in",
"a",
"format",
"that",
"is",
"suitable",
"for",
"a",
"directory",
"name",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/assignment.py#L49-L53 |
47,283 | troeger/opensubmit | web/opensubmit/models/assignment.py | Assignment.grading_url | def grading_url(self):
'''
Determines the teacher backend link to the filtered list of gradable submissions for this assignment.
'''
grading_url="%s?coursefilter=%u&assignmentfilter=%u&statefilter=tobegraded"%(
reverse('teacher:opensubmit_submission_change... | python | def grading_url(self):
'''
Determines the teacher backend link to the filtered list of gradable submissions for this assignment.
'''
grading_url="%s?coursefilter=%u&assignmentfilter=%u&statefilter=tobegraded"%(
reverse('teacher:opensubmit_submission_change... | [
"def",
"grading_url",
"(",
"self",
")",
":",
"grading_url",
"=",
"\"%s?coursefilter=%u&assignmentfilter=%u&statefilter=tobegraded\"",
"%",
"(",
"reverse",
"(",
"'teacher:opensubmit_submission_changelist'",
")",
",",
"self",
".",
"course",
".",
"pk",
",",
"self",
".",
... | Determines the teacher backend link to the filtered list of gradable submissions for this assignment. | [
"Determines",
"the",
"teacher",
"backend",
"link",
"to",
"the",
"filtered",
"list",
"of",
"gradable",
"submissions",
"for",
"this",
"assignment",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/assignment.py#L69-L77 |
47,284 | troeger/opensubmit | web/opensubmit/models/assignment.py | Assignment.has_perf_results | def has_perf_results(self):
'''
Figure out if any submission for this assignment has performance data being available.
'''
num_results = SubmissionTestResult.objects.filter(perf_data__isnull=False).filter(submission_file__submissions__assignment=self).count()
return num_resul... | python | def has_perf_results(self):
'''
Figure out if any submission for this assignment has performance data being available.
'''
num_results = SubmissionTestResult.objects.filter(perf_data__isnull=False).filter(submission_file__submissions__assignment=self).count()
return num_resul... | [
"def",
"has_perf_results",
"(",
"self",
")",
":",
"num_results",
"=",
"SubmissionTestResult",
".",
"objects",
".",
"filter",
"(",
"perf_data__isnull",
"=",
"False",
")",
".",
"filter",
"(",
"submission_file__submissions__assignment",
"=",
"self",
")",
".",
"count"... | Figure out if any submission for this assignment has performance data being available. | [
"Figure",
"out",
"if",
"any",
"submission",
"for",
"this",
"assignment",
"has",
"performance",
"data",
"being",
"available",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/assignment.py#L87-L92 |
47,285 | troeger/opensubmit | web/opensubmit/models/assignment.py | Assignment.url | def url(self, request):
'''
Return absolute URL for assignment description.
'''
if self.pk:
if self.has_description():
return request.build_absolute_uri(reverse('assignment_description_file', args=[self.pk]))
else:
return self.d... | python | def url(self, request):
'''
Return absolute URL for assignment description.
'''
if self.pk:
if self.has_description():
return request.build_absolute_uri(reverse('assignment_description_file', args=[self.pk]))
else:
return self.d... | [
"def",
"url",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"pk",
":",
"if",
"self",
".",
"has_description",
"(",
")",
":",
"return",
"request",
".",
"build_absolute_uri",
"(",
"reverse",
"(",
"'assignment_description_file'",
",",
"args",
"=",
... | Return absolute URL for assignment description. | [
"Return",
"absolute",
"URL",
"for",
"assignment",
"description",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/assignment.py#L118-L128 |
47,286 | troeger/opensubmit | web/opensubmit/models/assignment.py | Assignment.can_create_submission | def can_create_submission(self, user=None):
'''
Central access control for submitting things related to assignments.
'''
if user:
# Super users, course owners and tutors should be able to test their validations
# before the submission is officially possible.
... | python | def can_create_submission(self, user=None):
'''
Central access control for submitting things related to assignments.
'''
if user:
# Super users, course owners and tutors should be able to test their validations
# before the submission is officially possible.
... | [
"def",
"can_create_submission",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"if",
"user",
":",
"# Super users, course owners and tutors should be able to test their validations",
"# before the submission is officially possible.",
"# They should also be able to submit after the dea... | Central access control for submitting things related to assignments. | [
"Central",
"access",
"control",
"for",
"submitting",
"things",
"related",
"to",
"assignments",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/assignment.py#L142-L172 |
47,287 | troeger/opensubmit | web/opensubmit/models/assignment.py | Assignment.duplicate_files | def duplicate_files(self):
'''
Search for duplicates of submission file uploads for this assignment.
This includes the search in other course, whether inactive or not.
Returns a list of lists, where each latter is a set of duplicate submissions
with at least on of them for this a... | python | def duplicate_files(self):
'''
Search for duplicates of submission file uploads for this assignment.
This includes the search in other course, whether inactive or not.
Returns a list of lists, where each latter is a set of duplicate submissions
with at least on of them for this a... | [
"def",
"duplicate_files",
"(",
"self",
")",
":",
"result",
"=",
"list",
"(",
")",
"files",
"=",
"SubmissionFile",
".",
"valid_ones",
".",
"order_by",
"(",
"'md5'",
")",
"for",
"key",
",",
"dup_group",
"in",
"groupby",
"(",
"files",
",",
"lambda",
"f",
... | Search for duplicates of submission file uploads for this assignment.
This includes the search in other course, whether inactive or not.
Returns a list of lists, where each latter is a set of duplicate submissions
with at least on of them for this assignment | [
"Search",
"for",
"duplicates",
"of",
"submission",
"file",
"uploads",
"for",
"this",
"assignment",
".",
"This",
"includes",
"the",
"search",
"in",
"other",
"course",
"whether",
"inactive",
"or",
"not",
".",
"Returns",
"a",
"list",
"of",
"lists",
"where",
"ea... | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/models/assignment.py#L181-L198 |
47,288 | troeger/opensubmit | executor/opensubmitexec/cmdline.py | download_and_run | def download_and_run(config):
'''
Main operation of the executor.
Returns True when a job was downloaded and executed.
Returns False when no job could be downloaded.
'''
job = fetch_job(config)
if job:
job._run_validate()
return True
else:
return False | python | def download_and_run(config):
'''
Main operation of the executor.
Returns True when a job was downloaded and executed.
Returns False when no job could be downloaded.
'''
job = fetch_job(config)
if job:
job._run_validate()
return True
else:
return False | [
"def",
"download_and_run",
"(",
"config",
")",
":",
"job",
"=",
"fetch_job",
"(",
"config",
")",
"if",
"job",
":",
"job",
".",
"_run_validate",
"(",
")",
"return",
"True",
"else",
":",
"return",
"False"
] | Main operation of the executor.
Returns True when a job was downloaded and executed.
Returns False when no job could be downloaded. | [
"Main",
"operation",
"of",
"the",
"executor",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/cmdline.py#L12-L24 |
47,289 | troeger/opensubmit | executor/opensubmitexec/cmdline.py | copy_and_run | def copy_and_run(config, src_dir):
'''
Local-only operation of the executor.
Intended for validation script developers,
and the test suite.
Please not that this function only works correctly
if the validator has one of the following names:
- validator.py
- validator.zip
Ret... | python | def copy_and_run(config, src_dir):
'''
Local-only operation of the executor.
Intended for validation script developers,
and the test suite.
Please not that this function only works correctly
if the validator has one of the following names:
- validator.py
- validator.zip
Ret... | [
"def",
"copy_and_run",
"(",
"config",
",",
"src_dir",
")",
":",
"job",
"=",
"fake_fetch_job",
"(",
"config",
",",
"src_dir",
")",
"if",
"job",
":",
"job",
".",
"_run_validate",
"(",
")",
"return",
"True",
"else",
":",
"return",
"False"
] | Local-only operation of the executor.
Intended for validation script developers,
and the test suite.
Please not that this function only works correctly
if the validator has one of the following names:
- validator.py
- validator.zip
Returns True when a job was prepared and executed.... | [
"Local",
"-",
"only",
"operation",
"of",
"the",
"executor",
".",
"Intended",
"for",
"validation",
"script",
"developers",
"and",
"the",
"test",
"suite",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/cmdline.py#L27-L46 |
47,290 | troeger/opensubmit | executor/opensubmitexec/cmdline.py | console_script | def console_script():
'''
The main entry point for the production
administration script 'opensubmit-exec',
installed by setuptools.
'''
if len(sys.argv) == 1:
print("opensubmit-exec [configcreate <server_url>|configtest|run|test <dir>|unlock|help] [-c config_file]")
r... | python | def console_script():
'''
The main entry point for the production
administration script 'opensubmit-exec',
installed by setuptools.
'''
if len(sys.argv) == 1:
print("opensubmit-exec [configcreate <server_url>|configtest|run|test <dir>|unlock|help] [-c config_file]")
r... | [
"def",
"console_script",
"(",
")",
":",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"==",
"1",
":",
"print",
"(",
"\"opensubmit-exec [configcreate <server_url>|configtest|run|test <dir>|unlock|help] [-c config_file]\"",
")",
"return",
"0",
"if",
"\"help\"",
"in",
"sys"... | The main entry point for the production
administration script 'opensubmit-exec',
installed by setuptools. | [
"The",
"main",
"entry",
"point",
"for",
"the",
"production",
"administration",
"script",
"opensubmit",
"-",
"exec",
"installed",
"by",
"setuptools",
"."
] | 384a95b7c6fa41e3f949a129d25dafd9a1c54859 | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/cmdline.py#L56-L126 |
47,291 | timothydmorton/VESPA | vespa/hashutils.py | hashdict | def hashdict(d):
"""Hash a dictionary
"""
k = 0
for key,val in d.items():
k ^= hash(key) ^ hash(val)
return k | python | def hashdict(d):
"""Hash a dictionary
"""
k = 0
for key,val in d.items():
k ^= hash(key) ^ hash(val)
return k | [
"def",
"hashdict",
"(",
"d",
")",
":",
"k",
"=",
"0",
"for",
"key",
",",
"val",
"in",
"d",
".",
"items",
"(",
")",
":",
"k",
"^=",
"hash",
"(",
"key",
")",
"^",
"hash",
"(",
"val",
")",
"return",
"k"
] | Hash a dictionary | [
"Hash",
"a",
"dictionary"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/hashutils.py#L82-L88 |
47,292 | timothydmorton/VESPA | vespa/orbits/populations.py | TripleOrbitPopulation.from_df | def from_df(cls, df_long, df_short):
"""
Builds TripleOrbitPopulation from DataFrame
``DataFrame`` objects must be of appropriate form to pass
to :func:`OrbitPopulation.from_df`.
:param df_long, df_short:
:class:`pandas.DataFrame` objects to pass to
:fun... | python | def from_df(cls, df_long, df_short):
"""
Builds TripleOrbitPopulation from DataFrame
``DataFrame`` objects must be of appropriate form to pass
to :func:`OrbitPopulation.from_df`.
:param df_long, df_short:
:class:`pandas.DataFrame` objects to pass to
:fun... | [
"def",
"from_df",
"(",
"cls",
",",
"df_long",
",",
"df_short",
")",
":",
"pop",
"=",
"cls",
"(",
"1",
",",
"1",
",",
"1",
",",
"1",
",",
"1",
")",
"#dummy population",
"pop",
".",
"orbpop_long",
"=",
"OrbitPopulation",
".",
"from_df",
"(",
"df_long",... | Builds TripleOrbitPopulation from DataFrame
``DataFrame`` objects must be of appropriate form to pass
to :func:`OrbitPopulation.from_df`.
:param df_long, df_short:
:class:`pandas.DataFrame` objects to pass to
:func:`OrbitPopulation.from_df`. | [
"Builds",
"TripleOrbitPopulation",
"from",
"DataFrame"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/orbits/populations.py#L220-L235 |
47,293 | timothydmorton/VESPA | vespa/orbits/populations.py | TripleOrbitPopulation.load_hdf | def load_hdf(cls, filename, path=''):
"""
Load TripleOrbitPopulation from saved .h5 file.
:param filename:
HDF file name.
:param path:
Path within HDF file where data is stored.
"""
df_long = pd.read_hdf(filename,'{}/long/df'.format(path))
... | python | def load_hdf(cls, filename, path=''):
"""
Load TripleOrbitPopulation from saved .h5 file.
:param filename:
HDF file name.
:param path:
Path within HDF file where data is stored.
"""
df_long = pd.read_hdf(filename,'{}/long/df'.format(path))
... | [
"def",
"load_hdf",
"(",
"cls",
",",
"filename",
",",
"path",
"=",
"''",
")",
":",
"df_long",
"=",
"pd",
".",
"read_hdf",
"(",
"filename",
",",
"'{}/long/df'",
".",
"format",
"(",
"path",
")",
")",
"df_short",
"=",
"pd",
".",
"read_hdf",
"(",
"filenam... | Load TripleOrbitPopulation from saved .h5 file.
:param filename:
HDF file name.
:param path:
Path within HDF file where data is stored. | [
"Load",
"TripleOrbitPopulation",
"from",
"saved",
".",
"h5",
"file",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/orbits/populations.py#L238-L251 |
47,294 | timothydmorton/VESPA | vespa/orbits/populations.py | OrbitPopulation.RV_timeseries | def RV_timeseries(self,ts,recalc=False):
"""
Radial Velocity time series for star 1 at given times ts.
:param ts:
Times. If not ``Quantity``, assumed to be in days.
:type ts:
array-like or ``Quantity``
:param recalc: (optional)
If ``False``,... | python | def RV_timeseries(self,ts,recalc=False):
"""
Radial Velocity time series for star 1 at given times ts.
:param ts:
Times. If not ``Quantity``, assumed to be in days.
:type ts:
array-like or ``Quantity``
:param recalc: (optional)
If ``False``,... | [
"def",
"RV_timeseries",
"(",
"self",
",",
"ts",
",",
"recalc",
"=",
"False",
")",
":",
"if",
"type",
"(",
"ts",
")",
"!=",
"Quantity",
":",
"ts",
"*=",
"u",
".",
"day",
"if",
"not",
"recalc",
"and",
"hasattr",
"(",
"self",
",",
"'RV_measurements'",
... | Radial Velocity time series for star 1 at given times ts.
:param ts:
Times. If not ``Quantity``, assumed to be in days.
:type ts:
array-like or ``Quantity``
:param recalc: (optional)
If ``False``, then if called with the exact same ``ts``
as las... | [
"Radial",
"Velocity",
"time",
"series",
"for",
"star",
"1",
"at",
"given",
"times",
"ts",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/orbits/populations.py#L419-L447 |
47,295 | timothydmorton/VESPA | vespa/orbits/populations.py | OrbitPopulation.from_df | def from_df(cls, df):
"""Creates an OrbitPopulation from a DataFrame.
:param df:
:class:`pandas.DataFrame` object. Must contain the following
columns: ``['M1','M2','P','ecc','mean_anomaly','obsx','obsy','obsz']``,
i.e., as what is accessed via :attr:`OrbitPopulation... | python | def from_df(cls, df):
"""Creates an OrbitPopulation from a DataFrame.
:param df:
:class:`pandas.DataFrame` object. Must contain the following
columns: ``['M1','M2','P','ecc','mean_anomaly','obsx','obsy','obsz']``,
i.e., as what is accessed via :attr:`OrbitPopulation... | [
"def",
"from_df",
"(",
"cls",
",",
"df",
")",
":",
"return",
"cls",
"(",
"df",
"[",
"'M1'",
"]",
",",
"df",
"[",
"'M2'",
"]",
",",
"df",
"[",
"'P'",
"]",
",",
"ecc",
"=",
"df",
"[",
"'ecc'",
"]",
",",
"mean_anomaly",
"=",
"df",
"[",
"'mean_an... | Creates an OrbitPopulation from a DataFrame.
:param df:
:class:`pandas.DataFrame` object. Must contain the following
columns: ``['M1','M2','P','ecc','mean_anomaly','obsx','obsy','obsz']``,
i.e., as what is accessed via :attr:`OrbitPopulation.dataframe`.
:return:
... | [
"Creates",
"an",
"OrbitPopulation",
"from",
"a",
"DataFrame",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/orbits/populations.py#L513-L526 |
47,296 | timothydmorton/VESPA | vespa/orbits/populations.py | OrbitPopulation.load_hdf | def load_hdf(cls, filename, path=''):
"""Loads OrbitPopulation from HDF file.
:param filename:
HDF file
:param path:
Path within HDF file store where :class:`OrbitPopulation` is saved.
"""
df = pd.read_hdf(filename,'{}/df'.format(path))
return cl... | python | def load_hdf(cls, filename, path=''):
"""Loads OrbitPopulation from HDF file.
:param filename:
HDF file
:param path:
Path within HDF file store where :class:`OrbitPopulation` is saved.
"""
df = pd.read_hdf(filename,'{}/df'.format(path))
return cl... | [
"def",
"load_hdf",
"(",
"cls",
",",
"filename",
",",
"path",
"=",
"''",
")",
":",
"df",
"=",
"pd",
".",
"read_hdf",
"(",
"filename",
",",
"'{}/df'",
".",
"format",
"(",
"path",
")",
")",
"return",
"cls",
".",
"from_df",
"(",
"df",
")"
] | Loads OrbitPopulation from HDF file.
:param filename:
HDF file
:param path:
Path within HDF file store where :class:`OrbitPopulation` is saved. | [
"Loads",
"OrbitPopulation",
"from",
"HDF",
"file",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/orbits/populations.py#L529-L539 |
47,297 | timothydmorton/VESPA | vespa/stars/utils.py | draw_pers_eccs | def draw_pers_eccs(n,**kwargs):
"""
Draw random periods and eccentricities according to empirical survey data.
"""
pers = draw_raghavan_periods(n)
eccs = draw_eccs(n,pers,**kwargs)
return pers,eccs | python | def draw_pers_eccs(n,**kwargs):
"""
Draw random periods and eccentricities according to empirical survey data.
"""
pers = draw_raghavan_periods(n)
eccs = draw_eccs(n,pers,**kwargs)
return pers,eccs | [
"def",
"draw_pers_eccs",
"(",
"n",
",",
"*",
"*",
"kwargs",
")",
":",
"pers",
"=",
"draw_raghavan_periods",
"(",
"n",
")",
"eccs",
"=",
"draw_eccs",
"(",
"n",
",",
"pers",
",",
"*",
"*",
"kwargs",
")",
"return",
"pers",
",",
"eccs"
] | Draw random periods and eccentricities according to empirical survey data. | [
"Draw",
"random",
"periods",
"and",
"eccentricities",
"according",
"to",
"empirical",
"survey",
"data",
"."
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/stars/utils.py#L65-L71 |
47,298 | timothydmorton/VESPA | vespa/stars/utils.py | draw_eccs | def draw_eccs(n,per=10,binsize=0.1,fuzz=0.05,maxecc=0.97):
"""draws eccentricities appropriate to given periods, generated according to empirical data from Multiple Star Catalog
"""
if np.size(per) == 1 or np.std(np.atleast_1d(per))==0:
if np.size(per)>1:
per = per[0]
if per==0:
... | python | def draw_eccs(n,per=10,binsize=0.1,fuzz=0.05,maxecc=0.97):
"""draws eccentricities appropriate to given periods, generated according to empirical data from Multiple Star Catalog
"""
if np.size(per) == 1 or np.std(np.atleast_1d(per))==0:
if np.size(per)>1:
per = per[0]
if per==0:
... | [
"def",
"draw_eccs",
"(",
"n",
",",
"per",
"=",
"10",
",",
"binsize",
"=",
"0.1",
",",
"fuzz",
"=",
"0.05",
",",
"maxecc",
"=",
"0.97",
")",
":",
"if",
"np",
".",
"size",
"(",
"per",
")",
"==",
"1",
"or",
"np",
".",
"std",
"(",
"np",
".",
"a... | draws eccentricities appropriate to given periods, generated according to empirical data from Multiple Star Catalog | [
"draws",
"eccentricities",
"appropriate",
"to",
"given",
"periods",
"generated",
"according",
"to",
"empirical",
"data",
"from",
"Multiple",
"Star",
"Catalog"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/stars/utils.py#L95-L134 |
47,299 | timothydmorton/VESPA | vespa/stars/utils.py | withinroche | def withinroche(semimajors,M1,R1,M2,R2):
"""
Returns boolean array that is True where two stars are within Roche lobe
"""
q = M1/M2
return ((R1+R2)*RSUN) > (rochelobe(q)*semimajors*AU) | python | def withinroche(semimajors,M1,R1,M2,R2):
"""
Returns boolean array that is True where two stars are within Roche lobe
"""
q = M1/M2
return ((R1+R2)*RSUN) > (rochelobe(q)*semimajors*AU) | [
"def",
"withinroche",
"(",
"semimajors",
",",
"M1",
",",
"R1",
",",
"M2",
",",
"R2",
")",
":",
"q",
"=",
"M1",
"/",
"M2",
"return",
"(",
"(",
"R1",
"+",
"R2",
")",
"*",
"RSUN",
")",
">",
"(",
"rochelobe",
"(",
"q",
")",
"*",
"semimajors",
"*"... | Returns boolean array that is True where two stars are within Roche lobe | [
"Returns",
"boolean",
"array",
"that",
"is",
"True",
"where",
"two",
"stars",
"are",
"within",
"Roche",
"lobe"
] | 0446b54d48009f3655cfd1a3957ceea21d3adcaa | https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/stars/utils.py#L152-L157 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.