repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
publish_page
def publish_page(page, languages): """ Publish a CMS page in all given languages. """ for language_code, lang_name in iter_languages(languages): url = page.get_absolute_url() if page.publisher_is_draft: page.publish(language_code) log.info('page "%s" published in...
python
def publish_page(page, languages): """ Publish a CMS page in all given languages. """ for language_code, lang_name in iter_languages(languages): url = page.get_absolute_url() if page.publisher_is_draft: page.publish(language_code) log.info('page "%s" published in...
[ "def", "publish_page", "(", "page", ",", "languages", ")", ":", "for", "language_code", ",", "lang_name", "in", "iter_languages", "(", "languages", ")", ":", "url", "=", "page", ".", "get_absolute_url", "(", ")", "if", "page", ".", "publisher_is_draft", ":",...
Publish a CMS page in all given languages.
[ "Publish", "a", "CMS", "page", "in", "all", "given", "languages", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L47-L60
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
create_cms_index_pages
def create_cms_index_pages(placeholder_slot="content"): """ create cms home page and fill >content< placeholder with TextPlugin """ try: index_page = Page.objects.get(is_home=True, publisher_is_draft=False) except Page.DoesNotExist: log.debug('Create index page in "en" and...') ...
python
def create_cms_index_pages(placeholder_slot="content"): """ create cms home page and fill >content< placeholder with TextPlugin """ try: index_page = Page.objects.get(is_home=True, publisher_is_draft=False) except Page.DoesNotExist: log.debug('Create index page in "en" and...') ...
[ "def", "create_cms_index_pages", "(", "placeholder_slot", "=", "\"content\"", ")", ":", "try", ":", "index_page", "=", "Page", ".", "objects", ".", "get", "(", "is_home", "=", "True", ",", "publisher_is_draft", "=", "False", ")", "except", "Page", ".", "Does...
create cms home page and fill >content< placeholder with TextPlugin
[ "create", "cms", "home", "page", "and", "fill", ">", "content<", "placeholder", "with", "TextPlugin" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L372-L406
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
create_cms_plugin_page
def create_cms_plugin_page(apphook, apphook_namespace, placeholder_slot=None): """ Create cms plugin page in all existing languages. Add a link to the index page. :param apphook: e.g...........: 'FooBarApp' :param apphook_namespace: e.g.: 'foobar' :return: """ creator = CmsPluginPageCre...
python
def create_cms_plugin_page(apphook, apphook_namespace, placeholder_slot=None): """ Create cms plugin page in all existing languages. Add a link to the index page. :param apphook: e.g...........: 'FooBarApp' :param apphook_namespace: e.g.: 'foobar' :return: """ creator = CmsPluginPageCre...
[ "def", "create_cms_plugin_page", "(", "apphook", ",", "apphook_namespace", ",", "placeholder_slot", "=", "None", ")", ":", "creator", "=", "CmsPluginPageCreator", "(", "apphook", "=", "apphook", ",", "apphook_namespace", "=", "apphook_namespace", ",", ")", "creator"...
Create cms plugin page in all existing languages. Add a link to the index page. :param apphook: e.g...........: 'FooBarApp' :param apphook_namespace: e.g.: 'foobar' :return:
[ "Create", "cms", "plugin", "page", "in", "all", "existing", "languages", ".", "Add", "a", "link", "to", "the", "index", "page", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L458-L473
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.get_slug
def get_slug(self, language_code, lang_name): """ Notes: - slug must be unique! - slug is used to check if page already exists! :return: 'slug' string for cms.api.create_page() """ title = self.get_title(language_code, lang_name) assert title != ""...
python
def get_slug(self, language_code, lang_name): """ Notes: - slug must be unique! - slug is used to check if page already exists! :return: 'slug' string for cms.api.create_page() """ title = self.get_title(language_code, lang_name) assert title != ""...
[ "def", "get_slug", "(", "self", ",", "language_code", ",", "lang_name", ")", ":", "title", "=", "self", ".", "get_title", "(", "language_code", ",", "lang_name", ")", "assert", "title", "!=", "\"\"", "title", "=", "str", "(", "title", ")", "# e.g.: evaluat...
Notes: - slug must be unique! - slug is used to check if page already exists! :return: 'slug' string for cms.api.create_page()
[ "Notes", ":", "-", "slug", "must", "be", "unique!", "-", "slug", "is", "used", "to", "check", "if", "page", "already", "exists!", ":", "return", ":", "slug", "string", "for", "cms", ".", "api", ".", "create_page", "()" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L107-L121
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.get_home_page
def get_home_page(self): """ Return the published home page. Used for 'parent' in cms.api.create_page() """ try: home_page_draft = Page.objects.get( is_home=True, publisher_is_draft=True) except Page.DoesNotExist: log.error('ERROR: ...
python
def get_home_page(self): """ Return the published home page. Used for 'parent' in cms.api.create_page() """ try: home_page_draft = Page.objects.get( is_home=True, publisher_is_draft=True) except Page.DoesNotExist: log.error('ERROR: ...
[ "def", "get_home_page", "(", "self", ")", ":", "try", ":", "home_page_draft", "=", "Page", ".", "objects", ".", "get", "(", "is_home", "=", "True", ",", "publisher_is_draft", "=", "True", ")", "except", "Page", ".", "DoesNotExist", ":", "log", ".", "erro...
Return the published home page. Used for 'parent' in cms.api.create_page()
[ "Return", "the", "published", "home", "page", ".", "Used", "for", "parent", "in", "cms", ".", "api", ".", "create_page", "()" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L129-L140
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.publish
def publish(self, page): """ Publish the page in all languages. """ assert page.publisher_is_draft == True, "Page '%s' must be a draft!" % page publish_page(page, languages=self.languages)
python
def publish(self, page): """ Publish the page in all languages. """ assert page.publisher_is_draft == True, "Page '%s' must be a draft!" % page publish_page(page, languages=self.languages)
[ "def", "publish", "(", "self", ",", "page", ")", ":", "assert", "page", ".", "publisher_is_draft", "==", "True", ",", "\"Page '%s' must be a draft!\"", "%", "page", "publish_page", "(", "page", ",", "languages", "=", "self", ".", "languages", ")" ]
Publish the page in all languages.
[ "Publish", "the", "page", "in", "all", "languages", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L148-L153
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.create_page
def create_page(self, **extra_kwargs): """ Create page (and page title) in default language extra_kwargs will be pass to cms.api.create_page() e.g.: extra_kwargs={ "soft_root": True, "reverse_id": my_reverse_id, } """ ...
python
def create_page(self, **extra_kwargs): """ Create page (and page title) in default language extra_kwargs will be pass to cms.api.create_page() e.g.: extra_kwargs={ "soft_root": True, "reverse_id": my_reverse_id, } """ ...
[ "def", "create_page", "(", "self", ",", "*", "*", "extra_kwargs", ")", ":", "with", "translation", ".", "override", "(", "self", ".", "default_language_code", ")", ":", "# for evaluate the language name lazy translation", "# e.g.: settings.LANGUAGE_CODE is not \"en\"", "s...
Create page (and page title) in default language extra_kwargs will be pass to cms.api.create_page() e.g.: extra_kwargs={ "soft_root": True, "reverse_id": my_reverse_id, }
[ "Create", "page", "(", "and", "page", "title", ")", "in", "default", "language" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L155-L250
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.create_title
def create_title(self, page): """ Create page title in all other languages with cms.api.create_title() """ for language_code, lang_name in iter_languages(self.languages): try: title = Title.objects.get(page=page, language=language_code) except Titl...
python
def create_title(self, page): """ Create page title in all other languages with cms.api.create_title() """ for language_code, lang_name in iter_languages(self.languages): try: title = Title.objects.get(page=page, language=language_code) except Titl...
[ "def", "create_title", "(", "self", ",", "page", ")", ":", "for", "language_code", ",", "lang_name", "in", "iter_languages", "(", "self", ".", "languages", ")", ":", "try", ":", "title", "=", "Title", ".", "objects", ".", "get", "(", "page", "=", "page...
Create page title in all other languages with cms.api.create_title()
[ "Create", "page", "title", "in", "all", "other", "languages", "with", "cms", ".", "api", ".", "create_title", "()" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L252-L270
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.get_add_plugin_kwargs
def get_add_plugin_kwargs(self, page, no, placeholder, language_code, lang_name): """ Return "content" for create the plugin. Called from self.add_plugins() """ return { "plugin_type": 'TextPlugin', # djangocms_text_ckeditor ...
python
def get_add_plugin_kwargs(self, page, no, placeholder, language_code, lang_name): """ Return "content" for create the plugin. Called from self.add_plugins() """ return { "plugin_type": 'TextPlugin', # djangocms_text_ckeditor ...
[ "def", "get_add_plugin_kwargs", "(", "self", ",", "page", ",", "no", ",", "placeholder", ",", "language_code", ",", "lang_name", ")", ":", "return", "{", "\"plugin_type\"", ":", "'TextPlugin'", ",", "# djangocms_text_ckeditor", "\"body\"", ":", "self", ".", "get...
Return "content" for create the plugin. Called from self.add_plugins()
[ "Return", "content", "for", "create", "the", "plugin", ".", "Called", "from", "self", ".", "add_plugins", "()" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L289-L301
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.add_plugins
def add_plugins(self, page, placeholder): """ Add a "TextPlugin" in all languages. """ for language_code, lang_name in iter_languages(self.languages): for no in range(1, self.dummy_text_count + 1): add_plugin_kwargs = self.get_add_plugin_kwargs( ...
python
def add_plugins(self, page, placeholder): """ Add a "TextPlugin" in all languages. """ for language_code, lang_name in iter_languages(self.languages): for no in range(1, self.dummy_text_count + 1): add_plugin_kwargs = self.get_add_plugin_kwargs( ...
[ "def", "add_plugins", "(", "self", ",", "page", ",", "placeholder", ")", ":", "for", "language_code", ",", "lang_name", "in", "iter_languages", "(", "self", ".", "languages", ")", ":", "for", "no", "in", "range", "(", "1", ",", "self", ".", "dummy_text_c...
Add a "TextPlugin" in all languages.
[ "Add", "a", "TextPlugin", "in", "all", "languages", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L303-L320
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.get_or_create_placeholder
def get_or_create_placeholder(self, page, placeholder_slot): """ Add a placeholder if not exists. """ placeholder, created = get_or_create_placeholder( page, placeholder_slot, delete_existing=self.delete_first) return placeholder, created
python
def get_or_create_placeholder(self, page, placeholder_slot): """ Add a placeholder if not exists. """ placeholder, created = get_or_create_placeholder( page, placeholder_slot, delete_existing=self.delete_first) return placeholder, created
[ "def", "get_or_create_placeholder", "(", "self", ",", "page", ",", "placeholder_slot", ")", ":", "placeholder", ",", "created", "=", "get_or_create_placeholder", "(", "page", ",", "placeholder_slot", ",", "delete_existing", "=", "self", ".", "delete_first", ")", "...
Add a placeholder if not exists.
[ "Add", "a", "placeholder", "if", "not", "exists", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L322-L328
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPageCreator.fill_content
def fill_content(self, page, placeholder_slot): """ Add a placeholder to the page. Here we add a "TextPlugin" in all languages. """ if len(placeholder_slot) == 1: raise RuntimeError(placeholder_slot) placeholder, created = self.get_or_create_placeholder( ...
python
def fill_content(self, page, placeholder_slot): """ Add a placeholder to the page. Here we add a "TextPlugin" in all languages. """ if len(placeholder_slot) == 1: raise RuntimeError(placeholder_slot) placeholder, created = self.get_or_create_placeholder( ...
[ "def", "fill_content", "(", "self", ",", "page", ",", "placeholder_slot", ")", ":", "if", "len", "(", "placeholder_slot", ")", "==", "1", ":", "raise", "RuntimeError", "(", "placeholder_slot", ")", "placeholder", ",", "created", "=", "self", ".", "get_or_cre...
Add a placeholder to the page. Here we add a "TextPlugin" in all languages.
[ "Add", "a", "placeholder", "to", "the", "page", ".", "Here", "we", "add", "a", "TextPlugin", "in", "all", "languages", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L330-L339
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
CmsPluginPageCreator.create
def create(self): """ Create the plugin page in all languages and fill dummy content. """ plugin = CMSPlugin.objects.filter(plugin_type=self.apphook) if plugin.exists(): log.debug('Plugin page for "%s" plugin already exist, ok.', self.apphook) ...
python
def create(self): """ Create the plugin page in all languages and fill dummy content. """ plugin = CMSPlugin.objects.filter(plugin_type=self.apphook) if plugin.exists(): log.debug('Plugin page for "%s" plugin already exist, ok.', self.apphook) ...
[ "def", "create", "(", "self", ")", ":", "plugin", "=", "CMSPlugin", ".", "objects", ".", "filter", "(", "plugin_type", "=", "self", ".", "apphook", ")", "if", "plugin", ".", "exists", "(", ")", ":", "log", ".", "debug", "(", "'Plugin page for \"%s\" plug...
Create the plugin page in all languages and fill dummy content.
[ "Create", "the", "plugin", "page", "in", "all", "languages", "and", "fill", "dummy", "content", "." ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L437-L455
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
DummyPageGenerator.get_title
def get_title(self, language_code, lang_name): """ :return: 'title' string for cms.api.create_page() """ title = "%s %i-%i in %s" % (self.title_prefix, self.current_count, self.current_level, language_code) log.info(title) return title
python
def get_title(self, language_code, lang_name): """ :return: 'title' string for cms.api.create_page() """ title = "%s %i-%i in %s" % (self.title_prefix, self.current_count, self.current_level, language_code) log.info(title) return title
[ "def", "get_title", "(", "self", ",", "language_code", ",", "lang_name", ")", ":", "title", "=", "\"%s %i-%i in %s\"", "%", "(", "self", ".", "title_prefix", ",", "self", ".", "current_count", ",", "self", ".", "current_level", ",", "language_code", ")", "lo...
:return: 'title' string for cms.api.create_page()
[ ":", "return", ":", "title", "string", "for", "cms", ".", "api", ".", "create_page", "()" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L494-L501
jedie/django-cms-tools
django_cms_tools/fixture_helper/pages.py
DummyPageGenerator.get_parent_page
def get_parent_page(self): """ For 'parent' in cms.api.create_page() """ if self.current_level == 1: # 'root' page return None else: return self.page_data[(self.current_level - 1, self.current_count)]
python
def get_parent_page(self): """ For 'parent' in cms.api.create_page() """ if self.current_level == 1: # 'root' page return None else: return self.page_data[(self.current_level - 1, self.current_count)]
[ "def", "get_parent_page", "(", "self", ")", ":", "if", "self", ".", "current_level", "==", "1", ":", "# 'root' page", "return", "None", "else", ":", "return", "self", ".", "page_data", "[", "(", "self", ".", "current_level", "-", "1", ",", "self", ".", ...
For 'parent' in cms.api.create_page()
[ "For", "parent", "in", "cms", ".", "api", ".", "create_page", "()" ]
train
https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/pages.py#L503-L511
SmartTeleMax/iktomi
iktomi/web/filters.py
static_files.translate_path
def translate_path(self, pth): """Translate a /-separated PATH to the local filename syntax.""" # initially copied from SimpleHTTPServer words = pth.split('/') words = filter(None, words) pth = self.location for word in words: # Do not allow path separators ot...
python
def translate_path(self, pth): """Translate a /-separated PATH to the local filename syntax.""" # initially copied from SimpleHTTPServer words = pth.split('/') words = filter(None, words) pth = self.location for word in words: # Do not allow path separators ot...
[ "def", "translate_path", "(", "self", ",", "pth", ")", ":", "# initially copied from SimpleHTTPServer", "words", "=", "pth", ".", "split", "(", "'/'", ")", "words", "=", "filter", "(", "None", ",", "words", ")", "pth", "=", "self", ".", "location", "for", ...
Translate a /-separated PATH to the local filename syntax.
[ "Translate", "a", "/", "-", "separated", "PATH", "to", "the", "local", "filename", "syntax", "." ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/web/filters.py#L330-L347
CivicSpleen/ambry
ambry/orm/source_table.py
SourceColumn.dict
def dict(self): """A dict that holds key/values for all of the properties in the object. :return: """ from collections import OrderedDict SKIP_KEYS = () return OrderedDict( (p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ...
python
def dict(self): """A dict that holds key/values for all of the properties in the object. :return: """ from collections import OrderedDict SKIP_KEYS = () return OrderedDict( (p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ...
[ "def", "dict", "(", "self", ")", ":", "from", "collections", "import", "OrderedDict", "SKIP_KEYS", "=", "(", ")", "return", "OrderedDict", "(", "(", "p", ".", "key", ",", "getattr", "(", "self", ",", "p", ".", "key", ")", ")", "for", "p", "in", "se...
A dict that holds key/values for all of the properties in the object. :return:
[ "A", "dict", "that", "holds", "key", "/", "values", "for", "all", "of", "the", "properties", "in", "the", "object", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/source_table.py#L143-L153
CivicSpleen/ambry
ambry/orm/source_table.py
SourceTable.column
def column(self, source_header_or_pos): """ Return a column by name or position :param source_header_or_pos: If a string, a source header name. If an integer, column position :return: """ for c in self.columns: if c.source_header == source_header_or_pos: ...
python
def column(self, source_header_or_pos): """ Return a column by name or position :param source_header_or_pos: If a string, a source header name. If an integer, column position :return: """ for c in self.columns: if c.source_header == source_header_or_pos: ...
[ "def", "column", "(", "self", ",", "source_header_or_pos", ")", ":", "for", "c", "in", "self", ".", "columns", ":", "if", "c", ".", "source_header", "==", "source_header_or_pos", ":", "assert", "c", ".", "st_vid", "==", "self", ".", "vid", "return", "c",...
Return a column by name or position :param source_header_or_pos: If a string, a source header name. If an integer, column position :return:
[ "Return", "a", "column", "by", "name", "or", "position" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/source_table.py#L186-L202
CivicSpleen/ambry
ambry/orm/source_table.py
SourceTable.add_column
def add_column(self, position, source_header, datatype, **kwargs): """ Add a column to the source table. :param position: Integer position of the column started from 1. :param source_header: Name of the column, as it exists in the source file :param datatype: Python datatype ( st...
python
def add_column(self, position, source_header, datatype, **kwargs): """ Add a column to the source table. :param position: Integer position of the column started from 1. :param source_header: Name of the column, as it exists in the source file :param datatype: Python datatype ( st...
[ "def", "add_column", "(", "self", ",", "position", ",", "source_header", ",", "datatype", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "identity", "import", "GeneralNumber2", "c", "=", "self", ".", "column", "(", "source_header", ")", "c_by_pos", ...
Add a column to the source table. :param position: Integer position of the column started from 1. :param source_header: Name of the column, as it exists in the source file :param datatype: Python datatype ( str, int, float, None ) for the column :param kwargs: Other source record args. ...
[ "Add", "a", "column", "to", "the", "source", "table", ".", ":", "param", "position", ":", "Integer", "position", "of", "the", "column", "started", "from", "1", ".", ":", "param", "source_header", ":", "Name", "of", "the", "column", "as", "it", "exists", ...
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/source_table.py#L204-L266
CivicSpleen/ambry
ambry/orm/source_table.py
SourceTable.update_id
def update_id(self, sequence_id=None): """Alter the sequence id, and all of the names and ids derived from it. This often needs to be don after an IntegrityError in a multiprocessing run""" from ..identity import GeneralNumber1 if sequence_id: self.sequence_id = sequence_id ...
python
def update_id(self, sequence_id=None): """Alter the sequence id, and all of the names and ids derived from it. This often needs to be don after an IntegrityError in a multiprocessing run""" from ..identity import GeneralNumber1 if sequence_id: self.sequence_id = sequence_id ...
[ "def", "update_id", "(", "self", ",", "sequence_id", "=", "None", ")", ":", "from", ".", ".", "identity", "import", "GeneralNumber1", "if", "sequence_id", ":", "self", ".", "sequence_id", "=", "sequence_id", "self", ".", "vid", "=", "str", "(", "GeneralNum...
Alter the sequence id, and all of the names and ids derived from it. This often needs to be don after an IntegrityError in a multiprocessing run
[ "Alter", "the", "sequence", "id", "and", "all", "of", "the", "names", "and", "ids", "derived", "from", "it", ".", "This", "often", "needs", "to", "be", "don", "after", "an", "IntegrityError", "in", "a", "multiprocessing", "run" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/source_table.py#L292-L300
CivicSpleen/ambry
ambry/orm/__init__.py
table_convert_geometry
def table_convert_geometry(metadata, table_name): """Get table metadata from the database.""" from sqlalchemy import Table from ..orm import Geometry table = Table(table_name, metadata, autoload=True) for c in table.columns: # HACK! Sqlalchemy sees spatialte GEOMETRY types # as NU...
python
def table_convert_geometry(metadata, table_name): """Get table metadata from the database.""" from sqlalchemy import Table from ..orm import Geometry table = Table(table_name, metadata, autoload=True) for c in table.columns: # HACK! Sqlalchemy sees spatialte GEOMETRY types # as NU...
[ "def", "table_convert_geometry", "(", "metadata", ",", "table_name", ")", ":", "from", "sqlalchemy", "import", "Table", "from", ".", ".", "orm", "import", "Geometry", "table", "=", "Table", "(", "table_name", ",", "metadata", ",", "autoload", "=", "True", ")...
Get table metadata from the database.
[ "Get", "table", "metadata", "from", "the", "database", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L74-L89
CivicSpleen/ambry
ambry/orm/__init__.py
next_sequence_id
def next_sequence_id(session, sequence_ids, parent_vid, table_class, force_query = False): """ Return the next sequence id for a object, identified by the vid of the parent object, and the database prefix for the child object. On the first call, will load the max sequence number from the database, but s...
python
def next_sequence_id(session, sequence_ids, parent_vid, table_class, force_query = False): """ Return the next sequence id for a object, identified by the vid of the parent object, and the database prefix for the child object. On the first call, will load the max sequence number from the database, but s...
[ "def", "next_sequence_id", "(", "session", ",", "sequence_ids", ",", "parent_vid", ",", "table_class", ",", "force_query", "=", "False", ")", ":", "from", "sqlalchemy", "import", "text", "seq_col", "=", "table_class", ".", "sequence_id", ".", "property", ".", ...
Return the next sequence id for a object, identified by the vid of the parent object, and the database prefix for the child object. On the first call, will load the max sequence number from the database, but subsequence calls will run in process, so this isn't suitable for multi-process operation -- all of ...
[ "Return", "the", "next", "sequence", "id", "for", "a", "object", "identified", "by", "the", "vid", "of", "the", "parent", "object", "and", "the", "database", "prefix", "for", "the", "child", "object", ".", "On", "the", "first", "call", "will", "load", "t...
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L351-L405
CivicSpleen/ambry
ambry/orm/__init__.py
incver
def incver(o, prop_names): """Increment the version numbers of a set of properties and return a new object""" from ambry.identity import ObjectNumber d = {} for p in o.__mapper__.attrs: v = getattr(o, p.key) if v is None: d[p.key] = None elif p.key in prop_names: ...
python
def incver(o, prop_names): """Increment the version numbers of a set of properties and return a new object""" from ambry.identity import ObjectNumber d = {} for p in o.__mapper__.attrs: v = getattr(o, p.key) if v is None: d[p.key] = None elif p.key in prop_names: ...
[ "def", "incver", "(", "o", ",", "prop_names", ")", ":", "from", "ambry", ".", "identity", "import", "ObjectNumber", "d", "=", "{", "}", "for", "p", "in", "o", ".", "__mapper__", ".", "attrs", ":", "v", "=", "getattr", "(", "o", ",", "p", ".", "ke...
Increment the version numbers of a set of properties and return a new object
[ "Increment", "the", "version", "numbers", "of", "a", "set", "of", "properties", "and", "return", "a", "new", "object" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L408-L424
CivicSpleen/ambry
ambry/orm/__init__.py
MutationList.coerce
def coerce(cls, key, value): """Convert plain list to MutationList.""" if isinstance(value, string_types): value = value.strip() if value[0] == '[': # It's json encoded, probably try: value = json.loads(value) except ValueErro...
python
def coerce(cls, key, value): """Convert plain list to MutationList.""" if isinstance(value, string_types): value = value.strip() if value[0] == '[': # It's json encoded, probably try: value = json.loads(value) except ValueErro...
[ "def", "coerce", "(", "cls", ",", "key", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "value", "=", "value", ".", "strip", "(", ")", "if", "value", "[", "0", "]", "==", "'['", ":", "# It's json encoded, pro...
Convert plain list to MutationList.
[ "Convert", "plain", "list", "to", "MutationList", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/__init__.py#L214-L232
CivicSpleen/ambry
ambry/bundle/asql_parser.py
parse_view
def parse_view(query): """ Parses asql query to view object. Args: query (str): asql query Returns: View instance: parsed view. """ try: idx = query.lower().index('where') query = query[:idx] except ValueError: pass if not query.endswith(';'): ...
python
def parse_view(query): """ Parses asql query to view object. Args: query (str): asql query Returns: View instance: parsed view. """ try: idx = query.lower().index('where') query = query[:idx] except ValueError: pass if not query.endswith(';'): ...
[ "def", "parse_view", "(", "query", ")", ":", "try", ":", "idx", "=", "query", ".", "lower", "(", ")", ".", "index", "(", "'where'", ")", "query", "=", "query", "[", ":", "idx", "]", "except", "ValueError", ":", "pass", "if", "not", "query", ".", ...
Parses asql query to view object. Args: query (str): asql query Returns: View instance: parsed view.
[ "Parses", "asql", "query", "to", "view", "object", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L36-L58
CivicSpleen/ambry
ambry/bundle/asql_parser.py
_flat_alias
def _flat_alias(t): """ Populates token (column or table) fields from parse result. """ t.name = t.parsed_name t.alias = t.parsed_alias[0] if t.parsed_alias else '' return t
python
def _flat_alias(t): """ Populates token (column or table) fields from parse result. """ t.name = t.parsed_name t.alias = t.parsed_alias[0] if t.parsed_alias else '' return t
[ "def", "_flat_alias", "(", "t", ")", ":", "t", ".", "name", "=", "t", ".", "parsed_name", "t", ".", "alias", "=", "t", ".", "parsed_alias", "[", "0", "]", "if", "t", ".", "parsed_alias", "else", "''", "return", "t" ]
Populates token (column or table) fields from parse result.
[ "Populates", "token", "(", "column", "or", "table", ")", "fields", "from", "parse", "result", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L170-L174
CivicSpleen/ambry
ambry/bundle/asql_parser.py
_build_join
def _build_join(t): """ Populates join token fields. """ t.source.name = t.source.parsed_name t.source.alias = t.source.parsed_alias[0] if t.source.parsed_alias else '' return t
python
def _build_join(t): """ Populates join token fields. """ t.source.name = t.source.parsed_name t.source.alias = t.source.parsed_alias[0] if t.source.parsed_alias else '' return t
[ "def", "_build_join", "(", "t", ")", ":", "t", ".", "source", ".", "name", "=", "t", ".", "source", ".", "parsed_name", "t", ".", "source", ".", "alias", "=", "t", ".", "source", ".", "parsed_alias", "[", "0", "]", "if", "t", ".", "source", ".", ...
Populates join token fields.
[ "Populates", "join", "token", "fields", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L177-L182
CivicSpleen/ambry
ambry/bundle/asql_parser.py
substitute_vids
def substitute_vids(library, statement): """ Replace all of the references to tables and partitions with their vids. This is a bit of a hack -- it ought to work with the parser, but instead it just looks for common SQL tokens that indicate an identifier. :param statement: an sqlstatement. String. ...
python
def substitute_vids(library, statement): """ Replace all of the references to tables and partitions with their vids. This is a bit of a hack -- it ought to work with the parser, but instead it just looks for common SQL tokens that indicate an identifier. :param statement: an sqlstatement. String. ...
[ "def", "substitute_vids", "(", "library", ",", "statement", ")", ":", "from", "ambry", ".", "identity", "import", "ObjectNumber", ",", "TableNumber", ",", "NotObjectNumberError", "from", "ambry", ".", "orm", ".", "exc", "import", "NotFoundError", "try", ":", "...
Replace all of the references to tables and partitions with their vids. This is a bit of a hack -- it ought to work with the parser, but instead it just looks for common SQL tokens that indicate an identifier. :param statement: an sqlstatement. String. :return: tuple: new_statement, set of table vids,...
[ "Replace", "all", "of", "the", "references", "to", "tables", "and", "partitions", "with", "their", "vids", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L361-L413
CivicSpleen/ambry
ambry/bundle/asql_parser.py
find_indexable_materializable
def find_indexable_materializable(sql, library): """ Parse a statement, then call functions to install, materialize or create indexes for partitions referenced in the statement. :param sql: :param materialize_f: :param install_f: :param index_f: :return: """ derefed, tables, pa...
python
def find_indexable_materializable(sql, library): """ Parse a statement, then call functions to install, materialize or create indexes for partitions referenced in the statement. :param sql: :param materialize_f: :param install_f: :param index_f: :return: """ derefed, tables, pa...
[ "def", "find_indexable_materializable", "(", "sql", ",", "library", ")", ":", "derefed", ",", "tables", ",", "partitions", "=", "substitute_vids", "(", "library", ",", "sql", ")", "if", "derefed", ".", "lower", "(", ")", ".", "startswith", "(", "'create inde...
Parse a statement, then call functions to install, materialize or create indexes for partitions referenced in the statement. :param sql: :param materialize_f: :param install_f: :param index_f: :return:
[ "Parse", "a", "statement", "then", "call", "functions", "to", "install", "materialize", "or", "create", "indexes", "for", "partitions", "referenced", "in", "the", "statement", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L491-L574
CivicSpleen/ambry
ambry/bundle/asql_parser.py
FIMRecord.update
def update(self, rec=None, drop=None, tables=None, install=None, materialize=None, indexes=None, joins=0, views=0): """ Updates current record. Args: rec (FIMRecord): """ if not drop: drop = [] if not tables: tables = set() ...
python
def update(self, rec=None, drop=None, tables=None, install=None, materialize=None, indexes=None, joins=0, views=0): """ Updates current record. Args: rec (FIMRecord): """ if not drop: drop = [] if not tables: tables = set() ...
[ "def", "update", "(", "self", ",", "rec", "=", "None", ",", "drop", "=", "None", ",", "tables", "=", "None", ",", "install", "=", "None", ",", "materialize", "=", "None", ",", "indexes", "=", "None", ",", "joins", "=", "0", ",", "views", "=", "0"...
Updates current record. Args: rec (FIMRecord):
[ "Updates", "current", "record", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/asql_parser.py#L448-L488
project-ncl/pnc-cli
pnc_cli/swagger_client/models/product_release_rest.py
ProductReleaseRest.support_level
def support_level(self, support_level): """ Sets the support_level of this ProductReleaseRest. :param support_level: The support_level of this ProductReleaseRest. :type: str """ allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"] ...
python
def support_level(self, support_level): """ Sets the support_level of this ProductReleaseRest. :param support_level: The support_level of this ProductReleaseRest. :type: str """ allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"] ...
[ "def", "support_level", "(", "self", ",", "support_level", ")", ":", "allowed_values", "=", "[", "\"UNRELEASED\"", ",", "\"EARLYACCESS\"", ",", "\"SUPPORTED\"", ",", "\"EXTENDED_SUPPORT\"", ",", "\"EOL\"", "]", "if", "support_level", "not", "in", "allowed_values", ...
Sets the support_level of this ProductReleaseRest. :param support_level: The support_level of this ProductReleaseRest. :type: str
[ "Sets", "the", "support_level", "of", "this", "ProductReleaseRest", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/product_release_rest.py#L244-L258
twisted/epsilon
epsilon/hotfixes/internet_task_clock.py
callLater
def callLater(self, when, what, *a, **kw): """ Copied from twisted.internet.task.Clock, r20480. Fixes the bug where the wrong DelayedCall would sometimes be returned. """ dc = base.DelayedCall(self.seconds() + when, what, a, kw, self.calls.remo...
python
def callLater(self, when, what, *a, **kw): """ Copied from twisted.internet.task.Clock, r20480. Fixes the bug where the wrong DelayedCall would sometimes be returned. """ dc = base.DelayedCall(self.seconds() + when, what, a, kw, self.calls.remo...
[ "def", "callLater", "(", "self", ",", "when", ",", "what", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "dc", "=", "base", ".", "DelayedCall", "(", "self", ".", "seconds", "(", ")", "+", "when", ",", "what", ",", "a", ",", "kw", ",", "self",...
Copied from twisted.internet.task.Clock, r20480. Fixes the bug where the wrong DelayedCall would sometimes be returned.
[ "Copied", "from", "twisted", ".", "internet", ".", "task", ".", "Clock", "r20480", ".", "Fixes", "the", "bug", "where", "the", "wrong", "DelayedCall", "would", "sometimes", "be", "returned", "." ]
train
https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/internet_task_clock.py#L7-L19
twisted/epsilon
epsilon/hotfixes/internet_task_clock.py
clockIsBroken
def clockIsBroken(): """ Returns whether twisted.internet.task.Clock has the bug that returns the wrong DelayedCall or not. """ clock = Clock() dc1 = clock.callLater(10, lambda: None) dc2 = clock.callLater(1, lambda: None) if dc1 is dc2: return True else: return False
python
def clockIsBroken(): """ Returns whether twisted.internet.task.Clock has the bug that returns the wrong DelayedCall or not. """ clock = Clock() dc1 = clock.callLater(10, lambda: None) dc2 = clock.callLater(1, lambda: None) if dc1 is dc2: return True else: return False
[ "def", "clockIsBroken", "(", ")", ":", "clock", "=", "Clock", "(", ")", "dc1", "=", "clock", ".", "callLater", "(", "10", ",", "lambda", ":", "None", ")", "dc2", "=", "clock", ".", "callLater", "(", "1", ",", "lambda", ":", "None", ")", "if", "dc...
Returns whether twisted.internet.task.Clock has the bug that returns the wrong DelayedCall or not.
[ "Returns", "whether", "twisted", ".", "internet", ".", "task", ".", "Clock", "has", "the", "bug", "that", "returns", "the", "wrong", "DelayedCall", "or", "not", "." ]
train
https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/internet_task_clock.py#L21-L32
project-ncl/pnc-cli
pnc_cli/tools/scm_utils.py
get_scm_status
def get_scm_status(config, read_modules=False, repo_url=None, mvn_repo_local=None, additional_params=None): """ Gets the artifact status (MavenArtifact instance) from SCM defined by config. Only the top-level artifact is read by default, although it can be requested to read the whole available module struct...
python
def get_scm_status(config, read_modules=False, repo_url=None, mvn_repo_local=None, additional_params=None): """ Gets the artifact status (MavenArtifact instance) from SCM defined by config. Only the top-level artifact is read by default, although it can be requested to read the whole available module struct...
[ "def", "get_scm_status", "(", "config", ",", "read_modules", "=", "False", ",", "repo_url", "=", "None", ",", "mvn_repo_local", "=", "None", ",", "additional_params", "=", "None", ")", ":", "global", "scm_status_cache", "if", "config", ".", "artifact", "in", ...
Gets the artifact status (MavenArtifact instance) from SCM defined by config. Only the top-level artifact is read by default, although it can be requested to read the whole available module structure. :param config: artifact config (ArtifactConfig instance) :param read_modules: if True all modules are read...
[ "Gets", "the", "artifact", "status", "(", "MavenArtifact", "instance", ")", "from", "SCM", "defined", "by", "config", ".", "Only", "the", "top", "-", "level", "artifact", "is", "read", "by", "default", "although", "it", "can", "be", "requested", "to", "rea...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/scm_utils.py#L23-L47
project-ncl/pnc-cli
pnc_cli/tools/scm_utils.py
shrink_patch
def shrink_patch(patch_path, target_file): """ Shrinks a patch on patch_path to contain only changes for target_file. :param patch_path: path to the shrinked patch file :param target_file: filename of a file of which changes should be kept :return: True if the is a section containing changes for ta...
python
def shrink_patch(patch_path, target_file): """ Shrinks a patch on patch_path to contain only changes for target_file. :param patch_path: path to the shrinked patch file :param target_file: filename of a file of which changes should be kept :return: True if the is a section containing changes for ta...
[ "def", "shrink_patch", "(", "patch_path", ",", "target_file", ")", ":", "logging", ".", "debug", "(", "\"Shrinking patch file %s to keep only %s changes.\"", ",", "patch_path", ",", "target_file", ")", "shrinked_lines", "=", "[", "]", "patch_file", "=", "None", "try...
Shrinks a patch on patch_path to contain only changes for target_file. :param patch_path: path to the shrinked patch file :param target_file: filename of a file of which changes should be kept :return: True if the is a section containing changes for target_file, Flase otherwise
[ "Shrinks", "a", "patch", "on", "patch_path", "to", "contain", "only", "changes", "for", "target_file", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/scm_utils.py#L274-L313
project-ncl/pnc-cli
pnc_cli/tools/scm_utils.py
get_scm_info
def get_scm_info(directory, branch_id=False, read_only=False, filePath=None): """ Reads SCM info from the given directory. It can fill real commit ID into commit_id field or branch name. @param directory: directory name @param branch_id: reads commit ID if False (default) or branch name if True @pa...
python
def get_scm_info(directory, branch_id=False, read_only=False, filePath=None): """ Reads SCM info from the given directory. It can fill real commit ID into commit_id field or branch name. @param directory: directory name @param branch_id: reads commit ID if False (default) or branch name if True @pa...
[ "def", "get_scm_info", "(", "directory", ",", "branch_id", "=", "False", ",", "read_only", "=", "False", ",", "filePath", "=", "None", ")", ":", "#TODO use a commit id instead of branch if in detached state", "if", "(", "directory", ",", "branch_id", ",", "read_only...
Reads SCM info from the given directory. It can fill real commit ID into commit_id field or branch name. @param directory: directory name @param branch_id: reads commit ID if False (default) or branch name if True @param read_only: if True it replaces the actual scheme to the read-only for known hosts, e.g...
[ "Reads", "SCM", "info", "from", "the", "given", "directory", ".", "It", "can", "fill", "real", "commit", "ID", "into", "commit_id", "field", "or", "branch", "name", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/scm_utils.py#L321-L399
project-ncl/pnc-cli
pnc_cli/swagger_client/models/build_set_status_changed_event.py
BuildSetStatusChangedEvent.new_status
def new_status(self, new_status): """ Sets the new_status of this BuildSetStatusChangedEvent. :param new_status: The new_status of this BuildSetStatusChangedEvent. :type: str """ allowed_values = ["NEW", "DONE", "REJECTED"] if new_status not in allowed_values: ...
python
def new_status(self, new_status): """ Sets the new_status of this BuildSetStatusChangedEvent. :param new_status: The new_status of this BuildSetStatusChangedEvent. :type: str """ allowed_values = ["NEW", "DONE", "REJECTED"] if new_status not in allowed_values: ...
[ "def", "new_status", "(", "self", ",", "new_status", ")", ":", "allowed_values", "=", "[", "\"NEW\"", ",", "\"DONE\"", ",", "\"REJECTED\"", "]", "if", "new_status", "not", "in", "allowed_values", ":", "raise", "ValueError", "(", "\"Invalid value for `new_status` (...
Sets the new_status of this BuildSetStatusChangedEvent. :param new_status: The new_status of this BuildSetStatusChangedEvent. :type: str
[ "Sets", "the", "new_status", "of", "this", "BuildSetStatusChangedEvent", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/build_set_status_changed_event.py#L139-L153
project-ncl/pnc-cli
pnc_cli/swagger_client/models/build_set_status_changed_event.py
BuildSetStatusChangedEvent.old_status
def old_status(self, old_status): """ Sets the old_status of this BuildSetStatusChangedEvent. :param old_status: The old_status of this BuildSetStatusChangedEvent. :type: str """ allowed_values = ["NEW", "DONE", "REJECTED"] if old_status not in allowed_values: ...
python
def old_status(self, old_status): """ Sets the old_status of this BuildSetStatusChangedEvent. :param old_status: The old_status of this BuildSetStatusChangedEvent. :type: str """ allowed_values = ["NEW", "DONE", "REJECTED"] if old_status not in allowed_values: ...
[ "def", "old_status", "(", "self", ",", "old_status", ")", ":", "allowed_values", "=", "[", "\"NEW\"", ",", "\"DONE\"", ",", "\"REJECTED\"", "]", "if", "old_status", "not", "in", "allowed_values", ":", "raise", "ValueError", "(", "\"Invalid value for `old_status` (...
Sets the old_status of this BuildSetStatusChangedEvent. :param old_status: The old_status of this BuildSetStatusChangedEvent. :type: str
[ "Sets", "the", "old_status", "of", "this", "BuildSetStatusChangedEvent", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/build_set_status_changed_event.py#L250-L264
SmartTeleMax/iktomi
iktomi/cli/app.py
App.command_serve
def command_serve(self, host='', port='8000', level='debug'): ''' Run development server with automated reload on code change:: ./manage.py app:serve [host] [port] [level] ''' logging.basicConfig(level=getattr(logging, level.upper()), format=self.format) if self.boot...
python
def command_serve(self, host='', port='8000', level='debug'): ''' Run development server with automated reload on code change:: ./manage.py app:serve [host] [port] [level] ''' logging.basicConfig(level=getattr(logging, level.upper()), format=self.format) if self.boot...
[ "def", "command_serve", "(", "self", ",", "host", "=", "''", ",", "port", "=", "'8000'", ",", "level", "=", "'debug'", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "getattr", "(", "logging", ",", "level", ".", "upper", "(", ")", ")", ...
Run development server with automated reload on code change:: ./manage.py app:serve [host] [port] [level]
[ "Run", "development", "server", "with", "automated", "reload", "on", "code", "change", "::" ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/cli/app.py#L49-L94
SmartTeleMax/iktomi
iktomi/cli/app.py
App.command_shell
def command_shell(self): ''' Shell command:: ./manage.py app:shell Executed with `self.shell_namespace` as local variables namespace. ''' from code import interact interact('Namespace {!r}'.format(self.shell_namespace), local=self.shell_name...
python
def command_shell(self): ''' Shell command:: ./manage.py app:shell Executed with `self.shell_namespace` as local variables namespace. ''' from code import interact interact('Namespace {!r}'.format(self.shell_namespace), local=self.shell_name...
[ "def", "command_shell", "(", "self", ")", ":", "from", "code", "import", "interact", "interact", "(", "'Namespace {!r}'", ".", "format", "(", "self", ".", "shell_namespace", ")", ",", "local", "=", "self", ".", "shell_namespace", ")" ]
Shell command:: ./manage.py app:shell Executed with `self.shell_namespace` as local variables namespace.
[ "Shell", "command", "::" ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/cli/app.py#L96-L106
SmartTeleMax/iktomi
iktomi/unstable/db/sqla/mixin.py
declared_mixin
def declared_mixin(*bases): '''Create mix-in class with all assignments turned into methods decorated with declared_attr. Usage: @declared_mixin def FactoryFunction(): or with base mix-in class[es]: @declared_mixin(BaseMixIn1, BaseMixIn2) def FactoryFunction(): For ex...
python
def declared_mixin(*bases): '''Create mix-in class with all assignments turned into methods decorated with declared_attr. Usage: @declared_mixin def FactoryFunction(): or with base mix-in class[es]: @declared_mixin(BaseMixIn1, BaseMixIn2) def FactoryFunction(): For ex...
[ "def", "declared_mixin", "(", "*", "bases", ")", ":", "def", "wrapper", "(", "func", ")", ":", "attrs", "=", "weakref", ".", "WeakKeyDictionary", "(", ")", "def", "create_descriptor", "(", "name", ")", ":", "def", "get_attr", "(", "cls", ")", ":", "if"...
Create mix-in class with all assignments turned into methods decorated with declared_attr. Usage: @declared_mixin def FactoryFunction(): or with base mix-in class[es]: @declared_mixin(BaseMixIn1, BaseMixIn2) def FactoryFunction(): For example: @declared_mixin ...
[ "Create", "mix", "-", "in", "class", "with", "all", "assignments", "turned", "into", "methods", "decorated", "with", "declared_attr", ".", "Usage", ":" ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/unstable/db/sqla/mixin.py#L7-L58
cosven/feeluown-core
fuocore/utils.py
elfhash
def elfhash(s): """ :param string: bytes >>> import base64 >>> s = base64.b64encode(b'hello world') >>> elfhash(s) 224648685 """ hash = 0 x = 0 for c in s: hash = (hash << 4) + c x = hash & 0xF0000000 if x: hash ^= (x >> 24) hash &...
python
def elfhash(s): """ :param string: bytes >>> import base64 >>> s = base64.b64encode(b'hello world') >>> elfhash(s) 224648685 """ hash = 0 x = 0 for c in s: hash = (hash << 4) + c x = hash & 0xF0000000 if x: hash ^= (x >> 24) hash &...
[ "def", "elfhash", "(", "s", ")", ":", "hash", "=", "0", "x", "=", "0", "for", "c", "in", "s", ":", "hash", "=", "(", "hash", "<<", "4", ")", "+", "c", "x", "=", "hash", "&", "0xF0000000", "if", "x", ":", "hash", "^=", "(", "x", ">>", "24"...
:param string: bytes >>> import base64 >>> s = base64.b64encode(b'hello world') >>> elfhash(s) 224648685
[ ":", "param", "string", ":", "bytes" ]
train
https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/utils.py#L23-L40
cosven/feeluown-core
fuocore/utils.py
find_previous
def find_previous(element, l): """ find previous element in a sorted list >>> find_previous(0, [0]) 0 >>> find_previous(2, [1, 1, 3]) 1 >>> find_previous(0, [1, 2]) >>> find_previous(1.5, [1, 2]) 1 >>> find_previous(3, [1, 2]) 2 """ length = len(l) for index, cur...
python
def find_previous(element, l): """ find previous element in a sorted list >>> find_previous(0, [0]) 0 >>> find_previous(2, [1, 1, 3]) 1 >>> find_previous(0, [1, 2]) >>> find_previous(1.5, [1, 2]) 1 >>> find_previous(3, [1, 2]) 2 """ length = len(l) for index, cur...
[ "def", "find_previous", "(", "element", ",", "l", ")", ":", "length", "=", "len", "(", "l", ")", "for", "index", ",", "current", "in", "enumerate", "(", "l", ")", ":", "# current is the last element", "if", "length", "-", "1", "==", "index", ":", "retu...
find previous element in a sorted list >>> find_previous(0, [0]) 0 >>> find_previous(2, [1, 1, 3]) 1 >>> find_previous(0, [1, 2]) >>> find_previous(1.5, [1, 2]) 1 >>> find_previous(3, [1, 2]) 2
[ "find", "previous", "element", "in", "a", "sorted", "list" ]
train
https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/utils.py#L43-L69
CivicSpleen/ambry
ambry/orm/remote.py
patch_match_hostname
def patch_match_hostname(): """Fixes https://github.com/boto/boto/issues/2836""" _old_match_hostname = ssl.match_hostname def _new_match_hostname(cert, hostname): if hostname.endswith('.s3.amazonaws.com'): pos = hostname.find('.s3.amazonaws.com') hostname = hostname[:pos]....
python
def patch_match_hostname(): """Fixes https://github.com/boto/boto/issues/2836""" _old_match_hostname = ssl.match_hostname def _new_match_hostname(cert, hostname): if hostname.endswith('.s3.amazonaws.com'): pos = hostname.find('.s3.amazonaws.com') hostname = hostname[:pos]....
[ "def", "patch_match_hostname", "(", ")", ":", "_old_match_hostname", "=", "ssl", ".", "match_hostname", "def", "_new_match_hostname", "(", "cert", ",", "hostname", ")", ":", "if", "hostname", ".", "endswith", "(", "'.s3.amazonaws.com'", ")", ":", "pos", "=", "...
Fixes https://github.com/boto/boto/issues/2836
[ "Fixes", "https", ":", "//", "github", ".", "com", "/", "boto", "/", "boto", "/", "issues", "/", "2836" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L41-L53
CivicSpleen/ambry
ambry/orm/remote.py
Remote.dict
def dict(self): """A dict that holds key/values for all of the properties in the object. :return: """ from collections import OrderedDict d = OrderedDict( [(p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ('data',)]) if ...
python
def dict(self): """A dict that holds key/values for all of the properties in the object. :return: """ from collections import OrderedDict d = OrderedDict( [(p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ('data',)]) if ...
[ "def", "dict", "(", "self", ")", ":", "from", "collections", "import", "OrderedDict", "d", "=", "OrderedDict", "(", "[", "(", "p", ".", "key", ",", "getattr", "(", "self", ",", "p", ".", "key", ")", ")", "for", "p", "in", "self", ".", "__mapper__",...
A dict that holds key/values for all of the properties in the object. :return:
[ "A", "dict", "that", "holds", "key", "/", "values", "for", "all", "of", "the", "properties", "in", "the", "object", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L115-L136
CivicSpleen/ambry
ambry/orm/remote.py
Remote.update
def update(self): """Cache the list into the data section of the record""" from ambry.orm.exc import NotFoundError from requests.exceptions import ConnectionError, HTTPError from boto.exception import S3ResponseError d = {} try: for k, v in self.list(full=T...
python
def update(self): """Cache the list into the data section of the record""" from ambry.orm.exc import NotFoundError from requests.exceptions import ConnectionError, HTTPError from boto.exception import S3ResponseError d = {} try: for k, v in self.list(full=T...
[ "def", "update", "(", "self", ")", ":", "from", "ambry", ".", "orm", ".", "exc", "import", "NotFoundError", "from", "requests", ".", "exceptions", "import", "ConnectionError", ",", "HTTPError", "from", "boto", ".", "exception", "import", "S3ResponseError", "d"...
Cache the list into the data section of the record
[ "Cache", "the", "list", "into", "the", "data", "section", "of", "the", "record" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L177-L200
CivicSpleen/ambry
ambry/orm/remote.py
Remote.list
def list(self, full=False): """List all of the bundles in the remote""" if self.is_api: return self._list_api(full=full) else: return self._list_fs(full=full)
python
def list(self, full=False): """List all of the bundles in the remote""" if self.is_api: return self._list_api(full=full) else: return self._list_fs(full=full)
[ "def", "list", "(", "self", ",", "full", "=", "False", ")", ":", "if", "self", ".", "is_api", ":", "return", "self", ".", "_list_api", "(", "full", "=", "full", ")", "else", ":", "return", "self", ".", "_list_fs", "(", "full", "=", "full", ")" ]
List all of the bundles in the remote
[ "List", "all", "of", "the", "bundles", "in", "the", "remote" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L202-L208
CivicSpleen/ambry
ambry/orm/remote.py
Remote._update_fs_list
def _update_fs_list(self): """Cache the full list for http access. This creates a meta file that can be read all at once, rather than requiring a list operation like S3 access does""" from json import dumps full_list = [ e[1] for e in self._list_fs(full=True) ] remote = self._f...
python
def _update_fs_list(self): """Cache the full list for http access. This creates a meta file that can be read all at once, rather than requiring a list operation like S3 access does""" from json import dumps full_list = [ e[1] for e in self._list_fs(full=True) ] remote = self._f...
[ "def", "_update_fs_list", "(", "self", ")", ":", "from", "json", "import", "dumps", "full_list", "=", "[", "e", "[", "1", "]", "for", "e", "in", "self", ".", "_list_fs", "(", "full", "=", "True", ")", "]", "remote", "=", "self", ".", "_fs_remote", ...
Cache the full list for http access. This creates a meta file that can be read all at once, rather than requiring a list operation like S3 access does
[ "Cache", "the", "full", "list", "for", "http", "access", ".", "This", "creates", "a", "meta", "file", "that", "can", "be", "read", "all", "at", "once", "rather", "than", "requiring", "a", "list", "operation", "like", "S3", "access", "does" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L253-L262
CivicSpleen/ambry
ambry/orm/remote.py
Remote.checkin
def checkin(self, package, no_partitions=False, force=False, cb=None): """ Check in a bundle package to the remote. :param package: A Database, referencing a sqlite database holding the bundle :param cb: a two argument progress callback: cb(message, num_records) :return: ...
python
def checkin(self, package, no_partitions=False, force=False, cb=None): """ Check in a bundle package to the remote. :param package: A Database, referencing a sqlite database holding the bundle :param cb: a two argument progress callback: cb(message, num_records) :return: ...
[ "def", "checkin", "(", "self", ",", "package", ",", "no_partitions", "=", "False", ",", "force", "=", "False", ",", "cb", "=", "None", ")", ":", "from", "ambry", ".", "orm", ".", "exc", "import", "NotFoundError", "if", "not", "os", ".", "path", ".", ...
Check in a bundle package to the remote. :param package: A Database, referencing a sqlite database holding the bundle :param cb: a two argument progress callback: cb(message, num_records) :return:
[ "Check", "in", "a", "bundle", "package", "to", "the", "remote", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L307-L323
CivicSpleen/ambry
ambry/orm/remote.py
Remote._put_metadata
def _put_metadata(self, fs_remote, ds): """Store metadata on a pyfs remote""" from six import text_type from fs.errors import ResourceNotFoundError identity = ds.identity d = identity.dict d['summary'] = ds.config.metadata.about.summary d['title'] = ds.config....
python
def _put_metadata(self, fs_remote, ds): """Store metadata on a pyfs remote""" from six import text_type from fs.errors import ResourceNotFoundError identity = ds.identity d = identity.dict d['summary'] = ds.config.metadata.about.summary d['title'] = ds.config....
[ "def", "_put_metadata", "(", "self", ",", "fs_remote", ",", "ds", ")", ":", "from", "six", "import", "text_type", "from", "fs", ".", "errors", "import", "ResourceNotFoundError", "identity", "=", "ds", ".", "identity", "d", "=", "identity", ".", "dict", "d"...
Store metadata on a pyfs remote
[ "Store", "metadata", "on", "a", "pyfs", "remote" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L398-L428
CivicSpleen/ambry
ambry/orm/remote.py
Remote.checkout
def checkout(self, ref, cb=None): """Checkout a bundle from the remote. Returns a file-like object""" if self.is_api: return self._checkout_api(ref, cb=cb) else: return self._checkout_fs(ref, cb=cb)
python
def checkout(self, ref, cb=None): """Checkout a bundle from the remote. Returns a file-like object""" if self.is_api: return self._checkout_api(ref, cb=cb) else: return self._checkout_fs(ref, cb=cb)
[ "def", "checkout", "(", "self", ",", "ref", ",", "cb", "=", "None", ")", ":", "if", "self", ".", "is_api", ":", "return", "self", ".", "_checkout_api", "(", "ref", ",", "cb", "=", "cb", ")", "else", ":", "return", "self", ".", "_checkout_fs", "(", ...
Checkout a bundle from the remote. Returns a file-like object
[ "Checkout", "a", "bundle", "from", "the", "remote", ".", "Returns", "a", "file", "-", "like", "object" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L463-L468
CivicSpleen/ambry
ambry/orm/remote.py
Remote.remove
def remove(self, ref, cb=None): """Check in a bundle to the remote""" if self.is_api: return self._remove_api(ref, cb) else: return self._remove_fs(ref, cb)
python
def remove(self, ref, cb=None): """Check in a bundle to the remote""" if self.is_api: return self._remove_api(ref, cb) else: return self._remove_fs(ref, cb)
[ "def", "remove", "(", "self", ",", "ref", ",", "cb", "=", "None", ")", ":", "if", "self", ".", "is_api", ":", "return", "self", ".", "_remove_api", "(", "ref", ",", "cb", ")", "else", ":", "return", "self", ".", "_remove_fs", "(", "ref", ",", "cb...
Check in a bundle to the remote
[ "Check", "in", "a", "bundle", "to", "the", "remote" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L484-L490
CivicSpleen/ambry
ambry/orm/remote.py
Remote.s3
def s3(self, url, account_acessor=None, access=None, secret=None): """Setup an S3 pyfs, with account credentials, fixing an ssl matching problem""" from ambry.util.ambrys3 import AmbryS3FS from ambry.util import parse_url_to_dict import ssl pd = parse_url_to_dict(url) i...
python
def s3(self, url, account_acessor=None, access=None, secret=None): """Setup an S3 pyfs, with account credentials, fixing an ssl matching problem""" from ambry.util.ambrys3 import AmbryS3FS from ambry.util import parse_url_to_dict import ssl pd = parse_url_to_dict(url) i...
[ "def", "s3", "(", "self", ",", "url", ",", "account_acessor", "=", "None", ",", "access", "=", "None", ",", "secret", "=", "None", ")", ":", "from", "ambry", ".", "util", ".", "ambrys3", "import", "AmbryS3FS", "from", "ambry", ".", "util", "import", ...
Setup an S3 pyfs, with account credentials, fixing an ssl matching problem
[ "Setup", "an", "S3", "pyfs", "with", "account", "credentials", "fixing", "an", "ssl", "matching", "problem" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/remote.py#L555-L584
edoburu/django-any-urlfield
any_urlfield/templatetags/any_urlfield_tags.py
withdict
def withdict(parser, token): """ Take a complete context dict as extra layer. """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("{% withdict %} expects one argument") nodelist = parser.parse(('endwithdict',)) parser.delete_first_token() return WithD...
python
def withdict(parser, token): """ Take a complete context dict as extra layer. """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("{% withdict %} expects one argument") nodelist = parser.parse(('endwithdict',)) parser.delete_first_token() return WithD...
[ "def", "withdict", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "2", ":", "raise", "TemplateSyntaxError", "(", "\"{% withdict %} expects one argument\"", ")", "nodelist", "...
Take a complete context dict as extra layer.
[ "Take", "a", "complete", "context", "dict", "as", "extra", "layer", "." ]
train
https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/templatetags/any_urlfield_tags.py#L31-L45
edoburu/django-any-urlfield
any_urlfield/templatetags/any_urlfield_tags.py
WithDictNode.render
def render(self, context): """ Render the tag, with extra context layer. """ extra_context = self.context_expr.resolve(context) if not isinstance(extra_context, dict): raise TemplateSyntaxError("{% withdict %} expects the argument to be a dictionary.") with c...
python
def render(self, context): """ Render the tag, with extra context layer. """ extra_context = self.context_expr.resolve(context) if not isinstance(extra_context, dict): raise TemplateSyntaxError("{% withdict %} expects the argument to be a dictionary.") with c...
[ "def", "render", "(", "self", ",", "context", ")", ":", "extra_context", "=", "self", ".", "context_expr", ".", "resolve", "(", "context", ")", "if", "not", "isinstance", "(", "extra_context", ",", "dict", ")", ":", "raise", "TemplateSyntaxError", "(", "\"...
Render the tag, with extra context layer.
[ "Render", "the", "tag", "with", "extra", "context", "layer", "." ]
train
https://github.com/edoburu/django-any-urlfield/blob/8d7d36c8a1fc251930f6dbdcc8b5b5151d20e3ab/any_urlfield/templatetags/any_urlfield_tags.py#L18-L27
SmartTeleMax/iktomi
iktomi/db/sqla/files.py
filesessionmaker
def filesessionmaker(sessionmaker, file_manager, file_managers=None): u'''Wrapper of session maker adding link to a FileManager instance to session.:: file_manager = FileManager(cfg.TRANSIENT_ROOT, cfg.PERSISTENT_ROOT) filesessionmaker(sessionmaker(...), file_...
python
def filesessionmaker(sessionmaker, file_manager, file_managers=None): u'''Wrapper of session maker adding link to a FileManager instance to session.:: file_manager = FileManager(cfg.TRANSIENT_ROOT, cfg.PERSISTENT_ROOT) filesessionmaker(sessionmaker(...), file_...
[ "def", "filesessionmaker", "(", "sessionmaker", ",", "file_manager", ",", "file_managers", "=", "None", ")", ":", "registry", "=", "WeakKeyDictionary", "(", ")", "if", "file_managers", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "file_mana...
u'''Wrapper of session maker adding link to a FileManager instance to session.:: file_manager = FileManager(cfg.TRANSIENT_ROOT, cfg.PERSISTENT_ROOT) filesessionmaker(sessionmaker(...), file_manager)
[ "u", "Wrapper", "of", "session", "maker", "adding", "link", "to", "a", "FileManager", "instance", "to", "session", ".", "::" ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/db/sqla/files.py#L210-L256
sailthru/relay
relay/plugins/__init__.py
oscillating_setpoint
def oscillating_setpoint(_square_wave=False, shift=0): """A basic example of a target that you may want to approximate. If you have a thermostat, this is a temperature setting. This target can't change too often """ import math c = 0 while 1: if _square_wave: yield ((c %...
python
def oscillating_setpoint(_square_wave=False, shift=0): """A basic example of a target that you may want to approximate. If you have a thermostat, this is a temperature setting. This target can't change too often """ import math c = 0 while 1: if _square_wave: yield ((c %...
[ "def", "oscillating_setpoint", "(", "_square_wave", "=", "False", ",", "shift", "=", "0", ")", ":", "import", "math", "c", "=", "0", "while", "1", ":", "if", "_square_wave", ":", "yield", "(", "(", "c", "%", "300", ")", "<", "150", ")", "*", "30", ...
A basic example of a target that you may want to approximate. If you have a thermostat, this is a temperature setting. This target can't change too often
[ "A", "basic", "example", "of", "a", "target", "that", "you", "may", "want", "to", "approximate", "." ]
train
https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L71-L86
sailthru/relay
relay/plugins/__init__.py
bash_echo_metric
def bash_echo_metric(): """A very basic example that monitors a number of currently running processes""" import subprocess # import random # more predictable version of the metric cmd = ( 'set -o pipefail ' ' ; pgrep -f "^bash.*sleep .*from bash: started relay launcher"' ...
python
def bash_echo_metric(): """A very basic example that monitors a number of currently running processes""" import subprocess # import random # more predictable version of the metric cmd = ( 'set -o pipefail ' ' ; pgrep -f "^bash.*sleep .*from bash: started relay launcher"' ...
[ "def", "bash_echo_metric", "(", ")", ":", "import", "subprocess", "# import random", "# more predictable version of the metric", "cmd", "=", "(", "'set -o pipefail '", "' ; pgrep -f \"^bash.*sleep .*from bash: started relay launcher\"'", "' | wc -l '", ")", "# less predictable versio...
A very basic example that monitors a number of currently running processes
[ "A", "very", "basic", "example", "that", "monitors", "a", "number", "of", "currently", "running", "processes" ]
train
https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L101-L121
sailthru/relay
relay/plugins/__init__.py
bash_echo_warmer
def bash_echo_warmer(n): """A very basic example of how to create n additional tasks. This is a warmer function with randomly delayed effects on the bash_echo_metric and random task lengths to make the metric less predictable """ import subprocess import random cmd = ( 'set -o pi...
python
def bash_echo_warmer(n): """A very basic example of how to create n additional tasks. This is a warmer function with randomly delayed effects on the bash_echo_metric and random task lengths to make the metric less predictable """ import subprocess import random cmd = ( 'set -o pi...
[ "def", "bash_echo_warmer", "(", "n", ")", ":", "import", "subprocess", "import", "random", "cmd", "=", "(", "'set -o pipefail '", "\" ; sleep %s \"", "\" ; sh -c 'echo from bash: started relay launcher task && sleep %s'\"", ")", "for", "i", "in", "range", "(", "n", ")",...
A very basic example of how to create n additional tasks. This is a warmer function with randomly delayed effects on the bash_echo_metric and random task lengths to make the metric less predictable
[ "A", "very", "basic", "example", "of", "how", "to", "create", "n", "additional", "tasks", ".", "This", "is", "a", "warmer", "function", "with", "randomly", "delayed", "effects", "on", "the", "bash_echo_metric", "and", "random", "task", "lengths", "to", "make...
train
https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L124-L140
sailthru/relay
relay/plugins/__init__.py
bash_echo_cooler
def bash_echo_cooler(n): """A very basic example of how to destroy n running tasks This is a cooler function """ import subprocess cmd = ( 'set -o pipefile ' ' ; kill `pgrep -f "from bash: started relay launcher task"' ' | tail -n %s` 2>/dev/null' % n) subprocess.Popen(cm...
python
def bash_echo_cooler(n): """A very basic example of how to destroy n running tasks This is a cooler function """ import subprocess cmd = ( 'set -o pipefile ' ' ; kill `pgrep -f "from bash: started relay launcher task"' ' | tail -n %s` 2>/dev/null' % n) subprocess.Popen(cm...
[ "def", "bash_echo_cooler", "(", "n", ")", ":", "import", "subprocess", "cmd", "=", "(", "'set -o pipefile '", "' ; kill `pgrep -f \"from bash: started relay launcher task\"'", "' | tail -n %s` 2>/dev/null'", "%", "n", ")", "subprocess", ".", "Popen", "(", "cmd", ",", "s...
A very basic example of how to destroy n running tasks This is a cooler function
[ "A", "very", "basic", "example", "of", "how", "to", "destroy", "n", "running", "tasks", "This", "is", "a", "cooler", "function" ]
train
https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L143-L152
sailthru/relay
relay/plugins/__init__.py
stop_if_mostly_diverging
def stop_if_mostly_diverging(errdata): """This is an example stop condition that asks Relay to quit if the error difference between consecutive samples is increasing more than half of the time. It's quite sensitive and designed for the demo, so you probably shouldn't use this is a production settin...
python
def stop_if_mostly_diverging(errdata): """This is an example stop condition that asks Relay to quit if the error difference between consecutive samples is increasing more than half of the time. It's quite sensitive and designed for the demo, so you probably shouldn't use this is a production settin...
[ "def", "stop_if_mostly_diverging", "(", "errdata", ")", ":", "n_increases", "=", "sum", "(", "[", "abs", "(", "y", ")", "-", "abs", "(", "x", ")", ">", "0", "for", "x", ",", "y", "in", "zip", "(", "errdata", ",", "errdata", "[", "1", ":", "]", ...
This is an example stop condition that asks Relay to quit if the error difference between consecutive samples is increasing more than half of the time. It's quite sensitive and designed for the demo, so you probably shouldn't use this is a production setting
[ "This", "is", "an", "example", "stop", "condition", "that", "asks", "Relay", "to", "quit", "if", "the", "error", "difference", "between", "consecutive", "samples", "is", "increasing", "more", "than", "half", "of", "the", "time", "." ]
train
https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/plugins/__init__.py#L155-L172
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Task.has_resolved_dependencies
def has_resolved_dependencies(self): """Return True if all dependencies are in State.DONE""" for dependency in self.dependencies: if dependency.state != Task.State.DONE: return False return True
python
def has_resolved_dependencies(self): """Return True if all dependencies are in State.DONE""" for dependency in self.dependencies: if dependency.state != Task.State.DONE: return False return True
[ "def", "has_resolved_dependencies", "(", "self", ")", ":", "for", "dependency", "in", "self", ".", "dependencies", ":", "if", "dependency", ".", "state", "!=", "Task", ".", "State", ".", "DONE", ":", "return", "False", "return", "True" ]
Return True if all dependencies are in State.DONE
[ "Return", "True", "if", "all", "dependencies", "are", "in", "State", ".", "DONE" ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L46-L52
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Task.dependencies_as_list
def dependencies_as_list(self): """Returns a list of dependency names.""" dependencies = [] for dependency in self.dependencies: dependencies.append(dependency.name) return dependencies
python
def dependencies_as_list(self): """Returns a list of dependency names.""" dependencies = [] for dependency in self.dependencies: dependencies.append(dependency.name) return dependencies
[ "def", "dependencies_as_list", "(", "self", ")", ":", "dependencies", "=", "[", "]", "for", "dependency", "in", "self", ".", "dependencies", ":", "dependencies", ".", "append", "(", "dependency", ".", "name", ")", "return", "dependencies" ]
Returns a list of dependency names.
[ "Returns", "a", "list", "of", "dependency", "names", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L57-L62
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Tasks.get_task
def get_task(self, name): """Get task by name or create it if it does not exists.""" if name in self.tasks.keys(): task = self.tasks[name] else: task = Task(name) self.tasks[name] = task return task
python
def get_task(self, name): """Get task by name or create it if it does not exists.""" if name in self.tasks.keys(): task = self.tasks[name] else: task = Task(name) self.tasks[name] = task return task
[ "def", "get_task", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "tasks", ".", "keys", "(", ")", ":", "task", "=", "self", ".", "tasks", "[", "name", "]", "else", ":", "task", "=", "Task", "(", "name", ")", "self", ".", ...
Get task by name or create it if it does not exists.
[ "Get", "task", "by", "name", "or", "create", "it", "if", "it", "does", "not", "exists", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L97-L104
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Tasks.get_next
def get_next(self): """Return next task from the stack that has all dependencies resolved. Return None if there are no tasks with resolved dependencies or is there are no more tasks on stack. Use `count` to check is there are still some task left on the stack. raise ValueError if total ...
python
def get_next(self): """Return next task from the stack that has all dependencies resolved. Return None if there are no tasks with resolved dependencies or is there are no more tasks on stack. Use `count` to check is there are still some task left on the stack. raise ValueError if total ...
[ "def", "get_next", "(", "self", ")", ":", "self", ".", "update_tasks_status", "(", ")", "if", "self", ".", "dirty", ":", "self", ".", "tsort", "(", ")", "self", ".", "dirty", "=", "False", "for", "key", ",", "task", "in", "self", ".", "tasks", ".",...
Return next task from the stack that has all dependencies resolved. Return None if there are no tasks with resolved dependencies or is there are no more tasks on stack. Use `count` to check is there are still some task left on the stack. raise ValueError if total ordering is not possible.
[ "Return", "next", "task", "from", "the", "stack", "that", "has", "all", "dependencies", "resolved", ".", "Return", "None", "if", "there", "are", "no", "tasks", "with", "resolved", "dependencies", "or", "is", "there", "are", "no", "more", "tasks", "on", "st...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L114-L131
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Tasks.count_buildable_tasks
def count_buildable_tasks(self): """Count tasks that are new and have dependencies in non FAILED state.""" self.update_tasks_status() buildable_tasks_count = 0 for key, task in self.tasks.iteritems(): if task.state is Task.State.NEW: if self.are_dependencies_b...
python
def count_buildable_tasks(self): """Count tasks that are new and have dependencies in non FAILED state.""" self.update_tasks_status() buildable_tasks_count = 0 for key, task in self.tasks.iteritems(): if task.state is Task.State.NEW: if self.are_dependencies_b...
[ "def", "count_buildable_tasks", "(", "self", ")", ":", "self", ".", "update_tasks_status", "(", ")", "buildable_tasks_count", "=", "0", "for", "key", ",", "task", "in", "self", ".", "tasks", ".", "iteritems", "(", ")", ":", "if", "task", ".", "state", "i...
Count tasks that are new and have dependencies in non FAILED state.
[ "Count", "tasks", "that", "are", "new", "and", "have", "dependencies", "in", "non", "FAILED", "state", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L165-L177
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Tasks.filter_tasks
def filter_tasks(self, task_names, keep_dependencies=False): """If filter is applied only tasks with given name and its dependencies (if keep_keep_dependencies=True) are kept in the list of tasks.""" new_tasks = {} for task_name in task_names: task = self.get_task(task_name) ...
python
def filter_tasks(self, task_names, keep_dependencies=False): """If filter is applied only tasks with given name and its dependencies (if keep_keep_dependencies=True) are kept in the list of tasks.""" new_tasks = {} for task_name in task_names: task = self.get_task(task_name) ...
[ "def", "filter_tasks", "(", "self", ",", "task_names", ",", "keep_dependencies", "=", "False", ")", ":", "new_tasks", "=", "{", "}", "for", "task_name", "in", "task_names", ":", "task", "=", "self", ".", "get_task", "(", "task_name", ")", "if", "task", "...
If filter is applied only tasks with given name and its dependencies (if keep_keep_dependencies=True) are kept in the list of tasks.
[ "If", "filter", "is", "applied", "only", "tasks", "with", "given", "name", "and", "its", "dependencies", "(", "if", "keep_keep_dependencies", "=", "True", ")", "are", "kept", "in", "the", "list", "of", "tasks", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L179-L194
project-ncl/pnc-cli
pnc_cli/tools/tasks.py
Tasks.tsort
def tsort(self): """Given a partial ordering, return a totally ordered list. part is a dict of partial orderings. Each value is a set, which the key depends on. The return value is a list of sets, each of which has only dependencies on items in previous entries in the list. ...
python
def tsort(self): """Given a partial ordering, return a totally ordered list. part is a dict of partial orderings. Each value is a set, which the key depends on. The return value is a list of sets, each of which has only dependencies on items in previous entries in the list. ...
[ "def", "tsort", "(", "self", ")", ":", "task_dict", "=", "{", "}", "for", "key", ",", "task", "in", "self", ".", "tasks", ".", "iteritems", "(", ")", ":", "task_dict", "[", "task", "]", "=", "task", ".", "dependencies", "# parts = parts.copy()", "parts...
Given a partial ordering, return a totally ordered list. part is a dict of partial orderings. Each value is a set, which the key depends on. The return value is a list of sets, each of which has only dependencies on items in previous entries in the list. raise ValueError if o...
[ "Given", "a", "partial", "ordering", "return", "a", "totally", "ordered", "list", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/tools/tasks.py#L197-L223
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/buildtasks_api.py
BuildtasksApi.build
def build(self, build_execution_configuration, **kwargs): """ Triggers the build execution for a given configuration. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when rec...
python
def build(self, build_execution_configuration, **kwargs): """ Triggers the build execution for a given configuration. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when rec...
[ "def", "build", "(", "self", ",", "build_execution_configuration", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "build_with_htt...
Triggers the build execution for a given configuration. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> ...
[ "Triggers", "the", "build", "execution", "for", "a", "given", "configuration", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", "a", "callbac...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildtasks_api.py#L42-L68
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/buildtasks_api.py
BuildtasksApi.build_task_completed
def build_task_completed(self, task_id, build_result, **kwargs): """ Notifies the completion of externally managed build task process. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be...
python
def build_task_completed(self, task_id, build_result, **kwargs): """ Notifies the completion of externally managed build task process. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be...
[ "def", "build_task_completed", "(", "self", ",", "task_id", ",", "build_result", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".",...
Notifies the completion of externally managed build task process. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): ...
[ "Notifies", "the", "completion", "of", "externally", "managed", "build", "task", "process", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", ...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildtasks_api.py#L156-L181
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/buildtasks_api.py
BuildtasksApi.cancel_bbuild
def cancel_bbuild(self, build_execution_configuration_id, **kwargs): """ Cancel the build execution defined with given executionConfigurationId. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function ...
python
def cancel_bbuild(self, build_execution_configuration_id, **kwargs): """ Cancel the build execution defined with given executionConfigurationId. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function ...
[ "def", "cancel_bbuild", "(", "self", ",", "build_execution_configuration_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "can...
Cancel the build execution defined with given executionConfigurationId. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(respons...
[ "Cancel", "the", "build", "execution", "defined", "with", "given", "executionConfigurationId", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", ...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/buildtasks_api.py#L269-L293
PythonRails/rails
rails/config.py
Config._load_config
def _load_config(self): """ Load project's config and return dict. TODO: Convert the original dotted representation to hierarchical. """ config = import_module('config') variables = [var for var in dir(config) if not var.startswith('_')] return {var: getattr(conf...
python
def _load_config(self): """ Load project's config and return dict. TODO: Convert the original dotted representation to hierarchical. """ config = import_module('config') variables = [var for var in dir(config) if not var.startswith('_')] return {var: getattr(conf...
[ "def", "_load_config", "(", "self", ")", ":", "config", "=", "import_module", "(", "'config'", ")", "variables", "=", "[", "var", "for", "var", "in", "dir", "(", "config", ")", "if", "not", "var", ".", "startswith", "(", "'_'", ")", "]", "return", "{...
Load project's config and return dict. TODO: Convert the original dotted representation to hierarchical.
[ "Load", "project", "s", "config", "and", "return", "dict", "." ]
train
https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/config.py#L18-L26
PythonRails/rails
rails/config.py
Config.get
def get(name, default=None): """ Return variable by name from the project's config. Name can be a dotted path, like: 'rails.db.type'. """ if '.' not in name: raise Exception("Config path should be divided by at least one dot") section_name, var_path = name.sp...
python
def get(name, default=None): """ Return variable by name from the project's config. Name can be a dotted path, like: 'rails.db.type'. """ if '.' not in name: raise Exception("Config path should be divided by at least one dot") section_name, var_path = name.sp...
[ "def", "get", "(", "name", ",", "default", "=", "None", ")", ":", "if", "'.'", "not", "in", "name", ":", "raise", "Exception", "(", "\"Config path should be divided by at least one dot\"", ")", "section_name", ",", "var_path", "=", "name", ".", "split", "(", ...
Return variable by name from the project's config. Name can be a dotted path, like: 'rails.db.type'.
[ "Return", "variable", "by", "name", "from", "the", "project", "s", "config", "." ]
train
https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/config.py#L29-L39
CivicSpleen/ambry
ambry/util/sortedcollection.py
SortedCollection.find_le
def find_le(self, k): 'Return last item with a key <= k. Raise ValueError if not found.' i = bisect_right(self._keys, k) if i: return self._items[i - 1] raise ValueError('No item found with key at or below: %r' % (k,))
python
def find_le(self, k): 'Return last item with a key <= k. Raise ValueError if not found.' i = bisect_right(self._keys, k) if i: return self._items[i - 1] raise ValueError('No item found with key at or below: %r' % (k,))
[ "def", "find_le", "(", "self", ",", "k", ")", ":", "i", "=", "bisect_right", "(", "self", ".", "_keys", ",", "k", ")", "if", "i", ":", "return", "self", ".", "_items", "[", "i", "-", "1", "]", "raise", "ValueError", "(", "'No item found with key at o...
Return last item with a key <= k. Raise ValueError if not found.
[ "Return", "last", "item", "with", "a", "key", "<", "=", "k", ".", "Raise", "ValueError", "if", "not", "found", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L186-L191
CivicSpleen/ambry
ambry/util/sortedcollection.py
SortedCollection.find_le_index
def find_le_index(self, k): 'Return last item with a key <= k. Raise ValueError if not found.' i = bisect_right(self._keys, k) if i: return i - 1 raise ValueError('No item found with key at or below: %r' % (k,))
python
def find_le_index(self, k): 'Return last item with a key <= k. Raise ValueError if not found.' i = bisect_right(self._keys, k) if i: return i - 1 raise ValueError('No item found with key at or below: %r' % (k,))
[ "def", "find_le_index", "(", "self", ",", "k", ")", ":", "i", "=", "bisect_right", "(", "self", ".", "_keys", ",", "k", ")", "if", "i", ":", "return", "i", "-", "1", "raise", "ValueError", "(", "'No item found with key at or below: %r'", "%", "(", "k", ...
Return last item with a key <= k. Raise ValueError if not found.
[ "Return", "last", "item", "with", "a", "key", "<", "=", "k", ".", "Raise", "ValueError", "if", "not", "found", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L193-L198
CivicSpleen/ambry
ambry/util/sortedcollection.py
SortedCollection.find_lt
def find_lt(self, k): """Return last item with a key < k. Raise ValueError if not found. """ i = bisect_left(self._keys, k) if i: return self._items[i - 1] raise ValueError('No item found with key below: %r' % (k,))
python
def find_lt(self, k): """Return last item with a key < k. Raise ValueError if not found. """ i = bisect_left(self._keys, k) if i: return self._items[i - 1] raise ValueError('No item found with key below: %r' % (k,))
[ "def", "find_lt", "(", "self", ",", "k", ")", ":", "i", "=", "bisect_left", "(", "self", ".", "_keys", ",", "k", ")", "if", "i", ":", "return", "self", ".", "_items", "[", "i", "-", "1", "]", "raise", "ValueError", "(", "'No item found with key below...
Return last item with a key < k. Raise ValueError if not found.
[ "Return", "last", "item", "with", "a", "key", "<", "k", "." ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L200-L209
CivicSpleen/ambry
ambry/util/sortedcollection.py
SortedCollection.find_ge_index
def find_ge_index(self, k): 'Return first item with a key >= equal to k. Raise ValueError if not found' i = bisect_left(self._keys, k) if i != len(self): return i raise ValueError('No item found with key at or above: %r' % (k,))
python
def find_ge_index(self, k): 'Return first item with a key >= equal to k. Raise ValueError if not found' i = bisect_left(self._keys, k) if i != len(self): return i raise ValueError('No item found with key at or above: %r' % (k,))
[ "def", "find_ge_index", "(", "self", ",", "k", ")", ":", "i", "=", "bisect_left", "(", "self", ".", "_keys", ",", "k", ")", "if", "i", "!=", "len", "(", "self", ")", ":", "return", "i", "raise", "ValueError", "(", "'No item found with key at or above: %r...
Return first item with a key >= equal to k. Raise ValueError if not found
[ "Return", "first", "item", "with", "a", "key", ">", "=", "equal", "to", "k", ".", "Raise", "ValueError", "if", "not", "found" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/sortedcollection.py#L218-L223
andreafioraldi/angrdbg
angrdbg/brk.py
get_dbg_brk_linux64
def get_dbg_brk_linux64(): ''' Return the current brk value in the debugged process (only x86_64 Linux) ''' # TODO this method is so weird, find a unused address to inject code not # the base address debugger = get_debugger() code = b'\x0f\x05' # syscall rax = debugger.get_reg("rax")...
python
def get_dbg_brk_linux64(): ''' Return the current brk value in the debugged process (only x86_64 Linux) ''' # TODO this method is so weird, find a unused address to inject code not # the base address debugger = get_debugger() code = b'\x0f\x05' # syscall rax = debugger.get_reg("rax")...
[ "def", "get_dbg_brk_linux64", "(", ")", ":", "# TODO this method is so weird, find a unused address to inject code not", "# the base address", "debugger", "=", "get_debugger", "(", ")", "code", "=", "b'\\x0f\\x05'", "# syscall", "rax", "=", "debugger", ".", "get_reg", "(", ...
Return the current brk value in the debugged process (only x86_64 Linux)
[ "Return", "the", "current", "brk", "value", "in", "the", "debugged", "process", "(", "only", "x86_64", "Linux", ")" ]
train
https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/brk.py#L11-L52
andreafioraldi/angrdbg
angrdbg/brk.py
get_dbg_brk_linux32
def get_dbg_brk_linux32(): ''' Return the current brk value in the debugged process (only x86 Linux) ''' # TODO this method is so weird, find a unused address to inject code not # the base address debugger = get_debugger() code = b'\xcd\x80' # int 0x80 eax = debugger.get_reg("eax") ...
python
def get_dbg_brk_linux32(): ''' Return the current brk value in the debugged process (only x86 Linux) ''' # TODO this method is so weird, find a unused address to inject code not # the base address debugger = get_debugger() code = b'\xcd\x80' # int 0x80 eax = debugger.get_reg("eax") ...
[ "def", "get_dbg_brk_linux32", "(", ")", ":", "# TODO this method is so weird, find a unused address to inject code not", "# the base address", "debugger", "=", "get_debugger", "(", ")", "code", "=", "b'\\xcd\\x80'", "# int 0x80", "eax", "=", "debugger", ".", "get_reg", "(",...
Return the current brk value in the debugged process (only x86 Linux)
[ "Return", "the", "current", "brk", "value", "in", "the", "debugged", "process", "(", "only", "x86", "Linux", ")" ]
train
https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/brk.py#L55-L96
and800/aioreloader
aioreloader/_contents.py
start
def start( loop: abstract_loop = None, interval: float = 0.5, hook: hook_type = None) -> asyncio.Task: """ Start the reloader. Create the task which is watching loaded modules and manually added files via ``watch()`` and reloading the process in case of modification. Att...
python
def start( loop: abstract_loop = None, interval: float = 0.5, hook: hook_type = None) -> asyncio.Task: """ Start the reloader. Create the task which is watching loaded modules and manually added files via ``watch()`` and reloading the process in case of modification. Att...
[ "def", "start", "(", "loop", ":", "abstract_loop", "=", "None", ",", "interval", ":", "float", "=", "0.5", ",", "hook", ":", "hook_type", "=", "None", ")", "->", "asyncio", ".", "Task", ":", "if", "loop", "is", "None", ":", "loop", "=", "asyncio", ...
Start the reloader. Create the task which is watching loaded modules and manually added files via ``watch()`` and reloading the process in case of modification. Attach this task to the loop. If ``hook`` is provided, it will be called right before the application goes to the reload stage.
[ "Start", "the", "reloader", "." ]
train
https://github.com/and800/aioreloader/blob/9f44b537b69185be4f19d31d9427afdc195a8abd/aioreloader/_contents.py#L29-L62
SmartTeleMax/iktomi
iktomi/utils/dt.py
strftime
def strftime(dt, fmt): ''' `strftime` implementation working before 1900 ''' if _illegal_s.search(fmt): raise TypeError("This strftime implementation does not handle %s") if dt.year > 1900: return dt.strftime(fmt) fmt = fmt.replace('%c', '%a %b %d %H:%M:%S %Y')\ .re...
python
def strftime(dt, fmt): ''' `strftime` implementation working before 1900 ''' if _illegal_s.search(fmt): raise TypeError("This strftime implementation does not handle %s") if dt.year > 1900: return dt.strftime(fmt) fmt = fmt.replace('%c', '%a %b %d %H:%M:%S %Y')\ .re...
[ "def", "strftime", "(", "dt", ",", "fmt", ")", ":", "if", "_illegal_s", ".", "search", "(", "fmt", ")", ":", "raise", "TypeError", "(", "\"This strftime implementation does not handle %s\"", ")", "if", "dt", ".", "year", ">", "1900", ":", "return", "dt", "...
`strftime` implementation working before 1900
[ "strftime", "implementation", "working", "before", "1900" ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/dt.py#L19-L42
CivicSpleen/ambry
ambry/cli/library.py
library_pg
def library_pg(args, l, config): """Report on the operation of a Postgres Library database""" import tabulate import terminaltables from textwrap import fill from ambry.util.text import getTerminalSize import sys if args.connect: try: l.database.connection.execute('SELEC...
python
def library_pg(args, l, config): """Report on the operation of a Postgres Library database""" import tabulate import terminaltables from textwrap import fill from ambry.util.text import getTerminalSize import sys if args.connect: try: l.database.connection.execute('SELEC...
[ "def", "library_pg", "(", "args", ",", "l", ",", "config", ")", ":", "import", "tabulate", "import", "terminaltables", "from", "textwrap", "import", "fill", "from", "ambry", ".", "util", ".", "text", "import", "getTerminalSize", "import", "sys", "if", "args"...
Report on the operation of a Postgres Library database
[ "Report", "on", "the", "operation", "of", "a", "Postgres", "Library", "database" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/cli/library.py#L117-L228
mithro/python-datetime-tz
datetime_tz/detect_windows.py
_detect_timezone_windows
def _detect_timezone_windows(): """Detect timezone on the windows platform.""" # pylint: disable=global-statement global win32timezone_to_en # Try and fetch the key_name for the timezone using # Get(Dynamic)TimeZoneInformation tzi = DTZI_c() kernel32 = ctypes.windll.kernel32 getter = kernel32.GetTimeZo...
python
def _detect_timezone_windows(): """Detect timezone on the windows platform.""" # pylint: disable=global-statement global win32timezone_to_en # Try and fetch the key_name for the timezone using # Get(Dynamic)TimeZoneInformation tzi = DTZI_c() kernel32 = ctypes.windll.kernel32 getter = kernel32.GetTimeZo...
[ "def", "_detect_timezone_windows", "(", ")", ":", "# pylint: disable=global-statement", "global", "win32timezone_to_en", "# Try and fetch the key_name for the timezone using", "# Get(Dynamic)TimeZoneInformation", "tzi", "=", "DTZI_c", "(", ")", "kernel32", "=", "ctypes", ".", "...
Detect timezone on the windows platform.
[ "Detect", "timezone", "on", "the", "windows", "platform", "." ]
train
https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/detect_windows.py#L89-L126
SmartTeleMax/iktomi
iktomi/auth.py
encrypt_password
def encrypt_password(raw_password, algorithm='sha1', salt=None): """ Returns a string of the hexdigest of the given plaintext password and salt using the given algorithm ('md5', 'sha1' or other supported by hashlib). """ if salt is None: salt = binascii.hexlify(os.urandom(3))[:5] else: ...
python
def encrypt_password(raw_password, algorithm='sha1', salt=None): """ Returns a string of the hexdigest of the given plaintext password and salt using the given algorithm ('md5', 'sha1' or other supported by hashlib). """ if salt is None: salt = binascii.hexlify(os.urandom(3))[:5] else: ...
[ "def", "encrypt_password", "(", "raw_password", ",", "algorithm", "=", "'sha1'", ",", "salt", "=", "None", ")", ":", "if", "salt", "is", "None", ":", "salt", "=", "binascii", ".", "hexlify", "(", "os", ".", "urandom", "(", "3", ")", ")", "[", ":", ...
Returns a string of the hexdigest of the given plaintext password and salt using the given algorithm ('md5', 'sha1' or other supported by hashlib).
[ "Returns", "a", "string", "of", "the", "hexdigest", "of", "the", "given", "plaintext", "password", "and", "salt", "using", "the", "given", "algorithm", "(", "md5", "sha1", "or", "other", "supported", "by", "hashlib", ")", "." ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L18-L30
SmartTeleMax/iktomi
iktomi/auth.py
check_password
def check_password(raw_password, enc_password): """ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes. """ algo, salt, hsh = enc_password.split('$') return enc_password == encrypt_password(raw_password, algorithm=algo, ...
python
def check_password(raw_password, enc_password): """ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes. """ algo, salt, hsh = enc_password.split('$') return enc_password == encrypt_password(raw_password, algorithm=algo, ...
[ "def", "check_password", "(", "raw_password", ",", "enc_password", ")", ":", "algo", ",", "salt", ",", "hsh", "=", "enc_password", ".", "split", "(", "'$'", ")", "return", "enc_password", "==", "encrypt_password", "(", "raw_password", ",", "algorithm", "=", ...
Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes.
[ "Returns", "a", "boolean", "of", "whether", "the", "raw_password", "was", "correct", ".", "Handles", "encryption", "formats", "behind", "the", "scenes", "." ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L33-L40
SmartTeleMax/iktomi
iktomi/auth.py
CookieAuth.login
def login(self, template='login'): ''' This property will return component which will handle login requests. auth.login(template='login.html') ''' def _login(env, data): form = self._login_form(env) next = env.request.GET.get('next', '/') ...
python
def login(self, template='login'): ''' This property will return component which will handle login requests. auth.login(template='login.html') ''' def _login(env, data): form = self._login_form(env) next = env.request.GET.get('next', '/') ...
[ "def", "login", "(", "self", ",", "template", "=", "'login'", ")", ":", "def", "_login", "(", "env", ",", "data", ")", ":", "form", "=", "self", ".", "_login_form", "(", "env", ")", "next", "=", "env", ".", "request", ".", "GET", ".", "get", "(",...
This property will return component which will handle login requests. auth.login(template='login.html')
[ "This", "property", "will", "return", "component", "which", "will", "handle", "login", "requests", "." ]
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L104-L126
SmartTeleMax/iktomi
iktomi/auth.py
CookieAuth.logout
def logout(self, redirect_to='/'): ''' This property will return component which will handle logout requests. It only handles POST requests and do not display any rendered content. This handler deletes session id from `storage`. If there is no session id provided or id is incorre...
python
def logout(self, redirect_to='/'): ''' This property will return component which will handle logout requests. It only handles POST requests and do not display any rendered content. This handler deletes session id from `storage`. If there is no session id provided or id is incorre...
[ "def", "logout", "(", "self", ",", "redirect_to", "=", "'/'", ")", ":", "def", "_logout", "(", "env", ",", "data", ")", ":", "location", "=", "redirect_to", "if", "location", "is", "None", "and", "env", ".", "request", ".", "referer", ":", "location", ...
This property will return component which will handle logout requests. It only handles POST requests and do not display any rendered content. This handler deletes session id from `storage`. If there is no session id provided or id is incorrect handler silently redirects to login url and ...
[ "This", "property", "will", "return", "component", "which", "will", "handle", "logout", "requests", ".", "It", "only", "handles", "POST", "requests", "and", "do", "not", "display", "any", "rendered", "content", ".", "This", "handler", "deletes", "session", "id...
train
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/auth.py#L128-L145
project-ncl/pnc-cli
pnc_cli/swagger_client/models/support_level_page.py
SupportLevelPage.content
def content(self, content): """ Sets the content of this SupportLevelPage. :param content: The content of this SupportLevelPage. :type: list[str] """ allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"] if not set(content).issubs...
python
def content(self, content): """ Sets the content of this SupportLevelPage. :param content: The content of this SupportLevelPage. :type: list[str] """ allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"] if not set(content).issubs...
[ "def", "content", "(", "self", ",", "content", ")", ":", "allowed_values", "=", "[", "\"UNRELEASED\"", ",", "\"EARLYACCESS\"", ",", "\"SUPPORTED\"", ",", "\"EXTENDED_SUPPORT\"", ",", "\"EOL\"", "]", "if", "not", "set", "(", "content", ")", ".", "issubset", "...
Sets the content of this SupportLevelPage. :param content: The content of this SupportLevelPage. :type: list[str]
[ "Sets", "the", "content", "of", "this", "SupportLevelPage", "." ]
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/support_level_page.py#L140-L155
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/bpm_api.py
BpmApi.get_bpm_task_by_id
def get_bpm_task_by_id(self, task_id, **kwargs): """ Get single (recently) active BPM task. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. ...
python
def get_bpm_task_by_id(self, task_id, **kwargs): """ Get single (recently) active BPM task. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. ...
[ "def", "get_bpm_task_by_id", "(", "self", ",", "task_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "get_bpm_task_by_id_with...
Get single (recently) active BPM task. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(respon...
[ "Get", "single", "(", "recently", ")", "active", "BPM", "task", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", "a", "callback", "function...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/bpm_api.py#L42-L66
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/bpm_api.py
BpmApi.get_bpm_tasks
def get_bpm_tasks(self, **kwargs): """ List of (recently) active BPM tasks. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callb...
python
def get_bpm_tasks(self, **kwargs): """ List of (recently) active BPM tasks. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callb...
[ "def", "get_bpm_tasks", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "get_bpm_tasks_with_http_info", "(", "*", "...
List of (recently) active BPM tasks. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(response): >>> pprint(response...
[ "List", "of", "(", "recently", ")", "active", "BPM", "tasks", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "define", "a", "callback", "function",...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/bpm_api.py#L148-L173
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/bpm_api.py
BpmApi.notify_task
def notify_task(self, task_id, **kwargs): """ Notify PNC about a BPM task event. Accepts polymorphic JSON {\"eventType\": \"string\"} based on \"eventType\" field. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `cal...
python
def notify_task(self, task_id, **kwargs): """ Notify PNC about a BPM task event. Accepts polymorphic JSON {\"eventType\": \"string\"} based on \"eventType\" field. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `cal...
[ "def", "notify_task", "(", "self", ",", "task_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "notify_task_with_http_info", ...
Notify PNC about a BPM task event. Accepts polymorphic JSON {\"eventType\": \"string\"} based on \"eventType\" field. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the respo...
[ "Notify", "PNC", "about", "a", "BPM", "task", "event", ".", "Accepts", "polymorphic", "JSON", "{", "\\", "eventType", "\\", ":", "\\", "string", "\\", "}", "based", "on", "\\", "eventType", "\\", "field", ".", "This", "method", "makes", "a", "synchronous...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/bpm_api.py#L255-L279
project-ncl/pnc-cli
pnc_cli/swagger_client/apis/bpm_api.py
BpmApi.start_r_creation_task_with_single_url
def start_r_creation_task_with_single_url(self, body, **kwargs): """ Start Repository Creation task with url autodetect (internal vs. external). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function ...
python
def start_r_creation_task_with_single_url(self, body, **kwargs): """ Start Repository Creation task with url autodetect (internal vs. external). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function ...
[ "def", "start_r_creation_task_with_single_url", "(", "self", ",", "body", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'callback'", ")", ":", "return", "self", ".", "start_r...
Start Repository Creation task with url autodetect (internal vs. external). This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. >>> def callback_function(res...
[ "Start", "Repository", "Creation", "task", "with", "url", "autodetect", "(", "internal", "vs", ".", "external", ")", ".", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "req...
train
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/bpm_api.py#L361-L385
CivicSpleen/ambry
ambry/util/flo.py
copy_file_or_flo
def copy_file_or_flo(input_, output, buffer_size=64 * 1024, cb=None): """ Copy a file name or file-like-object to another file name or file-like object""" assert bool(input_) assert bool(output) input_opened = False output_opened = False try: if isinstance(input_, string_types): ...
python
def copy_file_or_flo(input_, output, buffer_size=64 * 1024, cb=None): """ Copy a file name or file-like-object to another file name or file-like object""" assert bool(input_) assert bool(output) input_opened = False output_opened = False try: if isinstance(input_, string_types): ...
[ "def", "copy_file_or_flo", "(", "input_", ",", "output", ",", "buffer_size", "=", "64", "*", "1024", ",", "cb", "=", "None", ")", ":", "assert", "bool", "(", "input_", ")", "assert", "bool", "(", "output", ")", "input_opened", "=", "False", "output_opene...
Copy a file name or file-like-object to another file name or file-like object
[ "Copy", "a", "file", "name", "or", "file", "-", "like", "-", "object", "to", "another", "file", "name", "or", "file", "-", "like", "object" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/flo.py#L38-L85
caktus/rapidsms-tropo
rtropo/outgoing.py
TropoBackend.configure
def configure(self, config=None, **kwargs): """ We expect all of our config (apart from the ENGINE) to be in a dictionary called 'config' in our INSTALLED_BACKENDS entry """ self.config = config or {} for key in ['messaging_token', 'number']: if key not in sel...
python
def configure(self, config=None, **kwargs): """ We expect all of our config (apart from the ENGINE) to be in a dictionary called 'config' in our INSTALLED_BACKENDS entry """ self.config = config or {} for key in ['messaging_token', 'number']: if key not in sel...
[ "def", "configure", "(", "self", ",", "config", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "config", "=", "config", "or", "{", "}", "for", "key", "in", "[", "'messaging_token'", ",", "'number'", "]", ":", "if", "key", "not", "in",...
We expect all of our config (apart from the ENGINE) to be in a dictionary called 'config' in our INSTALLED_BACKENDS entry
[ "We", "expect", "all", "of", "our", "config", "(", "apart", "from", "the", "ENGINE", ")", "to", "be", "in", "a", "dictionary", "called", "config", "in", "our", "INSTALLED_BACKENDS", "entry" ]
train
https://github.com/caktus/rapidsms-tropo/blob/7680f351053837f210bf90576fa8f947c8f1c5c6/rtropo/outgoing.py#L20-L34
caktus/rapidsms-tropo
rtropo/outgoing.py
TropoBackend.execute_tropo_program
def execute_tropo_program(self, program): """ Ask Tropo to execute a program for us. We can't do this directly; we have to ask Tropo to call us back and then give Tropo the program in the response body to that request from Tropo. But we can pass data to Tropo and ask Tr...
python
def execute_tropo_program(self, program): """ Ask Tropo to execute a program for us. We can't do this directly; we have to ask Tropo to call us back and then give Tropo the program in the response body to that request from Tropo. But we can pass data to Tropo and ask Tr...
[ "def", "execute_tropo_program", "(", "self", ",", "program", ")", ":", "# The signer will also \"pickle\" the data structure for us", "signed_program", "=", "signing", ".", "dumps", "(", "program", ")", "params", "=", "{", "'action'", ":", "'create'", ",", "# Required...
Ask Tropo to execute a program for us. We can't do this directly; we have to ask Tropo to call us back and then give Tropo the program in the response body to that request from Tropo. But we can pass data to Tropo and ask Tropo to pass it back to us when Tropo calls us back. So...
[ "Ask", "Tropo", "to", "execute", "a", "program", "for", "us", "." ]
train
https://github.com/caktus/rapidsms-tropo/blob/7680f351053837f210bf90576fa8f947c8f1c5c6/rtropo/outgoing.py#L40-L96
caktus/rapidsms-tropo
rtropo/outgoing.py
TropoBackend.send
def send(self, id_, text, identities, context=None): """ Send messages when using RapidSMS 0.14.0 or later. We can send multiple messages in one Tropo program, so we do that. :param id_: Unused, included for compatibility with RapidSMS. :param string text: The message t...
python
def send(self, id_, text, identities, context=None): """ Send messages when using RapidSMS 0.14.0 or later. We can send multiple messages in one Tropo program, so we do that. :param id_: Unused, included for compatibility with RapidSMS. :param string text: The message t...
[ "def", "send", "(", "self", ",", "id_", ",", "text", ",", "identities", ",", "context", "=", "None", ")", ":", "# Build our program", "from_", "=", "self", ".", "config", "[", "'number'", "]", ".", "replace", "(", "'-'", ",", "''", ")", "commands", "...
Send messages when using RapidSMS 0.14.0 or later. We can send multiple messages in one Tropo program, so we do that. :param id_: Unused, included for compatibility with RapidSMS. :param string text: The message text to send. :param identities: A list of identities to send the ...
[ "Send", "messages", "when", "using", "RapidSMS", "0", ".", "14", ".", "0", "or", "later", "." ]
train
https://github.com/caktus/rapidsms-tropo/blob/7680f351053837f210bf90576fa8f947c8f1c5c6/rtropo/outgoing.py#L98-L135
CivicSpleen/ambry
ambry/valuetype/geo.py
CensusTractGeoid.dotted
def dotted(self): """Return just the tract number, excluding the state and county, in the dotted format""" v = str(self.geoid.tract).zfill(6) return v[0:4] + '.' + v[4:]
python
def dotted(self): """Return just the tract number, excluding the state and county, in the dotted format""" v = str(self.geoid.tract).zfill(6) return v[0:4] + '.' + v[4:]
[ "def", "dotted", "(", "self", ")", ":", "v", "=", "str", "(", "self", ".", "geoid", ".", "tract", ")", ".", "zfill", "(", "6", ")", "return", "v", "[", "0", ":", "4", "]", "+", "'.'", "+", "v", "[", "4", ":", "]" ]
Return just the tract number, excluding the state and county, in the dotted format
[ "Return", "just", "the", "tract", "number", "excluding", "the", "state", "and", "county", "in", "the", "dotted", "format" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/geo.py#L115-L118
CivicSpleen/ambry
ambry/valuetype/geo.py
GeoCensusVT.subclass
def subclass(cls, vt_code, vt_args): """Return a dynamic subclass that has the extra parameters built in""" from geoid import get_class import geoid.census parser = get_class(geoid.census, vt_args.strip('/')).parse cls = type(vt_code.replace('/', '_'), (cls,), {'vt_code': vt_co...
python
def subclass(cls, vt_code, vt_args): """Return a dynamic subclass that has the extra parameters built in""" from geoid import get_class import geoid.census parser = get_class(geoid.census, vt_args.strip('/')).parse cls = type(vt_code.replace('/', '_'), (cls,), {'vt_code': vt_co...
[ "def", "subclass", "(", "cls", ",", "vt_code", ",", "vt_args", ")", ":", "from", "geoid", "import", "get_class", "import", "geoid", ".", "census", "parser", "=", "get_class", "(", "geoid", ".", "census", ",", "vt_args", ".", "strip", "(", "'/'", ")", "...
Return a dynamic subclass that has the extra parameters built in
[ "Return", "a", "dynamic", "subclass", "that", "has", "the", "extra", "parameters", "built", "in" ]
train
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/valuetype/geo.py#L139-L150
derpston/python-multitail2
src/multitail2.py
TailedFile._open
def _open(self, path, skip_to_end = True, offset = None): """Open `path`, optionally seeking to the end if `skip_to_end` is True.""" fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK)) # If the file is being opened for the first time, jump to the end. # Otherwise, it is being reopened af...
python
def _open(self, path, skip_to_end = True, offset = None): """Open `path`, optionally seeking to the end if `skip_to_end` is True.""" fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK)) # If the file is being opened for the first time, jump to the end. # Otherwise, it is being reopened af...
[ "def", "_open", "(", "self", ",", "path", ",", "skip_to_end", "=", "True", ",", "offset", "=", "None", ")", ":", "fh", "=", "os", ".", "fdopen", "(", "os", ".", "open", "(", "path", ",", "os", ".", "O_RDONLY", "|", "os", ".", "O_NONBLOCK", ")", ...
Open `path`, optionally seeking to the end if `skip_to_end` is True.
[ "Open", "path", "optionally", "seeking", "to", "the", "end", "if", "skip_to_end", "is", "True", "." ]
train
https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L27-L47
derpston/python-multitail2
src/multitail2.py
TailedFile._read
def _read(self, limit = None): """Checks the file for new data and refills the buffer if it finds any.""" # The code that used to be here was self._fh.read(limit) # However, this broke on OSX. os.read, however, works fine, but doesn't # take the None argument or have any way to specify "read to ...
python
def _read(self, limit = None): """Checks the file for new data and refills the buffer if it finds any.""" # The code that used to be here was self._fh.read(limit) # However, this broke on OSX. os.read, however, works fine, but doesn't # take the None argument or have any way to specify "read to ...
[ "def", "_read", "(", "self", ",", "limit", "=", "None", ")", ":", "# The code that used to be here was self._fh.read(limit)", "# However, this broke on OSX. os.read, however, works fine, but doesn't", "# take the None argument or have any way to specify \"read to the end\".", "# This emula...
Checks the file for new data and refills the buffer if it finds any.
[ "Checks", "the", "file", "for", "new", "data", "and", "refills", "the", "buffer", "if", "it", "finds", "any", "." ]
train
https://github.com/derpston/python-multitail2/blob/4f05311da3b18f7a8cfe2877e68e35e88c07298d/src/multitail2.py#L49-L65