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
TylerGubala/bpy-build
setup.py
InstallCMakeLibs.run
def run(self): """ Copy libraries from the bin directory and place them as appropriate """ self.announce("Moving library files", level=3) # We have already built the libraries in the previous build_ext step self.skip_build = True bin_dir = self.distribution.bi...
python
def run(self): """ Copy libraries from the bin directory and place them as appropriate """ self.announce("Moving library files", level=3) # We have already built the libraries in the previous build_ext step self.skip_build = True bin_dir = self.distribution.bi...
[ "def", "run", "(", "self", ")", ":", "self", ".", "announce", "(", "\"Moving library files\"", ",", "level", "=", "3", ")", "# We have already built the libraries in the previous build_ext step", "self", ".", "skip_build", "=", "True", "bin_dir", "=", "self", ".", ...
Copy libraries from the bin directory and place them as appropriate
[ "Copy", "libraries", "from", "the", "bin", "directory", "and", "place", "them", "as", "appropriate" ]
train
https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L181-L225
TylerGubala/bpy-build
setup.py
InstallBlenderScripts.run
def run(self): """ Copy the required directory to the build directory and super().run() """ self.announce("Moving scripts files", level=3) self.skip_build = True bin_dir = self.distribution.bin_dir scripts_dirs = [os.path.join(bin_dir, _dir) for _dir in ...
python
def run(self): """ Copy the required directory to the build directory and super().run() """ self.announce("Moving scripts files", level=3) self.skip_build = True bin_dir = self.distribution.bin_dir scripts_dirs = [os.path.join(bin_dir, _dir) for _dir in ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "announce", "(", "\"Moving scripts files\"", ",", "level", "=", "3", ")", "self", ".", "skip_build", "=", "True", "bin_dir", "=", "self", ".", "distribution", ".", "bin_dir", "scripts_dirs", "=", "[", "os...
Copy the required directory to the build directory and super().run()
[ "Copy", "the", "required", "directory", "to", "the", "build", "directory", "and", "super", "()", ".", "run", "()" ]
train
https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L232-L273
TylerGubala/bpy-build
setup.py
BuildCMakeExt.run
def run(self): """ Perform build_cmake before doing the 'normal' stuff """ for extension in self.extensions: if extension.name == "bpy": self.build_cmake(extension) super().run()
python
def run(self): """ Perform build_cmake before doing the 'normal' stuff """ for extension in self.extensions: if extension.name == "bpy": self.build_cmake(extension) super().run()
[ "def", "run", "(", "self", ")", ":", "for", "extension", "in", "self", ".", "extensions", ":", "if", "extension", ".", "name", "==", "\"bpy\"", ":", "self", ".", "build_cmake", "(", "extension", ")", "super", "(", ")", ".", "run", "(", ")" ]
Perform build_cmake before doing the 'normal' stuff
[ "Perform", "build_cmake", "before", "doing", "the", "normal", "stuff" ]
train
https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L280-L291
TylerGubala/bpy-build
setup.py
BuildCMakeExt.build_cmake
def build_cmake(self, extension: Extension): """ The steps required to build the extension """ # We import the setup_requires modules here because if we import them # at the top this script will always fail as they won't be present from git import Repo as GitRepo ...
python
def build_cmake(self, extension: Extension): """ The steps required to build the extension """ # We import the setup_requires modules here because if we import them # at the top this script will always fail as they won't be present from git import Repo as GitRepo ...
[ "def", "build_cmake", "(", "self", ",", "extension", ":", "Extension", ")", ":", "# We import the setup_requires modules here because if we import them", "# at the top this script will always fail as they won't be present", "from", "git", "import", "Repo", "as", "GitRepo", "from"...
The steps required to build the extension
[ "The", "steps", "required", "to", "build", "the", "extension" ]
train
https://github.com/TylerGubala/bpy-build/blob/667d41526a346cfa271e26c5d675689c7ab1a254/setup.py#L293-L536
Arubacloud/pyArubaCloud
ArubaCloud/ReverseDns/ReverseDns.py
ReverseDns.get
def get(self, addresses): """ :type addresses: list[str] :param addresses: (list[str]) List of addresses to retrieve their reverse dns Retrieve the current configured ReverseDns entries :return: (list) List containing the current ReverseDns Addresses """ request =...
python
def get(self, addresses): """ :type addresses: list[str] :param addresses: (list[str]) List of addresses to retrieve their reverse dns Retrieve the current configured ReverseDns entries :return: (list) List containing the current ReverseDns Addresses """ request =...
[ "def", "get", "(", "self", ",", "addresses", ")", ":", "request", "=", "self", ".", "_call", "(", "GetReverseDns", ".", "GetReverseDns", ",", "IPs", "=", "addresses", ")", "response", "=", "request", ".", "commit", "(", ")", "return", "response", "[", ...
:type addresses: list[str] :param addresses: (list[str]) List of addresses to retrieve their reverse dns Retrieve the current configured ReverseDns entries :return: (list) List containing the current ReverseDns Addresses
[ ":", "type", "addresses", ":", "list", "[", "str", "]", ":", "param", "addresses", ":", "(", "list", "[", "str", "]", ")", "List", "of", "addresses", "to", "retrieve", "their", "reverse", "dns", "Retrieve", "the", "current", "configured", "ReverseDns", "...
train
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L12-L21
Arubacloud/pyArubaCloud
ArubaCloud/ReverseDns/ReverseDns.py
ReverseDns.set
def set(self, address, host_name): """ Assign one or more PTR record to a single IP Address :type address: str :type host_name: list[str] :param address: (str) The IP address to configure :param host_name: (list[str]) The list of strings representing PTR records :...
python
def set(self, address, host_name): """ Assign one or more PTR record to a single IP Address :type address: str :type host_name: list[str] :param address: (str) The IP address to configure :param host_name: (list[str]) The list of strings representing PTR records :...
[ "def", "set", "(", "self", ",", "address", ",", "host_name", ")", ":", "request", "=", "self", ".", "_call", "(", "SetEnqueueSetReverseDns", ".", "SetEnqueueSetReverseDns", ",", "IP", "=", "address", ",", "Hosts", "=", "host_name", ")", "response", "=", "r...
Assign one or more PTR record to a single IP Address :type address: str :type host_name: list[str] :param address: (str) The IP address to configure :param host_name: (list[str]) The list of strings representing PTR records :return: (bool) True in case of success, False in case o...
[ "Assign", "one", "or", "more", "PTR", "record", "to", "a", "single", "IP", "Address", ":", "type", "address", ":", "str", ":", "type", "host_name", ":", "list", "[", "str", "]", ":", "param", "address", ":", "(", "str", ")", "The", "IP", "address", ...
train
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L23-L34
Arubacloud/pyArubaCloud
ArubaCloud/ReverseDns/ReverseDns.py
ReverseDns.reset
def reset(self, addresses): """ Remove all PTR records from the given address :type addresses: List[str] :param addresses: (List[str]) The IP Address to reset :return: (bool) True in case of success, False in case of failure """ request = self._call(SetEnqueueRese...
python
def reset(self, addresses): """ Remove all PTR records from the given address :type addresses: List[str] :param addresses: (List[str]) The IP Address to reset :return: (bool) True in case of success, False in case of failure """ request = self._call(SetEnqueueRese...
[ "def", "reset", "(", "self", ",", "addresses", ")", ":", "request", "=", "self", ".", "_call", "(", "SetEnqueueResetReverseDns", ".", "SetEnqueueResetReverseDns", ",", "IPs", "=", "addresses", ")", "response", "=", "request", ".", "commit", "(", ")", "return...
Remove all PTR records from the given address :type addresses: List[str] :param addresses: (List[str]) The IP Address to reset :return: (bool) True in case of success, False in case of failure
[ "Remove", "all", "PTR", "records", "from", "the", "given", "address", ":", "type", "addresses", ":", "List", "[", "str", "]", ":", "param", "addresses", ":", "(", "List", "[", "str", "]", ")", "The", "IP", "Address", "to", "reset", ":", "return", ":"...
train
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/ReverseDns/ReverseDns.py#L36-L45
Arubacloud/pyArubaCloud
ArubaCloud/Compute/LoadBalancer/LoadBalancer.py
LoadBalancer.create
def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules, loadBalancerClassOfServiceID=1, *args, **kwargs): """ :type healthCheckNotification: bool :type instance: list[Instance] :type ipAddressResourceId: list[int] ...
python
def create(self, healthCheckNotification, instance, ipAddressResourceId, name, notificationContacts, rules, loadBalancerClassOfServiceID=1, *args, **kwargs): """ :type healthCheckNotification: bool :type instance: list[Instance] :type ipAddressResourceId: list[int] ...
[ "def", "create", "(", "self", ",", "healthCheckNotification", ",", "instance", ",", "ipAddressResourceId", ",", "name", ",", "notificationContacts", ",", "rules", ",", "loadBalancerClassOfServiceID", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":...
:type healthCheckNotification: bool :type instance: list[Instance] :type ipAddressResourceId: list[int] :type loadBalancerClassOfServiceID: int :type name: str :type notificationContacts: NotificationContacts or list[NotificationContact] :type rules: Rules :param ...
[ ":", "type", "healthCheckNotification", ":", "bool", ":", "type", "instance", ":", "list", "[", "Instance", "]", ":", "type", "ipAddressResourceId", ":", "list", "[", "int", "]", ":", "type", "loadBalancerClassOfServiceID", ":", "int", ":", "type", "name", "...
train
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/Compute/LoadBalancer/LoadBalancer.py#L15-L41
Arubacloud/pyArubaCloud
ArubaCloud/Compute/LoadBalancer/LoadBalancer.py
LoadBalancer.get_notifications
def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID): """ Get the load balancer notifications for a specific rule within a specifying window time frame :type startDate: datetime :type endDate: datetime :type loadBalancerID: int :type loadBal...
python
def get_notifications(self, startDate, endDate, loadBalancerID, loadBalancerRuleID): """ Get the load balancer notifications for a specific rule within a specifying window time frame :type startDate: datetime :type endDate: datetime :type loadBalancerID: int :type loadBal...
[ "def", "get_notifications", "(", "self", ",", "startDate", ",", "endDate", ",", "loadBalancerID", ",", "loadBalancerRuleID", ")", ":", "return", "self", ".", "_call", "(", "GetLoadBalancerNotifications", ",", "startDate", "=", "startDate", ",", "endDate", "=", "...
Get the load balancer notifications for a specific rule within a specifying window time frame :type startDate: datetime :type endDate: datetime :type loadBalancerID: int :type loadBalancerRuleID: int :param startDate: From Date :param endDate: To Date :param loadB...
[ "Get", "the", "load", "balancer", "notifications", "for", "a", "specific", "rule", "within", "a", "specifying", "window", "time", "frame", ":", "type", "startDate", ":", "datetime", ":", "type", "endDate", ":", "datetime", ":", "type", "loadBalancerID", ":", ...
train
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/Compute/LoadBalancer/LoadBalancer.py#L50-L63
boundlessgeo/lib-qgis-commons
qgiscommons2/network/oauth2.py
get_oauth_authcfg
def get_oauth_authcfg(authcfg_id=AUTHCFG_ID): """Check if the given authcfg_id (or the default) exists, and if it's valid OAuth2, return the configuration or None""" # Handle empty strings if not authcfg_id: authcfg_id = AUTHCFG_ID configs = auth_manager().availableAuthMethodConfigs() if...
python
def get_oauth_authcfg(authcfg_id=AUTHCFG_ID): """Check if the given authcfg_id (or the default) exists, and if it's valid OAuth2, return the configuration or None""" # Handle empty strings if not authcfg_id: authcfg_id = AUTHCFG_ID configs = auth_manager().availableAuthMethodConfigs() if...
[ "def", "get_oauth_authcfg", "(", "authcfg_id", "=", "AUTHCFG_ID", ")", ":", "# Handle empty strings", "if", "not", "authcfg_id", ":", "authcfg_id", "=", "AUTHCFG_ID", "configs", "=", "auth_manager", "(", ")", ".", "availableAuthMethodConfigs", "(", ")", "if", "aut...
Check if the given authcfg_id (or the default) exists, and if it's valid OAuth2, return the configuration or None
[ "Check", "if", "the", "given", "authcfg_id", "(", "or", "the", "default", ")", "exists", "and", "if", "it", "s", "valid", "OAuth2", "return", "the", "configuration", "or", "None" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/oauth2.py#L47-L58
boundlessgeo/lib-qgis-commons
qgiscommons2/network/oauth2.py
setup_oauth
def setup_oauth(username, password, basemaps_token_uri, authcfg_id=AUTHCFG_ID, authcfg_name=AUTHCFG_NAME): """Setup oauth configuration to access the BCS API, return authcfg_id on success, None on failure """ cfgjson = { "accessMethod" : 0, "apiKey" : "", "clientId" : "", "clientSecr...
python
def setup_oauth(username, password, basemaps_token_uri, authcfg_id=AUTHCFG_ID, authcfg_name=AUTHCFG_NAME): """Setup oauth configuration to access the BCS API, return authcfg_id on success, None on failure """ cfgjson = { "accessMethod" : 0, "apiKey" : "", "clientId" : "", "clientSecr...
[ "def", "setup_oauth", "(", "username", ",", "password", ",", "basemaps_token_uri", ",", "authcfg_id", "=", "AUTHCFG_ID", ",", "authcfg_name", "=", "AUTHCFG_NAME", ")", ":", "cfgjson", "=", "{", "\"accessMethod\"", ":", "0", ",", "\"apiKey\"", ":", "\"\"", ",",...
Setup oauth configuration to access the BCS API, return authcfg_id on success, None on failure
[ "Setup", "oauth", "configuration", "to", "access", "the", "BCS", "API", "return", "authcfg_id", "on", "success", "None", "on", "failure" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/oauth2.py#L60-L99
yunojuno/elasticsearch-django
elasticsearch_django/models.py
execute_search
def execute_search( search, search_terms="", user=None, reference="", save=True, query_type=SearchQuery.QUERY_TYPE_SEARCH, ): """ Create a new SearchQuery instance and execute a search against ES. Args: search: elasticsearch.search.Search object, that internally contains ...
python
def execute_search( search, search_terms="", user=None, reference="", save=True, query_type=SearchQuery.QUERY_TYPE_SEARCH, ): """ Create a new SearchQuery instance and execute a search against ES. Args: search: elasticsearch.search.Search object, that internally contains ...
[ "def", "execute_search", "(", "search", ",", "search_terms", "=", "\"\"", ",", "user", "=", "None", ",", "reference", "=", "\"\"", ",", "save", "=", "True", ",", "query_type", "=", "SearchQuery", ".", "QUERY_TYPE_SEARCH", ",", ")", ":", "start", "=", "ti...
Create a new SearchQuery instance and execute a search against ES. Args: search: elasticsearch.search.Search object, that internally contains the connection and query; this is the query that is executed. All we are doing is logging the input and parsing the output. search_te...
[ "Create", "a", "new", "SearchQuery", "instance", "and", "execute", "a", "search", "against", "ES", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L565-L617
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentManagerMixin.in_search_queryset
def in_search_queryset(self, instance_id, index="_all"): """ Return True if an object is part of the search index queryset. Sometimes it's useful to know if an object _should_ be indexed. If an object is saved, how do you know if you should push that change to the search index? ...
python
def in_search_queryset(self, instance_id, index="_all"): """ Return True if an object is part of the search index queryset. Sometimes it's useful to know if an object _should_ be indexed. If an object is saved, how do you know if you should push that change to the search index? ...
[ "def", "in_search_queryset", "(", "self", ",", "instance_id", ",", "index", "=", "\"_all\"", ")", ":", "return", "self", ".", "get_search_queryset", "(", "index", "=", "index", ")", ".", "filter", "(", "pk", "=", "instance_id", ")", ".", "exists", "(", "...
Return True if an object is part of the search index queryset. Sometimes it's useful to know if an object _should_ be indexed. If an object is saved, how do you know if you should push that change to the search index? The simplest (albeit not most efficient) way is to check if it appear...
[ "Return", "True", "if", "an", "object", "is", "part", "of", "the", "search", "index", "queryset", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L59-L80
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentManagerMixin.from_search_query
def from_search_query(self, search_query): """ Return queryset of objects from SearchQuery.results, **in order**. EXPERIMENTAL: this will only work with results from a single index, with a single doc_type - as we are returning a single QuerySet. This method takes the hits JSON ...
python
def from_search_query(self, search_query): """ Return queryset of objects from SearchQuery.results, **in order**. EXPERIMENTAL: this will only work with results from a single index, with a single doc_type - as we are returning a single QuerySet. This method takes the hits JSON ...
[ "def", "from_search_query", "(", "self", ",", "search_query", ")", ":", "hits", "=", "search_query", ".", "hits", "score_sql", "=", "self", ".", "_raw_sql", "(", "[", "(", "h", "[", "\"id\"", "]", ",", "h", "[", "\"score\"", "]", "or", "0", ")", "for...
Return queryset of objects from SearchQuery.results, **in order**. EXPERIMENTAL: this will only work with results from a single index, with a single doc_type - as we are returning a single QuerySet. This method takes the hits JSON and converts that into a queryset of all the relevant o...
[ "Return", "queryset", "of", "objects", "from", "SearchQuery", ".", "results", "**", "in", "order", "**", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L82-L133
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentManagerMixin._raw_sql
def _raw_sql(self, values): """Prepare SQL statement consisting of a sequence of WHEN .. THEN statements.""" if isinstance(self.model._meta.pk, CharField): when_clauses = " ".join( [self._when("'{}'".format(x), y) for (x, y) in values] ) else: ...
python
def _raw_sql(self, values): """Prepare SQL statement consisting of a sequence of WHEN .. THEN statements.""" if isinstance(self.model._meta.pk, CharField): when_clauses = " ".join( [self._when("'{}'".format(x), y) for (x, y) in values] ) else: ...
[ "def", "_raw_sql", "(", "self", ",", "values", ")", ":", "if", "isinstance", "(", "self", ".", "model", ".", "_meta", ".", "pk", ",", "CharField", ")", ":", "when_clauses", "=", "\" \"", ".", "join", "(", "[", "self", ".", "_when", "(", "\"'{}'\"", ...
Prepare SQL statement consisting of a sequence of WHEN .. THEN statements.
[ "Prepare", "SQL", "statement", "consisting", "of", "a", "sequence", "of", "WHEN", "..", "THEN", "statements", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L138-L150
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.search_document_cache_key
def search_document_cache_key(self): """Key used for storing search docs in local cache.""" return "elasticsearch_django:{}.{}.{}".format( self._meta.app_label, self._meta.model_name, self.pk )
python
def search_document_cache_key(self): """Key used for storing search docs in local cache.""" return "elasticsearch_django:{}.{}.{}".format( self._meta.app_label, self._meta.model_name, self.pk )
[ "def", "search_document_cache_key", "(", "self", ")", ":", "return", "\"elasticsearch_django:{}.{}.{}\"", ".", "format", "(", "self", ".", "_meta", ".", "app_label", ",", "self", ".", "_meta", ".", "model_name", ",", "self", ".", "pk", ")" ]
Key used for storing search docs in local cache.
[ "Key", "used", "for", "storing", "search", "docs", "in", "local", "cache", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L188-L192
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin._is_field_serializable
def _is_field_serializable(self, field_name): """Return True if the field can be serialized into a JSON doc.""" return ( self._meta.get_field(field_name).get_internal_type() in self.SIMPLE_UPDATE_FIELD_TYPES )
python
def _is_field_serializable(self, field_name): """Return True if the field can be serialized into a JSON doc.""" return ( self._meta.get_field(field_name).get_internal_type() in self.SIMPLE_UPDATE_FIELD_TYPES )
[ "def", "_is_field_serializable", "(", "self", ",", "field_name", ")", ":", "return", "(", "self", ".", "_meta", ".", "get_field", "(", "field_name", ")", ".", "get_internal_type", "(", ")", "in", "self", ".", "SIMPLE_UPDATE_FIELD_TYPES", ")" ]
Return True if the field can be serialized into a JSON doc.
[ "Return", "True", "if", "the", "field", "can", "be", "serialized", "into", "a", "JSON", "doc", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L223-L228
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.clean_update_fields
def clean_update_fields(self, index, update_fields): """ Clean the list of update_fields based on the index being updated.\ If any field in the update_fields list is not in the set of properties defined by the index mapping for this model, then we ignore it. If a field _is_ in t...
python
def clean_update_fields(self, index, update_fields): """ Clean the list of update_fields based on the index being updated.\ If any field in the update_fields list is not in the set of properties defined by the index mapping for this model, then we ignore it. If a field _is_ in t...
[ "def", "clean_update_fields", "(", "self", ",", "index", ",", "update_fields", ")", ":", "search_fields", "=", "get_model_index_properties", "(", "self", ",", "index", ")", "clean_fields", "=", "[", "f", "for", "f", "in", "update_fields", "if", "f", "in", "s...
Clean the list of update_fields based on the index being updated.\ If any field in the update_fields list is not in the set of properties defined by the index mapping for this model, then we ignore it. If a field _is_ in the mapping, but the underlying model field is a related object, a...
[ "Clean", "the", "list", "of", "update_fields", "based", "on", "the", "index", "being", "updated", ".", "\\" ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L230-L255
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.as_search_document_update
def as_search_document_update(self, *, index, update_fields): """ Return a partial update document based on which fields have been updated. If an object is saved with the `update_fields` argument passed through, then it is assumed that this is a 'partial update'. In this scenari...
python
def as_search_document_update(self, *, index, update_fields): """ Return a partial update document based on which fields have been updated. If an object is saved with the `update_fields` argument passed through, then it is assumed that this is a 'partial update'. In this scenari...
[ "def", "as_search_document_update", "(", "self", ",", "*", ",", "index", ",", "update_fields", ")", ":", "if", "UPDATE_STRATEGY", "==", "UPDATE_STRATEGY_FULL", ":", "return", "self", ".", "as_search_document", "(", "index", "=", "index", ")", "if", "UPDATE_STRAT...
Return a partial update document based on which fields have been updated. If an object is saved with the `update_fields` argument passed through, then it is assumed that this is a 'partial update'. In this scenario we need a {property: value} dictionary containing just the fields we wan...
[ "Return", "a", "partial", "update", "document", "based", "on", "which", "fields", "have", "been", "updated", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L257-L306
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.as_search_action
def as_search_action(self, *, index, action): """ Return an object as represented in a bulk api operation. Bulk API operations have a very specific format. This function will call the standard `as_search_document` method on the object and then wrap that up in the correct format ...
python
def as_search_action(self, *, index, action): """ Return an object as represented in a bulk api operation. Bulk API operations have a very specific format. This function will call the standard `as_search_document` method on the object and then wrap that up in the correct format ...
[ "def", "as_search_action", "(", "self", ",", "*", ",", "index", ",", "action", ")", ":", "if", "action", "not", "in", "(", "\"index\"", ",", "\"update\"", ",", "\"delete\"", ")", ":", "raise", "ValueError", "(", "\"Action must be 'index', 'update' or 'delete'.\"...
Return an object as represented in a bulk api operation. Bulk API operations have a very specific format. This function will call the standard `as_search_document` method on the object and then wrap that up in the correct format for the action specified. https://www.elastic.co/guide/en...
[ "Return", "an", "object", "as", "represented", "in", "a", "bulk", "api", "operation", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L308-L342
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.fetch_search_document
def fetch_search_document(self, *, index): """Fetch the object's document from a search index by id.""" assert self.pk, "Object must have a primary key before being indexed." client = get_client() return client.get(index=index, doc_type=self.search_doc_type, id=self.pk)
python
def fetch_search_document(self, *, index): """Fetch the object's document from a search index by id.""" assert self.pk, "Object must have a primary key before being indexed." client = get_client() return client.get(index=index, doc_type=self.search_doc_type, id=self.pk)
[ "def", "fetch_search_document", "(", "self", ",", "*", ",", "index", ")", ":", "assert", "self", ".", "pk", ",", "\"Object must have a primary key before being indexed.\"", "client", "=", "get_client", "(", ")", "return", "client", ".", "get", "(", "index", "=",...
Fetch the object's document from a search index by id.
[ "Fetch", "the", "object", "s", "document", "from", "a", "search", "index", "by", "id", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L344-L348
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.index_search_document
def index_search_document(self, *, index): """ Create or replace search document in named index. Checks the local cache to see if the document has changed, and if not aborts the update, else pushes to ES, and then resets the local cache. Cache timeout is set as "cache_expiry" ...
python
def index_search_document(self, *, index): """ Create or replace search document in named index. Checks the local cache to see if the document has changed, and if not aborts the update, else pushes to ES, and then resets the local cache. Cache timeout is set as "cache_expiry" ...
[ "def", "index_search_document", "(", "self", ",", "*", ",", "index", ")", ":", "cache_key", "=", "self", ".", "search_document_cache_key", "new_doc", "=", "self", ".", "as_search_document", "(", "index", "=", "index", ")", "cached_doc", "=", "cache", ".", "g...
Create or replace search document in named index. Checks the local cache to see if the document has changed, and if not aborts the update, else pushes to ES, and then resets the local cache. Cache timeout is set as "cache_expiry" in the settings, and defaults to 60s.
[ "Create", "or", "replace", "search", "document", "in", "named", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L350-L369
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.update_search_document
def update_search_document(self, *, index, update_fields): """ Partial update of a document in named index. Partial updates are invoked via a call to save the document with 'update_fields'. These fields are passed to the as_search_document method so that it can build a partial ...
python
def update_search_document(self, *, index, update_fields): """ Partial update of a document in named index. Partial updates are invoked via a call to save the document with 'update_fields'. These fields are passed to the as_search_document method so that it can build a partial ...
[ "def", "update_search_document", "(", "self", ",", "*", ",", "index", ",", "update_fields", ")", ":", "doc", "=", "self", ".", "as_search_document_update", "(", "index", "=", "index", ",", "update_fields", "=", "update_fields", ")", "if", "not", "doc", ":", ...
Partial update of a document in named index. Partial updates are invoked via a call to save the document with 'update_fields'. These fields are passed to the as_search_document method so that it can build a partial document. NB we don't just call as_search_document and then stri...
[ "Partial", "update", "of", "a", "document", "in", "named", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L371-L398
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchDocumentMixin.delete_search_document
def delete_search_document(self, *, index): """Delete document from named index.""" cache.delete(self.search_document_cache_key) get_client().delete(index=index, doc_type=self.search_doc_type, id=self.pk)
python
def delete_search_document(self, *, index): """Delete document from named index.""" cache.delete(self.search_document_cache_key) get_client().delete(index=index, doc_type=self.search_doc_type, id=self.pk)
[ "def", "delete_search_document", "(", "self", ",", "*", ",", "index", ")", ":", "cache", ".", "delete", "(", "self", ".", "search_document_cache_key", ")", "get_client", "(", ")", ".", "delete", "(", "index", "=", "index", ",", "doc_type", "=", "self", "...
Delete document from named index.
[ "Delete", "document", "from", "named", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L400-L403
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchQuery.execute
def execute(cls, search, search_terms="", user=None, reference=None, save=True): """Create a new SearchQuery instance and execute a search against ES.""" warnings.warn( "Pending deprecation - please use `execute_search` function instead.", PendingDeprecationWarning, ) ...
python
def execute(cls, search, search_terms="", user=None, reference=None, save=True): """Create a new SearchQuery instance and execute a search against ES.""" warnings.warn( "Pending deprecation - please use `execute_search` function instead.", PendingDeprecationWarning, ) ...
[ "def", "execute", "(", "cls", ",", "search", ",", "search_terms", "=", "\"\"", ",", "user", "=", "None", ",", "reference", "=", "None", ",", "save", "=", "True", ")", ":", "warnings", ".", "warn", "(", "\"Pending deprecation - please use `execute_search` funct...
Create a new SearchQuery instance and execute a search against ES.
[ "Create", "a", "new", "SearchQuery", "instance", "and", "execute", "a", "search", "against", "ES", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L498-L506
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchQuery.save
def save(self, **kwargs): """Save and return the object (for chaining).""" if self.search_terms is None: self.search_terms = "" super().save(**kwargs) return self
python
def save(self, **kwargs): """Save and return the object (for chaining).""" if self.search_terms is None: self.search_terms = "" super().save(**kwargs) return self
[ "def", "save", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "search_terms", "is", "None", ":", "self", ".", "search_terms", "=", "\"\"", "super", "(", ")", ".", "save", "(", "*", "*", "kwargs", ")", "return", "self" ]
Save and return the object (for chaining).
[ "Save", "and", "return", "the", "object", "(", "for", "chaining", ")", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L508-L513
yunojuno/elasticsearch-django
elasticsearch_django/models.py
SearchQuery.page_slice
def page_slice(self): """Return the query from:size tuple (0-based).""" return ( None if self.query is None else (self.query.get("from", 0), self.query.get("size", 10)) )
python
def page_slice(self): """Return the query from:size tuple (0-based).""" return ( None if self.query is None else (self.query.get("from", 0), self.query.get("size", 10)) )
[ "def", "page_slice", "(", "self", ")", ":", "return", "(", "None", "if", "self", ".", "query", "is", "None", "else", "(", "self", ".", "query", ".", "get", "(", "\"from\"", ",", "0", ")", ",", "self", ".", "query", ".", "get", "(", "\"size\"", ",...
Return the query from:size tuple (0-based).
[ "Return", "the", "query", "from", ":", "size", "tuple", "(", "0", "-", "based", ")", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L541-L547
boundlessgeo/lib-qgis-commons
qgiscommons2/settings.py
setPluginSetting
def setPluginSetting(name, value, namespace = None): ''' Sets the value of a plugin setting. :param name: the name of the setting. It is not the full path, but just the last name of it :param value: the value to set for the plugin setting :param namespace: The namespace. If not passed or None, the ...
python
def setPluginSetting(name, value, namespace = None): ''' Sets the value of a plugin setting. :param name: the name of the setting. It is not the full path, but just the last name of it :param value: the value to set for the plugin setting :param namespace: The namespace. If not passed or None, the ...
[ "def", "setPluginSetting", "(", "name", ",", "value", ",", "namespace", "=", "None", ")", ":", "namespace", "=", "namespace", "or", "_callerName", "(", ")", ".", "split", "(", "\".\"", ")", "[", "0", "]", "settings", ".", "setValue", "(", "namespace", ...
Sets the value of a plugin setting. :param name: the name of the setting. It is not the full path, but just the last name of it :param value: the value to set for the plugin setting :param namespace: The namespace. If not passed or None, the namespace will be inferred from the caller method. Normally, ...
[ "Sets", "the", "value", "of", "a", "plugin", "setting", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/settings.py#L35-L47
boundlessgeo/lib-qgis-commons
qgiscommons2/settings.py
pluginSetting
def pluginSetting(name, namespace=None, typ=None): ''' Returns the value of a plugin setting. :param name: the name of the setting. It is not the full path, but just the last name of it :param namespace: The namespace. If not passed or None, the namespace will be inferred from the caller method. No...
python
def pluginSetting(name, namespace=None, typ=None): ''' Returns the value of a plugin setting. :param name: the name of the setting. It is not the full path, but just the last name of it :param namespace: The namespace. If not passed or None, the namespace will be inferred from the caller method. No...
[ "def", "pluginSetting", "(", "name", ",", "namespace", "=", "None", ",", "typ", "=", "None", ")", ":", "def", "_find_in_cache", "(", "name", ",", "key", ")", ":", "for", "setting", "in", "_settings", "[", "namespace", "]", ":", "if", "setting", "[", ...
Returns the value of a plugin setting. :param name: the name of the setting. It is not the full path, but just the last name of it :param namespace: The namespace. If not passed or None, the namespace will be inferred from the caller method. Normally, this should not be passed, since it suffices to let thi...
[ "Returns", "the", "value", "of", "a", "plugin", "setting", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/settings.py#L50-L88
boundlessgeo/lib-qgis-commons
qgiscommons2/settings.py
readSettings
def readSettings(settings_path=None): global _settings ''' Reads the settings corresponding to the plugin from where the method is called. This function has to be called in the __init__ method of the plugin class. Settings are stored in a settings.json file in the plugin folder. Here is an eampl...
python
def readSettings(settings_path=None): global _settings ''' Reads the settings corresponding to the plugin from where the method is called. This function has to be called in the __init__ method of the plugin class. Settings are stored in a settings.json file in the plugin folder. Here is an eampl...
[ "def", "readSettings", "(", "settings_path", "=", "None", ")", ":", "global", "_settings", "namespace", "=", "_callerName", "(", ")", ".", "split", "(", "\".\"", ")", "[", "0", "]", "settings_path", "=", "settings_path", "or", "os", ".", "path", ".", "jo...
Reads the settings corresponding to the plugin from where the method is called. This function has to be called in the __init__ method of the plugin class. Settings are stored in a settings.json file in the plugin folder. Here is an eample of such a file: [ {"name":"mysetting", "label": "My set...
[ "Reads", "the", "settings", "corresponding", "to", "the", "plugin", "from", "where", "the", "method", "is", "called", ".", "This", "function", "has", "to", "be", "called", "in", "the", "__init__", "method", "of", "the", "plugin", "class", ".", "Settings", ...
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/settings.py#L95-L146
yunojuno/elasticsearch-django
elasticsearch_django/management/commands/delete_search_index.py
Command.do_index_command
def do_index_command(self, index, **options): """Delete search index.""" if options["interactive"]: logger.warning("This will permanently delete the index '%s'.", index) if not self._confirm_action(): logger.warning( "Aborting deletion of index...
python
def do_index_command(self, index, **options): """Delete search index.""" if options["interactive"]: logger.warning("This will permanently delete the index '%s'.", index) if not self._confirm_action(): logger.warning( "Aborting deletion of index...
[ "def", "do_index_command", "(", "self", ",", "index", ",", "*", "*", "options", ")", ":", "if", "options", "[", "\"interactive\"", "]", ":", "logger", ".", "warning", "(", "\"This will permanently delete the index '%s'.\"", ",", "index", ")", "if", "not", "sel...
Delete search index.
[ "Delete", "search", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/management/commands/delete_search_index.py#L17-L26
yunojuno/elasticsearch-django
elasticsearch_django/index.py
create_index
def create_index(index): """Create an index and apply mapping if appropriate.""" logger.info("Creating search index: '%s'", index) client = get_client() return client.indices.create(index=index, body=get_index_mapping(index))
python
def create_index(index): """Create an index and apply mapping if appropriate.""" logger.info("Creating search index: '%s'", index) client = get_client() return client.indices.create(index=index, body=get_index_mapping(index))
[ "def", "create_index", "(", "index", ")", ":", "logger", ".", "info", "(", "\"Creating search index: '%s'\"", ",", "index", ")", "client", "=", "get_client", "(", ")", "return", "client", ".", "indices", ".", "create", "(", "index", "=", "index", ",", "bod...
Create an index and apply mapping if appropriate.
[ "Create", "an", "index", "and", "apply", "mapping", "if", "appropriate", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L10-L14
yunojuno/elasticsearch-django
elasticsearch_django/index.py
update_index
def update_index(index): """Re-index every document in a named index.""" logger.info("Updating search index: '%s'", index) client = get_client() responses = [] for model in get_index_models(index): logger.info("Updating search index model: '%s'", model.search_doc_type) objects = mode...
python
def update_index(index): """Re-index every document in a named index.""" logger.info("Updating search index: '%s'", index) client = get_client() responses = [] for model in get_index_models(index): logger.info("Updating search index model: '%s'", model.search_doc_type) objects = mode...
[ "def", "update_index", "(", "index", ")", ":", "logger", ".", "info", "(", "\"Updating search index: '%s'\"", ",", "index", ")", "client", "=", "get_client", "(", ")", "responses", "=", "[", "]", "for", "model", "in", "get_index_models", "(", "index", ")", ...
Re-index every document in a named index.
[ "Re", "-", "index", "every", "document", "in", "a", "named", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L17-L28
yunojuno/elasticsearch-django
elasticsearch_django/index.py
delete_index
def delete_index(index): """Delete index entirely (removes all documents and mapping).""" logger.info("Deleting search index: '%s'", index) client = get_client() return client.indices.delete(index=index)
python
def delete_index(index): """Delete index entirely (removes all documents and mapping).""" logger.info("Deleting search index: '%s'", index) client = get_client() return client.indices.delete(index=index)
[ "def", "delete_index", "(", "index", ")", ":", "logger", ".", "info", "(", "\"Deleting search index: '%s'\"", ",", "index", ")", "client", "=", "get_client", "(", ")", "return", "client", ".", "indices", ".", "delete", "(", "index", "=", "index", ")" ]
Delete index entirely (removes all documents and mapping).
[ "Delete", "index", "entirely", "(", "removes", "all", "documents", "and", "mapping", ")", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L31-L35
yunojuno/elasticsearch-django
elasticsearch_django/index.py
prune_index
def prune_index(index): """Remove all orphaned documents from an index. This function works by scanning the remote index, and in each returned batch of documents looking up whether they appear in the default index queryset. If they don't (they've been deleted, or no longer fit the qs filters) then ...
python
def prune_index(index): """Remove all orphaned documents from an index. This function works by scanning the remote index, and in each returned batch of documents looking up whether they appear in the default index queryset. If they don't (they've been deleted, or no longer fit the qs filters) then ...
[ "def", "prune_index", "(", "index", ")", ":", "logger", ".", "info", "(", "\"Pruning missing objects from index '%s'\"", ",", "index", ")", "prunes", "=", "[", "]", "responses", "=", "[", "]", "client", "=", "get_client", "(", ")", "for", "model", "in", "g...
Remove all orphaned documents from an index. This function works by scanning the remote index, and in each returned batch of documents looking up whether they appear in the default index queryset. If they don't (they've been deleted, or no longer fit the qs filters) then they are deleted from the index...
[ "Remove", "all", "orphaned", "documents", "from", "an", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L38-L76
yunojuno/elasticsearch-django
elasticsearch_django/index.py
_prune_hit
def _prune_hit(hit, model): """ Check whether a document should be pruned. This method uses the SearchDocumentManagerMixin.in_search_queryset method to determine whether a 'hit' (search document) should be pruned from an index, and if so it returns the hit as a Django object(id=hit_id). Args: ...
python
def _prune_hit(hit, model): """ Check whether a document should be pruned. This method uses the SearchDocumentManagerMixin.in_search_queryset method to determine whether a 'hit' (search document) should be pruned from an index, and if so it returns the hit as a Django object(id=hit_id). Args: ...
[ "def", "_prune_hit", "(", "hit", ",", "model", ")", ":", "hit_id", "=", "hit", "[", "\"_id\"", "]", "hit_index", "=", "hit", "[", "\"_index\"", "]", "if", "model", ".", "objects", ".", "in_search_queryset", "(", "hit_id", ",", "index", "=", "hit_index", ...
Check whether a document should be pruned. This method uses the SearchDocumentManagerMixin.in_search_queryset method to determine whether a 'hit' (search document) should be pruned from an index, and if so it returns the hit as a Django object(id=hit_id). Args: hit: dict object the represents ...
[ "Check", "whether", "a", "document", "should", "be", "pruned", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L79-L116
yunojuno/elasticsearch-django
elasticsearch_django/index.py
scan_index
def scan_index(index, model): """ Yield all documents of model type in an index. This function calls the elasticsearch.helpers.scan function, and yields all the documents in the index that match the doc_type produced by a specific Django model. Args: index: string, the name of the inde...
python
def scan_index(index, model): """ Yield all documents of model type in an index. This function calls the elasticsearch.helpers.scan function, and yields all the documents in the index that match the doc_type produced by a specific Django model. Args: index: string, the name of the inde...
[ "def", "scan_index", "(", "index", ",", "model", ")", ":", "# see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html", "query", "=", "{", "\"query\"", ":", "{", "\"type\"", ":", "{", "\"value\"", ":", "model", ".", "_meta", ".", ...
Yield all documents of model type in an index. This function calls the elasticsearch.helpers.scan function, and yields all the documents in the index that match the doc_type produced by a specific Django model. Args: index: string, the name of the index to scan, must be a configured ...
[ "Yield", "all", "documents", "of", "model", "type", "in", "an", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L119-L140
yunojuno/elasticsearch-django
elasticsearch_django/index.py
bulk_actions
def bulk_actions(objects, index, action): """ Yield bulk api 'actions' from a collection of objects. The output from this method can be fed in to the bulk api helpers - each document returned by get_documents is decorated with the appropriate bulk api op_type. Args: objects: iterable (...
python
def bulk_actions(objects, index, action): """ Yield bulk api 'actions' from a collection of objects. The output from this method can be fed in to the bulk api helpers - each document returned by get_documents is decorated with the appropriate bulk api op_type. Args: objects: iterable (...
[ "def", "bulk_actions", "(", "objects", ",", "index", ",", "action", ")", ":", "assert", "(", "index", "!=", "\"_all\"", ")", ",", "\"index arg must be a valid index name. '_all' is a reserved term.\"", "logger", ".", "info", "(", "\"Creating bulk '%s' actions for '%s'\"",...
Yield bulk api 'actions' from a collection of objects. The output from this method can be fed in to the bulk api helpers - each document returned by get_documents is decorated with the appropriate bulk api op_type. Args: objects: iterable (queryset, list, ...) of SearchDocumentMixin ...
[ "Yield", "bulk", "api", "actions", "from", "a", "collection", "of", "objects", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/index.py#L143-L170
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_validate_config
def _validate_config(strict=False): """Validate settings.SEARCH_SETTINGS.""" for index in settings.get_index_names(): _validate_mapping(index, strict=strict) for model in settings.get_index_models(index): _validate_model(model) if settings.get_setting("update_strategy", "full") n...
python
def _validate_config(strict=False): """Validate settings.SEARCH_SETTINGS.""" for index in settings.get_index_names(): _validate_mapping(index, strict=strict) for model in settings.get_index_models(index): _validate_model(model) if settings.get_setting("update_strategy", "full") n...
[ "def", "_validate_config", "(", "strict", "=", "False", ")", ":", "for", "index", "in", "settings", ".", "get_index_names", "(", ")", ":", "_validate_mapping", "(", "index", ",", "strict", "=", "strict", ")", "for", "model", "in", "settings", ".", "get_ind...
Validate settings.SEARCH_SETTINGS.
[ "Validate", "settings", ".", "SEARCH_SETTINGS", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L28-L37
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_validate_mapping
def _validate_mapping(index, strict=False): """Check that an index mapping JSON file exists.""" try: settings.get_index_mapping(index) except IOError: if strict: raise ImproperlyConfigured("Index '%s' has no mapping file." % index) else: logger.warning("Index ...
python
def _validate_mapping(index, strict=False): """Check that an index mapping JSON file exists.""" try: settings.get_index_mapping(index) except IOError: if strict: raise ImproperlyConfigured("Index '%s' has no mapping file." % index) else: logger.warning("Index ...
[ "def", "_validate_mapping", "(", "index", ",", "strict", "=", "False", ")", ":", "try", ":", "settings", ".", "get_index_mapping", "(", "index", ")", "except", "IOError", ":", "if", "strict", ":", "raise", "ImproperlyConfigured", "(", "\"Index '%s' has no mappin...
Check that an index mapping JSON file exists.
[ "Check", "that", "an", "index", "mapping", "JSON", "file", "exists", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L40-L48
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_validate_model
def _validate_model(model): """Check that a model configured for an index subclasses the required classes.""" if not hasattr(model, "as_search_document"): raise ImproperlyConfigured("'%s' must implement `as_search_document`." % model) if not hasattr(model.objects, "get_search_queryset"): rai...
python
def _validate_model(model): """Check that a model configured for an index subclasses the required classes.""" if not hasattr(model, "as_search_document"): raise ImproperlyConfigured("'%s' must implement `as_search_document`." % model) if not hasattr(model.objects, "get_search_queryset"): rai...
[ "def", "_validate_model", "(", "model", ")", ":", "if", "not", "hasattr", "(", "model", ",", "\"as_search_document\"", ")", ":", "raise", "ImproperlyConfigured", "(", "\"'%s' must implement `as_search_document`.\"", "%", "model", ")", "if", "not", "hasattr", "(", ...
Check that a model configured for an index subclasses the required classes.
[ "Check", "that", "a", "model", "configured", "for", "an", "index", "subclasses", "the", "required", "classes", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L51-L58
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_connect_signals
def _connect_signals(): """Connect up post_save, post_delete signals for models.""" for index in settings.get_index_names(): for model in settings.get_index_models(index): _connect_model_signals(model)
python
def _connect_signals(): """Connect up post_save, post_delete signals for models.""" for index in settings.get_index_names(): for model in settings.get_index_models(index): _connect_model_signals(model)
[ "def", "_connect_signals", "(", ")", ":", "for", "index", "in", "settings", ".", "get_index_names", "(", ")", ":", "for", "model", "in", "settings", ".", "get_index_models", "(", "index", ")", ":", "_connect_model_signals", "(", "model", ")" ]
Connect up post_save, post_delete signals for models.
[ "Connect", "up", "post_save", "post_delete", "signals", "for", "models", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L61-L65
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_connect_model_signals
def _connect_model_signals(model): """Connect signals for a single model.""" dispatch_uid = "%s.post_save" % model._meta.model_name logger.debug("Connecting search index model post_save signal: %s", dispatch_uid) signals.post_save.connect(_on_model_save, sender=model, dispatch_uid=dispatch_uid) disp...
python
def _connect_model_signals(model): """Connect signals for a single model.""" dispatch_uid = "%s.post_save" % model._meta.model_name logger.debug("Connecting search index model post_save signal: %s", dispatch_uid) signals.post_save.connect(_on_model_save, sender=model, dispatch_uid=dispatch_uid) disp...
[ "def", "_connect_model_signals", "(", "model", ")", ":", "dispatch_uid", "=", "\"%s.post_save\"", "%", "model", ".", "_meta", ".", "model_name", "logger", ".", "debug", "(", "\"Connecting search index model post_save signal: %s\"", ",", "dispatch_uid", ")", "signals", ...
Connect signals for a single model.
[ "Connect", "signals", "for", "a", "single", "model", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L68-L77
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_on_model_save
def _on_model_save(sender, **kwargs): """Update document in search index post_save.""" instance = kwargs.pop("instance") update_fields = kwargs.pop("update_fields") for index in instance.search_indexes: try: _update_search_index( instance=instance, index=index, update...
python
def _on_model_save(sender, **kwargs): """Update document in search index post_save.""" instance = kwargs.pop("instance") update_fields = kwargs.pop("update_fields") for index in instance.search_indexes: try: _update_search_index( instance=instance, index=index, update...
[ "def", "_on_model_save", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "instance", "=", "kwargs", ".", "pop", "(", "\"instance\"", ")", "update_fields", "=", "kwargs", ".", "pop", "(", "\"update_fields\"", ")", "for", "index", "in", "instance", ".", ...
Update document in search index post_save.
[ "Update", "document", "in", "search", "index", "post_save", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L80-L90
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_on_model_delete
def _on_model_delete(sender, **kwargs): """Remove documents from search indexes post_delete.""" instance = kwargs.pop("instance") for index in instance.search_indexes: try: _delete_from_search_index(instance=instance, index=index) except Exception: logger.exception("E...
python
def _on_model_delete(sender, **kwargs): """Remove documents from search indexes post_delete.""" instance = kwargs.pop("instance") for index in instance.search_indexes: try: _delete_from_search_index(instance=instance, index=index) except Exception: logger.exception("E...
[ "def", "_on_model_delete", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "instance", "=", "kwargs", ".", "pop", "(", "\"instance\"", ")", "for", "index", "in", "instance", ".", "search_indexes", ":", "try", ":", "_delete_from_search_index", "(", "instanc...
Remove documents from search indexes post_delete.
[ "Remove", "documents", "from", "search", "indexes", "post_delete", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L93-L100
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_in_search_queryset
def _in_search_queryset(*, instance, index) -> bool: """Wrapper around the instance manager method.""" try: return instance.__class__.objects.in_search_queryset(instance.id, index=index) except Exception: logger.exception("Error checking object in_search_queryset.") return False
python
def _in_search_queryset(*, instance, index) -> bool: """Wrapper around the instance manager method.""" try: return instance.__class__.objects.in_search_queryset(instance.id, index=index) except Exception: logger.exception("Error checking object in_search_queryset.") return False
[ "def", "_in_search_queryset", "(", "*", ",", "instance", ",", "index", ")", "->", "bool", ":", "try", ":", "return", "instance", ".", "__class__", ".", "objects", ".", "in_search_queryset", "(", "instance", ".", "id", ",", "index", "=", "index", ")", "ex...
Wrapper around the instance manager method.
[ "Wrapper", "around", "the", "instance", "manager", "method", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L103-L109
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_update_search_index
def _update_search_index(*, instance, index, update_fields): """Process index / update search index update actions.""" if not _in_search_queryset(instance=instance, index=index): logger.debug( "Object (%r) is not in search queryset, ignoring update.", instance ) return t...
python
def _update_search_index(*, instance, index, update_fields): """Process index / update search index update actions.""" if not _in_search_queryset(instance=instance, index=index): logger.debug( "Object (%r) is not in search queryset, ignoring update.", instance ) return t...
[ "def", "_update_search_index", "(", "*", ",", "instance", ",", "index", ",", "update_fields", ")", ":", "if", "not", "_in_search_queryset", "(", "instance", "=", "instance", ",", "index", "=", "index", ")", ":", "logger", ".", "debug", "(", "\"Object (%r) is...
Process index / update search index update actions.
[ "Process", "index", "/", "update", "search", "index", "update", "actions", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L112-L137
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
_delete_from_search_index
def _delete_from_search_index(*, instance, index): """Remove a document from a search index.""" pre_delete.send(sender=instance.__class__, instance=instance, index=index) if settings.auto_sync(instance): instance.delete_search_document(index=index)
python
def _delete_from_search_index(*, instance, index): """Remove a document from a search index.""" pre_delete.send(sender=instance.__class__, instance=instance, index=index) if settings.auto_sync(instance): instance.delete_search_document(index=index)
[ "def", "_delete_from_search_index", "(", "*", ",", "instance", ",", "index", ")", ":", "pre_delete", ".", "send", "(", "sender", "=", "instance", ".", "__class__", ",", "instance", "=", "instance", ",", "index", "=", "index", ")", "if", "settings", ".", ...
Remove a document from a search index.
[ "Remove", "a", "document", "from", "a", "search", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L140-L144
yunojuno/elasticsearch-django
elasticsearch_django/apps.py
ElasticAppConfig.ready
def ready(self): """Validate config and connect signals.""" super(ElasticAppConfig, self).ready() _validate_config(settings.get_setting("strict_validation")) _connect_signals()
python
def ready(self): """Validate config and connect signals.""" super(ElasticAppConfig, self).ready() _validate_config(settings.get_setting("strict_validation")) _connect_signals()
[ "def", "ready", "(", "self", ")", ":", "super", "(", "ElasticAppConfig", ",", "self", ")", ".", "ready", "(", ")", "_validate_config", "(", "settings", ".", "get_setting", "(", "\"strict_validation\"", ")", ")", "_connect_signals", "(", ")" ]
Validate config and connect signals.
[ "Validate", "config", "and", "connect", "signals", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/apps.py#L21-L25
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
get_setting
def get_setting(key, *default): """Return specific search setting from Django conf.""" if default: return get_settings().get(key, default[0]) else: return get_settings()[key]
python
def get_setting(key, *default): """Return specific search setting from Django conf.""" if default: return get_settings().get(key, default[0]) else: return get_settings()[key]
[ "def", "get_setting", "(", "key", ",", "*", "default", ")", ":", "if", "default", ":", "return", "get_settings", "(", ")", ".", "get", "(", "key", ",", "default", "[", "0", "]", ")", "else", ":", "return", "get_settings", "(", ")", "[", "key", "]" ...
Return specific search setting from Django conf.
[ "Return", "specific", "search", "setting", "from", "Django", "conf", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L29-L34
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
get_index_mapping
def get_index_mapping(index): """Return the JSON mapping file for an index. Mappings are stored as JSON files in the mappings subdirectory of this app. They must be saved as {{index}}.json. Args: index: string, the name of the index to look for. """ # app_path = apps.get_app_config('e...
python
def get_index_mapping(index): """Return the JSON mapping file for an index. Mappings are stored as JSON files in the mappings subdirectory of this app. They must be saved as {{index}}.json. Args: index: string, the name of the index to look for. """ # app_path = apps.get_app_config('e...
[ "def", "get_index_mapping", "(", "index", ")", ":", "# app_path = apps.get_app_config('elasticsearch_django').path", "mappings_dir", "=", "get_setting", "(", "\"mappings_dir\"", ")", "filename", "=", "\"%s.json\"", "%", "index", "path", "=", "os", ".", "path", ".", "j...
Return the JSON mapping file for an index. Mappings are stored as JSON files in the mappings subdirectory of this app. They must be saved as {{index}}.json. Args: index: string, the name of the index to look for.
[ "Return", "the", "JSON", "mapping", "file", "for", "an", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L57-L72
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
get_model_index_properties
def get_model_index_properties(instance, index): """Return the list of properties specified for a model in an index.""" mapping = get_index_mapping(index) doc_type = instance._meta.model_name.lower() return list(mapping["mappings"][doc_type]["properties"].keys())
python
def get_model_index_properties(instance, index): """Return the list of properties specified for a model in an index.""" mapping = get_index_mapping(index) doc_type = instance._meta.model_name.lower() return list(mapping["mappings"][doc_type]["properties"].keys())
[ "def", "get_model_index_properties", "(", "instance", ",", "index", ")", ":", "mapping", "=", "get_index_mapping", "(", "index", ")", "doc_type", "=", "instance", ".", "_meta", ".", "model_name", ".", "lower", "(", ")", "return", "list", "(", "mapping", "[",...
Return the list of properties specified for a model in an index.
[ "Return", "the", "list", "of", "properties", "specified", "for", "a", "model", "in", "an", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L75-L79
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
get_index_models
def get_index_models(index): """Return list of models configured for a named index. Args: index: string, the name of the index to look up. """ models = [] for app_model in get_index_config(index).get("models"): app, model = app_model.split(".") models.append(apps.get_model(...
python
def get_index_models(index): """Return list of models configured for a named index. Args: index: string, the name of the index to look up. """ models = [] for app_model in get_index_config(index).get("models"): app, model = app_model.split(".") models.append(apps.get_model(...
[ "def", "get_index_models", "(", "index", ")", ":", "models", "=", "[", "]", "for", "app_model", "in", "get_index_config", "(", "index", ")", ".", "get", "(", "\"models\"", ")", ":", "app", ",", "model", "=", "app_model", ".", "split", "(", "\".\"", ")"...
Return list of models configured for a named index. Args: index: string, the name of the index to look up.
[ "Return", "list", "of", "models", "configured", "for", "a", "named", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L82-L93
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
get_model_indexes
def get_model_indexes(model): """Return list of all indexes in which a model is configured. A model may be configured to appear in multiple indexes. This function will return the names of the indexes as a list of strings. This is useful if you want to know which indexes need updating when a model i...
python
def get_model_indexes(model): """Return list of all indexes in which a model is configured. A model may be configured to appear in multiple indexes. This function will return the names of the indexes as a list of strings. This is useful if you want to know which indexes need updating when a model i...
[ "def", "get_model_indexes", "(", "model", ")", ":", "indexes", "=", "[", "]", "for", "index", "in", "get_index_names", "(", ")", ":", "for", "app_model", "in", "get_index_models", "(", "index", ")", ":", "if", "app_model", "==", "model", ":", "indexes", ...
Return list of all indexes in which a model is configured. A model may be configured to appear in multiple indexes. This function will return the names of the indexes as a list of strings. This is useful if you want to know which indexes need updating when a model is saved. Args: model: a ...
[ "Return", "list", "of", "all", "indexes", "in", "which", "a", "model", "is", "configured", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L96-L113
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
get_document_models
def get_document_models(): """Return dict of index.doc_type: model.""" mappings = {} for i in get_index_names(): for m in get_index_models(i): key = "%s.%s" % (i, m._meta.model_name) mappings[key] = m return mappings
python
def get_document_models(): """Return dict of index.doc_type: model.""" mappings = {} for i in get_index_names(): for m in get_index_models(i): key = "%s.%s" % (i, m._meta.model_name) mappings[key] = m return mappings
[ "def", "get_document_models", "(", ")", ":", "mappings", "=", "{", "}", "for", "i", "in", "get_index_names", "(", ")", ":", "for", "m", "in", "get_index_models", "(", "i", ")", ":", "key", "=", "\"%s.%s\"", "%", "(", "i", ",", "m", ".", "_meta", "....
Return dict of index.doc_type: model.
[ "Return", "dict", "of", "index", ".", "doc_type", ":", "model", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L116-L123
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
auto_sync
def auto_sync(instance): """Returns bool if auto_sync is on for the model (instance)""" # this allows us to turn off sync temporarily - e.g. when doing bulk updates if not get_setting("auto_sync"): return False model_name = "{}.{}".format(instance._meta.app_label, instance._meta.model_name) ...
python
def auto_sync(instance): """Returns bool if auto_sync is on for the model (instance)""" # this allows us to turn off sync temporarily - e.g. when doing bulk updates if not get_setting("auto_sync"): return False model_name = "{}.{}".format(instance._meta.app_label, instance._meta.model_name) ...
[ "def", "auto_sync", "(", "instance", ")", ":", "# this allows us to turn off sync temporarily - e.g. when doing bulk updates", "if", "not", "get_setting", "(", "\"auto_sync\"", ")", ":", "return", "False", "model_name", "=", "\"{}.{}\"", ".", "format", "(", "instance", ...
Returns bool if auto_sync is on for the model (instance)
[ "Returns", "bool", "if", "auto_sync", "is", "on", "for", "the", "model", "(", "instance", ")" ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L131-L139
yunojuno/elasticsearch-django
elasticsearch_django/admin.py
pprint
def pprint(data): """ Returns an indented HTML pretty-print version of JSON. Take the event_payload JSON, indent it, order the keys and then present it as a <code> block. That's about as good as we can get until someone builds a custom syntax function. """ pretty = json.dumps(data, sort_ke...
python
def pprint(data): """ Returns an indented HTML pretty-print version of JSON. Take the event_payload JSON, indent it, order the keys and then present it as a <code> block. That's about as good as we can get until someone builds a custom syntax function. """ pretty = json.dumps(data, sort_ke...
[ "def", "pprint", "(", "data", ")", ":", "pretty", "=", "json", ".", "dumps", "(", "data", ",", "sort_keys", "=", "True", ",", "indent", "=", "4", ",", "separators", "=", "(", "\",\"", ",", "\": \"", ")", ")", "html", "=", "pretty", ".", "replace", ...
Returns an indented HTML pretty-print version of JSON. Take the event_payload JSON, indent it, order the keys and then present it as a <code> block. That's about as good as we can get until someone builds a custom syntax function.
[ "Returns", "an", "indented", "HTML", "pretty", "-", "print", "version", "of", "JSON", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/admin.py#L13-L24
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/__init__.py
addHelpMenu
def addHelpMenu(menuName, parentMenuFunction=None): ''' Adds a help menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added. ''' parentMenuFunction = parentMenuFunction or ...
python
def addHelpMenu(menuName, parentMenuFunction=None): ''' Adds a help menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added. ''' parentMenuFunction = parentMenuFunction or ...
[ "def", "addHelpMenu", "(", "menuName", ",", "parentMenuFunction", "=", "None", ")", ":", "parentMenuFunction", "=", "parentMenuFunction", "or", "iface", ".", "addPluginToMenu", "namespace", "=", "_callerName", "(", ")", ".", "split", "(", "\".\"", ")", "[", "0...
Adds a help menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added.
[ "Adds", "a", "help", "menu", "to", "the", "plugin", "menu", ".", "This", "method", "should", "be", "called", "from", "the", "initGui", "()", "method", "of", "the", "plugin" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/__init__.py#L12-L29
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/__init__.py
addAboutMenu
def addAboutMenu(menuName, parentMenuFunction=None): ''' Adds an 'about...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added ''' parentMenuFunction = parentMenuFunct...
python
def addAboutMenu(menuName, parentMenuFunction=None): ''' Adds an 'about...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added ''' parentMenuFunction = parentMenuFunct...
[ "def", "addAboutMenu", "(", "menuName", ",", "parentMenuFunction", "=", "None", ")", ":", "parentMenuFunction", "=", "parentMenuFunction", "or", "iface", ".", "addPluginToMenu", "namespace", "=", "_callerName", "(", ")", ".", "split", "(", "\".\"", ")", "[", "...
Adds an 'about...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the about menu is to be added
[ "Adds", "an", "about", "...", "menu", "to", "the", "plugin", "menu", ".", "This", "method", "should", "be", "called", "from", "the", "initGui", "()", "method", "of", "the", "plugin" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/__init__.py#L47-L63
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/__init__.py
showMessageDialog
def showMessageDialog(title, text): ''' Show a dialog containing a given text, with a given title. The text accepts HTML syntax ''' dlg = QgsMessageOutput.createMessageOutput() dlg.setTitle(title) dlg.setMessage(text, QgsMessageOutput.MessageHtml) dlg.showMessage()
python
def showMessageDialog(title, text): ''' Show a dialog containing a given text, with a given title. The text accepts HTML syntax ''' dlg = QgsMessageOutput.createMessageOutput() dlg.setTitle(title) dlg.setMessage(text, QgsMessageOutput.MessageHtml) dlg.showMessage()
[ "def", "showMessageDialog", "(", "title", ",", "text", ")", ":", "dlg", "=", "QgsMessageOutput", ".", "createMessageOutput", "(", ")", "dlg", ".", "setTitle", "(", "title", ")", "dlg", ".", "setMessage", "(", "text", ",", "QgsMessageOutput", ".", "MessageHtm...
Show a dialog containing a given text, with a given title. The text accepts HTML syntax
[ "Show", "a", "dialog", "containing", "a", "given", "text", "with", "a", "given", "title", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/__init__.py#L76-L85
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/__init__.py
askForFiles
def askForFiles(parent, msg = None, isSave = False, allowMultiple = False, exts = "*"): ''' Asks for a file or files, opening the corresponding dialog with the last path that was selected when this same function was invoked from the calling method. :param parent: The parent window :param msg: The m...
python
def askForFiles(parent, msg = None, isSave = False, allowMultiple = False, exts = "*"): ''' Asks for a file or files, opening the corresponding dialog with the last path that was selected when this same function was invoked from the calling method. :param parent: The parent window :param msg: The m...
[ "def", "askForFiles", "(", "parent", ",", "msg", "=", "None", ",", "isSave", "=", "False", ",", "allowMultiple", "=", "False", ",", "exts", "=", "\"*\"", ")", ":", "msg", "=", "msg", "or", "'Select file'", "caller", "=", "_callerName", "(", ")", ".", ...
Asks for a file or files, opening the corresponding dialog with the last path that was selected when this same function was invoked from the calling method. :param parent: The parent window :param msg: The message to use for the dialog title :param isSave: true if we are asking for file to save :pa...
[ "Asks", "for", "a", "file", "or", "files", "opening", "the", "corresponding", "dialog", "with", "the", "last", "path", "that", "was", "selected", "when", "this", "same", "function", "was", "invoked", "from", "the", "calling", "method", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/__init__.py#L103-L144
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/__init__.py
askForFolder
def askForFolder(parent, msg = None): ''' Asks for a folder, opening the corresponding dialog with the last path that was selected when this same function was invoked from the calling method :param parent: The parent window :param msg: The message to use for the dialog title ''' msg = msg o...
python
def askForFolder(parent, msg = None): ''' Asks for a folder, opening the corresponding dialog with the last path that was selected when this same function was invoked from the calling method :param parent: The parent window :param msg: The message to use for the dialog title ''' msg = msg o...
[ "def", "askForFolder", "(", "parent", ",", "msg", "=", "None", ")", ":", "msg", "=", "msg", "or", "'Select folder'", "caller", "=", "_callerName", "(", ")", ".", "split", "(", "\".\"", ")", "name", "=", "\"/\"", ".", "join", "(", "[", "LAST_PATH", ",...
Asks for a folder, opening the corresponding dialog with the last path that was selected when this same function was invoked from the calling method :param parent: The parent window :param msg: The message to use for the dialog title
[ "Asks", "for", "a", "folder", "opening", "the", "corresponding", "dialog", "with", "the", "last", "path", "that", "was", "selected", "when", "this", "same", "function", "was", "invoked", "from", "the", "calling", "method" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/__init__.py#L146-L162
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/__init__.py
execute
def execute(func, message = None): ''' Executes a lengthy tasks in a separate thread and displays a waiting dialog if needed. Sets the cursor to wait cursor while the task is running. This function does not provide any support for progress indication :param func: The function to execute. :par...
python
def execute(func, message = None): ''' Executes a lengthy tasks in a separate thread and displays a waiting dialog if needed. Sets the cursor to wait cursor while the task is running. This function does not provide any support for progress indication :param func: The function to execute. :par...
[ "def", "execute", "(", "func", ",", "message", "=", "None", ")", ":", "global", "_dialog", "cursor", "=", "QtWidgets", ".", "QApplication", ".", "overrideCursor", "(", ")", "waitCursor", "=", "(", "cursor", "is", "not", "None", "and", "cursor", ".", "sha...
Executes a lengthy tasks in a separate thread and displays a waiting dialog if needed. Sets the cursor to wait cursor while the task is running. This function does not provide any support for progress indication :param func: The function to execute. :param message: The message to display in the wait ...
[ "Executes", "a", "lengthy", "tasks", "in", "a", "separate", "thread", "and", "displays", "a", "waiting", "dialog", "if", "needed", ".", "Sets", "the", "cursor", "to", "wait", "cursor", "while", "the", "task", "is", "running", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/__init__.py#L186-L239
yunojuno/elasticsearch-django
elasticsearch_django/decorators.py
disable_search_updates
def disable_search_updates(): """ Context manager used to temporarily disable auto_sync. This is useful when performing bulk updates on objects - when you may not want to flood the indexing process. >>> with disable_search_updates(): ... for obj in model.objects.all(): ... obj.save...
python
def disable_search_updates(): """ Context manager used to temporarily disable auto_sync. This is useful when performing bulk updates on objects - when you may not want to flood the indexing process. >>> with disable_search_updates(): ... for obj in model.objects.all(): ... obj.save...
[ "def", "disable_search_updates", "(", ")", ":", "_receivers", "=", "signals", ".", "post_save", ".", "receivers", ".", "copy", "(", ")", "signals", ".", "post_save", ".", "receivers", "=", "_strip_on_model_save", "(", ")", "yield", "signals", ".", "post_save",...
Context manager used to temporarily disable auto_sync. This is useful when performing bulk updates on objects - when you may not want to flood the indexing process. >>> with disable_search_updates(): ... for obj in model.objects.all(): ... obj.save() The function works by temporarily ...
[ "Context", "manager", "used", "to", "temporarily", "disable", "auto_sync", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/decorators.py#L15-L34
boundlessgeo/lib-qgis-commons
qgiscommons2/network/networkaccessmanager.py
NetworkAccessManager.request
def request(self, url, method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None, blocking=True): """ Make a network request by calling QgsNetworkAccessManager. redirections argument is ignored and is here only for httplib2 compatibility. """ ...
python
def request(self, url, method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None, blocking=True): """ Make a network request by calling QgsNetworkAccessManager. redirections argument is ignored and is here only for httplib2 compatibility. """ ...
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "\"GET\"", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "redirections", "=", "DEFAULT_MAX_REDIRECTS", ",", "connection_type", "=", "None", ",", "blocking", "=", "True", ")", ":...
Make a network request by calling QgsNetworkAccessManager. redirections argument is ignored and is here only for httplib2 compatibility.
[ "Make", "a", "network", "request", "by", "calling", "QgsNetworkAccessManager", ".", "redirections", "argument", "is", "ignored", "and", "is", "here", "only", "for", "httplib2", "compatibility", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/networkaccessmanager.py#L174-L261
boundlessgeo/lib-qgis-commons
qgiscommons2/network/networkaccessmanager.py
NetworkAccessManager.requestTimedOut
def requestTimedOut(self, reply): """Trap the timeout. In Async mode requestTimedOut is called after replyFinished""" # adapt http_call_result basing on receiving qgs timer timout signal self.exception_class = RequestsExceptionTimeout self.http_call_result.exception = RequestsExceptionTi...
python
def requestTimedOut(self, reply): """Trap the timeout. In Async mode requestTimedOut is called after replyFinished""" # adapt http_call_result basing on receiving qgs timer timout signal self.exception_class = RequestsExceptionTimeout self.http_call_result.exception = RequestsExceptionTi...
[ "def", "requestTimedOut", "(", "self", ",", "reply", ")", ":", "# adapt http_call_result basing on receiving qgs timer timout signal", "self", ".", "exception_class", "=", "RequestsExceptionTimeout", "self", ".", "http_call_result", ".", "exception", "=", "RequestsExceptionTi...
Trap the timeout. In Async mode requestTimedOut is called after replyFinished
[ "Trap", "the", "timeout", ".", "In", "Async", "mode", "requestTimedOut", "is", "called", "after", "replyFinished" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/networkaccessmanager.py#L268-L272
boundlessgeo/lib-qgis-commons
qgiscommons2/network/networkaccessmanager.py
NetworkAccessManager.sslErrors
def sslErrors(self, ssl_errors): """ Handle SSL errors, logging them if debug is on and ignoring them if disable_ssl_certificate_validation is set. """ if ssl_errors: for v in ssl_errors: self.msg_log("SSL Error: %s" % v.errorString()) if self....
python
def sslErrors(self, ssl_errors): """ Handle SSL errors, logging them if debug is on and ignoring them if disable_ssl_certificate_validation is set. """ if ssl_errors: for v in ssl_errors: self.msg_log("SSL Error: %s" % v.errorString()) if self....
[ "def", "sslErrors", "(", "self", ",", "ssl_errors", ")", ":", "if", "ssl_errors", ":", "for", "v", "in", "ssl_errors", ":", "self", ".", "msg_log", "(", "\"SSL Error: %s\"", "%", "v", ".", "errorString", "(", ")", ")", "if", "self", ".", "disable_ssl_cer...
Handle SSL errors, logging them if debug is on and ignoring them if disable_ssl_certificate_validation is set.
[ "Handle", "SSL", "errors", "logging", "them", "if", "debug", "is", "on", "and", "ignoring", "them", "if", "disable_ssl_certificate_validation", "is", "set", "." ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/networkaccessmanager.py#L377-L386
boundlessgeo/lib-qgis-commons
qgiscommons2/network/networkaccessmanager.py
NetworkAccessManager.abort
def abort(self): """ Handle request to cancel HTTP call """ if (self.reply and self.reply.isRunning()): self.on_abort = True self.reply.abort()
python
def abort(self): """ Handle request to cancel HTTP call """ if (self.reply and self.reply.isRunning()): self.on_abort = True self.reply.abort()
[ "def", "abort", "(", "self", ")", ":", "if", "(", "self", ".", "reply", "and", "self", ".", "reply", ".", "isRunning", "(", ")", ")", ":", "self", ".", "on_abort", "=", "True", "self", ".", "reply", ".", "abort", "(", ")" ]
Handle request to cancel HTTP call
[ "Handle", "request", "to", "cancel", "HTTP", "call" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/network/networkaccessmanager.py#L388-L394
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
mapLayers
def mapLayers(name=None, types=None): """ Return all the loaded layers. Filters by name (optional) first and then type (optional) :param name: (optional) name of layer to return.. :param type: (optional) The QgsMapLayer type of layer to return. Accepts a single value or a list of them :return: List...
python
def mapLayers(name=None, types=None): """ Return all the loaded layers. Filters by name (optional) first and then type (optional) :param name: (optional) name of layer to return.. :param type: (optional) The QgsMapLayer type of layer to return. Accepts a single value or a list of them :return: List...
[ "def", "mapLayers", "(", "name", "=", "None", ",", "types", "=", "None", ")", ":", "if", "types", "is", "not", "None", "and", "not", "isinstance", "(", "types", ",", "list", ")", ":", "types", "=", "[", "types", "]", "layers", "=", "_layerreg", "."...
Return all the loaded layers. Filters by name (optional) first and then type (optional) :param name: (optional) name of layer to return.. :param type: (optional) The QgsMapLayer type of layer to return. Accepts a single value or a list of them :return: List of loaded layers. If name given will return all l...
[ "Return", "all", "the", "loaded", "layers", ".", "Filters", "by", "name", "(", "optional", ")", "first", "and", "then", "type", "(", "optional", ")", ":", "param", "name", ":", "(", "optional", ")", "name", "of", "layer", "to", "return", "..", ":", "...
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L28-L46
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
addLayer
def addLayer(layer, loadInLegend=True): """ Add one or several layers to the QGIS session and layer registry. :param layer: The layer object or list with layers to add the QGIS layer registry and session. :param loadInLegend: True if this layer should be added to the legend. :return: The added laye...
python
def addLayer(layer, loadInLegend=True): """ Add one or several layers to the QGIS session and layer registry. :param layer: The layer object or list with layers to add the QGIS layer registry and session. :param loadInLegend: True if this layer should be added to the legend. :return: The added laye...
[ "def", "addLayer", "(", "layer", ",", "loadInLegend", "=", "True", ")", ":", "if", "not", "hasattr", "(", "layer", ",", "\"__iter__\"", ")", ":", "layer", "=", "[", "layer", "]", "_layerreg", ".", "addMapLayers", "(", "layer", ",", "loadInLegend", ")", ...
Add one or several layers to the QGIS session and layer registry. :param layer: The layer object or list with layers to add the QGIS layer registry and session. :param loadInLegend: True if this layer should be added to the legend. :return: The added layer
[ "Add", "one", "or", "several", "layers", "to", "the", "QGIS", "session", "and", "layer", "registry", ".", ":", "param", "layer", ":", "The", "layer", "object", "or", "list", "with", "layers", "to", "add", "the", "QGIS", "layer", "registry", "and", "sessi...
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L51-L61
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
addLayerNoCrsDialog
def addLayerNoCrsDialog(layer, loadInLegend=True): ''' Tries to add a layer from layer object Same as the addLayer method, but it does not ask for CRS, regardless of current configuration in QGIS settings ''' settings = QSettings() prjSetting = settings.value('/Projections/defaultBehaviour')...
python
def addLayerNoCrsDialog(layer, loadInLegend=True): ''' Tries to add a layer from layer object Same as the addLayer method, but it does not ask for CRS, regardless of current configuration in QGIS settings ''' settings = QSettings() prjSetting = settings.value('/Projections/defaultBehaviour')...
[ "def", "addLayerNoCrsDialog", "(", "layer", ",", "loadInLegend", "=", "True", ")", ":", "settings", "=", "QSettings", "(", ")", "prjSetting", "=", "settings", ".", "value", "(", "'/Projections/defaultBehaviour'", ")", "settings", ".", "setValue", "(", "'/Project...
Tries to add a layer from layer object Same as the addLayer method, but it does not ask for CRS, regardless of current configuration in QGIS settings
[ "Tries", "to", "add", "a", "layer", "from", "layer", "object", "Same", "as", "the", "addLayer", "method", "but", "it", "does", "not", "ask", "for", "CRS", "regardless", "of", "current", "configuration", "in", "QGIS", "settings" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L63-L78
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
newVectorLayer
def newVectorLayer(filename, fields, geometryType, crs, encoding="utf-8"): ''' Creates a new vector layer :param filename: The filename to store the file. The extensions determines the type of file. If extension is not among the supported ones, a shapefile will be created and the file will get an a...
python
def newVectorLayer(filename, fields, geometryType, crs, encoding="utf-8"): ''' Creates a new vector layer :param filename: The filename to store the file. The extensions determines the type of file. If extension is not among the supported ones, a shapefile will be created and the file will get an a...
[ "def", "newVectorLayer", "(", "filename", ",", "fields", ",", "geometryType", ",", "crs", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "isinstance", "(", "crs", ",", "basestring", ")", ":", "crs", "=", "QgsCoordinateReferenceSystem", "(", "crs", ")", ...
Creates a new vector layer :param filename: The filename to store the file. The extensions determines the type of file. If extension is not among the supported ones, a shapefile will be created and the file will get an added '.shp' to its path. If the filename is None, a memory layer will be created ...
[ "Creates", "a", "new", "vector", "layer" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L131-L186
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
layerFromName
def layerFromName(name): ''' Returns the layer from the current project with the passed name Raises WrongLayerNameException if no layer with that name is found If several layers with that name exist, only the first one is returned ''' layers =_layerreg.mapLayers().values() for layer in layer...
python
def layerFromName(name): ''' Returns the layer from the current project with the passed name Raises WrongLayerNameException if no layer with that name is found If several layers with that name exist, only the first one is returned ''' layers =_layerreg.mapLayers().values() for layer in layer...
[ "def", "layerFromName", "(", "name", ")", ":", "layers", "=", "_layerreg", ".", "mapLayers", "(", ")", ".", "values", "(", ")", "for", "layer", "in", "layers", ":", "if", "layer", ".", "name", "(", ")", "==", "name", ":", "return", "layer", "raise", ...
Returns the layer from the current project with the passed name Raises WrongLayerNameException if no layer with that name is found If several layers with that name exist, only the first one is returned
[ "Returns", "the", "layer", "from", "the", "current", "project", "with", "the", "passed", "name", "Raises", "WrongLayerNameException", "if", "no", "layer", "with", "that", "name", "is", "found", "If", "several", "layers", "with", "that", "name", "exist", "only"...
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L202-L212
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
layerFromSource
def layerFromSource(source): ''' Returns the layer from the current project with the passed source Raises WrongLayerSourceException if no layer with that source is found ''' layers =_layerreg.mapLayers().values() for layer in layers: if layer.source() == source: return layer ...
python
def layerFromSource(source): ''' Returns the layer from the current project with the passed source Raises WrongLayerSourceException if no layer with that source is found ''' layers =_layerreg.mapLayers().values() for layer in layers: if layer.source() == source: return layer ...
[ "def", "layerFromSource", "(", "source", ")", ":", "layers", "=", "_layerreg", ".", "mapLayers", "(", ")", ".", "values", "(", ")", "for", "layer", "in", "layers", ":", "if", "layer", ".", "source", "(", ")", "==", "source", ":", "return", "layer", "...
Returns the layer from the current project with the passed source Raises WrongLayerSourceException if no layer with that source is found
[ "Returns", "the", "layer", "from", "the", "current", "project", "with", "the", "passed", "source", "Raises", "WrongLayerSourceException", "if", "no", "layer", "with", "that", "source", "is", "found" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L214-L223
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
loadLayer
def loadLayer(filename, name = None, provider=None): ''' Tries to load a layer from the given file :param filename: the path to the file to load. :param name: the name to use for adding the layer to the current project. If not passed or None, it will use the filename basename ''' name = na...
python
def loadLayer(filename, name = None, provider=None): ''' Tries to load a layer from the given file :param filename: the path to the file to load. :param name: the name to use for adding the layer to the current project. If not passed or None, it will use the filename basename ''' name = na...
[ "def", "loadLayer", "(", "filename", ",", "name", "=", "None", ",", "provider", "=", "None", ")", ":", "name", "=", "name", "or", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "filename", ")", ")", "[", "0", "]...
Tries to load a layer from the given file :param filename: the path to the file to load. :param name: the name to use for adding the layer to the current project. If not passed or None, it will use the filename basename
[ "Tries", "to", "load", "a", "layer", "from", "the", "given", "file" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L226-L243
boundlessgeo/lib-qgis-commons
qgiscommons2/layers.py
loadLayerNoCrsDialog
def loadLayerNoCrsDialog(filename, name=None, provider=None): ''' Tries to load a layer from the given file Same as the loadLayer method, but it does not ask for CRS, regardless of current configuration in QGIS settings ''' settings = QSettings() prjSetting = settings.value('/Projections/def...
python
def loadLayerNoCrsDialog(filename, name=None, provider=None): ''' Tries to load a layer from the given file Same as the loadLayer method, but it does not ask for CRS, regardless of current configuration in QGIS settings ''' settings = QSettings() prjSetting = settings.value('/Projections/def...
[ "def", "loadLayerNoCrsDialog", "(", "filename", ",", "name", "=", "None", ",", "provider", "=", "None", ")", ":", "settings", "=", "QSettings", "(", ")", "prjSetting", "=", "settings", ".", "value", "(", "'/Projections/defaultBehaviour'", ")", "settings", ".",...
Tries to load a layer from the given file Same as the loadLayer method, but it does not ask for CRS, regardless of current configuration in QGIS settings
[ "Tries", "to", "load", "a", "layer", "from", "the", "given", "file", "Same", "as", "the", "loadLayer", "method", "but", "it", "does", "not", "ask", "for", "CRS", "regardless", "of", "current", "configuration", "in", "QGIS", "settings" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/layers.py#L246-L261
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/settings.py
addSettingsMenu
def addSettingsMenu(menuName, parentMenuFunction=None): ''' Adds a 'open settings...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the settings menu is to be added :param parentMenuFunction: a fun...
python
def addSettingsMenu(menuName, parentMenuFunction=None): ''' Adds a 'open settings...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the settings menu is to be added :param parentMenuFunction: a fun...
[ "def", "addSettingsMenu", "(", "menuName", ",", "parentMenuFunction", "=", "None", ")", ":", "parentMenuFunction", "=", "parentMenuFunction", "or", "iface", ".", "addPluginToMenu", "namespace", "=", "_callerName", "(", ")", ".", "split", "(", "\".\"", ")", "[", ...
Adds a 'open settings...' menu to the plugin menu. This method should be called from the initGui() method of the plugin :param menuName: The name of the plugin menu in which the settings menu is to be added :param parentMenuFunction: a function from QgisInterface to indicate where to put the container plug...
[ "Adds", "a", "open", "settings", "...", "menu", "to", "the", "plugin", "menu", ".", "This", "method", "should", "be", "called", "from", "the", "initGui", "()", "method", "of", "the", "plugin" ]
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/settings.py#L38-L58
boundlessgeo/lib-qgis-commons
qgiscommons2/gui/paramdialog.py
openParametersDialog
def openParametersDialog(params, title=None): ''' Opens a dialog to enter parameters. Parameters are passed as a list of Parameter objects Returns a dict with param names as keys and param values as values Returns None if the dialog was cancelled ''' QApplication.setOverrideCursor(QCursor(Qt...
python
def openParametersDialog(params, title=None): ''' Opens a dialog to enter parameters. Parameters are passed as a list of Parameter objects Returns a dict with param names as keys and param values as values Returns None if the dialog was cancelled ''' QApplication.setOverrideCursor(QCursor(Qt...
[ "def", "openParametersDialog", "(", "params", ",", "title", "=", "None", ")", ":", "QApplication", ".", "setOverrideCursor", "(", "QCursor", "(", "Qt", ".", "ArrowCursor", ")", ")", "dlg", "=", "ParametersDialog", "(", "params", ",", "title", ")", "dlg", "...
Opens a dialog to enter parameters. Parameters are passed as a list of Parameter objects Returns a dict with param names as keys and param values as values Returns None if the dialog was cancelled
[ "Opens", "a", "dialog", "to", "enter", "parameters", ".", "Parameters", "are", "passed", "as", "a", "list", "of", "Parameter", "objects", "Returns", "a", "dict", "with", "param", "names", "as", "keys", "and", "param", "values", "as", "values", "Returns", "...
train
https://github.com/boundlessgeo/lib-qgis-commons/blob/d25d13803db08c18632b55d12036e332f006d9ac/qgiscommons2/gui/paramdialog.py#L45-L56
yunojuno/elasticsearch-django
elasticsearch_django/management/commands/rebuild_search_index.py
Command.do_index_command
def do_index_command(self, index, **options): """Rebuild search index.""" if options["interactive"]: logger.warning("This will permanently delete the index '%s'.", index) if not self._confirm_action(): logger.warning( "Aborting rebuild of index...
python
def do_index_command(self, index, **options): """Rebuild search index.""" if options["interactive"]: logger.warning("This will permanently delete the index '%s'.", index) if not self._confirm_action(): logger.warning( "Aborting rebuild of index...
[ "def", "do_index_command", "(", "self", ",", "index", ",", "*", "*", "options", ")", ":", "if", "options", "[", "\"interactive\"", "]", ":", "logger", ".", "warning", "(", "\"This will permanently delete the index '%s'.\"", ",", "index", ")", "if", "not", "sel...
Rebuild search index.
[ "Rebuild", "search", "index", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/management/commands/rebuild_search_index.py#L21-L39
yunojuno/elasticsearch-django
elasticsearch_django/management/commands/__init__.py
BaseSearchCommand.handle
def handle(self, *args, **options): """Run do_index_command on each specified index and log the output.""" for index in options.pop("indexes"): data = {} try: data = self.do_index_command(index, **options) except TransportError as ex: l...
python
def handle(self, *args, **options): """Run do_index_command on each specified index and log the output.""" for index in options.pop("indexes"): data = {} try: data = self.do_index_command(index, **options) except TransportError as ex: l...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "for", "index", "in", "options", ".", "pop", "(", "\"indexes\"", ")", ":", "data", "=", "{", "}", "try", ":", "data", "=", "self", ".", "do_index_command", "(", "...
Run do_index_command on each specified index and log the output.
[ "Run", "do_index_command", "on", "each", "specified", "index", "and", "log", "the", "output", "." ]
train
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/management/commands/__init__.py#L39-L49
Stranger6667/postmarker
postmarker/models/templates.py
TemplateManager.create
def create(self, Name, Subject, HtmlBody=None, TextBody=None, Alias=None): """ Creates a template. :param Name: Name of template :param Subject: The content to use for the Subject when this template is used to send email. :param HtmlBody: The content to use for the HtmlBody when...
python
def create(self, Name, Subject, HtmlBody=None, TextBody=None, Alias=None): """ Creates a template. :param Name: Name of template :param Subject: The content to use for the Subject when this template is used to send email. :param HtmlBody: The content to use for the HtmlBody when...
[ "def", "create", "(", "self", ",", "Name", ",", "Subject", ",", "HtmlBody", "=", "None", ",", "TextBody", "=", "None", ",", "Alias", "=", "None", ")", ":", "assert", "TextBody", "or", "HtmlBody", ",", "\"Provide either email TextBody or HtmlBody or both\"", "d...
Creates a template. :param Name: Name of template :param Subject: The content to use for the Subject when this template is used to send email. :param HtmlBody: The content to use for the HtmlBody when this template is used to send email. :param TextBody: The content to use for the HtmlB...
[ "Creates", "a", "template", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/templates.py#L31-L43
Stranger6667/postmarker
postmarker/logging.py
get_logger
def get_logger(name, verbosity, stream): """ Returns simple console logger. """ logger = logging.getLogger(name) logger.setLevel( {0: DEFAULT_LOGGING_LEVEL, 1: logging.INFO, 2: logging.DEBUG}.get(min(2, verbosity), DEFAULT_LOGGING_LEVEL) ) logger.handlers = [] handler = logging.S...
python
def get_logger(name, verbosity, stream): """ Returns simple console logger. """ logger = logging.getLogger(name) logger.setLevel( {0: DEFAULT_LOGGING_LEVEL, 1: logging.INFO, 2: logging.DEBUG}.get(min(2, verbosity), DEFAULT_LOGGING_LEVEL) ) logger.handlers = [] handler = logging.S...
[ "def", "get_logger", "(", "name", ",", "verbosity", ",", "stream", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "setLevel", "(", "{", "0", ":", "DEFAULT_LOGGING_LEVEL", ",", "1", ":", "logging", ".", "INFO", ",...
Returns simple console logger.
[ "Returns", "simple", "console", "logger", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/logging.py#L11-L24
Stranger6667/postmarker
postmarker/core.py
PostmarkClient.from_config
def from_config(cls, config, prefix="postmark_", is_uppercase=False): """ Helper method for instantiating PostmarkClient from dict-like objects. """ kwargs = {} for arg in get_args(cls): key = prefix + arg if is_uppercase: key = key.upper()...
python
def from_config(cls, config, prefix="postmark_", is_uppercase=False): """ Helper method for instantiating PostmarkClient from dict-like objects. """ kwargs = {} for arg in get_args(cls): key = prefix + arg if is_uppercase: key = key.upper()...
[ "def", "from_config", "(", "cls", ",", "config", ",", "prefix", "=", "\"postmark_\"", ",", "is_uppercase", "=", "False", ")", ":", "kwargs", "=", "{", "}", "for", "arg", "in", "get_args", "(", "cls", ")", ":", "key", "=", "prefix", "+", "arg", "if", ...
Helper method for instantiating PostmarkClient from dict-like objects.
[ "Helper", "method", "for", "instantiating", "PostmarkClient", "from", "dict", "-", "like", "objects", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/core.py#L59-L72
Stranger6667/postmarker
postmarker/utils.py
chunks
def chunks(container, n): """ Split a container into n-sized chunks. """ for i in range(0, len(container), n): yield container[i : i + n]
python
def chunks(container, n): """ Split a container into n-sized chunks. """ for i in range(0, len(container), n): yield container[i : i + n]
[ "def", "chunks", "(", "container", ",", "n", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "container", ")", ",", "n", ")", ":", "yield", "container", "[", "i", ":", "i", "+", "n", "]" ]
Split a container into n-sized chunks.
[ "Split", "a", "container", "into", "n", "-", "sized", "chunks", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/utils.py#L4-L9
Stranger6667/postmarker
postmarker/utils.py
sizes
def sizes(count, offset=0, max_chunk=500): """ Helper to iterate over remote data via count & offset pagination. """ if count is None: chunk = max_chunk while True: yield chunk, offset offset += chunk else: while count: chunk = min(count, m...
python
def sizes(count, offset=0, max_chunk=500): """ Helper to iterate over remote data via count & offset pagination. """ if count is None: chunk = max_chunk while True: yield chunk, offset offset += chunk else: while count: chunk = min(count, m...
[ "def", "sizes", "(", "count", ",", "offset", "=", "0", ",", "max_chunk", "=", "500", ")", ":", "if", "count", "is", "None", ":", "chunk", "=", "max_chunk", "while", "True", ":", "yield", "chunk", ",", "offset", "offset", "+=", "chunk", "else", ":", ...
Helper to iterate over remote data via count & offset pagination.
[ "Helper", "to", "iterate", "over", "remote", "data", "via", "count", "&", "offset", "pagination", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/utils.py#L12-L26
Stranger6667/postmarker
postmarker/django/backend.py
EmailBackend.raise_for_response
def raise_for_response(self, responses): """ Constructs appropriate exception from list of responses and raises it. """ exception_messages = [self.client.format_exception_message(response) for response in responses] if len(exception_messages) == 1: message = exception...
python
def raise_for_response(self, responses): """ Constructs appropriate exception from list of responses and raises it. """ exception_messages = [self.client.format_exception_message(response) for response in responses] if len(exception_messages) == 1: message = exception...
[ "def", "raise_for_response", "(", "self", ",", "responses", ")", ":", "exception_messages", "=", "[", "self", ".", "client", ".", "format_exception_message", "(", "response", ")", "for", "response", "in", "responses", "]", "if", "len", "(", "exception_messages",...
Constructs appropriate exception from list of responses and raises it.
[ "Constructs", "appropriate", "exception", "from", "list", "of", "responses", "and", "raises", "it", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/django/backend.py#L76-L85
Stranger6667/postmarker
postmarker/models/emails.py
list_to_csv
def list_to_csv(value): """ Converts list to string with comma separated values. For string is no-op. """ if isinstance(value, (list, tuple, set)): value = ",".join(value) return value
python
def list_to_csv(value): """ Converts list to string with comma separated values. For string is no-op. """ if isinstance(value, (list, tuple, set)): value = ",".join(value) return value
[ "def", "list_to_csv", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "list", ",", "tuple", ",", "set", ")", ")", ":", "value", "=", "\",\"", ".", "join", "(", "value", ")", "return", "value" ]
Converts list to string with comma separated values. For string is no-op.
[ "Converts", "list", "to", "string", "with", "comma", "separated", "values", ".", "For", "string", "is", "no", "-", "op", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L24-L30
Stranger6667/postmarker
postmarker/models/emails.py
prepare_attachments
def prepare_attachments(attachment): """ Converts incoming attachment into dictionary. """ if isinstance(attachment, tuple): result = {"Name": attachment[0], "Content": attachment[1], "ContentType": attachment[2]} if len(attachment) == 4: result["ContentID"] = attachment[3] ...
python
def prepare_attachments(attachment): """ Converts incoming attachment into dictionary. """ if isinstance(attachment, tuple): result = {"Name": attachment[0], "Content": attachment[1], "ContentType": attachment[2]} if len(attachment) == 4: result["ContentID"] = attachment[3] ...
[ "def", "prepare_attachments", "(", "attachment", ")", ":", "if", "isinstance", "(", "attachment", ",", "tuple", ")", ":", "result", "=", "{", "\"Name\"", ":", "attachment", "[", "0", "]", ",", "\"Content\"", ":", "attachment", "[", "1", "]", ",", "\"Cont...
Converts incoming attachment into dictionary.
[ "Converts", "incoming", "attachment", "into", "dictionary", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L40-L76
Stranger6667/postmarker
postmarker/models/emails.py
BaseEmail.as_dict
def as_dict(self): """ Additionally encodes headers. :return: """ data = super(BaseEmail, self).as_dict() data["Headers"] = [{"Name": name, "Value": value} for name, value in data["Headers"].items()] for field in ("To", "Cc", "Bcc"): if field in data:...
python
def as_dict(self): """ Additionally encodes headers. :return: """ data = super(BaseEmail, self).as_dict() data["Headers"] = [{"Name": name, "Value": value} for name, value in data["Headers"].items()] for field in ("To", "Cc", "Bcc"): if field in data:...
[ "def", "as_dict", "(", "self", ")", ":", "data", "=", "super", "(", "BaseEmail", ",", "self", ")", ".", "as_dict", "(", ")", "data", "[", "\"Headers\"", "]", "=", "[", "{", "\"Name\"", ":", "name", ",", "\"Value\"", ":", "value", "}", "for", "name"...
Additionally encodes headers. :return:
[ "Additionally", "encodes", "headers", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L124-L136
Stranger6667/postmarker
postmarker/models/emails.py
BaseEmail.attach_binary
def attach_binary(self, content, filename): """ Attaches given binary data. :param bytes content: Binary data to be attached. :param str filename: :return: None. """ content_type = guess_content_type(filename) payload = {"Name": filename, "Content": b64en...
python
def attach_binary(self, content, filename): """ Attaches given binary data. :param bytes content: Binary data to be attached. :param str filename: :return: None. """ content_type = guess_content_type(filename) payload = {"Name": filename, "Content": b64en...
[ "def", "attach_binary", "(", "self", ",", "content", ",", "filename", ")", ":", "content_type", "=", "guess_content_type", "(", "filename", ")", "payload", "=", "{", "\"Name\"", ":", "filename", ",", "\"Content\"", ":", "b64encode", "(", "content", ")", ".",...
Attaches given binary data. :param bytes content: Binary data to be attached. :param str filename: :return: None.
[ "Attaches", "given", "binary", "data", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L148-L158
Stranger6667/postmarker
postmarker/models/emails.py
Email.from_mime
def from_mime(cls, message, manager): """ Instantiates ``Email`` instance from ``MIMEText`` instance. :param message: ``email.mime.text.MIMEText`` instance. :param manager: :py:class:`EmailManager` instance. :return: :py:class:`Email` """ text, html, attachments ...
python
def from_mime(cls, message, manager): """ Instantiates ``Email`` instance from ``MIMEText`` instance. :param message: ``email.mime.text.MIMEText`` instance. :param manager: :py:class:`EmailManager` instance. :return: :py:class:`Email` """ text, html, attachments ...
[ "def", "from_mime", "(", "cls", ",", "message", ",", "manager", ")", ":", "text", ",", "html", ",", "attachments", "=", "deconstruct_multipart", "(", "message", ")", "subject", "=", "prepare_header", "(", "message", "[", "\"Subject\"", "]", ")", "sender", ...
Instantiates ``Email`` instance from ``MIMEText`` instance. :param message: ``email.mime.text.MIMEText`` instance. :param manager: :py:class:`EmailManager` instance. :return: :py:class:`Email`
[ "Instantiates", "Email", "instance", "from", "MIMEText", "instance", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L182-L210
Stranger6667/postmarker
postmarker/models/emails.py
EmailBatch.as_dict
def as_dict(self, **extra): """ Converts all available emails to dictionaries. :return: List of dictionaries. """ return [self._construct_email(email, **extra) for email in self.emails]
python
def as_dict(self, **extra): """ Converts all available emails to dictionaries. :return: List of dictionaries. """ return [self._construct_email(email, **extra) for email in self.emails]
[ "def", "as_dict", "(", "self", ",", "*", "*", "extra", ")", ":", "return", "[", "self", ".", "_construct_email", "(", "email", ",", "*", "*", "extra", ")", "for", "email", "in", "self", ".", "emails", "]" ]
Converts all available emails to dictionaries. :return: List of dictionaries.
[ "Converts", "all", "available", "emails", "to", "dictionaries", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L235-L241
Stranger6667/postmarker
postmarker/models/emails.py
EmailBatch._construct_email
def _construct_email(self, email, **extra): """ Converts incoming data to properly structured dictionary. """ if isinstance(email, dict): email = Email(manager=self._manager, **email) elif isinstance(email, (MIMEText, MIMEMultipart)): email = Email.from_mi...
python
def _construct_email(self, email, **extra): """ Converts incoming data to properly structured dictionary. """ if isinstance(email, dict): email = Email(manager=self._manager, **email) elif isinstance(email, (MIMEText, MIMEMultipart)): email = Email.from_mi...
[ "def", "_construct_email", "(", "self", ",", "email", ",", "*", "*", "extra", ")", ":", "if", "isinstance", "(", "email", ",", "dict", ")", ":", "email", "=", "Email", "(", "manager", "=", "self", ".", "_manager", ",", "*", "*", "email", ")", "elif...
Converts incoming data to properly structured dictionary.
[ "Converts", "incoming", "data", "to", "properly", "structured", "dictionary", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L243-L254
Stranger6667/postmarker
postmarker/models/emails.py
EmailBatch.send
def send(self, **extra): """ Sends email batch. :return: Information about sent emails. :rtype: `list` """ emails = self.as_dict(**extra) responses = [self._manager._send_batch(*batch) for batch in chunks(emails, self.MAX_SIZE)] return sum(responses, [])
python
def send(self, **extra): """ Sends email batch. :return: Information about sent emails. :rtype: `list` """ emails = self.as_dict(**extra) responses = [self._manager._send_batch(*batch) for batch in chunks(emails, self.MAX_SIZE)] return sum(responses, [])
[ "def", "send", "(", "self", ",", "*", "*", "extra", ")", ":", "emails", "=", "self", ".", "as_dict", "(", "*", "*", "extra", ")", "responses", "=", "[", "self", ".", "_manager", ".", "_send_batch", "(", "*", "batch", ")", "for", "batch", "in", "c...
Sends email batch. :return: Information about sent emails. :rtype: `list`
[ "Sends", "email", "batch", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L256-L265
Stranger6667/postmarker
postmarker/models/emails.py
EmailManager.send
def send( self, message=None, From=None, To=None, Cc=None, Bcc=None, Subject=None, Tag=None, HtmlBody=None, TextBody=None, Metadata=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None"...
python
def send( self, message=None, From=None, To=None, Cc=None, Bcc=None, Subject=None, Tag=None, HtmlBody=None, TextBody=None, Metadata=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None"...
[ "def", "send", "(", "self", ",", "message", "=", "None", ",", "From", "=", "None", ",", "To", "=", "None", ",", "Cc", "=", "None", ",", "Bcc", "=", "None", ",", "Subject", "=", "None", ",", "Tag", "=", "None", ",", "HtmlBody", "=", "None", ",",...
Sends a single email. :param message: :py:class:`Email` or ``email.mime.text.MIMEText`` instance. :param str From: The sender email address. :param To: Recipient's email address. Multiple recipients could be specified as a list or string with comma separated values. :...
[ "Sends", "a", "single", "email", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L295-L362
Stranger6667/postmarker
postmarker/models/emails.py
EmailManager.Email
def Email( self, From, To, Cc=None, Bcc=None, Subject=None, Tag=None, HtmlBody=None, TextBody=None, Metadata=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None", Attachments=None, ...
python
def Email( self, From, To, Cc=None, Bcc=None, Subject=None, Tag=None, HtmlBody=None, TextBody=None, Metadata=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None", Attachments=None, ...
[ "def", "Email", "(", "self", ",", "From", ",", "To", ",", "Cc", "=", "None", ",", "Bcc", "=", "None", ",", "Subject", "=", "None", ",", "Tag", "=", "None", ",", "HtmlBody", "=", "None", ",", "TextBody", "=", "None", ",", "Metadata", "=", "None", ...
Constructs :py:class:`Email` instance. :return: :py:class:`Email`
[ "Constructs", ":", "py", ":", "class", ":", "Email", "instance", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L411-L449
Stranger6667/postmarker
postmarker/models/emails.py
EmailManager.EmailTemplate
def EmailTemplate( self, TemplateId, TemplateModel, From, To, TemplateAlias=None, Cc=None, Bcc=None, Subject=None, Tag=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None", Attachments...
python
def EmailTemplate( self, TemplateId, TemplateModel, From, To, TemplateAlias=None, Cc=None, Bcc=None, Subject=None, Tag=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None", Attachments...
[ "def", "EmailTemplate", "(", "self", ",", "TemplateId", ",", "TemplateModel", ",", "From", ",", "To", ",", "TemplateAlias", "=", "None", ",", "Cc", "=", "None", ",", "Bcc", "=", "None", ",", "Subject", "=", "None", ",", "Tag", "=", "None", ",", "Repl...
Constructs :py:class:`EmailTemplate` instance. :return: :py:class:`EmailTemplate`
[ "Constructs", ":", "py", ":", "class", ":", "EmailTemplate", "instance", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L451-L491
Stranger6667/postmarker
postmarker/models/bounces.py
Bounce.activate
def activate(self): """ Activates the bounce instance and updates it with the latest data. :return: Activation status. :rtype: `str` """ response = self._manager.activate(self.ID) self._update(response["Bounce"]) return response["Message"]
python
def activate(self): """ Activates the bounce instance and updates it with the latest data. :return: Activation status. :rtype: `str` """ response = self._manager.activate(self.ID) self._update(response["Bounce"]) return response["Message"]
[ "def", "activate", "(", "self", ")", ":", "response", "=", "self", ".", "_manager", ".", "activate", "(", "self", ".", "ID", ")", "self", ".", "_update", "(", "response", "[", "\"Bounce\"", "]", ")", "return", "response", "[", "\"Message\"", "]" ]
Activates the bounce instance and updates it with the latest data. :return: Activation status. :rtype: `str`
[ "Activates", "the", "bounce", "instance", "and", "updates", "it", "with", "the", "latest", "data", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/bounces.py#L24-L33
Stranger6667/postmarker
postmarker/models/bounces.py
BounceManager.all
def all( self, count=500, offset=0, type=None, inactive=None, emailFilter=None, tag=None, messageID=None, fromdate=None, todate=None, ): """ Returns many bounces. :param int count: Number of bounces to return pe...
python
def all( self, count=500, offset=0, type=None, inactive=None, emailFilter=None, tag=None, messageID=None, fromdate=None, todate=None, ): """ Returns many bounces. :param int count: Number of bounces to return pe...
[ "def", "all", "(", "self", ",", "count", "=", "500", ",", "offset", "=", "0", ",", "type", "=", "None", ",", "inactive", "=", "None", ",", "emailFilter", "=", "None", ",", "tag", "=", "None", ",", "messageID", "=", "None", ",", "fromdate", "=", "...
Returns many bounces. :param int count: Number of bounces to return per request. :param int offset: Number of bounces to skip. :param str type: Filter by type of bounce. :param bool inactive: Filter by emails that were deactivated by Postmark due to the bounce. :param str emailF...
[ "Returns", "many", "bounces", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/bounces.py#L72-L112
Stranger6667/postmarker
postmarker/models/base.py
ModelManager.update_kwargs
def update_kwargs(self, kwargs, count, offset): """ Helper to support handy dictionaries merging on all Python versions. """ kwargs.update({self.count_key: count, self.offset_key: offset}) return kwargs
python
def update_kwargs(self, kwargs, count, offset): """ Helper to support handy dictionaries merging on all Python versions. """ kwargs.update({self.count_key: count, self.offset_key: offset}) return kwargs
[ "def", "update_kwargs", "(", "self", ",", "kwargs", ",", "count", ",", "offset", ")", ":", "kwargs", ".", "update", "(", "{", "self", ".", "count_key", ":", "count", ",", "self", ".", "offset_key", ":", "offset", "}", ")", "return", "kwargs" ]
Helper to support handy dictionaries merging on all Python versions.
[ "Helper", "to", "support", "handy", "dictionaries", "merging", "on", "all", "Python", "versions", "." ]
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/base.py#L97-L102