repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
contentful/contentful-management.py
contentful_management/entry.py
Entry.update
def update(self, attributes=None): """ Updates the entry with attributes. """ if attributes is None: attributes = {} attributes['content_type_id'] = self.sys['content_type'].id return super(Entry, self).update(attributes)
python
def update(self, attributes=None): """ Updates the entry with attributes. """ if attributes is None: attributes = {} attributes['content_type_id'] = self.sys['content_type'].id return super(Entry, self).update(attributes)
[ "def", "update", "(", "self", ",", "attributes", "=", "None", ")", ":", "if", "attributes", "is", "None", ":", "attributes", "=", "{", "}", "attributes", "[", "'content_type_id'", "]", "=", "self", ".", "sys", "[", "'content_type'", "]", ".", "id", "re...
Updates the entry with attributes.
[ "Updates", "the", "entry", "with", "attributes", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/entry.py#L54-L64
contentful/contentful-management.py
contentful_management/client_proxy.py
ClientProxy.all
def all(self, query=None): """ Gets resource collection for _resource_class. """ if query is None: query = {} return self.client._get( self._url(), query )
python
def all(self, query=None): """ Gets resource collection for _resource_class. """ if query is None: query = {} return self.client._get( self._url(), query )
[ "def", "all", "(", "self", ",", "query", "=", "None", ")", ":", "if", "query", "is", "None", ":", "query", "=", "{", "}", "return", "self", ".", "client", ".", "_get", "(", "self", ".", "_url", "(", ")", ",", "query", ")" ]
Gets resource collection for _resource_class.
[ "Gets", "resource", "collection", "for", "_resource_class", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/client_proxy.py#L33-L43
contentful/contentful-management.py
contentful_management/client_proxy.py
ClientProxy.find
def find(self, resource_id, query=None, **kwargs): """Gets a single resource.""" if query is None: query = {} return self.client._get( self._url(resource_id), query, **kwargs )
python
def find(self, resource_id, query=None, **kwargs): """Gets a single resource.""" if query is None: query = {} return self.client._get( self._url(resource_id), query, **kwargs )
[ "def", "find", "(", "self", ",", "resource_id", ",", "query", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "query", "is", "None", ":", "query", "=", "{", "}", "return", "self", ".", "client", ".", "_get", "(", "self", ".", "_url", "(", ...
Gets a single resource.
[ "Gets", "a", "single", "resource", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/client_proxy.py#L45-L54
contentful/contentful-management.py
contentful_management/client_proxy.py
ClientProxy.create
def create(self, resource_id=None, attributes=None): """ Creates a resource with the given ID (optional) and attributes. """ if attributes is None: attributes = {} result = None if not resource_id: result = self.client._post( self...
python
def create(self, resource_id=None, attributes=None): """ Creates a resource with the given ID (optional) and attributes. """ if attributes is None: attributes = {} result = None if not resource_id: result = self.client._post( self...
[ "def", "create", "(", "self", ",", "resource_id", "=", "None", ",", "attributes", "=", "None", ")", ":", "if", "attributes", "is", "None", ":", "attributes", "=", "{", "}", "result", "=", "None", "if", "not", "resource_id", ":", "result", "=", "self", ...
Creates a resource with the given ID (optional) and attributes.
[ "Creates", "a", "resource", "with", "the", "given", "ID", "(", "optional", ")", "and", "attributes", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/client_proxy.py#L56-L78
contentful/contentful-management.py
contentful_management/client_proxy.py
ClientProxy.delete
def delete(self, resource_id, **kwargs): """ Deletes a resource by ID. """ return self.client._delete(self._url(resource_id), **kwargs)
python
def delete(self, resource_id, **kwargs): """ Deletes a resource by ID. """ return self.client._delete(self._url(resource_id), **kwargs)
[ "def", "delete", "(", "self", ",", "resource_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "client", ".", "_delete", "(", "self", ".", "_url", "(", "resource_id", ")", ",", "*", "*", "kwargs", ")" ]
Deletes a resource by ID.
[ "Deletes", "a", "resource", "by", "ID", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/client_proxy.py#L80-L85
contentful/contentful-management.py
contentful_management/role.py
Role.to_json
def to_json(self): """ Returns the JSON representation of the role. """ result = super(Role, self).to_json() result.update({ 'name': self.name, 'description': self.description, 'permissions': self.permissions, 'policies': self.poli...
python
def to_json(self): """ Returns the JSON representation of the role. """ result = super(Role, self).to_json() result.update({ 'name': self.name, 'description': self.description, 'permissions': self.permissions, 'policies': self.poli...
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "super", "(", "Role", ",", "self", ")", ".", "to_json", "(", ")", "result", ".", "update", "(", "{", "'name'", ":", "self", ".", "name", ",", "'description'", ":", "self", ".", "description", ...
Returns the JSON representation of the role.
[ "Returns", "the", "JSON", "representation", "of", "the", "role", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/role.py#L42-L54
contentful/contentful-management.py
contentful_management/space_membership.py
SpaceMembership.to_json
def to_json(self): """ Returns the JSON representation of the space membership. """ result = super(SpaceMembership, self).to_json() result.update({ 'admin': self.admin, 'roles': self.roles }) return result
python
def to_json(self): """ Returns the JSON representation of the space membership. """ result = super(SpaceMembership, self).to_json() result.update({ 'admin': self.admin, 'roles': self.roles }) return result
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "super", "(", "SpaceMembership", ",", "self", ")", ".", "to_json", "(", ")", "result", ".", "update", "(", "{", "'admin'", ":", "self", ".", "admin", ",", "'roles'", ":", "self", ".", "roles", ...
Returns the JSON representation of the space membership.
[ "Returns", "the", "JSON", "representation", "of", "the", "space", "membership", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/space_membership.py#L28-L38
contentful/contentful-management.py
contentful_management/uploads_proxy.py
UploadsProxy.create
def create(self, file_or_path, **kwargs): """ Creates an upload for the given file or path. """ opened = False if isinstance(file_or_path, str_type()): file_or_path = open(file_or_path, 'rb') opened = True elif not getattr(file_or_path, 'read', Fa...
python
def create(self, file_or_path, **kwargs): """ Creates an upload for the given file or path. """ opened = False if isinstance(file_or_path, str_type()): file_or_path = open(file_or_path, 'rb') opened = True elif not getattr(file_or_path, 'read', Fa...
[ "def", "create", "(", "self", ",", "file_or_path", ",", "*", "*", "kwargs", ")", ":", "opened", "=", "False", "if", "isinstance", "(", "file_or_path", ",", "str_type", "(", ")", ")", ":", "file_or_path", "=", "open", "(", "file_or_path", ",", "'rb'", "...
Creates an upload for the given file or path.
[ "Creates", "an", "upload", "for", "the", "given", "file", "or", "path", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/uploads_proxy.py#L35-L56
contentful/contentful-management.py
contentful_management/uploads_proxy.py
UploadsProxy.find
def find(self, upload_id, **kwargs): """ Finds an upload by ID. """ return super(UploadsProxy, self).find(upload_id, file_upload=True)
python
def find(self, upload_id, **kwargs): """ Finds an upload by ID. """ return super(UploadsProxy, self).find(upload_id, file_upload=True)
[ "def", "find", "(", "self", ",", "upload_id", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "UploadsProxy", ",", "self", ")", ".", "find", "(", "upload_id", ",", "file_upload", "=", "True", ")" ]
Finds an upload by ID.
[ "Finds", "an", "upload", "by", "ID", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/uploads_proxy.py#L58-L63
contentful/contentful-management.py
contentful_management/uploads_proxy.py
UploadsProxy.delete
def delete(self, upload_id): """ Deletes an upload by ID. """ return super(UploadsProxy, self).delete(upload_id, file_upload=True)
python
def delete(self, upload_id): """ Deletes an upload by ID. """ return super(UploadsProxy, self).delete(upload_id, file_upload=True)
[ "def", "delete", "(", "self", ",", "upload_id", ")", ":", "return", "super", "(", "UploadsProxy", ",", "self", ")", ".", "delete", "(", "upload_id", ",", "file_upload", "=", "True", ")" ]
Deletes an upload by ID.
[ "Deletes", "an", "upload", "by", "ID", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/uploads_proxy.py#L65-L70
contentful/contentful-management.py
contentful_management/content_type_field.py
ContentTypeField.to_json
def to_json(self): """ Returns the JSON Representation of the content type field. """ result = { 'name': self.name, 'id': self._real_id(), 'type': self.type, 'localized': self.localized, 'omitted': self.omitted, 're...
python
def to_json(self): """ Returns the JSON Representation of the content type field. """ result = { 'name': self.name, 'id': self._real_id(), 'type': self.type, 'localized': self.localized, 'omitted': self.omitted, 're...
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "{", "'name'", ":", "self", ".", "name", ",", "'id'", ":", "self", ".", "_real_id", "(", ")", ",", "'type'", ":", "self", ".", "type", ",", "'localized'", ":", "self", ".", "localized", ",", ...
Returns the JSON Representation of the content type field.
[ "Returns", "the", "JSON", "Representation", "of", "the", "content", "type", "field", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/content_type_field.py#L38-L60
contentful/contentful-management.py
contentful_management/content_type_field_types.py
LocationField.coerce
def coerce(self, value): """ Coerces value to location hash. """ return { 'lat': float(value.get('lat', value.get('latitude'))), 'lon': float(value.get('lon', value.get('longitude'))) }
python
def coerce(self, value): """ Coerces value to location hash. """ return { 'lat': float(value.get('lat', value.get('latitude'))), 'lon': float(value.get('lon', value.get('longitude'))) }
[ "def", "coerce", "(", "self", ",", "value", ")", ":", "return", "{", "'lat'", ":", "float", "(", "value", ".", "get", "(", "'lat'", ",", "value", ".", "get", "(", "'latitude'", ")", ")", ")", ",", "'lon'", ":", "float", "(", "value", ".", "get", ...
Coerces value to location hash.
[ "Coerces", "value", "to", "location", "hash", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/content_type_field_types.py#L167-L175
contentful/contentful-management.py
contentful_management/snapshot.py
Snapshot.base_url
def base_url(klass, space_id, parent_resource_id, resource_url='entries', resource_id=None, environment_id=None): """ Returns the URI for the snapshot. """ return "spaces/{0}{1}/{2}/{3}/snapshots/{4}".format( space_id, '/environments/{0}'.format(environment_id) i...
python
def base_url(klass, space_id, parent_resource_id, resource_url='entries', resource_id=None, environment_id=None): """ Returns the URI for the snapshot. """ return "spaces/{0}{1}/{2}/{3}/snapshots/{4}".format( space_id, '/environments/{0}'.format(environment_id) i...
[ "def", "base_url", "(", "klass", ",", "space_id", ",", "parent_resource_id", ",", "resource_url", "=", "'entries'", ",", "resource_id", "=", "None", ",", "environment_id", "=", "None", ")", ":", "return", "\"spaces/{0}{1}/{2}/{3}/snapshots/{4}\"", ".", "format", "...
Returns the URI for the snapshot.
[ "Returns", "the", "URI", "for", "the", "snapshot", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/snapshot.py#L38-L49
contentful/contentful-management.py
contentful_management/snapshot.py
Snapshot.to_json
def to_json(self): """ Returns the JSON representation of the snapshot. """ result = super(Snapshot, self).to_json() result.update({ 'snapshot': self.snapshot.to_json(), }) return result
python
def to_json(self): """ Returns the JSON representation of the snapshot. """ result = super(Snapshot, self).to_json() result.update({ 'snapshot': self.snapshot.to_json(), }) return result
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "super", "(", "Snapshot", ",", "self", ")", ".", "to_json", "(", ")", "result", ".", "update", "(", "{", "'snapshot'", ":", "self", ".", "snapshot", ".", "to_json", "(", ")", ",", "}", ")", ...
Returns the JSON representation of the snapshot.
[ "Returns", "the", "JSON", "representation", "of", "the", "snapshot", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/snapshot.py#L51-L60
contentful/contentful-management.py
contentful_management/usage_periods_proxy.py
UsagePeriodsProxy.all
def all(self, *args, **kwargs): """ Gets all usage periods. """ return self.client._get( self._url(), {}, headers={ 'x-contentful-enable-alpha-feature': 'usage-insights' } )
python
def all(self, *args, **kwargs): """ Gets all usage periods. """ return self.client._get( self._url(), {}, headers={ 'x-contentful-enable-alpha-feature': 'usage-insights' } )
[ "def", "all", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "client", ".", "_get", "(", "self", ".", "_url", "(", ")", ",", "{", "}", ",", "headers", "=", "{", "'x-contentful-enable-alpha-feature'", ":", "...
Gets all usage periods.
[ "Gets", "all", "usage", "periods", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/usage_periods_proxy.py#L31-L42
contentful/contentful-management.py
contentful_management/webhook.py
Webhook.create_attributes
def create_attributes(klass, attributes, previous_object=None): """ Attributes for webhook creation. """ result = super(Webhook, klass).create_attributes(attributes, previous_object) if 'topics' not in result: raise Exception("Topics ('topics') must be provided for ...
python
def create_attributes(klass, attributes, previous_object=None): """ Attributes for webhook creation. """ result = super(Webhook, klass).create_attributes(attributes, previous_object) if 'topics' not in result: raise Exception("Topics ('topics') must be provided for ...
[ "def", "create_attributes", "(", "klass", ",", "attributes", ",", "previous_object", "=", "None", ")", ":", "result", "=", "super", "(", "Webhook", ",", "klass", ")", ".", "create_attributes", "(", "attributes", ",", "previous_object", ")", "if", "'topics'", ...
Attributes for webhook creation.
[ "Attributes", "for", "webhook", "creation", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/webhook.py#L51-L60
contentful/contentful-management.py
contentful_management/webhook.py
Webhook.calls
def calls(self): """ Provides access to call overview for the given webhook. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls :return: :class:`WebhookWebhooksCallProxy <contentful_management.webhook_webhooks_call_prox...
python
def calls(self): """ Provides access to call overview for the given webhook. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls :return: :class:`WebhookWebhooksCallProxy <contentful_management.webhook_webhooks_call_prox...
[ "def", "calls", "(", "self", ")", ":", "return", "WebhookWebhooksCallProxy", "(", "self", ".", "_client", ",", "self", ".", "sys", "[", "'space'", "]", ".", "id", ",", "self", ".", "sys", "[", "'id'", "]", ")" ]
Provides access to call overview for the given webhook. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls :return: :class:`WebhookWebhooksCallProxy <contentful_management.webhook_webhooks_call_proxy.WebhookWebhooksCallProxy>` object. ...
[ "Provides", "access", "to", "call", "overview", "for", "the", "given", "webhook", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/webhook.py#L62-L76
contentful/contentful-management.py
contentful_management/webhook.py
Webhook.health
def health(self): """ Provides access to health overview for the given webhook. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-health :return: :class:`WebhookWebhooksHealthProxy <contentful_management.webhoo...
python
def health(self): """ Provides access to health overview for the given webhook. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-health :return: :class:`WebhookWebhooksHealthProxy <contentful_management.webhoo...
[ "def", "health", "(", "self", ")", ":", "return", "WebhookWebhooksHealthProxy", "(", "self", ".", "_client", ",", "self", ".", "sys", "[", "'space'", "]", ".", "id", ",", "self", ".", "sys", "[", "'id'", "]", ")" ]
Provides access to health overview for the given webhook. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/webhook-calls/webhook-health :return: :class:`WebhookWebhooksHealthProxy <contentful_management.webhook_webhooks_health_proxy.WebhookWebhook...
[ "Provides", "access", "to", "health", "overview", "for", "the", "given", "webhook", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/webhook.py#L78-L92
contentful/contentful-management.py
contentful_management/webhook.py
Webhook.to_json
def to_json(self): """ Returns the JSON representation of the webhook. """ result = super(Webhook, self).to_json() result.update({ 'name': self.name, 'url': self.url, 'topics': self.topics, 'httpBasicUsername': self.http_basic_user...
python
def to_json(self): """ Returns the JSON representation of the webhook. """ result = super(Webhook, self).to_json() result.update({ 'name': self.name, 'url': self.url, 'topics': self.topics, 'httpBasicUsername': self.http_basic_user...
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "super", "(", "Webhook", ",", "self", ")", ".", "to_json", "(", ")", "result", ".", "update", "(", "{", "'name'", ":", "self", ".", "name", ",", "'url'", ":", "self", ".", "url", ",", "'topi...
Returns the JSON representation of the webhook.
[ "Returns", "the", "JSON", "representation", "of", "the", "webhook", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/webhook.py#L94-L114
contentful/contentful-management.py
contentful_management/editor_interface.py
EditorInterface.base_url
def base_url(self, space_id, content_type_id, environment_id=None, **kwargs): """ Returns the URI for the editor interface. """ return "spaces/{0}{1}/content_types/{2}/editor_interface".format( space_id, '/environments/{0}'.format(environment_id) if environment_i...
python
def base_url(self, space_id, content_type_id, environment_id=None, **kwargs): """ Returns the URI for the editor interface. """ return "spaces/{0}{1}/content_types/{2}/editor_interface".format( space_id, '/environments/{0}'.format(environment_id) if environment_i...
[ "def", "base_url", "(", "self", ",", "space_id", ",", "content_type_id", ",", "environment_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "\"spaces/{0}{1}/content_types/{2}/editor_interface\"", ".", "format", "(", "space_id", ",", "'/environments/{0}...
Returns the URI for the editor interface.
[ "Returns", "the", "URI", "for", "the", "editor", "interface", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/editor_interface.py#L27-L36
contentful/contentful-management.py
contentful_management/editor_interface.py
EditorInterface.to_json
def to_json(self): """ Returns the JSON representation of the editor interface. """ result = super(EditorInterface, self).to_json() result.update({'controls': self.controls}) return result
python
def to_json(self): """ Returns the JSON representation of the editor interface. """ result = super(EditorInterface, self).to_json() result.update({'controls': self.controls}) return result
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "super", "(", "EditorInterface", ",", "self", ")", ".", "to_json", "(", ")", "result", ".", "update", "(", "{", "'controls'", ":", "self", ".", "controls", "}", ")", "return", "result" ]
Returns the JSON representation of the editor interface.
[ "Returns", "the", "JSON", "representation", "of", "the", "editor", "interface", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/editor_interface.py#L46-L53
contentful/contentful-management.py
contentful_management/content_type_field_validation.py
ContentTypeFieldValidation.to_json
def to_json(self): """ Returns the JSON Representation of the content type field validation. """ result = {} for k, v in self._data.items(): result[camel_case(k)] = v return result
python
def to_json(self): """ Returns the JSON Representation of the content type field validation. """ result = {} for k, v in self._data.items(): result[camel_case(k)] = v return result
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "_data", ".", "items", "(", ")", ":", "result", "[", "camel_case", "(", "k", ")", "]", "=", "v", "return", "result" ]
Returns the JSON Representation of the content type field validation.
[ "Returns", "the", "JSON", "Representation", "of", "the", "content", "type", "field", "validation", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/content_type_field_validation.py#L28-L36
contentful/contentful-management.py
contentful_management/resource_builder.py
ResourceBuilder.build
def build(self): """ Creates the objects from the JSON response. """ if self.json['sys']['type'] == 'Array': return self._build_array() return self._build_item(self.json)
python
def build(self): """ Creates the objects from the JSON response. """ if self.json['sys']['type'] == 'Array': return self._build_array() return self._build_item(self.json)
[ "def", "build", "(", "self", ")", ":", "if", "self", ".", "json", "[", "'sys'", "]", "[", "'type'", "]", "==", "'Array'", ":", "return", "self", ".", "_build_array", "(", ")", "return", "self", ".", "_build_item", "(", "self", ".", "json", ")" ]
Creates the objects from the JSON response.
[ "Creates", "the", "objects", "from", "the", "JSON", "response", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/resource_builder.py#L47-L54
contentful/contentful-management.py
contentful_management/content_type_resource_proxy.py
ContentTypeResourceProxy.create
def create(self, resource_id=None, attributes=None): """ Creates a resource with a given ID (optional) and attributes for the current content type. """ return self.proxy.create(resource_id=resource_id, attributes=attributes)
python
def create(self, resource_id=None, attributes=None): """ Creates a resource with a given ID (optional) and attributes for the current content type. """ return self.proxy.create(resource_id=resource_id, attributes=attributes)
[ "def", "create", "(", "self", ",", "resource_id", "=", "None", ",", "attributes", "=", "None", ")", ":", "return", "self", ".", "proxy", ".", "create", "(", "resource_id", "=", "resource_id", ",", "attributes", "=", "attributes", ")" ]
Creates a resource with a given ID (optional) and attributes for the current content type.
[ "Creates", "a", "resource", "with", "a", "given", "ID", "(", "optional", ")", "and", "attributes", "for", "the", "current", "content", "type", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/content_type_resource_proxy.py#L43-L48
contentful/contentful-management.py
contentful_management/space_resource_proxy.py
SpaceResourceProxy.find
def find(self, resource_id, query=None): """ Finds a single resource by ID related to the current space. """ return self.proxy.find(resource_id, query=query)
python
def find(self, resource_id, query=None): """ Finds a single resource by ID related to the current space. """ return self.proxy.find(resource_id, query=query)
[ "def", "find", "(", "self", ",", "resource_id", ",", "query", "=", "None", ")", ":", "return", "self", ".", "proxy", ".", "find", "(", "resource_id", ",", "query", "=", "query", ")" ]
Finds a single resource by ID related to the current space.
[ "Finds", "a", "single", "resource", "by", "ID", "related", "to", "the", "current", "space", "." ]
train
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/space_resource_proxy.py#L36-L41
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_ngroups
def get_ngroups(self, field=None): ''' Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_f...
python
def get_ngroups(self, field=None): ''' Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_f...
[ "def", "get_ngroups", "(", "self", ",", "field", "=", "None", ")", ":", "field", "=", "field", "if", "field", "else", "self", ".", "_determine_group_field", "(", "field", ")", "if", "'ngroups'", "in", "self", ".", "data", "[", "'grouped'", "]", "[", "f...
Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for.
[ "Returns", "ngroups", "count", "if", "it", "was", "specified", "in", "the", "query", "otherwise", "ValueError", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L77-L86
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_groups_count
def get_groups_count(self, field=None): ''' Returns 'matches' from group response. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_field(field) if 'ma...
python
def get_groups_count(self, field=None): ''' Returns 'matches' from group response. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_field(field) if 'ma...
[ "def", "get_groups_count", "(", "self", ",", "field", "=", "None", ")", ":", "field", "=", "field", "if", "field", "else", "self", ".", "_determine_group_field", "(", "field", ")", "if", "'matches'", "in", "self", ".", "data", "[", "'grouped'", "]", "[",...
Returns 'matches' from group response. If grouping on more than one field, provide the field argument to specify which count you are looking for.
[ "Returns", "matches", "from", "group", "response", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L89-L98
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_flat_groups
def get_flat_groups(self, field=None): ''' Flattens the group response and just returns a list of documents. ''' field = field if field else self._determine_group_field(field) temp_groups = self.data['grouped'][field]['groups'] return [y for x in temp_groups for y in x['d...
python
def get_flat_groups(self, field=None): ''' Flattens the group response and just returns a list of documents. ''' field = field if field else self._determine_group_field(field) temp_groups = self.data['grouped'][field]['groups'] return [y for x in temp_groups for y in x['d...
[ "def", "get_flat_groups", "(", "self", ",", "field", "=", "None", ")", ":", "field", "=", "field", "if", "field", "else", "self", ".", "_determine_group_field", "(", "field", ")", "temp_groups", "=", "self", ".", "data", "[", "'grouped'", "]", "[", "fiel...
Flattens the group response and just returns a list of documents.
[ "Flattens", "the", "group", "response", "and", "just", "returns", "a", "list", "of", "documents", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L101-L107
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facets
def get_facets(self): ''' Returns a dictionary of facets:: >>> res = solr.query('SolrClient_unittest',{ 'q':'product_name:Lorem', 'facet':True, 'facet.field':'facet_test', })... ... ... ... >>> res.get_resul...
python
def get_facets(self): ''' Returns a dictionary of facets:: >>> res = solr.query('SolrClient_unittest',{ 'q':'product_name:Lorem', 'facet':True, 'facet.field':'facet_test', })... ... ... ... >>> res.get_resul...
[ "def", "get_facets", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'facets'", ")", ":", "self", ".", "facets", "=", "{", "}", "data", "=", "self", ".", "data", "if", "'facet_counts'", "in", "data", ".", "keys", "(", ")", "and", ...
Returns a dictionary of facets:: >>> res = solr.query('SolrClient_unittest',{ 'q':'product_name:Lorem', 'facet':True, 'facet.field':'facet_test', })... ... ... ... >>> res.get_results_count() 4 >>> r...
[ "Returns", "a", "dictionary", "of", "facets", "::" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L110-L138
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facets_ranges
def get_facets_ranges(self): ''' Returns query facet ranges :: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':True, 'facet.range':'price', 'facet.range.start':0, 'facet.range.end':100, ...
python
def get_facets_ranges(self): ''' Returns query facet ranges :: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':True, 'facet.range':'price', 'facet.range.start':0, 'facet.range.end':100, ...
[ "def", "get_facets_ranges", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'facet_ranges'", ")", ":", "self", ".", "facet_ranges", "=", "{", "}", "data", "=", "self", ".", "data", "if", "'facet_counts'", "in", "data", ".", "keys", "(...
Returns query facet ranges :: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':True, 'facet.range':'price', 'facet.range.start':0, 'facet.range.end':100, 'facet.range.gap':10 }) ...
[ "Returns", "query", "facet", "ranges", "::" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L150-L179
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facet_pivot
def get_facet_pivot(self): ''' Parses facet pivot response. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'fq':'price:[50 TO *]', 'facet':True, 'facet.pivot':'facet_test,price' #Note how there is no space between fields. The...
python
def get_facet_pivot(self): ''' Parses facet pivot response. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'fq':'price:[50 TO *]', 'facet':True, 'facet.pivot':'facet_test,price' #Note how there is no space between fields. The...
[ "def", "get_facet_pivot", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'facet_pivot'", ")", ":", "self", ".", "facet_pivot", "=", "{", "}", "if", "'facet_counts'", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "pivots", ...
Parses facet pivot response. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'fq':'price:[50 TO *]', 'facet':True, 'facet.pivot':'facet_test,price' #Note how there is no space between fields. They are just separated by commas }) ...
[ "Parses", "facet", "pivot", "response", ".", "Example", "::", ">>>", "res", "=", "solr", ".", "query", "(", "SolrClient_unittest", "{", "q", ":", "*", ":", "*", "fq", ":", "price", ":", "[", "50", "TO", "*", "]", "facet", ":", "True", "facet", ".",...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L182-L207
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_field_values_as_list
def get_field_values_as_list(self,field): ''' :param str field: The name of the field for which to pull in values. Will parse the query results (must be ungrouped) and return all values of 'field' as a list. Note that these are not unique values. Example:: >>> r.get_field_values_as...
python
def get_field_values_as_list(self,field): ''' :param str field: The name of the field for which to pull in values. Will parse the query results (must be ungrouped) and return all values of 'field' as a list. Note that these are not unique values. Example:: >>> r.get_field_values_as...
[ "def", "get_field_values_as_list", "(", "self", ",", "field", ")", ":", "return", "[", "doc", "[", "field", "]", "for", "doc", "in", "self", ".", "docs", "if", "field", "in", "doc", "]" ]
:param str field: The name of the field for which to pull in values. Will parse the query results (must be ungrouped) and return all values of 'field' as a list. Note that these are not unique values. Example:: >>> r.get_field_values_as_list('product_name_exact') ['Mauris risus risus l...
[ ":", "param", "str", "field", ":", "The", "name", "of", "the", "field", "for", "which", "to", "pull", "in", "values", ".", "Will", "parse", "the", "query", "results", "(", "must", "be", "ungrouped", ")", "and", "return", "all", "values", "of", "field",...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L222-L231
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_first_field_values_as_list
def get_first_field_values_as_list(self, field): ''' :param str field: The name of the field for lookup. Goes through all documents returned looking for specified field. At first encounter will return the field's value. ''' for doc in self.docs: if field in doc.keys(...
python
def get_first_field_values_as_list(self, field): ''' :param str field: The name of the field for lookup. Goes through all documents returned looking for specified field. At first encounter will return the field's value. ''' for doc in self.docs: if field in doc.keys(...
[ "def", "get_first_field_values_as_list", "(", "self", ",", "field", ")", ":", "for", "doc", "in", "self", ".", "docs", ":", "if", "field", "in", "doc", ".", "keys", "(", ")", ":", "return", "doc", "[", "field", "]", "raise", "SolrResponseError", "(", "...
:param str field: The name of the field for lookup. Goes through all documents returned looking for specified field. At first encounter will return the field's value.
[ ":", "param", "str", "field", ":", "The", "name", "of", "the", "field", "for", "lookup", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L270-L279
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facet_values_as_list
def get_facet_values_as_list(self, field): ''' :param str field: Name of facet field to retrieve values from. Returns facet values as list for a given field. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':'true', ...
python
def get_facet_values_as_list(self, field): ''' :param str field: Name of facet field to retrieve values from. Returns facet values as list for a given field. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':'true', ...
[ "def", "get_facet_values_as_list", "(", "self", ",", "field", ")", ":", "facets", "=", "self", ".", "get_facets", "(", ")", "out", "=", "[", "]", "if", "field", "in", "facets", ".", "keys", "(", ")", ":", "for", "facetfield", "in", "facets", "[", "fi...
:param str field: Name of facet field to retrieve values from. Returns facet values as list for a given field. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':'true', 'facet.field':'facet_test', }) >>...
[ ":", "param", "str", "field", ":", "Name", "of", "facet", "field", "to", "retrieve", "values", "from", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L281-L305
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facet_keys_as_list
def get_facet_keys_as_list(self,field): ''' :param str field: Name of facet field to retrieve keys from. Similar to get_facet_values_as_list but returns the list of keys as a list instead. Example:: >>> r.get_facet_keys_as_list('facet_test') ['Lorem', 'ipsum', '...
python
def get_facet_keys_as_list(self,field): ''' :param str field: Name of facet field to retrieve keys from. Similar to get_facet_values_as_list but returns the list of keys as a list instead. Example:: >>> r.get_facet_keys_as_list('facet_test') ['Lorem', 'ipsum', '...
[ "def", "get_facet_keys_as_list", "(", "self", ",", "field", ")", ":", "facets", "=", "self", ".", "get_facets", "(", ")", "if", "facets", "==", "-", "1", ":", "return", "facets", "if", "field", "in", "facets", ".", "keys", "(", ")", ":", "return", "[...
:param str field: Name of facet field to retrieve keys from. Similar to get_facet_values_as_list but returns the list of keys as a list instead. Example:: >>> r.get_facet_keys_as_list('facet_test') ['Lorem', 'ipsum', 'amet,', 'dolor', 'sit']
[ ":", "param", "str", "field", ":", "Name", "of", "facet", "field", "to", "retrieve", "keys", "from", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L307-L322
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.json_facet
def json_facet(self, field=None): ''' EXPERIMENTAL Tried to kick back the json.fact output. ''' facets = self.data['facets'] if field is None: temp_fields = [x for x in facets.keys() if x != 'count'] if len(temp_fields) != 1: raise...
python
def json_facet(self, field=None): ''' EXPERIMENTAL Tried to kick back the json.fact output. ''' facets = self.data['facets'] if field is None: temp_fields = [x for x in facets.keys() if x != 'count'] if len(temp_fields) != 1: raise...
[ "def", "json_facet", "(", "self", ",", "field", "=", "None", ")", ":", "facets", "=", "self", ".", "data", "[", "'facets'", "]", "if", "field", "is", "None", ":", "temp_fields", "=", "[", "x", "for", "x", "in", "facets", ".", "keys", "(", ")", "i...
EXPERIMENTAL Tried to kick back the json.fact output.
[ "EXPERIMENTAL" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L331-L347
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_jsonfacet_counts_as_dict
def get_jsonfacet_counts_as_dict(self, field, data=None): ''' EXPERIMENTAL Takes facets and returns then as a dictionary that is easier to work with, for example, if you are getting something this:: {'facets': {'count': 50, 'test': {'buckets': [{'count': 10, ...
python
def get_jsonfacet_counts_as_dict(self, field, data=None): ''' EXPERIMENTAL Takes facets and returns then as a dictionary that is easier to work with, for example, if you are getting something this:: {'facets': {'count': 50, 'test': {'buckets': [{'count': 10, ...
[ "def", "get_jsonfacet_counts_as_dict", "(", "self", ",", "field", ",", "data", "=", "None", ")", ":", "data", "=", "data", "if", "data", "else", "self", ".", "data", "[", "'facets'", "]", "if", "field", "not", "in", "data", ":", "raise", "ValueError", ...
EXPERIMENTAL Takes facets and returns then as a dictionary that is easier to work with, for example, if you are getting something this:: {'facets': {'count': 50, 'test': {'buckets': [{'count': 10, 'pr': {'buckets': [{'count': 2, 'unique': 1, 'val': 79}, ...
[ "EXPERIMENTAL", "Takes", "facets", "and", "returns", "then", "as", "a", "dictionary", "that", "is", "easier", "to", "work", "with", "for", "example", "if", "you", "are", "getting", "something", "this", "::" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L349-L394
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._gen_file_name
def _gen_file_name(self): ''' Generates a random file name based on self._output_filename_pattern for the output to do file. ''' date = datetime.datetime.now() dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date...
python
def _gen_file_name(self): ''' Generates a random file name based on self._output_filename_pattern for the output to do file. ''' date = datetime.datetime.now() dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date...
[ "def", "_gen_file_name", "(", "self", ")", ":", "date", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "dt", "=", "\"{}-{}-{}-{}-{}-{}-{}\"", ".", "format", "(", "str", "(", "date", ".", "year", ")", ",", "str", "(", "date", ".", "month", ")...
Generates a random file name based on self._output_filename_pattern for the output to do file.
[ "Generates", "a", "random", "file", "name", "based", "on", "self", ".", "_output_filename_pattern", "for", "the", "output", "to", "do", "file", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L74-L80
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.add
def add(self, item=None, finalize=False, callback=None): ''' Takes a string, dictionary or list of items for adding to queue. To help troubleshoot it will output the updated buffer size, however when the content gets written it will output the file path of the new file. Generally this can be safely disc...
python
def add(self, item=None, finalize=False, callback=None): ''' Takes a string, dictionary or list of items for adding to queue. To help troubleshoot it will output the updated buffer size, however when the content gets written it will output the file path of the new file. Generally this can be safely disc...
[ "def", "add", "(", "self", ",", "item", "=", "None", ",", "finalize", "=", "False", ",", "callback", "=", "None", ")", ":", "if", "item", ":", "if", "type", "(", "item", ")", "is", "list", ":", "check", "=", "list", "(", "set", "(", "[", "type"...
Takes a string, dictionary or list of items for adding to queue. To help troubleshoot it will output the updated buffer size, however when the content gets written it will output the file path of the new file. Generally this can be safely discarded. :param <dict,list> item: Item to add to the queue. If dict wi...
[ "Takes", "a", "string", "dictionary", "or", "list", "of", "items", "for", "adding", "to", "queue", ".", "To", "help", "troubleshoot", "it", "will", "output", "the", "updated", "buffer", "size", "however", "when", "the", "content", "gets", "written", "it", ...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L83-L104
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._lock
def _lock(self): ''' Locks, or returns False if already locked ''' if not self._is_locked(): with open(self._lck,'w') as fh: if self._devel: self.logger.debug("Locking") fh.write(str(os.getpid())) return True else: ...
python
def _lock(self): ''' Locks, or returns False if already locked ''' if not self._is_locked(): with open(self._lck,'w') as fh: if self._devel: self.logger.debug("Locking") fh.write(str(os.getpid())) return True else: ...
[ "def", "_lock", "(", "self", ")", ":", "if", "not", "self", ".", "_is_locked", "(", ")", ":", "with", "open", "(", "self", ".", "_lck", ",", "'w'", ")", "as", "fh", ":", "if", "self", ".", "_devel", ":", "self", ".", "logger", ".", "debug", "("...
Locks, or returns False if already locked
[ "Locks", "or", "returns", "False", "if", "already", "locked" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L167-L177
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._is_locked
def _is_locked(self): ''' Checks to see if we are already pulling items from the queue ''' if os.path.isfile(self._lck): try: import psutil except ImportError: return True #Lock file exists and no psutil #If psutil is im...
python
def _is_locked(self): ''' Checks to see if we are already pulling items from the queue ''' if os.path.isfile(self._lck): try: import psutil except ImportError: return True #Lock file exists and no psutil #If psutil is im...
[ "def", "_is_locked", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "_lck", ")", ":", "try", ":", "import", "psutil", "except", "ImportError", ":", "return", "True", "#Lock file exists and no psutil", "#If psutil is imported",...
Checks to see if we are already pulling items from the queue
[ "Checks", "to", "see", "if", "we", "are", "already", "pulling", "items", "from", "the", "queue" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L180-L194
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._unlock
def _unlock(self): ''' Unlocks the index ''' if self._devel: self.logger.debug("Unlocking Index") if self._is_locked(): os.remove(self._lck) return True else: return True
python
def _unlock(self): ''' Unlocks the index ''' if self._devel: self.logger.debug("Unlocking Index") if self._is_locked(): os.remove(self._lck) return True else: return True
[ "def", "_unlock", "(", "self", ")", ":", "if", "self", ".", "_devel", ":", "self", ".", "logger", ".", "debug", "(", "\"Unlocking Index\"", ")", "if", "self", ".", "_is_locked", "(", ")", ":", "os", ".", "remove", "(", "self", ".", "_lck", ")", "re...
Unlocks the index
[ "Unlocks", "the", "index" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L197-L206
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_all_as_list
def get_all_as_list(self, dir='_todo_dir'): ''' Returns a list of the the full path to all items currently in the todo directory. The items will be listed in ascending order based on filesystem time. This will re-scan the directory on each execution. Do not use this to process items, th...
python
def get_all_as_list(self, dir='_todo_dir'): ''' Returns a list of the the full path to all items currently in the todo directory. The items will be listed in ascending order based on filesystem time. This will re-scan the directory on each execution. Do not use this to process items, th...
[ "def", "get_all_as_list", "(", "self", ",", "dir", "=", "'_todo_dir'", ")", ":", "dir", "=", "getattr", "(", "self", ",", "dir", ")", "list", "=", "[", "x", "for", "x", "in", "os", ".", "listdir", "(", "dir", ")", "if", "x", ".", "endswith", "(",...
Returns a list of the the full path to all items currently in the todo directory. The items will be listed in ascending order based on filesystem time. This will re-scan the directory on each execution. Do not use this to process items, this method should only be used for troubleshooting or something a...
[ "Returns", "a", "list", "of", "the", "the", "full", "path", "to", "all", "items", "currently", "in", "the", "todo", "directory", ".", "The", "items", "will", "be", "listed", "in", "ascending", "order", "based", "on", "filesystem", "time", ".", "This", "w...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L209-L220
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_todo_items
def get_todo_items(self, **kwargs): ''' Returns an iterator that will provide each item in the todo queue. Note that to complete each item you have to run complete method with the output of this iterator. That will move the item to the done directory and prevent it from being retrieved in the f...
python
def get_todo_items(self, **kwargs): ''' Returns an iterator that will provide each item in the todo queue. Note that to complete each item you have to run complete method with the output of this iterator. That will move the item to the done directory and prevent it from being retrieved in the f...
[ "def", "get_todo_items", "(", "self", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "self", ")", ":", "for", "item", "in", "self", ".", "get_all_as_list", "(", ")", ":", "yield", "item", "self", ".", "_unlock", "(", ")", "if", "not", "sel...
Returns an iterator that will provide each item in the todo queue. Note that to complete each item you have to run complete method with the output of this iterator. That will move the item to the done directory and prevent it from being retrieved in the future.
[ "Returns", "an", "iterator", "that", "will", "provide", "each", "item", "in", "the", "todo", "queue", ".", "Note", "that", "to", "complete", "each", "item", "you", "have", "to", "run", "complete", "method", "with", "the", "output", "of", "this", "iterator"...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L223-L237
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.complete
def complete(self, filepath): ''' Marks the item as complete by moving it to the done directory and optionally gzipping it. ''' if not os.path.exists(filepath): raise FileNotFoundError("Can't Complete {}, it doesn't exist".format(filepath)) if self._devel: self.logger...
python
def complete(self, filepath): ''' Marks the item as complete by moving it to the done directory and optionally gzipping it. ''' if not os.path.exists(filepath): raise FileNotFoundError("Can't Complete {}, it doesn't exist".format(filepath)) if self._devel: self.logger...
[ "def", "complete", "(", "self", ",", "filepath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "raise", "FileNotFoundError", "(", "\"Can't Complete {}, it doesn't exist\"", ".", "format", "(", "filepath", ")", ")", "if",...
Marks the item as complete by moving it to the done directory and optionally gzipping it.
[ "Marks", "the", "item", "as", "complete", "by", "moving", "it", "to", "the", "done", "directory", "and", "optionally", "gzipping", "it", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L240-L279
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.index
def index(self, solr, collection, threads=1, send_method='stream_file', **kwargs): ''' Will index the queue into a specified solr instance and collection. Specify multiple threads to make this faster, however keep in mind that if you specify multiple threads the items may not be in order. Exampl...
python
def index(self, solr, collection, threads=1, send_method='stream_file', **kwargs): ''' Will index the queue into a specified solr instance and collection. Specify multiple threads to make this faster, however keep in mind that if you specify multiple threads the items may not be in order. Exampl...
[ "def", "index", "(", "self", ",", "solr", ",", "collection", ",", "threads", "=", "1", ",", "send_method", "=", "'stream_file'", ",", "*", "*", "kwargs", ")", ":", "try", ":", "method", "=", "getattr", "(", "solr", ",", "send_method", ")", "except", ...
Will index the queue into a specified solr instance and collection. Specify multiple threads to make this faster, however keep in mind that if you specify multiple threads the items may not be in order. Example:: solr = SolrClient('http://localhost:8983/solr/') for doc in self.docs: ...
[ "Will", "index", "the", "queue", "into", "a", "specified", "solr", "instance", "and", "collection", ".", "Specify", "multiple", "threads", "to", "make", "this", "faster", "however", "keep", "in", "mind", "that", "if", "you", "specify", "multiple", "threads", ...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L295-L336
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_all_json_from_indexq
def get_all_json_from_indexq(self): ''' Gets all data from the todo files in indexq and returns one huge list of all data. ''' files = self.get_all_as_list() out = [] for efile in files: out.extend(self._open_file(efile)) return out
python
def get_all_json_from_indexq(self): ''' Gets all data from the todo files in indexq and returns one huge list of all data. ''' files = self.get_all_as_list() out = [] for efile in files: out.extend(self._open_file(efile)) return out
[ "def", "get_all_json_from_indexq", "(", "self", ")", ":", "files", "=", "self", ".", "get_all_as_list", "(", ")", "out", "=", "[", "]", "for", "efile", "in", "files", ":", "out", ".", "extend", "(", "self", ".", "_open_file", "(", "efile", ")", ")", ...
Gets all data from the todo files in indexq and returns one huge list of all data.
[ "Gets", "all", "data", "from", "the", "todo", "files", "in", "indexq", "and", "returns", "one", "huge", "list", "of", "all", "data", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L389-L397
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_multi_q
def get_multi_q(self, sentinel='STOP'): ''' This helps indexq operate in multiprocessing environment without each process having to have it's own IndexQ. It also is a handy way to deal with thread / process safety. This method will create and return a JoinableQueue object. Additionally, it will...
python
def get_multi_q(self, sentinel='STOP'): ''' This helps indexq operate in multiprocessing environment without each process having to have it's own IndexQ. It also is a handy way to deal with thread / process safety. This method will create and return a JoinableQueue object. Additionally, it will...
[ "def", "get_multi_q", "(", "self", ",", "sentinel", "=", "'STOP'", ")", ":", "self", ".", "in_q", "=", "JoinableQueue", "(", ")", "self", ".", "indexer_process", "=", "Process", "(", "target", "=", "self", ".", "_indexer_process", ",", "args", "=", "(", ...
This helps indexq operate in multiprocessing environment without each process having to have it's own IndexQ. It also is a handy way to deal with thread / process safety. This method will create and return a JoinableQueue object. Additionally, it will kick off a back end process that will monitor the queue, de...
[ "This", "helps", "indexq", "operate", "in", "multiprocessing", "environment", "without", "each", "process", "having", "to", "have", "it", "s", "own", "IndexQ", ".", "It", "also", "is", "a", "handy", "way", "to", "deal", "with", "thread", "/", "process", "s...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L408-L424
moonlitesolutions/SolrClient
SolrClient/transport/transportbase.py
TransportBase._retry
def _retry(function): """ Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one. """ def inner(self, **kwargs): last_exception = None #for host in self.router.get_hosts(**kwargs): for host in self.ho...
python
def _retry(function): """ Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one. """ def inner(self, **kwargs): last_exception = None #for host in self.router.get_hosts(**kwargs): for host in self.ho...
[ "def", "_retry", "(", "function", ")", ":", "def", "inner", "(", "self", ",", "*", "*", "kwargs", ")", ":", "last_exception", "=", "None", "#for host in self.router.get_hosts(**kwargs):", "for", "host", "in", "self", ".", "host", ":", "try", ":", "return", ...
Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one.
[ "Internal", "mechanism", "to", "try", "to", "send", "data", "to", "multiple", "Solr", "Hosts", "if", "the", "query", "fails", "on", "the", "first", "one", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/transport/transportbase.py#L28-L51
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.commit
def commit(self, collection, openSearcher=False, softCommit=False, waitSearcher=True, commit=True, **kwargs): """ :param str collection: The name of the collection for the request :param bool openSearcher: If new searcher is to be opened :param bool softCommit: SoftCommit ...
python
def commit(self, collection, openSearcher=False, softCommit=False, waitSearcher=True, commit=True, **kwargs): """ :param str collection: The name of the collection for the request :param bool openSearcher: If new searcher is to be opened :param bool softCommit: SoftCommit ...
[ "def", "commit", "(", "self", ",", "collection", ",", "openSearcher", "=", "False", ",", "softCommit", "=", "False", ",", "waitSearcher", "=", "True", ",", "commit", "=", "True", ",", "*", "*", "kwargs", ")", ":", "comm", "=", "{", "'openSearcher'", ":...
:param str collection: The name of the collection for the request :param bool openSearcher: If new searcher is to be opened :param bool softCommit: SoftCommit :param bool waitServer: Blocks until the new searcher is opened :param bool commit: Commit Sends a commit to a Solr coll...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "bool", "openSearcher", ":", "If", "new", "searcher", "is", "to", "be", "opened", ":", "param", "bool", "softCommit", ":", "SoftCommit"...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L39-L64
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.query_raw
def query_raw(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictionary of Solr query parameters. Sends...
python
def query_raw(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictionary of Solr query parameters. Sends...
[ "def", "query_raw", "(", "self", ",", "collection", ",", "query", ",", "request_handler", "=", "'select'", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/x-www-form-urlencoded'", "}", "data", "=", "query", "resp", ...
:param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictionary of Solr query parameters. Sends a query to Solr, returns a dict. `query` should be a dictionary of solr request handler argumen...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "request_handler", ":", "Request", "handler", "default", "is", "select", ":", "param", "dict", "query", ":", "Python", "dictionary...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L66-L90
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.query
def query(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictonary of Solr query parameters. Sends a qu...
python
def query(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictonary of Solr query parameters. Sends a qu...
[ "def", "query", "(", "self", ",", "collection", ",", "query", ",", "request_handler", "=", "'select'", ",", "*", "*", "kwargs", ")", ":", "for", "field", "in", "[", "'facet.pivot'", "]", ":", "if", "field", "in", "query", ".", "keys", "(", ")", ":", ...
:param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictonary of Solr query parameters. Sends a query to Solr, returns a SolrResults Object. `query` should be a dictionary of solr request ha...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "request_handler", ":", "Request", "handler", "default", "is", "select", ":", "param", "dict", "query", ":", "Python", "dictonary"...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L92-L129
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.index
def index(self, collection, docs, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}] :param min_rf int min_rf: Required number of replica...
python
def index(self, collection, docs, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}] :param min_rf int min_rf: Required number of replica...
[ "def", "index", "(", "self", ",", "collection", ",", "docs", ",", "params", "=", "None", ",", "min_rf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "json", ".", "dumps", "(", "docs", ")", "return", "self", ".", "index_json", "(", ...
:param str collection: The name of the collection for the request. :param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}] :param min_rf int min_rf: Required number of replicas to write to' Sends supplied list of dicts to solr for indexing. :: ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "docs", "list", "docs", ":", "List", "of", "dicts", ".", "ex", ":", "[", "{", "title", ":", "testing", "solr", "indexing", "...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L131-L144
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.index_json
def index_json(self, collection, data, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param data str data: Valid Solr JSON as a string. ex: '[{"title": "testing solr indexing", "id": "test1"}]' :param min_rf int min_rf: Requir...
python
def index_json(self, collection, data, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param data str data: Valid Solr JSON as a string. ex: '[{"title": "testing solr indexing", "id": "test1"}]' :param min_rf int min_rf: Requir...
[ "def", "index_json", "(", "self", ",", "collection", ",", "data", ",", "params", "=", "None", ",", "min_rf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "resp", ",", "con_inf", "=", ...
:param str collection: The name of the collection for the request. :param data str data: Valid Solr JSON as a string. ex: '[{"title": "testing solr indexing", "id": "test1"}]' :param min_rf int min_rf: Required number of replicas to write to' Sends supplied json to solr for indexing, supplied J...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "data", "str", "data", ":", "Valid", "Solr", "JSON", "as", "a", "string", ".", "ex", ":", "[", "{", "title", ":", "testing",...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L146-L175
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.get
def get(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str doc_id: ID of the document to be retrieved. Retrieve document from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') "...
python
def get(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str doc_id: ID of the document to be retrieved. Retrieve document from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') "...
[ "def", "get", "(", "self", ",", "collection", ",", "doc_id", ",", "*", "*", "kwargs", ")", ":", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", "send_request", "(", "method", "=", "'GET'", ",", "endpoint", "=", "'get'", ",", "collection", ...
:param str collection: The name of the collection for the request :param str doc_id: ID of the document to be retrieved. Retrieve document from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "doc_id", ":", "ID", "of", "the", "document", "to", "be", "retrieved", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L177-L194
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.mget
def mget(self, collection, doc_ids, **kwargs): """ :param str collection: The name of the collection for the request :param tuple doc_ids: ID of the document to be retrieved. Retrieve documents from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') ...
python
def mget(self, collection, doc_ids, **kwargs): """ :param str collection: The name of the collection for the request :param tuple doc_ids: ID of the document to be retrieved. Retrieve documents from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') ...
[ "def", "mget", "(", "self", ",", "collection", ",", "doc_ids", ",", "*", "*", "kwargs", ")", ":", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", "send_request", "(", "method", "=", "'GET'", ",", "endpoint", "=", "'get'", ",", "collection",...
:param str collection: The name of the collection for the request :param tuple doc_ids: ID of the document to be retrieved. Retrieve documents from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "tuple", "doc_ids", ":", "ID", "of", "the", "document", "to", "be", "retrieved", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L196-L213
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.delete_doc_by_id
def delete_doc_by_id(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str id: ID of the document to be deleted. Can specify '*' to delete everything. Deletes items from Solr based on the ID. :: >>> solr.delete...
python
def delete_doc_by_id(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str id: ID of the document to be deleted. Can specify '*' to delete everything. Deletes items from Solr based on the ID. :: >>> solr.delete...
[ "def", "delete_doc_by_id", "(", "self", ",", "collection", ",", "doc_id", ",", "*", "*", "kwargs", ")", ":", "if", "' '", "in", "doc_id", ":", "doc_id", "=", "'\"{}\"'", ".", "format", "(", "doc_id", ")", "temp", "=", "{", "\"delete\"", ":", "{", "\"...
:param str collection: The name of the collection for the request :param str id: ID of the document to be deleted. Can specify '*' to delete everything. Deletes items from Solr based on the ID. :: >>> solr.delete_doc_by_id('SolrClient_unittest','changeme')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "id", ":", "ID", "of", "the", "document", "to", "be", "deleted", ".", "Can", "specify", "*", "to", "delete", "everything", "...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L215-L233
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.delete_doc_by_query
def delete_doc_by_query(self, collection, query, **kwargs): """ :param str collection: The name of the collection for the request :param str query: Query selecting documents to be deleted. Deletes items from Solr based on a given query. :: >>> solr.delete_doc_by_query('Solr...
python
def delete_doc_by_query(self, collection, query, **kwargs): """ :param str collection: The name of the collection for the request :param str query: Query selecting documents to be deleted. Deletes items from Solr based on a given query. :: >>> solr.delete_doc_by_query('Solr...
[ "def", "delete_doc_by_query", "(", "self", ",", "collection", ",", "query", ",", "*", "*", "kwargs", ")", ":", "temp", "=", "{", "\"delete\"", ":", "{", "\"query\"", ":", "query", "}", "}", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", ...
:param str collection: The name of the collection for the request :param str query: Query selecting documents to be deleted. Deletes items from Solr based on a given query. :: >>> solr.delete_doc_by_query('SolrClient_unittest','*:*')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "query", ":", "Query", "selecting", "documents", "to", "be", "deleted", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L235-L251
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.local_index
def local_index(self, collection, filename, **kwargs): """ :param str collection: The name of the collection for the request :param str filename: String file path of the file to index. Will index specified file into Solr. The `file` must be local to the server, this is faster than other...
python
def local_index(self, collection, filename, **kwargs): """ :param str collection: The name of the collection for the request :param str filename: String file path of the file to index. Will index specified file into Solr. The `file` must be local to the server, this is faster than other...
[ "def", "local_index", "(", "self", ",", "collection", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "self", ".", "logger", ".", "info", "(", "\"Indexing {} into Solr Collection...
:param str collection: The name of the collection for the request :param str filename: String file path of the file to index. Will index specified file into Solr. The `file` must be local to the server, this is faster than other indexing options. If the files are already on the servers I sugges...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "filename", ":", "String", "file", "path", "of", "the", "file", "to", "index", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L276-L298
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.paging_query
def paging_query(self, collection, query, rows=1000, start=0, max_start=200000): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. :param int rows: Number of rows to return in each batch. Default is 1000. :param int...
python
def paging_query(self, collection, query, rows=1000, start=0, max_start=200000): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. :param int rows: Number of rows to return in each batch. Default is 1000. :param int...
[ "def", "paging_query", "(", "self", ",", "collection", ",", "query", ",", "rows", "=", "1000", ",", "start", "=", "0", ",", "max_start", "=", "200000", ")", ":", "query", "=", "dict", "(", "query", ")", "while", "True", ":", "query", "[", "'start'", ...
:param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. :param int rows: Number of rows to return in each batch. Default is 1000. :param int start: What position to start with. Default is 0. :param int max_start: Once the start will ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "dict", "query", ":", "Dictionary", "of", "solr", "args", ".", ":", "param", "int", "rows", ":", "Number", "of", "rows", "to",...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L301-L328
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.cursor_query
def cursor_query(self, collection, query): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. Will page through the result set in increments using cursorMark until it has all items. Sort is required for cursorMark \ ...
python
def cursor_query(self, collection, query): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. Will page through the result set in increments using cursorMark until it has all items. Sort is required for cursorMark \ ...
[ "def", "cursor_query", "(", "self", ",", "collection", ",", "query", ")", ":", "cursor", "=", "'*'", "if", "'sort'", "not", "in", "query", ":", "query", "[", "'sort'", "]", "=", "'id desc'", "while", "True", ":", "query", "[", "'cursorMark'", "]", "=",...
:param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. Will page through the result set in increments using cursorMark until it has all items. Sort is required for cursorMark \ queries, if you don't specify it, the default is 'id desc'. ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "dict", "query", ":", "Dictionary", "of", "solr", "args", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L330-L355
moonlitesolutions/SolrClient
SolrClient/routers/aware.py
AwareRouter.get_shard_map
def get_shard_map(self, force_refresh=False): """ You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map(). """ now = datetime.utcnow() if force_refresh is True or \ self.shard_map is ...
python
def get_shard_map(self, force_refresh=False): """ You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map(). """ now = datetime.utcnow() if force_refresh is True or \ self.shard_map is ...
[ "def", "get_shard_map", "(", "self", ",", "force_refresh", "=", "False", ")", ":", "now", "=", "datetime", ".", "utcnow", "(", ")", "if", "force_refresh", "is", "True", "or", "self", ".", "shard_map", "is", "None", "or", "(", "now", "-", "self", ".", ...
You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map().
[ "You", "can", "change", "this", "function", "to", "get", "the", "shard", "-", "map", "from", "somewhere", "/", "somehow", "place", "else", "in", "conjuction", "with", "save_shard_map", "()", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/routers/aware.py#L122-L134
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.check_zk
def check_zk(self): ''' Will attempt to telnet to each zookeeper that is used by SolrClient and issue 'mntr' command. Response is parsed to check to see if the zookeeper node is a leader or a follower and returned as a dict. If the telnet collection fails or the proper response is not...
python
def check_zk(self): ''' Will attempt to telnet to each zookeeper that is used by SolrClient and issue 'mntr' command. Response is parsed to check to see if the zookeeper node is a leader or a follower and returned as a dict. If the telnet collection fails or the proper response is not...
[ "def", "check_zk", "(", "self", ")", ":", "import", "telnetlib", "temp", "=", "self", ".", "zk_hosts", ".", "split", "(", "'/'", ")", "zks", "=", "temp", "[", "0", "]", ".", "split", "(", "','", ")", "status", "=", "{", "}", "for", "zk", "in", ...
Will attempt to telnet to each zookeeper that is used by SolrClient and issue 'mntr' command. Response is parsed to check to see if the zookeeper node is a leader or a follower and returned as a dict. If the telnet collection fails or the proper response is not parsed, the zk node will be listed as '...
[ "Will", "attempt", "to", "telnet", "to", "each", "zookeeper", "that", "is", "used", "by", "SolrClient", "and", "issue", "mntr", "command", ".", "Response", "is", "parsed", "to", "check", "to", "see", "if", "the", "zookeeper", "node", "is", "a", "leader", ...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L43-L72
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.copy_config
def copy_config(self, original, new): ''' Copies collection configs into a new folder. Can be used to create new collections based on existing configs. Basically, copies all nodes under /configs/original to /configs/new. :param original str: ZK name of original config :param n...
python
def copy_config(self, original, new): ''' Copies collection configs into a new folder. Can be used to create new collections based on existing configs. Basically, copies all nodes under /configs/original to /configs/new. :param original str: ZK name of original config :param n...
[ "def", "copy_config", "(", "self", ",", "original", ",", "new", ")", ":", "if", "not", "self", ".", "kz", ".", "exists", "(", "'/configs/{}'", ".", "format", "(", "original", ")", ")", ":", "raise", "ZookeeperError", "(", "\"Collection doesn't exist in Zooke...
Copies collection configs into a new folder. Can be used to create new collections based on existing configs. Basically, copies all nodes under /configs/original to /configs/new. :param original str: ZK name of original config :param new str: New name of the ZK config.
[ "Copies", "collection", "configs", "into", "a", "new", "folder", ".", "Can", "be", "used", "to", "create", "new", "collections", "based", "on", "existing", "configs", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L98-L111
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.download_collection_configs
def download_collection_configs(self, collection, fs_path): ''' Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path. ''' if not self.kz.exists('/configs/{}'.for...
python
def download_collection_configs(self, collection, fs_path): ''' Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path. ''' if not self.kz.exists('/configs/{}'.for...
[ "def", "download_collection_configs", "(", "self", ",", "collection", ",", "fs_path", ")", ":", "if", "not", "self", ".", "kz", ".", "exists", "(", "'/configs/{}'", ".", "format", "(", "collection", ")", ")", ":", "raise", "ZookeeperError", "(", "\"Collectio...
Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path.
[ "Downloads", "ZK", "Directory", "to", "the", "FileSystem", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L114-L124
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.upload_collection_configs
def upload_collection_configs(self, collection, fs_path): ''' Uploads collection configurations from a specified directory to zookeeper. ''' coll_path = fs_path if not os.path.isdir(coll_path): raise ValueError("{} Doesn't Exist".format(coll_path)) s...
python
def upload_collection_configs(self, collection, fs_path): ''' Uploads collection configurations from a specified directory to zookeeper. ''' coll_path = fs_path if not os.path.isdir(coll_path): raise ValueError("{} Doesn't Exist".format(coll_path)) s...
[ "def", "upload_collection_configs", "(", "self", ",", "collection", ",", "fs_path", ")", ":", "coll_path", "=", "fs_path", "if", "not", "os", ".", "path", ".", "isdir", "(", "coll_path", ")", ":", "raise", "ValueError", "(", "\"{} Doesn't Exist\"", ".", "for...
Uploads collection configurations from a specified directory to zookeeper.
[ "Uploads", "collection", "configurations", "from", "a", "specified", "directory", "to", "zookeeper", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L144-L152
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.create_field
def create_field(self, collection, field_dict): ''' Creates a new field in managed schema, will raise ValueError if the field already exists. field_dict should look like this:: { "name":"sell-by", "type":"tdate", "stored":True ...
python
def create_field(self, collection, field_dict): ''' Creates a new field in managed schema, will raise ValueError if the field already exists. field_dict should look like this:: { "name":"sell-by", "type":"tdate", "stored":True ...
[ "def", "create_field", "(", "self", ",", "collection", ",", "field_dict", ")", ":", "if", "self", ".", "does_field_exist", "(", "collection", ",", "field_dict", "[", "'name'", "]", ")", ":", "raise", "ValueError", "(", "\"Field {} Already Exists in Solr Collection...
Creates a new field in managed schema, will raise ValueError if the field already exists. field_dict should look like this:: { "name":"sell-by", "type":"tdate", "stored":True } Reference: https://cwiki.apache.org/confluence/display/so...
[ "Creates", "a", "new", "field", "in", "managed", "schema", "will", "raise", "ValueError", "if", "the", "field", "already", "exists", ".", "field_dict", "should", "look", "like", "this", "::" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L35-L52
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.delete_field
def delete_field(self,collection,field_name): ''' Deletes a field from the Solr Collection. Will raise ValueError if the field doesn't exist. :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' if not se...
python
def delete_field(self,collection,field_name): ''' Deletes a field from the Solr Collection. Will raise ValueError if the field doesn't exist. :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' if not se...
[ "def", "delete_field", "(", "self", ",", "collection", ",", "field_name", ")", ":", "if", "not", "self", ".", "does_field_exist", "(", "collection", ",", "field_name", ")", ":", "raise", "ValueError", "(", "\"Field {} Doesn't Exists in Solr Collection {}\"", ".", ...
Deletes a field from the Solr Collection. Will raise ValueError if the field doesn't exist. :param string collection: Name of the collection for the action :param string field_name: String name of the field.
[ "Deletes", "a", "field", "from", "the", "Solr", "Collection", ".", "Will", "raise", "ValueError", "if", "the", "field", "doesn", "t", "exist", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L70-L82
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.does_field_exist
def does_field_exist(self,collection,field_name): ''' Checks if the field exists will return a boolean True (exists) or False(doesn't exist). :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' schema = ...
python
def does_field_exist(self,collection,field_name): ''' Checks if the field exists will return a boolean True (exists) or False(doesn't exist). :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' schema = ...
[ "def", "does_field_exist", "(", "self", ",", "collection", ",", "field_name", ")", ":", "schema", "=", "self", ".", "get_schema_fields", "(", "collection", ")", "logging", ".", "info", "(", "schema", ")", "return", "True", "if", "field_name", "in", "[", "f...
Checks if the field exists will return a boolean True (exists) or False(doesn't exist). :param string collection: Name of the collection for the action :param string field_name: String name of the field.
[ "Checks", "if", "the", "field", "exists", "will", "return", "a", "boolean", "True", "(", "exists", ")", "or", "False", "(", "doesn", "t", "exist", ")", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L85-L94
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.create_copy_field
def create_copy_field(self,collection,copy_dict): ''' Creates a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictiona...
python
def create_copy_field(self,collection,copy_dict): ''' Creates a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictiona...
[ "def", "create_copy_field", "(", "self", ",", "collection", ",", "copy_dict", ")", ":", "temp", "=", "{", "\"add-copy-field\"", ":", "dict", "(", "copy_dict", ")", "}", "res", ",", "con_info", "=", "self", ".", "solr", ".", "transport", ".", "send_request"...
Creates a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictionary of field info Reference: https://cwiki.apache.org/confluen...
[ "Creates", "a", "copy", "field", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L96-L111
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.delete_copy_field
def delete_copy_field(self, collection, copy_dict): ''' Deletes a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictio...
python
def delete_copy_field(self, collection, copy_dict): ''' Deletes a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictio...
[ "def", "delete_copy_field", "(", "self", ",", "collection", ",", "copy_dict", ")", ":", "#Fix this later to check for field before sending a delete", "if", "self", ".", "devel", ":", "self", ".", "logger", ".", "debug", "(", "\"Deleting {}\"", ".", "format", "(", ...
Deletes a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictionary of field info
[ "Deletes", "a", "copy", "field", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L113-L133
moonlitesolutions/SolrClient
SolrClient/routers/base.py
BaseRouter.shuffle_hosts
def shuffle_hosts(self): """ Shuffle hosts so we don't always query the first one. Example: using in a webapp with X processes in Y servers, the hosts contacted will be more random. The user can also call this function to reshuffle every 'x' seconds or before every request. :retu...
python
def shuffle_hosts(self): """ Shuffle hosts so we don't always query the first one. Example: using in a webapp with X processes in Y servers, the hosts contacted will be more random. The user can also call this function to reshuffle every 'x' seconds or before every request. :retu...
[ "def", "shuffle_hosts", "(", "self", ")", ":", "if", "len", "(", "self", ".", "hosts", ")", ">", "1", ":", "random", ".", "shuffle", "(", "self", ".", "hosts", ")", "return", "self", ".", "hosts" ]
Shuffle hosts so we don't always query the first one. Example: using in a webapp with X processes in Y servers, the hosts contacted will be more random. The user can also call this function to reshuffle every 'x' seconds or before every request. :return:
[ "Shuffle", "hosts", "so", "we", "don", "t", "always", "query", "the", "first", "one", ".", "Example", ":", "using", "in", "a", "webapp", "with", "X", "processes", "in", "Y", "servers", "the", "hosts", "contacted", "will", "be", "more", "random", ".", "...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/routers/base.py#L26-L35
drobota/robotframework-xvfb
XvfbRobot/__init__.py
XvfbRobot.start_virtual_display
def start_virtual_display(self, width=1440, height=900, colordepth=24, **kwargs): """Starts virtual display which will be destroyed after test execution will be end *Arguments:* - width: a width to be set in pixels - height: a height to be set in p...
python
def start_virtual_display(self, width=1440, height=900, colordepth=24, **kwargs): """Starts virtual display which will be destroyed after test execution will be end *Arguments:* - width: a width to be set in pixels - height: a height to be set in p...
[ "def", "start_virtual_display", "(", "self", ",", "width", "=", "1440", ",", "height", "=", "900", ",", "colordepth", "=", "24", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_display", "is", "None", ":", "logger", ".", "info", "(", "\"Using...
Starts virtual display which will be destroyed after test execution will be end *Arguments:* - width: a width to be set in pixels - height: a height to be set in pixels - color_depth: a color depth to be used - kwargs: extra parameters *Example:* | Sta...
[ "Starts", "virtual", "display", "which", "will", "be", "destroyed", "after", "test", "execution", "will", "be", "end" ]
train
https://github.com/drobota/robotframework-xvfb/blob/66cd6174b637ab71aada71067ce4eaaa3280eb17/XvfbRobot/__init__.py#L34-L58
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.api
def api(self, action, args=None): """ Sends a request to Solr Collections API. Documentation is here: https://cwiki.apache.org/confluence/display/solr/Collections+API :param string action: Name of the collection for the action :param dict args: Dictionary of specific parameters ...
python
def api(self, action, args=None): """ Sends a request to Solr Collections API. Documentation is here: https://cwiki.apache.org/confluence/display/solr/Collections+API :param string action: Name of the collection for the action :param dict args: Dictionary of specific parameters ...
[ "def", "api", "(", "self", ",", "action", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "{", "}", "args", "[", "'action'", "]", "=", "action", ".", "upper", "(", ")", "try", ":", "res", ",", "con_info", "=", ...
Sends a request to Solr Collections API. Documentation is here: https://cwiki.apache.org/confluence/display/solr/Collections+API :param string action: Name of the collection for the action :param dict args: Dictionary of specific parameters for action
[ "Sends", "a", "request", "to", "Solr", "Collections", "API", ".", "Documentation", "is", "here", ":", "https", ":", "//", "cwiki", ".", "apache", ".", "org", "/", "confluence", "/", "display", "/", "solr", "/", "Collections", "+", "API" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L20-L42
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.clusterstatus
def clusterstatus(self): """ Returns a slightly slimmed down version of the clusterstatus api command. It also gets count of documents in each shard on each replica and returns it as doc_count key for each replica. """ res = self.cluster_status_raw() cluster = res['clu...
python
def clusterstatus(self): """ Returns a slightly slimmed down version of the clusterstatus api command. It also gets count of documents in each shard on each replica and returns it as doc_count key for each replica. """ res = self.cluster_status_raw() cluster = res['clu...
[ "def", "clusterstatus", "(", "self", ")", ":", "res", "=", "self", ".", "cluster_status_raw", "(", ")", "cluster", "=", "res", "[", "'cluster'", "]", "[", "'collections'", "]", "out", "=", "{", "}", "try", ":", "for", "collection", "in", "cluster", ":"...
Returns a slightly slimmed down version of the clusterstatus api command. It also gets count of documents in each shard on each replica and returns it as doc_count key for each replica.
[ "Returns", "a", "slightly", "slimmed", "down", "version", "of", "the", "clusterstatus", "api", "command", ".", "It", "also", "gets", "count", "of", "documents", "in", "each", "shard", "on", "each", "replica", "and", "returns", "it", "as", "doc_count", "key",...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L44-L71
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.create
def create(self, name, numShards, params=None): """ Create a new collection. """ if params is None: params = {} params.update( name=name, numShards=numShards ) return self.api('CREATE', params)
python
def create(self, name, numShards, params=None): """ Create a new collection. """ if params is None: params = {} params.update( name=name, numShards=numShards ) return self.api('CREATE', params)
[ "def", "create", "(", "self", ",", "name", ",", "numShards", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "params", ".", "update", "(", "name", "=", "name", ",", "numShards", "=", "numShards", ")...
Create a new collection.
[ "Create", "a", "new", "collection", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L97-L107
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections._get_collection_counts
def _get_collection_counts(self, core_data): """ Queries each core to get individual counts for each core for each shard. """ if core_data['base_url'] not in self.solr_clients: from SolrClient import SolrClient self.solr_clients['base_url'] = SolrClient(core_data[...
python
def _get_collection_counts(self, core_data): """ Queries each core to get individual counts for each core for each shard. """ if core_data['base_url'] not in self.solr_clients: from SolrClient import SolrClient self.solr_clients['base_url'] = SolrClient(core_data[...
[ "def", "_get_collection_counts", "(", "self", ",", "core_data", ")", ":", "if", "core_data", "[", "'base_url'", "]", "not", "in", "self", ".", "solr_clients", ":", "from", "SolrClient", "import", "SolrClient", "self", ".", "solr_clients", "[", "'base_url'", "]...
Queries each core to get individual counts for each core for each shard.
[ "Queries", "each", "core", "to", "get", "individual", "counts", "for", "each", "core", "for", "each", "shard", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L109-L125
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.check_status
def check_status(self, ignore=(), status=None): """ Checks status of each collection and shard to make sure that: a) Cluster state is active b) Number of docs matches across replicas for a given shard. Returns a dict of results for custom alerting. """ self.SH...
python
def check_status(self, ignore=(), status=None): """ Checks status of each collection and shard to make sure that: a) Cluster state is active b) Number of docs matches across replicas for a given shard. Returns a dict of results for custom alerting. """ self.SH...
[ "def", "check_status", "(", "self", ",", "ignore", "=", "(", ")", ",", "status", "=", "None", ")", ":", "self", ".", "SHARD_CHECKS", "=", "[", "{", "'check_msg'", ":", "'Bad Core Count Check'", ",", "'f'", ":", "self", ".", "_check_shard_count", "}", ","...
Checks status of each collection and shard to make sure that: a) Cluster state is active b) Number of docs matches across replicas for a given shard. Returns a dict of results for custom alerting.
[ "Checks", "status", "of", "each", "collection", "and", "shard", "to", "make", "sure", "that", ":", "a", ")", "Cluster", "state", "is", "active", "b", ")", "Number", "of", "docs", "matches", "across", "replicas", "for", "a", "given", "shard", ".", "Return...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L142-L172
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer.reindex
def reindex(self, fq= [], **kwargs): ''' Starts Reindexing Process. All parameter arguments will be passed down to the getter function. :param string fq: FilterQuery to pass to source Solr to retrieve items. This can be used to limit the results. ''' for items in self._gette...
python
def reindex(self, fq= [], **kwargs): ''' Starts Reindexing Process. All parameter arguments will be passed down to the getter function. :param string fq: FilterQuery to pass to source Solr to retrieve items. This can be used to limit the results. ''' for items in self._gette...
[ "def", "reindex", "(", "self", ",", "fq", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "for", "items", "in", "self", ".", "_getter", "(", "fq", "=", "fq", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_putter", "(", "items", ")", "if"...
Starts Reindexing Process. All parameter arguments will be passed down to the getter function. :param string fq: FilterQuery to pass to source Solr to retrieve items. This can be used to limit the results.
[ "Starts", "Reindexing", "Process", ".", "All", "parameter", "arguments", "will", "be", "passed", "down", "to", "the", "getter", "function", ".", ":", "param", "string", "fq", ":", "FilterQuery", "to", "pass", "to", "source", "Solr", "to", "retrieve", "items"...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L87-L96
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._from_solr
def _from_solr(self, fq=[], report_frequency = 25): ''' Method for retrieving batch data from Solr. ''' cursor = '*' stime = datetime.now() query_count = 0 while True: #Get data with starting cursorMark query = self._get_query(curs...
python
def _from_solr(self, fq=[], report_frequency = 25): ''' Method for retrieving batch data from Solr. ''' cursor = '*' stime = datetime.now() query_count = 0 while True: #Get data with starting cursorMark query = self._get_query(curs...
[ "def", "_from_solr", "(", "self", ",", "fq", "=", "[", "]", ",", "report_frequency", "=", "25", ")", ":", "cursor", "=", "'*'", "stime", "=", "datetime", ".", "now", "(", ")", "query_count", "=", "0", "while", "True", ":", "#Get data with starting cursor...
Method for retrieving batch data from Solr.
[ "Method", "for", "retrieving", "batch", "data", "from", "Solr", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L99-L139
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._trim_fields
def _trim_fields(self, docs): ''' Removes ignore fields from the data that we got from Solr. ''' for doc in docs: for field in self._ignore_fields: if field in doc: del(doc[field]) return docs
python
def _trim_fields(self, docs): ''' Removes ignore fields from the data that we got from Solr. ''' for doc in docs: for field in self._ignore_fields: if field in doc: del(doc[field]) return docs
[ "def", "_trim_fields", "(", "self", ",", "docs", ")", ":", "for", "doc", "in", "docs", ":", "for", "field", "in", "self", ".", "_ignore_fields", ":", "if", "field", "in", "doc", ":", "del", "(", "doc", "[", "field", "]", ")", "return", "docs" ]
Removes ignore fields from the data that we got from Solr.
[ "Removes", "ignore", "fields", "from", "the", "data", "that", "we", "got", "from", "Solr", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L142-L150
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_query
def _get_query(self, cursor): ''' Query tempalte for source Solr, sorts by id by default. ''' query = {'q':'*:*', 'sort':'id desc', 'rows':self._rows, 'cursorMark':cursor} if self._date_field: query['sort'] = "{...
python
def _get_query(self, cursor): ''' Query tempalte for source Solr, sorts by id by default. ''' query = {'q':'*:*', 'sort':'id desc', 'rows':self._rows, 'cursorMark':cursor} if self._date_field: query['sort'] = "{...
[ "def", "_get_query", "(", "self", ",", "cursor", ")", ":", "query", "=", "{", "'q'", ":", "'*:*'", ",", "'sort'", ":", "'id desc'", ",", "'rows'", ":", "self", ".", "_rows", ",", "'cursorMark'", ":", "cursor", "}", "if", "self", ".", "_date_field", "...
Query tempalte for source Solr, sorts by id by default.
[ "Query", "tempalte", "for", "source", "Solr", "sorts", "by", "id", "by", "default", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L153-L165
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._to_solr
def _to_solr(self, data): ''' Sends data to a Solr instance. ''' return self._dest.index_json(self._dest_coll, json.dumps(data,sort_keys=True))
python
def _to_solr(self, data): ''' Sends data to a Solr instance. ''' return self._dest.index_json(self._dest_coll, json.dumps(data,sort_keys=True))
[ "def", "_to_solr", "(", "self", ",", "data", ")", ":", "return", "self", ".", "_dest", ".", "index_json", "(", "self", ".", "_dest_coll", ",", "json", ".", "dumps", "(", "data", ",", "sort_keys", "=", "True", ")", ")" ]
Sends data to a Solr instance.
[ "Sends", "data", "to", "a", "Solr", "instance", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L175-L179
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_date_range_query
def _get_date_range_query(self, start_date, end_date, timespan= 'DAY', date_field= None): ''' Gets counts of items per specified date range. :param collection: Solr Collection to use. :param timespan: Solr Date Math compliant value for faceting ex HOUR, MONTH, DAY ''' ...
python
def _get_date_range_query(self, start_date, end_date, timespan= 'DAY', date_field= None): ''' Gets counts of items per specified date range. :param collection: Solr Collection to use. :param timespan: Solr Date Math compliant value for faceting ex HOUR, MONTH, DAY ''' ...
[ "def", "_get_date_range_query", "(", "self", ",", "start_date", ",", "end_date", ",", "timespan", "=", "'DAY'", ",", "date_field", "=", "None", ")", ":", "if", "date_field", "is", "None", ":", "date_field", "=", "self", ".", "_date_field", "query", "=", "{...
Gets counts of items per specified date range. :param collection: Solr Collection to use. :param timespan: Solr Date Math compliant value for faceting ex HOUR, MONTH, DAY
[ "Gets", "counts", "of", "items", "per", "specified", "date", "range", ".", ":", "param", "collection", ":", "Solr", "Collection", "to", "use", ".", ":", "param", "timespan", ":", "Solr", "Date", "Math", "compliant", "value", "for", "faceting", "ex", "HOUR"...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L182-L201
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_edge_date
def _get_edge_date(self, date_field, sort): ''' This method is used to get start and end dates for the collection. ''' return self._source.query(self._source_coll, { 'q':'*:*', 'rows':1, 'fq':'+{}:*'.format(date_field), ...
python
def _get_edge_date(self, date_field, sort): ''' This method is used to get start and end dates for the collection. ''' return self._source.query(self._source_coll, { 'q':'*:*', 'rows':1, 'fq':'+{}:*'.format(date_field), ...
[ "def", "_get_edge_date", "(", "self", ",", "date_field", ",", "sort", ")", ":", "return", "self", ".", "_source", ".", "query", "(", "self", ".", "_source_coll", ",", "{", "'q'", ":", "'*:*'", ",", "'rows'", ":", "1", ",", "'fq'", ":", "'+{}:*'", "."...
This method is used to get start and end dates for the collection.
[ "This", "method", "is", "used", "to", "get", "start", "and", "end", "dates", "for", "the", "collection", "." ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L204-L212
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_date_facet_counts
def _get_date_facet_counts(self, timespan, date_field, start_date=None, end_date=None): ''' Returns Range Facet counts based on ''' if 'DAY' not in timespan: raise ValueError("At this time, only DAY date range increment is supported. Aborting..... ") #Need to ...
python
def _get_date_facet_counts(self, timespan, date_field, start_date=None, end_date=None): ''' Returns Range Facet counts based on ''' if 'DAY' not in timespan: raise ValueError("At this time, only DAY date range increment is supported. Aborting..... ") #Need to ...
[ "def", "_get_date_facet_counts", "(", "self", ",", "timespan", ",", "date_field", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ")", ":", "if", "'DAY'", "not", "in", "timespan", ":", "raise", "ValueError", "(", "\"At this time, only DAY date rang...
Returns Range Facet counts based on
[ "Returns", "Range", "Facet", "counts", "based", "on" ]
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L215-L248
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer.resume
def resume(self, start_date=None, end_date=None, timespan='DAY', check= False): ''' This method may help if the original run was interrupted for some reason. It will only work under the following conditions * You have a date field that you can facet on * Indexing was stopped for the ...
python
def resume(self, start_date=None, end_date=None, timespan='DAY', check= False): ''' This method may help if the original run was interrupted for some reason. It will only work under the following conditions * You have a date field that you can facet on * Indexing was stopped for the ...
[ "def", "resume", "(", "self", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "timespan", "=", "'DAY'", ",", "check", "=", "False", ")", ":", "if", "type", "(", "self", ".", "_source", ")", "is", "not", "SolrClient", "or", "type", ...
This method may help if the original run was interrupted for some reason. It will only work under the following conditions * You have a date field that you can facet on * Indexing was stopped for the duration of the copy The way this tries to resume re-indexing is by running a date range fa...
[ "This", "method", "may", "help", "if", "the", "original", "run", "was", "interrupted", "for", "some", "reason", ".", "It", "will", "only", "work", "under", "the", "following", "conditions", "*", "You", "have", "a", "date", "field", "that", "you", "can", ...
train
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L251-L291
bitprophet/ssh
ssh/transport.py
Transport.start_client
def start_client(self, event=None): """ Negotiate a new SSH2 session as a client. This is the first step after creating a new L{Transport}. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiati...
python
def start_client(self, event=None): """ Negotiate a new SSH2 session as a client. This is the first step after creating a new L{Transport}. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiati...
[ "def", "start_client", "(", "self", ",", "event", "=", "None", ")", ":", "self", ".", "active", "=", "True", "if", "event", "is", "not", "None", ":", "# async, return immediately and let the app poll for completion", "self", ".", "completion_event", "=", "event", ...
Negotiate a new SSH2 session as a client. This is the first step after creating a new L{Transport}. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiation is done (successful or not), the given C{Event} will ...
[ "Negotiate", "a", "new", "SSH2", "session", "as", "a", "client", ".", "This", "is", "the", "first", "step", "after", "creating", "a", "new", "L", "{", "Transport", "}", ".", "A", "separate", "thread", "is", "created", "for", "protocol", "negotiation", "....
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L417-L467
bitprophet/ssh
ssh/transport.py
Transport.start_server
def start_server(self, event=None, server=None): """ Negotiate a new SSH2 session as a server. This is the first step after creating a new L{Transport} and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this...
python
def start_server(self, event=None, server=None): """ Negotiate a new SSH2 session as a server. This is the first step after creating a new L{Transport} and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this...
[ "def", "start_server", "(", "self", ",", "event", "=", "None", ",", "server", "=", "None", ")", ":", "if", "server", "is", "None", ":", "server", "=", "ServerInterface", "(", ")", "self", ".", "server_mode", "=", "True", "self", ".", "server_object", "...
Negotiate a new SSH2 session as a server. This is the first step after creating a new L{Transport} and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiation is done (succe...
[ "Negotiate", "a", "new", "SSH2", "session", "as", "a", "server", ".", "This", "is", "the", "first", "step", "after", "creating", "a", "new", "L", "{", "Transport", "}", "and", "setting", "up", "your", "server", "host", "key", "(", "s", ")", ".", "A",...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L469-L531
bitprophet/ssh
ssh/transport.py
Transport.close
def close(self): """ Close this session, and any open channels that are tied to it. """ if not self.active: return self.active = False self.packetizer.close() self.join() for chan in self._channels.values(): chan._unlink()
python
def close(self): """ Close this session, and any open channels that are tied to it. """ if not self.active: return self.active = False self.packetizer.close() self.join() for chan in self._channels.values(): chan._unlink()
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "active", ":", "return", "self", ".", "active", "=", "False", "self", ".", "packetizer", ".", "close", "(", ")", "self", ".", "join", "(", ")", "for", "chan", "in", "self", ".", "_c...
Close this session, and any open channels that are tied to it.
[ "Close", "this", "session", "and", "any", "open", "channels", "that", "are", "tied", "to", "it", "." ]
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L610-L620
bitprophet/ssh
ssh/transport.py
Transport.open_forwarded_tcpip_channel
def open_forwarded_tcpip_channel(self, (src_addr, src_port), (dest_addr, dest_port)): """ Request a new channel back to the client, of type C{"forwarded-tcpip"}. This is used after a client has requested port forwarding, for sending incoming connections back to the client. @para...
python
def open_forwarded_tcpip_channel(self, (src_addr, src_port), (dest_addr, dest_port)): """ Request a new channel back to the client, of type C{"forwarded-tcpip"}. This is used after a client has requested port forwarding, for sending incoming connections back to the client. @para...
[ "def", "open_forwarded_tcpip_channel", "(", "self", ",", "(", "src_addr", ",", "src_port", ")", ",", "(", "dest_addr", ",", "dest_port", ")", ")", ":", "return", "self", ".", "open_channel", "(", "'forwarded-tcpip'", ",", "(", "dest_addr", ",", "dest_port", ...
Request a new channel back to the client, of type C{"forwarded-tcpip"}. This is used after a client has requested port forwarding, for sending incoming connections back to the client. @param src_addr: originator's address @param src_port: originator's port @param dest_addr: loca...
[ "Request", "a", "new", "channel", "back", "to", "the", "client", "of", "type", "C", "{", "forwarded", "-", "tcpip", "}", ".", "This", "is", "used", "after", "a", "client", "has", "requested", "port", "forwarding", "for", "sending", "incoming", "connections...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L693-L704
bitprophet/ssh
ssh/transport.py
Transport.request_port_forward
def request_port_forward(self, address, port, handler=None): """ Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives....
python
def request_port_forward(self, address, port, handler=None): """ Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives....
[ "def", "request_port_forward", "(", "self", ",", "address", ",", "port", ",", "handler", "=", "None", ")", ":", "if", "not", "self", ".", "active", ":", "raise", "SSHException", "(", "'SSH session not active'", ")", "address", "=", "str", "(", "address", "...
Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives. The handler parameters are:: handler(channel, (origin_addr, origin...
[ "Ask", "the", "server", "to", "forward", "TCP", "connections", "from", "a", "listening", "port", "on", "the", "server", "across", "this", "SSH", "session", "." ]
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L774-L817
bitprophet/ssh
ssh/transport.py
Transport.send_ignore
def send_ignore(self, bytes=None): """ Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls. @param bytes: ...
python
def send_ignore(self, bytes=None): """ Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls. @param bytes: ...
[ "def", "send_ignore", "(", "self", ",", "bytes", "=", "None", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_byte", "(", "chr", "(", "MSG_IGNORE", ")", ")", "if", "bytes", "is", "None", ":", "bytes", "=", "(", "ord", "(", "rng", ".", "...
Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls. @param bytes: the number of random bytes to send in the payload of th...
[ "Send", "a", "junk", "packet", "across", "the", "encrypted", "link", ".", "This", "is", "sometimes", "used", "to", "add", "noise", "to", "a", "connection", "to", "confuse", "would", "-", "be", "attackers", ".", "It", "can", "also", "be", "used", "as", ...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L847-L863
bitprophet/ssh
ssh/transport.py
Transport.renegotiate_keys
def renegotiate_keys(self): """ Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating ne...
python
def renegotiate_keys(self): """ Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating ne...
[ "def", "renegotiate_keys", "(", "self", ")", ":", "self", ".", "completion_event", "=", "threading", ".", "Event", "(", ")", "self", ".", "_send_kex_init", "(", ")", "while", "True", ":", "self", ".", "completion_event", ".", "wait", "(", "0.1", ")", "if...
Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating new keys causes a pause in traffic both wa...
[ "Force", "this", "session", "to", "switch", "to", "new", "keys", ".", "Normally", "this", "is", "done", "automatically", "after", "the", "session", "hits", "a", "certain", "number", "of", "packets", "or", "bytes", "sent", "or", "received", "but", "this", "...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L865-L888
bitprophet/ssh
ssh/transport.py
Transport.set_keepalive
def set_keepalive(self, interval): """ Turn on/off keepalive packets (default is off). If this is set, after C{interval} seconds without sending any data over the connection, a "keepalive" packet will be sent (and ignored by the remote host). This can be useful to keep connecti...
python
def set_keepalive(self, interval): """ Turn on/off keepalive packets (default is off). If this is set, after C{interval} seconds without sending any data over the connection, a "keepalive" packet will be sent (and ignored by the remote host). This can be useful to keep connecti...
[ "def", "set_keepalive", "(", "self", ",", "interval", ")", ":", "self", ".", "packetizer", ".", "set_keepalive", "(", "interval", ",", "lambda", "x", "=", "weakref", ".", "proxy", "(", "self", ")", ":", "x", ".", "global_request", "(", "'keepalive@lag.net'...
Turn on/off keepalive packets (default is off). If this is set, after C{interval} seconds without sending any data over the connection, a "keepalive" packet will be sent (and ignored by the remote host). This can be useful to keep connections alive over a NAT, for example. @param inte...
[ "Turn", "on", "/", "off", "keepalive", "packets", "(", "default", "is", "off", ")", ".", "If", "this", "is", "set", "after", "C", "{", "interval", "}", "seconds", "without", "sending", "any", "data", "over", "the", "connection", "a", "keepalive", "packet...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L890-L902
bitprophet/ssh
ssh/transport.py
Transport.connect
def connect(self, hostkey=None, username='', password=None, pkey=None): """ Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for L{start_client}, L{get_remote_server_key}, and L{Transport....
python
def connect(self, hostkey=None, username='', password=None, pkey=None): """ Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for L{start_client}, L{get_remote_server_key}, and L{Transport....
[ "def", "connect", "(", "self", ",", "hostkey", "=", "None", ",", "username", "=", "''", ",", "password", "=", "None", ",", "pkey", "=", "None", ")", ":", "if", "hostkey", "is", "not", "None", ":", "self", ".", "_preferred_keys", "=", "[", "hostkey", ...
Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for L{start_client}, L{get_remote_server_key}, and L{Transport.auth_password} or L{Transport.auth_publickey}. Use those methods if you want more c...
[ "Negotiate", "an", "SSH2", "session", "and", "optionally", "verify", "the", "server", "s", "host", "key", "and", "authenticate", "using", "a", "password", "or", "private", "key", ".", "This", "is", "a", "shortcut", "for", "L", "{", "start_client", "}", "L"...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L969-L1026
bitprophet/ssh
ssh/transport.py
Transport.auth_none
def auth_none(self, username): """ Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the L{BadAuthenticationType} exception raised...
python
def auth_none(self, username): """ Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the L{BadAuthenticationType} exception raised...
[ "def", "auth_none", "(", "self", ",", "username", ")", ":", "if", "(", "not", "self", ".", "active", ")", "or", "(", "not", "self", ".", "initial_kex_done", ")", ":", "raise", "SSHException", "(", "'No existing session'", ")", "my_event", "=", "threading",...
Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the L{BadAuthenticationType} exception raised. @param username: the username to authent...
[ "Try", "to", "authenticate", "to", "the", "server", "using", "no", "authentication", "at", "all", ".", "This", "will", "almost", "always", "fail", ".", "It", "may", "be", "useful", "for", "determining", "the", "list", "of", "authentication", "types", "suppor...
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1094-L1119
bitprophet/ssh
ssh/transport.py
Transport._send_user_message
def _send_user_message(self, data): """ send a message, but block if we're in key negotiation. this is used for user-initiated requests. """ start = time.time() while True: self.clear_to_send.wait(0.1) if not self.active: self._log...
python
def _send_user_message(self, data): """ send a message, but block if we're in key negotiation. this is used for user-initiated requests. """ start = time.time() while True: self.clear_to_send.wait(0.1) if not self.active: self._log...
[ "def", "_send_user_message", "(", "self", ",", "data", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "True", ":", "self", ".", "clear_to_send", ".", "wait", "(", "0.1", ")", "if", "not", "self", ".", "active", ":", "self", ".", "_...
send a message, but block if we're in key negotiation. this is used for user-initiated requests.
[ "send", "a", "message", "but", "block", "if", "we", "re", "in", "key", "negotiation", ".", "this", "is", "used", "for", "user", "-", "initiated", "requests", "." ]
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1425-L1445
bitprophet/ssh
ssh/transport.py
Transport._set_K_H
def _set_K_H(self, k, h): "used by a kex object to set the K (root key) and H (exchange hash)" self.K = k self.H = h if self.session_id == None: self.session_id = h
python
def _set_K_H(self, k, h): "used by a kex object to set the K (root key) and H (exchange hash)" self.K = k self.H = h if self.session_id == None: self.session_id = h
[ "def", "_set_K_H", "(", "self", ",", "k", ",", "h", ")", ":", "self", ".", "K", "=", "k", "self", ".", "H", "=", "h", "if", "self", ".", "session_id", "==", "None", ":", "self", ".", "session_id", "=", "h" ]
used by a kex object to set the K (root key) and H (exchange hash)
[ "used", "by", "a", "kex", "object", "to", "set", "the", "K", "(", "root", "key", ")", "and", "H", "(", "exchange", "hash", ")" ]
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1447-L1452
bitprophet/ssh
ssh/transport.py
Transport._compute_key
def _compute_key(self, id, nbytes): "id is 'A' - 'F' for the various keys used by ssh" m = Message() m.add_mpint(self.K) m.add_bytes(self.H) m.add_byte(id) m.add_bytes(self.session_id) out = sofar = SHA.new(str(m)).digest() while len(out) < nbytes: ...
python
def _compute_key(self, id, nbytes): "id is 'A' - 'F' for the various keys used by ssh" m = Message() m.add_mpint(self.K) m.add_bytes(self.H) m.add_byte(id) m.add_bytes(self.session_id) out = sofar = SHA.new(str(m)).digest() while len(out) < nbytes: ...
[ "def", "_compute_key", "(", "self", ",", "id", ",", "nbytes", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_mpint", "(", "self", ".", "K", ")", "m", ".", "add_bytes", "(", "self", ".", "H", ")", "m", ".", "add_byte", "(", "id", ")", ...
id is 'A' - 'F' for the various keys used by ssh
[ "id", "is", "A", "-", "F", "for", "the", "various", "keys", "used", "by", "ssh" ]
train
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1466-L1482