repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
idlesign/django-sitemessage
sitemessage/messengers/smtp.py
SMTPMessenger._build_message
def _build_message(self, to, text, subject=None, mtype=None, unsubscribe_url=None): """Constructs a MIME message from message and dispatch models.""" # TODO Maybe file attachments handling through `files` message_model context var. if subject is None: subject = u'%s' % _('No Subject...
python
def _build_message(self, to, text, subject=None, mtype=None, unsubscribe_url=None): """Constructs a MIME message from message and dispatch models.""" # TODO Maybe file attachments handling through `files` message_model context var. if subject is None: subject = u'%s' % _('No Subject...
[ "def", "_build_message", "(", "self", ",", "to", ",", "text", ",", "subject", "=", "None", ",", "mtype", "=", "None", ",", "unsubscribe_url", "=", "None", ")", ":", "# TODO Maybe file attachments handling through `files` message_model context var.", "if", "subject", ...
Constructs a MIME message from message and dispatch models.
[ "Constructs", "a", "MIME", "message", "from", "message", "and", "dispatch", "models", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/smtp.py#L94-L118
train
64,100
troeger/opensubmit
web/opensubmit/admin/__init__.py
_social_auth_login
def _social_auth_login(self, request, **kwargs): ''' View function that redirects to social auth login, in case the user is not logged in. ''' if request.user.is_authenticated(): if not request.user.is_active or not request.user.is_staff: raise PermissionDenied() else...
python
def _social_auth_login(self, request, **kwargs): ''' View function that redirects to social auth login, in case the user is not logged in. ''' if request.user.is_authenticated(): if not request.user.is_active or not request.user.is_staff: raise PermissionDenied() else...
[ "def", "_social_auth_login", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "user", ".", "is_authenticated", "(", ")", ":", "if", "not", "request", ".", "user", ".", "is_active", "or", "not", "request", ".", "user...
View function that redirects to social auth login, in case the user is not logged in.
[ "View", "function", "that", "redirects", "to", "social", "auth", "login", "in", "case", "the", "user", "is", "not", "logged", "in", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/__init__.py#L20-L30
train
64,101
troeger/opensubmit
web/opensubmit/admin/course.py
CourseAdmin.get_queryset
def get_queryset(self, request): ''' Restrict the listed courses for the current user.''' qs = super(CourseAdmin, self).get_queryset(request) if request.user.is_superuser: return qs else: return qs.filter(Q(tutors__pk=request.user.pk) | Q(owner=request.user)).dist...
python
def get_queryset(self, request): ''' Restrict the listed courses for the current user.''' qs = super(CourseAdmin, self).get_queryset(request) if request.user.is_superuser: return qs else: return qs.filter(Q(tutors__pk=request.user.pk) | Q(owner=request.user)).dist...
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "qs", "=", "super", "(", "CourseAdmin", ",", "self", ")", ".", "get_queryset", "(", "request", ")", "if", "request", ".", "user", ".", "is_superuser", ":", "return", "qs", "else", ":", "retu...
Restrict the listed courses for the current user.
[ "Restrict", "the", "listed", "courses", "for", "the", "current", "user", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/admin/course.py#L25-L31
train
64,102
umich-brcf-bioinf/Connor
connor/connor.py
_build_tag_families
def _build_tag_families(tagged_paired_aligns, ranked_tags, hamming_threshold, consensus_threshold, family_filter=lambda _: None): '''Partition paired aligns into families. Each read is considered against each ranked...
python
def _build_tag_families(tagged_paired_aligns, ranked_tags, hamming_threshold, consensus_threshold, family_filter=lambda _: None): '''Partition paired aligns into families. Each read is considered against each ranked...
[ "def", "_build_tag_families", "(", "tagged_paired_aligns", ",", "ranked_tags", ",", "hamming_threshold", ",", "consensus_threshold", ",", "family_filter", "=", "lambda", "_", ":", "None", ")", ":", "tag_aligns", "=", "defaultdict", "(", "set", ")", "tag_inexact_matc...
Partition paired aligns into families. Each read is considered against each ranked tag until all reads are partitioned into families.
[ "Partition", "paired", "aligns", "into", "families", "." ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/connor.py#L61-L96
train
64,103
umich-brcf-bioinf/Connor
connor/connor.py
_rank_tags
def _rank_tags(tagged_paired_aligns): '''Return the list of tags ranked from most to least popular.''' tag_count_dict = defaultdict(int) for paired_align in tagged_paired_aligns: tag_count_dict[paired_align.umt] += 1 tags_by_count = utils.sort_dict(tag_count_dict) ranked_tags = [tag_count[0]...
python
def _rank_tags(tagged_paired_aligns): '''Return the list of tags ranked from most to least popular.''' tag_count_dict = defaultdict(int) for paired_align in tagged_paired_aligns: tag_count_dict[paired_align.umt] += 1 tags_by_count = utils.sort_dict(tag_count_dict) ranked_tags = [tag_count[0]...
[ "def", "_rank_tags", "(", "tagged_paired_aligns", ")", ":", "tag_count_dict", "=", "defaultdict", "(", "int", ")", "for", "paired_align", "in", "tagged_paired_aligns", ":", "tag_count_dict", "[", "paired_align", ".", "umt", "]", "+=", "1", "tags_by_count", "=", ...
Return the list of tags ranked from most to least popular.
[ "Return", "the", "list", "of", "tags", "ranked", "from", "most", "to", "least", "popular", "." ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/connor.py#L102-L109
train
64,104
umich-brcf-bioinf/Connor
connor/connor.py
main
def main(command_line_args=None): '''Connor entry point. See help for more info''' log = None if not command_line_args: command_line_args = sys.argv try: start_time = time.time() args = parse_command_line_args(command_line_args) log = utils.Logger(args) command_va...
python
def main(command_line_args=None): '''Connor entry point. See help for more info''' log = None if not command_line_args: command_line_args = sys.argv try: start_time = time.time() args = parse_command_line_args(command_line_args) log = utils.Logger(args) command_va...
[ "def", "main", "(", "command_line_args", "=", "None", ")", ":", "log", "=", "None", "if", "not", "command_line_args", ":", "command_line_args", "=", "sys", ".", "argv", "try", ":", "start_time", "=", "time", ".", "time", "(", ")", "args", "=", "parse_com...
Connor entry point. See help for more info
[ "Connor", "entry", "point", ".", "See", "help", "for", "more", "info" ]
b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13
https://github.com/umich-brcf-bioinf/Connor/blob/b20e9f36e9730c29eaa27ea5fa8b0151e58d2f13/connor/connor.py#L151-L198
train
64,105
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_email
def schedule_email(message, to, subject=None, sender=None, priority=None): """Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|s...
python
def schedule_email(message, to, subject=None, sender=None, priority=None): """Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|s...
[ "def", "schedule_email", "(", "message", ",", "to", ",", "subject", "=", "None", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "if", "SHORTCUT_EMAIL_MESSAGE_TYPE", ":", "message_cls", "=", "get_registered_message_type", "(", "SHORTCUT_EMAIL...
Schedules an email message for delivery. :param dict, str message: str or dict: use str for simple text email; dict - to compile email from a template (default: `sitemessage/messages/email_html__smtp.html`). :param list|str|unicode to: recipients addresses or Django User model heir instances :param...
[ "Schedules", "an", "email", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L6-L31
train
64,106
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_jabber_message
def schedule_jabber_message(message, to, sender=None, priority=None): """Schedules Jabber XMPP message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `email` attributes. :param User sender: User model heir instan...
python
def schedule_jabber_message(message, to, sender=None, priority=None): """Schedules Jabber XMPP message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `email` attributes. :param User sender: User model heir instan...
[ "def", "schedule_jabber_message", "(", "message", ",", "to", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'xmppsleek'", ",", "to", ")", ",", "sender", "=", "sender", ",", ...
Schedules Jabber XMPP message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `email` attributes. :param User sender: User model heir instance :param int priority: number describing message priority. If set overri...
[ "Schedules", "Jabber", "XMPP", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L34-L42
train
64,107
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_tweet
def schedule_tweet(message, to='', sender=None, priority=None): """Schedules a Tweet for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. If supplied tweets will be @-replies. :param User...
python
def schedule_tweet(message, to='', sender=None, priority=None): """Schedules a Tweet for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. If supplied tweets will be @-replies. :param User...
[ "def", "schedule_tweet", "(", "message", ",", "to", "=", "''", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'twitter'", ",", "to", ")", ",", "sender", "=", "sender", "...
Schedules a Tweet for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. If supplied tweets will be @-replies. :param User sender: User model heir instance :param int priority: number descr...
[ "Schedules", "a", "Tweet", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L45-L54
train
64,108
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_telegram_message
def schedule_telegram_message(message, to, sender=None, priority=None): """Schedules Telegram message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. :param User sender: User model heir inst...
python
def schedule_telegram_message(message, to, sender=None, priority=None): """Schedules Telegram message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. :param User sender: User model heir inst...
[ "def", "schedule_telegram_message", "(", "message", ",", "to", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'telegram'", ",", "to", ")", ",", "sender", "=", "sender", ",",...
Schedules Telegram message for delivery. :param str message: text to send. :param list|str|unicode to: recipients addresses or Django User model heir instances with `telegram` attributes. :param User sender: User model heir instance :param int priority: number describing message priority. If set overri...
[ "Schedules", "Telegram", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L57-L65
train
64,109
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_facebook_message
def schedule_facebook_message(message, sender=None, priority=None): """Schedules Facebook wall message for delivery. :param str message: text or URL to publish. :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with ...
python
def schedule_facebook_message(message, sender=None, priority=None): """Schedules Facebook wall message for delivery. :param str message: text or URL to publish. :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with ...
[ "def", "schedule_facebook_message", "(", "message", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'fb'", ",", "''", ")", ",", "sender", "=", "sender", ",", "priority", "=",...
Schedules Facebook wall message for delivery. :param str message: text or URL to publish. :param User sender: User model heir instance :param int priority: number describing message priority. If set overrides priority provided with message type.
[ "Schedules", "Facebook", "wall", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L68-L75
train
64,110
idlesign/django-sitemessage
sitemessage/shortcuts.py
schedule_vkontakte_message
def schedule_vkontakte_message(message, to, sender=None, priority=None): """Schedules VKontakte message for delivery. :param str message: text or URL to publish on wall. :param list|str|unicode to: recipients addresses or Django User model heir instances with `vk` attributes. :param User sender: User m...
python
def schedule_vkontakte_message(message, to, sender=None, priority=None): """Schedules VKontakte message for delivery. :param str message: text or URL to publish on wall. :param list|str|unicode to: recipients addresses or Django User model heir instances with `vk` attributes. :param User sender: User m...
[ "def", "schedule_vkontakte_message", "(", "message", ",", "to", ",", "sender", "=", "None", ",", "priority", "=", "None", ")", ":", "schedule_messages", "(", "message", ",", "recipients", "(", "'vk'", ",", "to", ")", ",", "sender", "=", "sender", ",", "p...
Schedules VKontakte message for delivery. :param str message: text or URL to publish on wall. :param list|str|unicode to: recipients addresses or Django User model heir instances with `vk` attributes. :param User sender: User model heir instance :param int priority: number describing message priority. ...
[ "Schedules", "VKontakte", "message", "for", "delivery", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/shortcuts.py#L78-L86
train
64,111
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase.get_alias
def get_alias(cls): """Returns messenger alias. :return: str :rtype: str """ if cls.alias is None: cls.alias = cls.__name__ return cls.alias
python
def get_alias(cls): """Returns messenger alias. :return: str :rtype: str """ if cls.alias is None: cls.alias = cls.__name__ return cls.alias
[ "def", "get_alias", "(", "cls", ")", ":", "if", "cls", ".", "alias", "is", "None", ":", "cls", ".", "alias", "=", "cls", ".", "__name__", "return", "cls", ".", "alias" ]
Returns messenger alias. :return: str :rtype: str
[ "Returns", "messenger", "alias", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L28-L36
train
64,112
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase._structure_recipients_data
def _structure_recipients_data(cls, recipients): """Converts recipients data into a list of Recipient objects. :param list recipients: list of objects :return: list of Recipient :rtype: list """ try: # That's all due Django 1.7 apps loading. from django.cont...
python
def _structure_recipients_data(cls, recipients): """Converts recipients data into a list of Recipient objects. :param list recipients: list of objects :return: list of Recipient :rtype: list """ try: # That's all due Django 1.7 apps loading. from django.cont...
[ "def", "_structure_recipients_data", "(", "cls", ",", "recipients", ")", ":", "try", ":", "# That's all due Django 1.7 apps loading.", "from", "django", ".", "contrib", ".", "auth", "import", "get_user_model", "USER_MODEL", "=", "get_user_model", "(", ")", "except", ...
Converts recipients data into a list of Recipient objects. :param list recipients: list of objects :return: list of Recipient :rtype: list
[ "Converts", "recipients", "data", "into", "a", "list", "of", "Recipient", "objects", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L89-L115
train
64,113
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase.mark_error
def mark_error(self, dispatch, error_log, message_cls): """Marks a dispatch as having error or consequently as failed if send retry limit for that message type is exhausted. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: error message ...
python
def mark_error(self, dispatch, error_log, message_cls): """Marks a dispatch as having error or consequently as failed if send retry limit for that message type is exhausted. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: error message ...
[ "def", "mark_error", "(", "self", ",", "dispatch", ",", "error_log", ",", "message_cls", ")", ":", "if", "message_cls", ".", "send_retry_limit", "is", "not", "None", "and", "(", "dispatch", ".", "retry_count", "+", "1", ")", ">=", "message_cls", ".", "send...
Marks a dispatch as having error or consequently as failed if send retry limit for that message type is exhausted. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: error message :param MessageBase message_cls: MessageBase heir
[ "Marks", "a", "dispatch", "as", "having", "error", "or", "consequently", "as", "failed", "if", "send", "retry", "limit", "for", "that", "message", "type", "is", "exhausted", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L144-L158
train
64,114
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase.mark_failed
def mark_failed(self, dispatch, error_log): """Marks a dispatch as failed. Sitemessage won't try to deliver already failed messages. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: str - error message """ dispatch.error_...
python
def mark_failed(self, dispatch, error_log): """Marks a dispatch as failed. Sitemessage won't try to deliver already failed messages. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: str - error message """ dispatch.error_...
[ "def", "mark_failed", "(", "self", ",", "dispatch", ",", "error_log", ")", ":", "dispatch", ".", "error_log", "=", "error_log", "self", ".", "_st", "[", "'failed'", "]", ".", "append", "(", "dispatch", ")" ]
Marks a dispatch as failed. Sitemessage won't try to deliver already failed messages. Should be used within send(). :param Dispatch dispatch: a Dispatch :param str error_log: str - error message
[ "Marks", "a", "dispatch", "as", "failed", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L160-L171
train
64,115
idlesign/django-sitemessage
sitemessage/messengers/base.py
MessengerBase._process_messages
def _process_messages(self, messages, ignore_unknown_message_types=False): """Performs message processing. :param dict messages: indexed by message id dict with messages data :param bool ignore_unknown_message_types: whether to silence exceptions :raises UnknownMessageTypeError: ...
python
def _process_messages(self, messages, ignore_unknown_message_types=False): """Performs message processing. :param dict messages: indexed by message id dict with messages data :param bool ignore_unknown_message_types: whether to silence exceptions :raises UnknownMessageTypeError: ...
[ "def", "_process_messages", "(", "self", ",", "messages", ",", "ignore_unknown_message_types", "=", "False", ")", ":", "with", "self", ".", "before_after_send_handling", "(", ")", ":", "for", "message_id", ",", "message_data", "in", "messages", ".", "items", "("...
Performs message processing. :param dict messages: indexed by message id dict with messages data :param bool ignore_unknown_message_types: whether to silence exceptions :raises UnknownMessageTypeError:
[ "Performs", "message", "processing", "." ]
25b179b798370354c5988042ec209e255d23793f
https://github.com/idlesign/django-sitemessage/blob/25b179b798370354c5988042ec209e255d23793f/sitemessage/messengers/base.py#L185-L217
train
64,116
tg123/bottle-mysql
bottle_mysql.py
MySQLPlugin.setup
def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument. ''' for other in app.plugins: if not isinstance(other, MySQLPlugin): continue if other.keyword == self.keyword: raise PluginErr...
python
def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument. ''' for other in app.plugins: if not isinstance(other, MySQLPlugin): continue if other.keyword == self.keyword: raise PluginErr...
[ "def", "setup", "(", "self", ",", "app", ")", ":", "for", "other", "in", "app", ".", "plugins", ":", "if", "not", "isinstance", "(", "other", ",", "MySQLPlugin", ")", ":", "continue", "if", "other", ".", "keyword", "==", "self", ".", "keyword", ":", ...
Make sure that other installed plugins don't affect the same keyword argument.
[ "Make", "sure", "that", "other", "installed", "plugins", "don", "t", "affect", "the", "same", "keyword", "argument", "." ]
6e7a7ae034f7735334c664bb0af6e7c72e15cbd9
https://github.com/tg123/bottle-mysql/blob/6e7a7ae034f7735334c664bb0af6e7c72e15cbd9/bottle_mysql.py#L79-L89
train
64,117
troeger/opensubmit
web/opensubmit/views/demo.py
assign_role
def assign_role(backend, user, response, *args, **kwargs): ''' Part of the Python Social Auth Pipeline. Checks if the created demo user should be pushed into some group. ''' if backend.name is 'passthrough' and settings.DEMO is True and 'role' in kwargs['request'].session[passthrough.SESSION_VAR]: ...
python
def assign_role(backend, user, response, *args, **kwargs): ''' Part of the Python Social Auth Pipeline. Checks if the created demo user should be pushed into some group. ''' if backend.name is 'passthrough' and settings.DEMO is True and 'role' in kwargs['request'].session[passthrough.SESSION_VAR]: ...
[ "def", "assign_role", "(", "backend", ",", "user", ",", "response", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "backend", ".", "name", "is", "'passthrough'", "and", "settings", ".", "DEMO", "is", "True", "and", "'role'", "in", "kwargs",...
Part of the Python Social Auth Pipeline. Checks if the created demo user should be pushed into some group.
[ "Part", "of", "the", "Python", "Social", "Auth", "Pipeline", ".", "Checks", "if", "the", "created", "demo", "user", "should", "be", "pushed", "into", "some", "group", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/views/demo.py#L13-L25
train
64,118
troeger/opensubmit
executor/opensubmitexec/server.py
fetch
def fetch(url, fullpath): ''' Fetch data from an URL and save it under the given target name. ''' logger.debug("Fetching %s from %s" % (fullpath, url)) try: tmpfile, headers = urlretrieve(url) if os.path.exists(fullpath): os.remove(fullpath) shutil.move(tmpfile, ...
python
def fetch(url, fullpath): ''' Fetch data from an URL and save it under the given target name. ''' logger.debug("Fetching %s from %s" % (fullpath, url)) try: tmpfile, headers = urlretrieve(url) if os.path.exists(fullpath): os.remove(fullpath) shutil.move(tmpfile, ...
[ "def", "fetch", "(", "url", ",", "fullpath", ")", ":", "logger", ".", "debug", "(", "\"Fetching %s from %s\"", "%", "(", "fullpath", ",", "url", ")", ")", "try", ":", "tmpfile", ",", "headers", "=", "urlretrieve", "(", "url", ")", "if", "os", ".", "p...
Fetch data from an URL and save it under the given target name.
[ "Fetch", "data", "from", "an", "URL", "and", "save", "it", "under", "the", "given", "target", "name", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L24-L37
train
64,119
troeger/opensubmit
executor/opensubmitexec/server.py
send_post
def send_post(config, urlpath, post_data): ''' Send POST data to an OpenSubmit server url path, according to the configuration. ''' server = config.get("Server", "url") logger.debug("Sending executor payload to " + server) post_data = urlencode(post_data) post_data = post_data.encode("ut...
python
def send_post(config, urlpath, post_data): ''' Send POST data to an OpenSubmit server url path, according to the configuration. ''' server = config.get("Server", "url") logger.debug("Sending executor payload to " + server) post_data = urlencode(post_data) post_data = post_data.encode("ut...
[ "def", "send_post", "(", "config", ",", "urlpath", ",", "post_data", ")", ":", "server", "=", "config", ".", "get", "(", "\"Server\"", ",", "\"url\"", ")", "logger", ".", "debug", "(", "\"Sending executor payload to \"", "+", "server", ")", "post_data", "=",...
Send POST data to an OpenSubmit server url path, according to the configuration.
[ "Send", "POST", "data", "to", "an", "OpenSubmit", "server", "url", "path", "according", "to", "the", "configuration", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L39-L52
train
64,120
troeger/opensubmit
executor/opensubmitexec/server.py
send_hostinfo
def send_hostinfo(config): ''' Register this host on OpenSubmit test machine. ''' info = all_host_infos() logger.debug("Sending host information: " + str(info)) post_data = [("Config", json.dumps(info)), ("Action", "get_config"), ("UUID", config.get("Server", "u...
python
def send_hostinfo(config): ''' Register this host on OpenSubmit test machine. ''' info = all_host_infos() logger.debug("Sending host information: " + str(info)) post_data = [("Config", json.dumps(info)), ("Action", "get_config"), ("UUID", config.get("Server", "u...
[ "def", "send_hostinfo", "(", "config", ")", ":", "info", "=", "all_host_infos", "(", ")", "logger", ".", "debug", "(", "\"Sending host information: \"", "+", "str", "(", "info", ")", ")", "post_data", "=", "[", "(", "\"Config\"", ",", "json", ".", "dumps",...
Register this host on OpenSubmit test machine.
[ "Register", "this", "host", "on", "OpenSubmit", "test", "machine", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L55-L68
train
64,121
troeger/opensubmit
executor/opensubmitexec/server.py
compatible_api_version
def compatible_api_version(server_version): ''' Check if this server API version is compatible to us. ''' try: semver = server_version.split('.') if semver[0] != '1': logger.error( 'Server API version (%s) is too new for us. Please update the executor installa...
python
def compatible_api_version(server_version): ''' Check if this server API version is compatible to us. ''' try: semver = server_version.split('.') if semver[0] != '1': logger.error( 'Server API version (%s) is too new for us. Please update the executor installa...
[ "def", "compatible_api_version", "(", "server_version", ")", ":", "try", ":", "semver", "=", "server_version", ".", "split", "(", "'.'", ")", "if", "semver", "[", "0", "]", "!=", "'1'", ":", "logger", ".", "error", "(", "'Server API version (%s) is too new for...
Check if this server API version is compatible to us.
[ "Check", "if", "this", "server", "API", "version", "is", "compatible", "to", "us", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L71-L86
train
64,122
troeger/opensubmit
executor/opensubmitexec/server.py
fetch_job
def fetch_job(config): ''' Fetch any available work from the OpenSubmit server and return an according job object. Returns None if no work is available. Errors are reported by this function directly. ''' url = "%s/jobs/?Secret=%s&UUID=%s" % (config.get("Server", "url"), ...
python
def fetch_job(config): ''' Fetch any available work from the OpenSubmit server and return an according job object. Returns None if no work is available. Errors are reported by this function directly. ''' url = "%s/jobs/?Secret=%s&UUID=%s" % (config.get("Server", "url"), ...
[ "def", "fetch_job", "(", "config", ")", ":", "url", "=", "\"%s/jobs/?Secret=%s&UUID=%s\"", "%", "(", "config", ".", "get", "(", "\"Server\"", ",", "\"url\"", ")", ",", "config", ".", "get", "(", "\"Server\"", ",", "\"secret\"", ")", ",", "config", ".", "...
Fetch any available work from the OpenSubmit server and return an according job object. Returns None if no work is available. Errors are reported by this function directly.
[ "Fetch", "any", "available", "work", "from", "the", "OpenSubmit", "server", "and", "return", "an", "according", "job", "object", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L89-L168
train
64,123
troeger/opensubmit
executor/opensubmitexec/server.py
fake_fetch_job
def fake_fetch_job(config, src_dir): ''' Act like fetch_job, but take the validator file and the student submission files directly from a directory. Intended for testing purposes when developing test scripts. Check also cmdline.py. ''' logger.debug("Creating fake job from " + src_dir) ...
python
def fake_fetch_job(config, src_dir): ''' Act like fetch_job, but take the validator file and the student submission files directly from a directory. Intended for testing purposes when developing test scripts. Check also cmdline.py. ''' logger.debug("Creating fake job from " + src_dir) ...
[ "def", "fake_fetch_job", "(", "config", ",", "src_dir", ")", ":", "logger", ".", "debug", "(", "\"Creating fake job from \"", "+", "src_dir", ")", "from", ".", "job", "import", "Job", "job", "=", "Job", "(", "config", ",", "online", "=", "False", ")", "j...
Act like fetch_job, but take the validator file and the student submission files directly from a directory. Intended for testing purposes when developing test scripts. Check also cmdline.py.
[ "Act", "like", "fetch_job", "but", "take", "the", "validator", "file", "and", "the", "student", "submission", "files", "directly", "from", "a", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/server.py#L171-L205
train
64,124
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_configure
def run_configure(self, mandatory=True): """Runs the 'configure' program in the working directory. Args: mandatory (bool): Throw exception if 'configure' fails or a 'configure' file is missing. """ if not has_file(self.working_dir, 'configure')...
python
def run_configure(self, mandatory=True): """Runs the 'configure' program in the working directory. Args: mandatory (bool): Throw exception if 'configure' fails or a 'configure' file is missing. """ if not has_file(self.working_dir, 'configure')...
[ "def", "run_configure", "(", "self", ",", "mandatory", "=", "True", ")", ":", "if", "not", "has_file", "(", "self", ".", "working_dir", ",", "'configure'", ")", ":", "if", "mandatory", ":", "raise", "FileNotFoundError", "(", "\"Could not find a configure script ...
Runs the 'configure' program in the working directory. Args: mandatory (bool): Throw exception if 'configure' fails or a 'configure' file is missing.
[ "Runs", "the", "configure", "program", "in", "the", "working", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L81-L100
train
64,125
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_compiler
def run_compiler(self, compiler=GCC, inputs=None, output=None): """Runs a compiler in the working directory. Args: compiler (tuple): The compiler program and its command-line arguments, including placeholders for output and input files. inputs (tupl...
python
def run_compiler(self, compiler=GCC, inputs=None, output=None): """Runs a compiler in the working directory. Args: compiler (tuple): The compiler program and its command-line arguments, including placeholders for output and input files. inputs (tupl...
[ "def", "run_compiler", "(", "self", ",", "compiler", "=", "GCC", ",", "inputs", "=", "None", ",", "output", "=", "None", ")", ":", "# Let exceptions travel through", "prog", "=", "RunningProgram", "(", "self", ",", "*", "compiler_cmdline", "(", "compiler", "...
Runs a compiler in the working directory. Args: compiler (tuple): The compiler program and its command-line arguments, including placeholders for output and input files. inputs (tuple): The list of input files for the compiler. output (str): ...
[ "Runs", "a", "compiler", "in", "the", "working", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L122-L136
train
64,126
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_build
def run_build(self, compiler=GCC, inputs=None, output=None): """Combined call of 'configure', 'make' and the compiler. The success of 'configure' and 'make' is optional. The arguments are the same as for run_compiler. """ logger.info("Running build steps ...") self.run_...
python
def run_build(self, compiler=GCC, inputs=None, output=None): """Combined call of 'configure', 'make' and the compiler. The success of 'configure' and 'make' is optional. The arguments are the same as for run_compiler. """ logger.info("Running build steps ...") self.run_...
[ "def", "run_build", "(", "self", ",", "compiler", "=", "GCC", ",", "inputs", "=", "None", ",", "output", "=", "None", ")", ":", "logger", ".", "info", "(", "\"Running build steps ...\"", ")", "self", ".", "run_configure", "(", "mandatory", "=", "False", ...
Combined call of 'configure', 'make' and the compiler. The success of 'configure' and 'make' is optional. The arguments are the same as for run_compiler.
[ "Combined", "call", "of", "configure", "make", "and", "the", "compiler", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L138-L150
train
64,127
troeger/opensubmit
executor/opensubmitexec/job.py
Job.spawn_program
def spawn_program(self, name, arguments=[], timeout=30, exclusive=False): """Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program...
python
def spawn_program(self, name, arguments=[], timeout=30, exclusive=False): """Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program...
[ "def", "spawn_program", "(", "self", ",", "name", ",", "arguments", "=", "[", "]", ",", "timeout", "=", "30", ",", "exclusive", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Spawning program for interaction ...\"", ")", "if", "exclusive", ":", "k...
Spawns a program in the working directory. This method allows the interaction with the running program, based on the returned RunningProgram object. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the progra...
[ "Spawns", "a", "program", "in", "the", "working", "directory", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L152-L174
train
64,128
troeger/opensubmit
executor/opensubmitexec/job.py
Job.run_program
def run_program(self, name, arguments=[], timeout=30, exclusive=False): """Runs a program in the working directory to completion. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the program. timeout (int)...
python
def run_program(self, name, arguments=[], timeout=30, exclusive=False): """Runs a program in the working directory to completion. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the program. timeout (int)...
[ "def", "run_program", "(", "self", ",", "name", ",", "arguments", "=", "[", "]", ",", "timeout", "=", "30", ",", "exclusive", "=", "False", ")", ":", "logger", ".", "debug", "(", "\"Running program ...\"", ")", "if", "exclusive", ":", "kill_longrunning", ...
Runs a program in the working directory to completion. Args: name (str): The name of the program to be executed. arguments (tuple): Command-line arguments for the program. timeout (int): The timeout for execution. exclusive (bool): Prevent parallel va...
[ "Runs", "a", "program", "in", "the", "working", "directory", "to", "completion", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L176-L196
train
64,129
troeger/opensubmit
executor/opensubmitexec/job.py
Job.grep
def grep(self, regex): """Scans the student files for text patterns. Args: regex (str): Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory. """ matches = [] logger...
python
def grep(self, regex): """Scans the student files for text patterns. Args: regex (str): Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory. """ matches = [] logger...
[ "def", "grep", "(", "self", ",", "regex", ")", ":", "matches", "=", "[", "]", "logger", ".", "debug", "(", "\"Searching student files for '{0}'\"", ".", "format", "(", "regex", ")", ")", "for", "fname", "in", "self", ".", "student_files", ":", "if", "os"...
Scans the student files for text patterns. Args: regex (str): Regular expression used for scanning inside the files. Returns: tuple: Names of the matching files in the working directory.
[ "Scans", "the", "student", "files", "for", "text", "patterns", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L198-L215
train
64,130
troeger/opensubmit
executor/opensubmitexec/job.py
Job.ensure_files
def ensure_files(self, filenames): """Checks the student submission for specific files. Args: filenames (tuple): The list of file names to be cjecked for. Returns: bool: Indicator if all files are found in the student archive. """ logger.debug("Testing {...
python
def ensure_files(self, filenames): """Checks the student submission for specific files. Args: filenames (tuple): The list of file names to be cjecked for. Returns: bool: Indicator if all files are found in the student archive. """ logger.debug("Testing {...
[ "def", "ensure_files", "(", "self", ",", "filenames", ")", ":", "logger", ".", "debug", "(", "\"Testing {0} for the following files: {1}\"", ".", "format", "(", "self", ".", "working_dir", ",", "filenames", ")", ")", "dircontent", "=", "os", ".", "listdir", "(...
Checks the student submission for specific files. Args: filenames (tuple): The list of file names to be cjecked for. Returns: bool: Indicator if all files are found in the student archive.
[ "Checks", "the", "student", "submission", "for", "specific", "files", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L217-L232
train
64,131
praekelt/django-livechat
livechat/templatetags/livechat_tags.py
live_chat_banner
def live_chat_banner(context): """ Display any available live chats as advertisements. """ context = copy(context) # Find any upcoming or current live chat. The Chat date must be less than 5 # days away, or currently in progress. oldchat = LiveChat.chat_finder.get_last_live_chat() if oldc...
python
def live_chat_banner(context): """ Display any available live chats as advertisements. """ context = copy(context) # Find any upcoming or current live chat. The Chat date must be less than 5 # days away, or currently in progress. oldchat = LiveChat.chat_finder.get_last_live_chat() if oldc...
[ "def", "live_chat_banner", "(", "context", ")", ":", "context", "=", "copy", "(", "context", ")", "# Find any upcoming or current live chat. The Chat date must be less than 5", "# days away, or currently in progress.", "oldchat", "=", "LiveChat", ".", "chat_finder", ".", "get...
Display any available live chats as advertisements.
[ "Display", "any", "available", "live", "chats", "as", "advertisements", "." ]
22d86fb4219e5af6c83e0542aa30e5ea54e71d26
https://github.com/praekelt/django-livechat/blob/22d86fb4219e5af6c83e0542aa30e5ea54e71d26/livechat/templatetags/livechat_tags.py#L18-L58
train
64,132
troeger/opensubmit
executor/opensubmitexec/running.py
kill_longrunning
def kill_longrunning(config): ''' Terminate everything under the current user account that has run too long. This is a final safeguard if the subprocess timeout stuff is not working. You better have no production servers running also under the current user account ... '''...
python
def kill_longrunning(config): ''' Terminate everything under the current user account that has run too long. This is a final safeguard if the subprocess timeout stuff is not working. You better have no production servers running also under the current user account ... '''...
[ "def", "kill_longrunning", "(", "config", ")", ":", "import", "psutil", "ourpid", "=", "os", ".", "getpid", "(", ")", "username", "=", "psutil", ".", "Process", "(", "ourpid", ")", ".", "username", "# Check for other processes running under this account", "# Take ...
Terminate everything under the current user account that has run too long. This is a final safeguard if the subprocess timeout stuff is not working. You better have no production servers running also under the current user account ...
[ "Terminate", "everything", "under", "the", "current", "user", "account", "that", "has", "run", "too", "long", ".", "This", "is", "a", "final", "safeguard", "if", "the", "subprocess", "timeout", "stuff", "is", "not", "working", ".", "You", "better", "have", ...
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L12-L36
train
64,133
troeger/opensubmit
executor/opensubmitexec/running.py
RunningProgram.get_exitstatus
def get_exitstatus(self): """Get the exit status of the program execution. Returns: int: Exit status as reported by the operating system, or None if it is not available. """ logger.debug("Exit status is {0}".format(self._spawn.exitstatus)) return sel...
python
def get_exitstatus(self): """Get the exit status of the program execution. Returns: int: Exit status as reported by the operating system, or None if it is not available. """ logger.debug("Exit status is {0}".format(self._spawn.exitstatus)) return sel...
[ "def", "get_exitstatus", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Exit status is {0}\"", ".", "format", "(", "self", ".", "_spawn", ".", "exitstatus", ")", ")", "return", "self", ".", "_spawn", ".", "exitstatus" ]
Get the exit status of the program execution. Returns: int: Exit status as reported by the operating system, or None if it is not available.
[ "Get", "the", "exit", "status", "of", "the", "program", "execution", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L67-L75
train
64,134
troeger/opensubmit
executor/opensubmitexec/running.py
RunningProgram.expect_output
def expect_output(self, pattern, timeout=-1): """Wait until the running program performs some given output, or terminates. Args: pattern: The pattern the output should be checked for. timeout (int): How many seconds should be waited for the output. The pattern argumen...
python
def expect_output(self, pattern, timeout=-1): """Wait until the running program performs some given output, or terminates. Args: pattern: The pattern the output should be checked for. timeout (int): How many seconds should be waited for the output. The pattern argumen...
[ "def", "expect_output", "(", "self", ",", "pattern", ",", "timeout", "=", "-", "1", ")", ":", "logger", ".", "debug", "(", "\"Expecting output '{0}' from '{1}'\"", ".", "format", "(", "pattern", ",", "self", ".", "name", ")", ")", "try", ":", "return", "...
Wait until the running program performs some given output, or terminates. Args: pattern: The pattern the output should be checked for. timeout (int): How many seconds should be waited for the output. The pattern argument may be a string, a compiled regular expression, ...
[ "Wait", "until", "the", "running", "program", "performs", "some", "given", "output", "or", "terminates", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L105-L134
train
64,135
troeger/opensubmit
executor/opensubmitexec/running.py
RunningProgram.sendline
def sendline(self, text): """Sends an input line to the running program, including os.linesep. Args: text (str): The input text to be send. Raises: TerminationException: The program terminated before / while / after sending the input. NestedException: An in...
python
def sendline(self, text): """Sends an input line to the running program, including os.linesep. Args: text (str): The input text to be send. Raises: TerminationException: The program terminated before / while / after sending the input. NestedException: An in...
[ "def", "sendline", "(", "self", ",", "text", ")", ":", "logger", ".", "debug", "(", "\"Sending input '{0}' to '{1}'\"", ".", "format", "(", "text", ",", "self", ".", "name", ")", ")", "try", ":", "return", "self", ".", "_spawn", ".", "sendline", "(", "...
Sends an input line to the running program, including os.linesep. Args: text (str): The input text to be send. Raises: TerminationException: The program terminated before / while / after sending the input. NestedException: An internal problem occured while waiting ...
[ "Sends", "an", "input", "line", "to", "the", "running", "program", "including", "os", ".", "linesep", "." ]
384a95b7c6fa41e3f949a129d25dafd9a1c54859
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/running.py#L136-L157
train
64,136
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
train
64,137
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
train
64,138
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
train
64,139
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
train
64,140
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
train
64,141
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
train
64,142
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
train
64,143
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
train
64,144
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
train
64,145
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
train
64,146
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
train
64,147
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
train
64,148
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
train
64,149
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
train
64,150
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
train
64,151
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
train
64,152
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
train
64,153
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
train
64,154
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
train
64,155
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
train
64,156
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
train
64,157
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
train
64,158
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
train
64,159
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
train
64,160
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
train
64,161
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
train
64,162
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
train
64,163
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
train
64,164
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
train
64,165
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
train
64,166
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
train
64,167
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
train
64,168
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
train
64,169
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
train
64,170
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
train
64,171
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
train
64,172
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
train
64,173
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
train
64,174
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
train
64,175
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
train
64,176
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
train
64,177
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
train
64,178
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
train
64,179
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
train
64,180
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
train
64,181
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
train
64,182
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
train
64,183
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
train
64,184
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
train
64,185
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
train
64,186
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
train
64,187
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
train
64,188
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
train
64,189
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
train
64,190
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
train
64,191
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
train
64,192
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
train
64,193
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
train
64,194
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
train
64,195
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
train
64,196
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
train
64,197
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
train
64,198
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
train
64,199