repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
linkedin/luminol
src/luminol/anomaly_detector.py
AnomalyDetector._detect_anomalies
def _detect_anomalies(self): """ Detect anomalies using a threshold on anomaly scores. """ anom_scores = self.anom_scores max_anom_score = anom_scores.max() anomalies = [] if max_anom_score: threshold = self.threshold or max_anom_score * self.score_pe...
python
def _detect_anomalies(self): """ Detect anomalies using a threshold on anomaly scores. """ anom_scores = self.anom_scores max_anom_score = anom_scores.max() anomalies = [] if max_anom_score: threshold = self.threshold or max_anom_score * self.score_pe...
[ "def", "_detect_anomalies", "(", "self", ")", ":", "anom_scores", "=", "self", ".", "anom_scores", "max_anom_score", "=", "anom_scores", ".", "max", "(", ")", "anomalies", "=", "[", "]", "if", "max_anom_score", ":", "threshold", "=", "self", ".", "threshold"...
Detect anomalies using a threshold on anomaly scores.
[ "Detect", "anomalies", "using", "a", "threshold", "on", "anomaly", "scores", "." ]
42e4ab969b774ff98f902d064cb041556017f635
https://github.com/linkedin/luminol/blob/42e4ab969b774ff98f902d064cb041556017f635/src/luminol/anomaly_detector.py#L106-L145
train
jpoullet2000/atlasclient
atlasclient/exceptions.py
handle_response
def handle_response(response): """ Given a requests.Response object, throw the appropriate exception, if applicable. """ # ignore valid responses if response.status_code < 400: return cls = _status_to_exception_type.get(response.status_code, HttpError) kwargs = { 'code': r...
python
def handle_response(response): """ Given a requests.Response object, throw the appropriate exception, if applicable. """ # ignore valid responses if response.status_code < 400: return cls = _status_to_exception_type.get(response.status_code, HttpError) kwargs = { 'code': r...
[ "def", "handle_response", "(", "response", ")", ":", "if", "response", ".", "status_code", "<", "400", ":", "return", "cls", "=", "_status_to_exception_type", ".", "get", "(", "response", ".", "status_code", ",", "HttpError", ")", "kwargs", "=", "{", "'code'...
Given a requests.Response object, throw the appropriate exception, if applicable.
[ "Given", "a", "requests", ".", "Response", "object", "throw", "the", "appropriate", "exception", "if", "applicable", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/exceptions.py#L178-L199
train
jpoullet2000/atlasclient
atlasclient/models.py
EntityBulkCollection.create
def create(self, data, **kwargs): """ Create classifitions for specific entity """ self.client.post(self.url, data=data)
python
def create(self, data, **kwargs): """ Create classifitions for specific entity """ self.client.post(self.url, data=data)
[ "def", "create", "(", "self", ",", "data", ",", "**", "kwargs", ")", ":", "self", ".", "client", ".", "post", "(", "self", ".", "url", ",", "data", "=", "data", ")" ]
Create classifitions for specific entity
[ "Create", "classifitions", "for", "specific", "entity" ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/models.py#L259-L263
train
jpoullet2000/atlasclient
atlasclient/models.py
RelationshipGuid.create
def create(self, **kwargs): """Raise error since guid cannot be duplicated """ raise exceptions.MethodNotImplemented(method=self.create, url=self.url, details='GUID cannot be duplicated, to create a new GUID use the relationship resource')
python
def create(self, **kwargs): """Raise error since guid cannot be duplicated """ raise exceptions.MethodNotImplemented(method=self.create, url=self.url, details='GUID cannot be duplicated, to create a new GUID use the relationship resource')
[ "def", "create", "(", "self", ",", "**", "kwargs", ")", ":", "raise", "exceptions", ".", "MethodNotImplemented", "(", "method", "=", "self", ".", "create", ",", "url", "=", "self", ".", "url", ",", "details", "=", "'GUID cannot be duplicated, to create a new G...
Raise error since guid cannot be duplicated
[ "Raise", "error", "since", "guid", "cannot", "be", "duplicated" ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/models.py#L706-L709
train
jpoullet2000/atlasclient
atlasclient/utils.py
normalize_underscore_case
def normalize_underscore_case(name): """Normalize an underscore-separated descriptor to something more readable. i.e. 'NAGIOS_SERVER' becomes 'Nagios Server', and 'host_components' becomes 'Host Components' """ normalized = name.lower() normalized = re.sub(r'_(\w)', lamb...
python
def normalize_underscore_case(name): """Normalize an underscore-separated descriptor to something more readable. i.e. 'NAGIOS_SERVER' becomes 'Nagios Server', and 'host_components' becomes 'Host Components' """ normalized = name.lower() normalized = re.sub(r'_(\w)', lamb...
[ "def", "normalize_underscore_case", "(", "name", ")", ":", "normalized", "=", "name", ".", "lower", "(", ")", "normalized", "=", "re", ".", "sub", "(", "r'_(\\w)'", ",", "lambda", "match", ":", "' '", "+", "match", ".", "group", "(", "1", ")", ".", "...
Normalize an underscore-separated descriptor to something more readable. i.e. 'NAGIOS_SERVER' becomes 'Nagios Server', and 'host_components' becomes 'Host Components'
[ "Normalize", "an", "underscore", "-", "separated", "descriptor", "to", "something", "more", "readable", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/utils.py#L32-L42
train
jpoullet2000/atlasclient
atlasclient/utils.py
normalize_camel_case
def normalize_camel_case(name): """Normalize a camelCase descriptor to something more readable. i.e. 'camelCase' or 'CamelCase' becomes 'Camel Case' """ normalized = re.sub('([a-z])([A-Z])', lambda match: ' '.join([match.group(1), match.group(2)]), name) ...
python
def normalize_camel_case(name): """Normalize a camelCase descriptor to something more readable. i.e. 'camelCase' or 'CamelCase' becomes 'Camel Case' """ normalized = re.sub('([a-z])([A-Z])', lambda match: ' '.join([match.group(1), match.group(2)]), name) ...
[ "def", "normalize_camel_case", "(", "name", ")", ":", "normalized", "=", "re", ".", "sub", "(", "'([a-z])([A-Z])'", ",", "lambda", "match", ":", "' '", ".", "join", "(", "[", "match", ".", "group", "(", "1", ")", ",", "match", ".", "group", "(", "2",...
Normalize a camelCase descriptor to something more readable. i.e. 'camelCase' or 'CamelCase' becomes 'Camel Case'
[ "Normalize", "a", "camelCase", "descriptor", "to", "something", "more", "readable", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/utils.py#L45-L53
train
jpoullet2000/atlasclient
atlasclient/utils.py
version_tuple
def version_tuple(version): """Convert a version string or tuple to a tuple. Should be returned in the form: (major, minor, release). """ if isinstance(version, str): return tuple(int(x) for x in version.split('.')) elif isinstance(version, tuple): return version else: r...
python
def version_tuple(version): """Convert a version string or tuple to a tuple. Should be returned in the form: (major, minor, release). """ if isinstance(version, str): return tuple(int(x) for x in version.split('.')) elif isinstance(version, tuple): return version else: r...
[ "def", "version_tuple", "(", "version", ")", ":", "if", "isinstance", "(", "version", ",", "str", ")", ":", "return", "tuple", "(", "int", "(", "x", ")", "for", "x", "in", "version", ".", "split", "(", "'.'", ")", ")", "elif", "isinstance", "(", "v...
Convert a version string or tuple to a tuple. Should be returned in the form: (major, minor, release).
[ "Convert", "a", "version", "string", "or", "tuple", "to", "a", "tuple", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/utils.py#L56-L66
train
jpoullet2000/atlasclient
atlasclient/utils.py
version_str
def version_str(version): """Convert a version tuple or string to a string. Should be returned in the form: major.minor.release """ if isinstance(version, str): return version elif isinstance(version, tuple): return '.'.join([str(int(x)) for x in version]) else: raise Va...
python
def version_str(version): """Convert a version tuple or string to a string. Should be returned in the form: major.minor.release """ if isinstance(version, str): return version elif isinstance(version, tuple): return '.'.join([str(int(x)) for x in version]) else: raise Va...
[ "def", "version_str", "(", "version", ")", ":", "if", "isinstance", "(", "version", ",", "str", ")", ":", "return", "version", "elif", "isinstance", "(", "version", ",", "tuple", ")", ":", "return", "'.'", ".", "join", "(", "[", "str", "(", "int", "(...
Convert a version tuple or string to a string. Should be returned in the form: major.minor.release
[ "Convert", "a", "version", "tuple", "or", "string", "to", "a", "string", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/utils.py#L69-L79
train
jpoullet2000/atlasclient
atlasclient/utils.py
generate_http_basic_token
def generate_http_basic_token(username, password): """ Generates a HTTP basic token from username and password Returns a token string (not a byte) """ token = base64.b64encode('{}:{}'.format(username, password).encode('utf-8')).decode('utf-8') return token
python
def generate_http_basic_token(username, password): """ Generates a HTTP basic token from username and password Returns a token string (not a byte) """ token = base64.b64encode('{}:{}'.format(username, password).encode('utf-8')).decode('utf-8') return token
[ "def", "generate_http_basic_token", "(", "username", ",", "password", ")", ":", "token", "=", "base64", ".", "b64encode", "(", "'{}:{}'", ".", "format", "(", "username", ",", "password", ")", ".", "encode", "(", "'utf-8'", ")", ")", ".", "decode", "(", "...
Generates a HTTP basic token from username and password Returns a token string (not a byte)
[ "Generates", "a", "HTTP", "basic", "token", "from", "username", "and", "password" ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/utils.py#L81-L88
train
jpoullet2000/atlasclient
atlasclient/base.py
GeneratedIdentifierMixin.identifier
def identifier(self): """These models have server-generated identifiers. If we don't already have it in memory, then assume that it has not yet been generated. """ if self.primary_key not in self._data: return 'Unknown' return str(self._data[self.primary_key]...
python
def identifier(self): """These models have server-generated identifiers. If we don't already have it in memory, then assume that it has not yet been generated. """ if self.primary_key not in self._data: return 'Unknown' return str(self._data[self.primary_key]...
[ "def", "identifier", "(", "self", ")", ":", "if", "self", ".", "primary_key", "not", "in", "self", ".", "_data", ":", "return", "'Unknown'", "return", "str", "(", "self", ".", "_data", "[", "self", ".", "primary_key", "]", ")" ]
These models have server-generated identifiers. If we don't already have it in memory, then assume that it has not yet been generated.
[ "These", "models", "have", "server", "-", "generated", "identifiers", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L79-L87
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.url
def url(self): """The url for this collection.""" if self.parent is None: # TODO: differing API Versions? pieces = [self.client.base_url, 'api', 'atlas', 'v2'] else: pieces = [self.parent.url] pieces.append(self.model_class.path) return '/'.jo...
python
def url(self): """The url for this collection.""" if self.parent is None: # TODO: differing API Versions? pieces = [self.client.base_url, 'api', 'atlas', 'v2'] else: pieces = [self.parent.url] pieces.append(self.model_class.path) return '/'.jo...
[ "def", "url", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "None", ":", "pieces", "=", "[", "self", ".", "client", ".", "base_url", ",", "'api'", ",", "'atlas'", ",", "'v2'", "]", "else", ":", "pieces", "=", "[", "self", ".", "parent...
The url for this collection.
[ "The", "url", "for", "this", "collection", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L230-L239
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.inflate
def inflate(self): """Load the collection from the server, if necessary.""" if not self._is_inflated: self.check_version() for k, v in self._filter.items(): if '[' in v: self._filter[k] = ast.literal_eval(v) self.load(self.client.ge...
python
def inflate(self): """Load the collection from the server, if necessary.""" if not self._is_inflated: self.check_version() for k, v in self._filter.items(): if '[' in v: self._filter[k] = ast.literal_eval(v) self.load(self.client.ge...
[ "def", "inflate", "(", "self", ")", ":", "if", "not", "self", ".", "_is_inflated", ":", "self", ".", "check_version", "(", ")", "for", "k", ",", "v", "in", "self", ".", "_filter", ".", "items", "(", ")", ":", "if", "'['", "in", "v", ":", "self", ...
Load the collection from the server, if necessary.
[ "Load", "the", "collection", "from", "the", "server", "if", "necessary", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L241-L251
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.load
def load(self, response): """Parse the GET response for the collection. This operates as a lazy-loader, meaning that the data are only downloaded from the server if there are not already loaded. Collection items are loaded sequentially. In some rare cases, a collection can have...
python
def load(self, response): """Parse the GET response for the collection. This operates as a lazy-loader, meaning that the data are only downloaded from the server if there are not already loaded. Collection items are loaded sequentially. In some rare cases, a collection can have...
[ "def", "load", "(", "self", ",", "response", ")", ":", "self", ".", "_models", "=", "[", "]", "if", "isinstance", "(", "response", ",", "dict", ")", ":", "for", "key", "in", "response", ".", "keys", "(", ")", ":", "model", "=", "self", ".", "mode...
Parse the GET response for the collection. This operates as a lazy-loader, meaning that the data are only downloaded from the server if there are not already loaded. Collection items are loaded sequentially. In some rare cases, a collection can have an asynchronous request trig...
[ "Parse", "the", "GET", "response", "for", "the", "collection", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L254-L275
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.create
def create(self, *args, **kwargs): """Add a resource to this collection.""" href = self.url if len(args) == 1: kwargs[self.model_class.primary_key] = args[0] href = '/'.join([href, args[0]]) model = self.model_class(self, href=href...
python
def create(self, *args, **kwargs): """Add a resource to this collection.""" href = self.url if len(args) == 1: kwargs[self.model_class.primary_key] = args[0] href = '/'.join([href, args[0]]) model = self.model_class(self, href=href...
[ "def", "create", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "href", "=", "self", ".", "url", "if", "len", "(", "args", ")", "==", "1", ":", "kwargs", "[", "self", ".", "model_class", ".", "primary_key", "]", "=", "args", "[", ...
Add a resource to this collection.
[ "Add", "a", "resource", "to", "this", "collection", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L277-L288
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.update
def update(self, **kwargs): """Update all resources in this collection.""" self.inflate() for model in self._models: model.update(**kwargs) return self
python
def update(self, **kwargs): """Update all resources in this collection.""" self.inflate() for model in self._models: model.update(**kwargs) return self
[ "def", "update", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "inflate", "(", ")", "for", "model", "in", "self", ".", "_models", ":", "model", ".", "update", "(", "**", "kwargs", ")", "return", "self" ]
Update all resources in this collection.
[ "Update", "all", "resources", "in", "this", "collection", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L290-L295
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.delete
def delete(self, **kwargs): """Delete all resources in this collection.""" self.inflate() for model in self._models: model.delete(**kwargs) return
python
def delete(self, **kwargs): """Delete all resources in this collection.""" self.inflate() for model in self._models: model.delete(**kwargs) return
[ "def", "delete", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "inflate", "(", ")", "for", "model", "in", "self", ".", "_models", ":", "model", ".", "delete", "(", "**", "kwargs", ")", "return" ]
Delete all resources in this collection.
[ "Delete", "all", "resources", "in", "this", "collection", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L297-L302
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModelCollection.wait
def wait(self, **kwargs): """Wait until any pending asynchronous requests are finished for this collection.""" if self.request: self.request.wait(**kwargs) self.request = None return self.inflate()
python
def wait(self, **kwargs): """Wait until any pending asynchronous requests are finished for this collection.""" if self.request: self.request.wait(**kwargs) self.request = None return self.inflate()
[ "def", "wait", "(", "self", ",", "**", "kwargs", ")", ":", "if", "self", ".", "request", ":", "self", ".", "request", ".", "wait", "(", "**", "kwargs", ")", "self", ".", "request", "=", "None", "return", "self", ".", "inflate", "(", ")" ]
Wait until any pending asynchronous requests are finished for this collection.
[ "Wait", "until", "any", "pending", "asynchronous", "requests", "are", "finished", "for", "this", "collection", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L305-L310
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModel.url
def url(self): """Gets the url for the resource this model represents. It will just use the 'href' passed in to the constructor if that exists. Otherwise, it will generated it based on the collection's url and the model's identifier. """ if self._href is not None: ...
python
def url(self): """Gets the url for the resource this model represents. It will just use the 'href' passed in to the constructor if that exists. Otherwise, it will generated it based on the collection's url and the model's identifier. """ if self._href is not None: ...
[ "def", "url", "(", "self", ")", ":", "if", "self", ".", "_href", "is", "not", "None", ":", "return", "self", ".", "_href", "if", "self", ".", "identifier", ":", "path", "=", "'/'", ".", "join", "(", "[", "self", ".", "parent", ".", "url", ".", ...
Gets the url for the resource this model represents. It will just use the 'href' passed in to the constructor if that exists. Otherwise, it will generated it based on the collection's url and the model's identifier.
[ "Gets", "the", "url", "for", "the", "resource", "this", "model", "represents", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L568-L581
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModel.inflate
def inflate(self): """Load the resource from the server, if not already loaded.""" if not self._is_inflated: if self._is_inflating: # catch infinite recursion when attempting to inflate # an object that doesn't have enough data to inflate msg...
python
def inflate(self): """Load the resource from the server, if not already loaded.""" if not self._is_inflated: if self._is_inflating: # catch infinite recursion when attempting to inflate # an object that doesn't have enough data to inflate msg...
[ "def", "inflate", "(", "self", ")", ":", "if", "not", "self", ".", "_is_inflated", ":", "if", "self", ".", "_is_inflating", ":", "msg", "=", "(", "\"There is not enough data to inflate this object. \"", "\"Need either an href: {} or a {}: {}\"", ")", "msg", "=", "m...
Load the resource from the server, if not already loaded.
[ "Load", "the", "resource", "from", "the", "server", "if", "not", "already", "loaded", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L583-L605
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModel.load
def load(self, response): """The load method parses the raw JSON response from the server. Most models are not returned in the main response body, but in a key such as 'entity', defined by the 'data_key' attribute on the class. Also, related objects are often returned and can be used to...
python
def load(self, response): """The load method parses the raw JSON response from the server. Most models are not returned in the main response body, but in a key such as 'entity', defined by the 'data_key' attribute on the class. Also, related objects are often returned and can be used to...
[ "def", "load", "(", "self", ",", "response", ")", ":", "if", "'href'", "in", "response", ":", "self", ".", "_href", "=", "response", ".", "pop", "(", "'href'", ")", "if", "self", ".", "data_key", "and", "self", ".", "data_key", "in", "response", ":",...
The load method parses the raw JSON response from the server. Most models are not returned in the main response body, but in a key such as 'entity', defined by the 'data_key' attribute on the class. Also, related objects are often returned and can be used to pre-cache related model obje...
[ "The", "load", "method", "parses", "the", "raw", "JSON", "response", "from", "the", "server", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L623-L648
train
jpoullet2000/atlasclient
atlasclient/base.py
QueryableModel.delete
def delete(self, **kwargs): """Delete a resource by issuing a DELETE http request against it.""" self.method = 'delete' if len(kwargs) > 0: self.load(self.client.delete(self.url, params=kwargs)) else: self.load(self.client.delete(self.url)) self.parent.rem...
python
def delete(self, **kwargs): """Delete a resource by issuing a DELETE http request against it.""" self.method = 'delete' if len(kwargs) > 0: self.load(self.client.delete(self.url, params=kwargs)) else: self.load(self.client.delete(self.url)) self.parent.rem...
[ "def", "delete", "(", "self", ",", "**", "kwargs", ")", ":", "self", ".", "method", "=", "'delete'", "if", "len", "(", "kwargs", ")", ">", "0", ":", "self", ".", "load", "(", "self", ".", "client", ".", "delete", "(", "self", ".", "url", ",", "...
Delete a resource by issuing a DELETE http request against it.
[ "Delete", "a", "resource", "by", "issuing", "a", "DELETE", "http", "request", "against", "it", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/base.py#L686-L694
train
jpoullet2000/atlasclient
atlasclient/events.py
publish
def publish(obj, event, event_state, **kwargs): """Publish an event from an object. This is a really basic pub-sub event system to allow for tracking progress on methods externally. It fires the events for the first match it finds in the object hierarchy, going most specific to least. If no match is ...
python
def publish(obj, event, event_state, **kwargs): """Publish an event from an object. This is a really basic pub-sub event system to allow for tracking progress on methods externally. It fires the events for the first match it finds in the object hierarchy, going most specific to least. If no match is ...
[ "def", "publish", "(", "obj", ",", "event", ",", "event_state", ",", "**", "kwargs", ")", ":", "if", "len", "(", "EVENT_HANDLERS", ")", "==", "0", ":", "return", "if", "inspect", ".", "isclass", "(", "obj", ")", ":", "pub_cls", "=", "obj", "else", ...
Publish an event from an object. This is a really basic pub-sub event system to allow for tracking progress on methods externally. It fires the events for the first match it finds in the object hierarchy, going most specific to least. If no match is found for the exact event+event_state, the most spe...
[ "Publish", "an", "event", "from", "an", "object", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/events.py#L41-L81
train
jpoullet2000/atlasclient
atlasclient/events.py
subscribe
def subscribe(obj, event, callback, event_state=None): """Subscribe an event from an class. Subclasses of the class/object will also fire events for this class, unless a more specific event exists. """ if inspect.isclass(obj): cls = obj.__name__ else: cls = obj.__class__.__name_...
python
def subscribe(obj, event, callback, event_state=None): """Subscribe an event from an class. Subclasses of the class/object will also fire events for this class, unless a more specific event exists. """ if inspect.isclass(obj): cls = obj.__name__ else: cls = obj.__class__.__name_...
[ "def", "subscribe", "(", "obj", ",", "event", ",", "callback", ",", "event_state", "=", "None", ")", ":", "if", "inspect", ".", "isclass", "(", "obj", ")", ":", "cls", "=", "obj", ".", "__name__", "else", ":", "cls", "=", "obj", ".", "__class__", "...
Subscribe an event from an class. Subclasses of the class/object will also fire events for this class, unless a more specific event exists.
[ "Subscribe", "an", "event", "from", "an", "class", "." ]
4548b441143ebf7fc4075d113db5ca5a23e0eed2
https://github.com/jpoullet2000/atlasclient/blob/4548b441143ebf7fc4075d113db5ca5a23e0eed2/atlasclient/events.py#L84-L103
train
psolin/cleanco
cleanco.py
cleanco.clean_name
def clean_name(self, suffix=True, prefix=False, middle=False, multi=False): "return cleared version of the business name" name = self.business_name # Run it through the string_stripper once more name = self.string_stripper(name) loname = name.lower() # return name without suffixed/prefixed/middle type ...
python
def clean_name(self, suffix=True, prefix=False, middle=False, multi=False): "return cleared version of the business name" name = self.business_name # Run it through the string_stripper once more name = self.string_stripper(name) loname = name.lower() # return name without suffixed/prefixed/middle type ...
[ "def", "clean_name", "(", "self", ",", "suffix", "=", "True", ",", "prefix", "=", "False", ",", "middle", "=", "False", ",", "multi", "=", "False", ")", ":", "\"return cleared version of the business name\"", "name", "=", "self", ".", "business_name", "name", ...
return cleared version of the business name
[ "return", "cleared", "version", "of", "the", "business", "name" ]
56ff6542c339df625adcaf7f4ed4c81035fd575a
https://github.com/psolin/cleanco/blob/56ff6542c339df625adcaf7f4ed4c81035fd575a/cleanco.py#L70-L104
train
mosdef-hub/foyer
foyer/smarts_graph.py
SMARTSGraph._add_nodes
def _add_nodes(self): """Add all atoms in the SMARTS string as nodes in the graph.""" for n, atom in enumerate(self.ast.select('atom')): self.add_node(n, atom=atom) self._atom_indices[id(atom)] = n
python
def _add_nodes(self): """Add all atoms in the SMARTS string as nodes in the graph.""" for n, atom in enumerate(self.ast.select('atom')): self.add_node(n, atom=atom) self._atom_indices[id(atom)] = n
[ "def", "_add_nodes", "(", "self", ")", ":", "for", "n", ",", "atom", "in", "enumerate", "(", "self", ".", "ast", ".", "select", "(", "'atom'", ")", ")", ":", "self", ".", "add_node", "(", "n", ",", "atom", "=", "atom", ")", "self", ".", "_atom_in...
Add all atoms in the SMARTS string as nodes in the graph.
[ "Add", "all", "atoms", "in", "the", "SMARTS", "string", "as", "nodes", "in", "the", "graph", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/smarts_graph.py#L51-L55
train
mosdef-hub/foyer
foyer/smarts_graph.py
SMARTSGraph._add_edges
def _add_edges(self, ast_node, trunk=None): """"Add all bonds in the SMARTS string as edges in the graph.""" atom_indices = self._atom_indices for atom in ast_node.tail: if atom.head == 'atom': atom_idx = atom_indices[id(atom)] if atom.is_first_kid and...
python
def _add_edges(self, ast_node, trunk=None): """"Add all bonds in the SMARTS string as edges in the graph.""" atom_indices = self._atom_indices for atom in ast_node.tail: if atom.head == 'atom': atom_idx = atom_indices[id(atom)] if atom.is_first_kid and...
[ "def", "_add_edges", "(", "self", ",", "ast_node", ",", "trunk", "=", "None", ")", ":", "atom_indices", "=", "self", ".", "_atom_indices", "for", "atom", "in", "ast_node", ".", "tail", ":", "if", "atom", ".", "head", "==", "'atom'", ":", "atom_idx", "=...
Add all bonds in the SMARTS string as edges in the graph.
[ "Add", "all", "bonds", "in", "the", "SMARTS", "string", "as", "edges", "in", "the", "graph", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/smarts_graph.py#L57-L75
train
mosdef-hub/foyer
foyer/smarts_graph.py
SMARTSGraph._add_label_edges
def _add_label_edges(self): """Add edges between all atoms with the same atom_label in rings.""" labels = self.ast.select('atom_label') if not labels: return # We need each individual label and atoms with multiple ring labels # would yield e.g. the string '12' so spl...
python
def _add_label_edges(self): """Add edges between all atoms with the same atom_label in rings.""" labels = self.ast.select('atom_label') if not labels: return # We need each individual label and atoms with multiple ring labels # would yield e.g. the string '12' so spl...
[ "def", "_add_label_edges", "(", "self", ")", ":", "labels", "=", "self", ".", "ast", ".", "select", "(", "'atom_label'", ")", "if", "not", "labels", ":", "return", "label_digits", "=", "defaultdict", "(", "list", ")", "for", "label", "in", "labels", ":",...
Add edges between all atoms with the same atom_label in rings.
[ "Add", "edges", "between", "all", "atoms", "with", "the", "same", "atom_label", "in", "rings", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/smarts_graph.py#L77-L94
train
mosdef-hub/foyer
foyer/smarts_graph.py
SMARTSGraph.find_matches
def find_matches(self, topology): """Return sets of atoms that match this SMARTS pattern in a topology. Notes: ------ When this function gets used in atomtyper.py, we actively modify the white- and blacklists of the atoms in `topology` after finding a match. This means t...
python
def find_matches(self, topology): """Return sets of atoms that match this SMARTS pattern in a topology. Notes: ------ When this function gets used in atomtyper.py, we actively modify the white- and blacklists of the atoms in `topology` after finding a match. This means t...
[ "def", "find_matches", "(", "self", ",", "topology", ")", ":", "ring_tokens", "=", "[", "'ring_size'", ",", "'ring_count'", "]", "has_ring_rules", "=", "any", "(", "self", ".", "ast", ".", "select", "(", "token", ")", "for", "token", "in", "ring_tokens", ...
Return sets of atoms that match this SMARTS pattern in a topology. Notes: ------ When this function gets used in atomtyper.py, we actively modify the white- and blacklists of the atoms in `topology` after finding a match. This means that between every successive call of ...
[ "Return", "sets", "of", "atoms", "that", "match", "this", "SMARTS", "pattern", "in", "a", "topology", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/smarts_graph.py#L150-L203
train
mosdef-hub/foyer
foyer/smarts_graph.py
SMARTSMatcher.candidate_pairs_iter
def candidate_pairs_iter(self): """Iterator over candidate pairs of nodes in G1 and G2.""" # All computations are done using the current state! G2_nodes = self.G2_nodes # First we compute the inout-terminal sets. T1_inout = set(self.inout_1.keys()) - set(self.core_1.keys()) ...
python
def candidate_pairs_iter(self): """Iterator over candidate pairs of nodes in G1 and G2.""" # All computations are done using the current state! G2_nodes = self.G2_nodes # First we compute the inout-terminal sets. T1_inout = set(self.inout_1.keys()) - set(self.core_1.keys()) ...
[ "def", "candidate_pairs_iter", "(", "self", ")", ":", "G2_nodes", "=", "self", ".", "G2_nodes", "T1_inout", "=", "set", "(", "self", ".", "inout_1", ".", "keys", "(", ")", ")", "-", "set", "(", "self", ".", "core_1", ".", "keys", "(", ")", ")", "T2...
Iterator over candidate pairs of nodes in G1 and G2.
[ "Iterator", "over", "candidate", "pairs", "of", "nodes", "in", "G1", "and", "G2", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/smarts_graph.py#L216-L236
train
mosdef-hub/foyer
foyer/atomtyper.py
find_atomtypes
def find_atomtypes(topology, forcefield, max_iter=10): """Determine atomtypes for all atoms. Parameters ---------- topology : simtk.openmm.app.Topology The topology that we are trying to atomtype. forcefield : foyer.Forcefield The forcefield object. max_iter : int, optional, def...
python
def find_atomtypes(topology, forcefield, max_iter=10): """Determine atomtypes for all atoms. Parameters ---------- topology : simtk.openmm.app.Topology The topology that we are trying to atomtype. forcefield : foyer.Forcefield The forcefield object. max_iter : int, optional, def...
[ "def", "find_atomtypes", "(", "topology", ",", "forcefield", ",", "max_iter", "=", "10", ")", ":", "rules", "=", "_load_rules", "(", "forcefield", ")", "subrules", "=", "dict", "(", ")", "system_elements", "=", "{", "a", ".", "element", ".", "symbol", "f...
Determine atomtypes for all atoms. Parameters ---------- topology : simtk.openmm.app.Topology The topology that we are trying to atomtype. forcefield : foyer.Forcefield The forcefield object. max_iter : int, optional, default=10 The maximum number of iterations.
[ "Determine", "atomtypes", "for", "all", "atoms", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/atomtyper.py#L7-L43
train
mosdef-hub/foyer
foyer/atomtyper.py
_load_rules
def _load_rules(forcefield): """Load atomtyping rules from a forcefield into SMARTSGraphs. """ rules = dict() for rule_name, smarts in forcefield.atomTypeDefinitions.items(): overrides = forcefield.atomTypeOverrides.get(rule_name) if overrides is not None: overrides = set(overrid...
python
def _load_rules(forcefield): """Load atomtyping rules from a forcefield into SMARTSGraphs. """ rules = dict() for rule_name, smarts in forcefield.atomTypeDefinitions.items(): overrides = forcefield.atomTypeOverrides.get(rule_name) if overrides is not None: overrides = set(overrid...
[ "def", "_load_rules", "(", "forcefield", ")", ":", "rules", "=", "dict", "(", ")", "for", "rule_name", ",", "smarts", "in", "forcefield", ".", "atomTypeDefinitions", ".", "items", "(", ")", ":", "overrides", "=", "forcefield", ".", "atomTypeOverrides", ".", ...
Load atomtyping rules from a forcefield into SMARTSGraphs.
[ "Load", "atomtyping", "rules", "from", "a", "forcefield", "into", "SMARTSGraphs", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/atomtyper.py#L46-L59
train
mosdef-hub/foyer
foyer/atomtyper.py
_iterate_rules
def _iterate_rules(rules, topology, max_iter): """Iteratively run all the rules until the white- and backlists converge. Parameters ---------- rules : dict A dictionary mapping rule names (typically atomtype names) to SMARTSGraphs that evaluate those rules. topology : simtk.openmm.a...
python
def _iterate_rules(rules, topology, max_iter): """Iteratively run all the rules until the white- and backlists converge. Parameters ---------- rules : dict A dictionary mapping rule names (typically atomtype names) to SMARTSGraphs that evaluate those rules. topology : simtk.openmm.a...
[ "def", "_iterate_rules", "(", "rules", ",", "topology", ",", "max_iter", ")", ":", "atoms", "=", "list", "(", "topology", ".", "atoms", "(", ")", ")", "for", "_", "in", "range", "(", "max_iter", ")", ":", "max_iter", "-=", "1", "found_something", "=", ...
Iteratively run all the rules until the white- and backlists converge. Parameters ---------- rules : dict A dictionary mapping rule names (typically atomtype names) to SMARTSGraphs that evaluate those rules. topology : simtk.openmm.app.Topology The topology that we are trying to...
[ "Iteratively", "run", "all", "the", "rules", "until", "the", "white", "-", "and", "backlists", "converge", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/atomtyper.py#L62-L90
train
mosdef-hub/foyer
foyer/atomtyper.py
_resolve_atomtypes
def _resolve_atomtypes(topology): """Determine the final atomtypes from the white- and blacklists. """ for atom in topology.atoms(): atomtype = [rule_name for rule_name in atom.whitelist - atom.blacklist] if len(atomtype) == 1: atom.id = atomtype[0] elif len(atomtype) > 1: ...
python
def _resolve_atomtypes(topology): """Determine the final atomtypes from the white- and blacklists. """ for atom in topology.atoms(): atomtype = [rule_name for rule_name in atom.whitelist - atom.blacklist] if len(atomtype) == 1: atom.id = atomtype[0] elif len(atomtype) > 1: ...
[ "def", "_resolve_atomtypes", "(", "topology", ")", ":", "for", "atom", "in", "topology", ".", "atoms", "(", ")", ":", "atomtype", "=", "[", "rule_name", "for", "rule_name", "in", "atom", ".", "whitelist", "-", "atom", ".", "blacklist", "]", "if", "len", ...
Determine the final atomtypes from the white- and blacklists.
[ "Determine", "the", "final", "atomtypes", "from", "the", "white", "-", "and", "blacklists", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/atomtyper.py#L93-L104
train
mosdef-hub/foyer
foyer/forcefield.py
generate_topology
def generate_topology(non_omm_topology, non_element_types=None, residues=None): """Create an OpenMM Topology from another supported topology structure.""" if non_element_types is None: non_element_types = set() if isinstance(non_omm_topology, pmd.Structure): return _topology_from_pa...
python
def generate_topology(non_omm_topology, non_element_types=None, residues=None): """Create an OpenMM Topology from another supported topology structure.""" if non_element_types is None: non_element_types = set() if isinstance(non_omm_topology, pmd.Structure): return _topology_from_pa...
[ "def", "generate_topology", "(", "non_omm_topology", ",", "non_element_types", "=", "None", ",", "residues", "=", "None", ")", ":", "if", "non_element_types", "is", "None", ":", "non_element_types", "=", "set", "(", ")", "if", "isinstance", "(", "non_omm_topolog...
Create an OpenMM Topology from another supported topology structure.
[ "Create", "an", "OpenMM", "Topology", "from", "another", "supported", "topology", "structure", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L87-L105
train
mosdef-hub/foyer
foyer/forcefield.py
_topology_from_parmed
def _topology_from_parmed(structure, non_element_types): """Convert a ParmEd Structure to an OpenMM Topology.""" topology = app.Topology() residues = dict() for pmd_residue in structure.residues: chain = topology.addChain() omm_residue = topology.addResidue(pmd_residue.name, chain) ...
python
def _topology_from_parmed(structure, non_element_types): """Convert a ParmEd Structure to an OpenMM Topology.""" topology = app.Topology() residues = dict() for pmd_residue in structure.residues: chain = topology.addChain() omm_residue = topology.addResidue(pmd_residue.name, chain) ...
[ "def", "_topology_from_parmed", "(", "structure", ",", "non_element_types", ")", ":", "topology", "=", "app", ".", "Topology", "(", ")", "residues", "=", "dict", "(", ")", "for", "pmd_residue", "in", "structure", ".", "residues", ":", "chain", "=", "topology...
Convert a ParmEd Structure to an OpenMM Topology.
[ "Convert", "a", "ParmEd", "Structure", "to", "an", "OpenMM", "Topology", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L108-L143
train
mosdef-hub/foyer
foyer/forcefield.py
_topology_from_residue
def _topology_from_residue(res): """Converts a openmm.app.Topology.Residue to openmm.app.Topology. Parameters ---------- res : openmm.app.Topology.Residue An individual residue in an openmm.app.Topology Returns ------- topology : openmm.app.Topology The generated topology ...
python
def _topology_from_residue(res): """Converts a openmm.app.Topology.Residue to openmm.app.Topology. Parameters ---------- res : openmm.app.Topology.Residue An individual residue in an openmm.app.Topology Returns ------- topology : openmm.app.Topology The generated topology ...
[ "def", "_topology_from_residue", "(", "res", ")", ":", "topology", "=", "app", ".", "Topology", "(", ")", "chain", "=", "topology", ".", "addChain", "(", ")", "new_res", "=", "topology", ".", "addResidue", "(", "res", ".", "name", ",", "chain", ")", "a...
Converts a openmm.app.Topology.Residue to openmm.app.Topology. Parameters ---------- res : openmm.app.Topology.Residue An individual residue in an openmm.app.Topology Returns ------- topology : openmm.app.Topology The generated topology
[ "Converts", "a", "openmm", ".", "app", ".", "Topology", ".", "Residue", "to", "openmm", ".", "app", ".", "Topology", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L146-L180
train
mosdef-hub/foyer
foyer/forcefield.py
_check_independent_residues
def _check_independent_residues(topology): """Check to see if residues will constitute independent graphs.""" for res in topology.residues(): atoms_in_residue = set([atom for atom in res.atoms()]) bond_partners_in_residue = [item for sublist in [atom.bond_partners for atom in res.atoms()] for it...
python
def _check_independent_residues(topology): """Check to see if residues will constitute independent graphs.""" for res in topology.residues(): atoms_in_residue = set([atom for atom in res.atoms()]) bond_partners_in_residue = [item for sublist in [atom.bond_partners for atom in res.atoms()] for it...
[ "def", "_check_independent_residues", "(", "topology", ")", ":", "for", "res", "in", "topology", ".", "residues", "(", ")", ":", "atoms_in_residue", "=", "set", "(", "[", "atom", "for", "atom", "in", "res", ".", "atoms", "(", ")", "]", ")", "bond_partner...
Check to see if residues will constitute independent graphs.
[ "Check", "to", "see", "if", "residues", "will", "constitute", "independent", "graphs", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L183-L193
train
mosdef-hub/foyer
foyer/forcefield.py
_update_atomtypes
def _update_atomtypes(unatomtyped_topology, res_name, prototype): """Update atomtypes in residues in a topology using a prototype topology. Atomtypes are updated when residues in each topology have matching names. Parameters ---------- unatomtyped_topology : openmm.app.Topology Topology la...
python
def _update_atomtypes(unatomtyped_topology, res_name, prototype): """Update atomtypes in residues in a topology using a prototype topology. Atomtypes are updated when residues in each topology have matching names. Parameters ---------- unatomtyped_topology : openmm.app.Topology Topology la...
[ "def", "_update_atomtypes", "(", "unatomtyped_topology", ",", "res_name", ",", "prototype", ")", ":", "for", "res", "in", "unatomtyped_topology", ".", "residues", "(", ")", ":", "if", "res", ".", "name", "==", "res_name", ":", "for", "old_atom", ",", "new_at...
Update atomtypes in residues in a topology using a prototype topology. Atomtypes are updated when residues in each topology have matching names. Parameters ---------- unatomtyped_topology : openmm.app.Topology Topology lacking atomtypes defined by `find_atomtypes`. prototype : openmm.app.T...
[ "Update", "atomtypes", "in", "residues", "in", "a", "topology", "using", "a", "prototype", "topology", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L196-L212
train
mosdef-hub/foyer
foyer/forcefield.py
Forcefield.registerAtomType
def registerAtomType(self, parameters): """Register a new atom type. """ name = parameters['name'] if name in self._atomTypes: raise ValueError('Found multiple definitions for atom type: ' + name) atom_class = parameters['class'] mass = _convertParameterToNumber(param...
python
def registerAtomType(self, parameters): """Register a new atom type. """ name = parameters['name'] if name in self._atomTypes: raise ValueError('Found multiple definitions for atom type: ' + name) atom_class = parameters['class'] mass = _convertParameterToNumber(param...
[ "def", "registerAtomType", "(", "self", ",", "parameters", ")", ":", "name", "=", "parameters", "[", "'name'", "]", "if", "name", "in", "self", ".", "_atomTypes", ":", "raise", "ValueError", "(", "'Found multiple definitions for atom type: '", "+", "name", ")", ...
Register a new atom type.
[ "Register", "a", "new", "atom", "type", "." ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L307-L341
train
mosdef-hub/foyer
foyer/forcefield.py
Forcefield.run_atomtyping
def run_atomtyping(self, topology, use_residue_map=True): """Atomtype the topology Parameters ---------- topology : openmm.app.Topology Molecular structure to find atom types of use_residue_map : boolean, optional, default=True Store atomtyped topologies ...
python
def run_atomtyping(self, topology, use_residue_map=True): """Atomtype the topology Parameters ---------- topology : openmm.app.Topology Molecular structure to find atom types of use_residue_map : boolean, optional, default=True Store atomtyped topologies ...
[ "def", "run_atomtyping", "(", "self", ",", "topology", ",", "use_residue_map", "=", "True", ")", ":", "if", "use_residue_map", ":", "independent_residues", "=", "_check_independent_residues", "(", "topology", ")", "if", "independent_residues", ":", "residue_map", "=...
Atomtype the topology Parameters ---------- topology : openmm.app.Topology Molecular structure to find atom types of use_residue_map : boolean, optional, default=True Store atomtyped topologies of residues to a dictionary that maps them to residue nam...
[ "Atomtype", "the", "topology" ]
9e39c71208fc01a6cc7b7cbe5a533c56830681d3
https://github.com/mosdef-hub/foyer/blob/9e39c71208fc01a6cc7b7cbe5a533c56830681d3/foyer/forcefield.py#L452-L493
train
mgedmin/check-manifest
check_manifest.py
cd
def cd(directory): """Change the current working directory, temporarily. Use as a context manager: with cd(d): ... """ old_dir = os.getcwd() try: os.chdir(directory) yield finally: os.chdir(old_dir)
python
def cd(directory): """Change the current working directory, temporarily. Use as a context manager: with cd(d): ... """ old_dir = os.getcwd() try: os.chdir(directory) yield finally: os.chdir(old_dir)
[ "def", "cd", "(", "directory", ")", ":", "old_dir", "=", "os", ".", "getcwd", "(", ")", "try", ":", "os", ".", "chdir", "(", "directory", ")", "yield", "finally", ":", "os", ".", "chdir", "(", "old_dir", ")" ]
Change the current working directory, temporarily. Use as a context manager: with cd(d): ...
[ "Change", "the", "current", "working", "directory", "temporarily", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L164-L174
train
mgedmin/check-manifest
check_manifest.py
mkdtemp
def mkdtemp(hint=''): """Create a temporary directory, then clean it up. Use as a context manager: with mkdtemp('-purpose'): ... """ dirname = tempfile.mkdtemp(prefix='check-manifest-', suffix=hint) try: yield dirname finally: rmtree(dirname)
python
def mkdtemp(hint=''): """Create a temporary directory, then clean it up. Use as a context manager: with mkdtemp('-purpose'): ... """ dirname = tempfile.mkdtemp(prefix='check-manifest-', suffix=hint) try: yield dirname finally: rmtree(dirname)
[ "def", "mkdtemp", "(", "hint", "=", "''", ")", ":", "dirname", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "'check-manifest-'", ",", "suffix", "=", "hint", ")", "try", ":", "yield", "dirname", "finally", ":", "rmtree", "(", "dirname", ")" ]
Create a temporary directory, then clean it up. Use as a context manager: with mkdtemp('-purpose'): ...
[ "Create", "a", "temporary", "directory", "then", "clean", "it", "up", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L178-L187
train
mgedmin/check-manifest
check_manifest.py
chmod_plus
def chmod_plus(path, add_bits=stat.S_IWUSR): """Change a file's mode by adding a few bits. Like chmod +<bits> <path> in a Unix shell. """ try: os.chmod(path, stat.S_IMODE(os.stat(path).st_mode) | add_bits) except OSError: # pragma: nocover pass
python
def chmod_plus(path, add_bits=stat.S_IWUSR): """Change a file's mode by adding a few bits. Like chmod +<bits> <path> in a Unix shell. """ try: os.chmod(path, stat.S_IMODE(os.stat(path).st_mode) | add_bits) except OSError: # pragma: nocover pass
[ "def", "chmod_plus", "(", "path", ",", "add_bits", "=", "stat", ".", "S_IWUSR", ")", ":", "try", ":", "os", ".", "chmod", "(", "path", ",", "stat", ".", "S_IMODE", "(", "os", ".", "stat", "(", "path", ")", ".", "st_mode", ")", "|", "add_bits", ")...
Change a file's mode by adding a few bits. Like chmod +<bits> <path> in a Unix shell.
[ "Change", "a", "file", "s", "mode", "by", "adding", "a", "few", "bits", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L190-L198
train
mgedmin/check-manifest
check_manifest.py
rmtree
def rmtree(path): """A version of rmtree that can deal with read-only files and directories. Needed because the stock shutil.rmtree() fails with an access error when there are read-only files in the directory on Windows, or when the directory itself is read-only on Unix. """ def onerror(func, p...
python
def rmtree(path): """A version of rmtree that can deal with read-only files and directories. Needed because the stock shutil.rmtree() fails with an access error when there are read-only files in the directory on Windows, or when the directory itself is read-only on Unix. """ def onerror(func, p...
[ "def", "rmtree", "(", "path", ")", ":", "def", "onerror", "(", "func", ",", "path", ",", "exc_info", ")", ":", "if", "func", "is", "os", ".", "remove", "or", "func", "is", "os", ".", "unlink", "or", "func", "is", "os", ".", "rmdir", ":", "if", ...
A version of rmtree that can deal with read-only files and directories. Needed because the stock shutil.rmtree() fails with an access error when there are read-only files in the directory on Windows, or when the directory itself is read-only on Unix.
[ "A", "version", "of", "rmtree", "that", "can", "deal", "with", "read", "-", "only", "files", "and", "directories", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L201-L218
train
mgedmin/check-manifest
check_manifest.py
copy_files
def copy_files(filelist, destdir): """Copy a list of files to destdir, preserving directory structure. File names should be relative to the current working directory. """ for filename in filelist: destfile = os.path.join(destdir, filename) # filename should not be absolute, but let's do...
python
def copy_files(filelist, destdir): """Copy a list of files to destdir, preserving directory structure. File names should be relative to the current working directory. """ for filename in filelist: destfile = os.path.join(destdir, filename) # filename should not be absolute, but let's do...
[ "def", "copy_files", "(", "filelist", ",", "destdir", ")", ":", "for", "filename", "in", "filelist", ":", "destfile", "=", "os", ".", "path", ".", "join", "(", "destdir", ",", "filename", ")", "assert", "destfile", ".", "startswith", "(", "destdir", "+",...
Copy a list of files to destdir, preserving directory structure. File names should be relative to the current working directory.
[ "Copy", "a", "list", "of", "files", "to", "destdir", "preserving", "directory", "structure", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L221-L236
train
mgedmin/check-manifest
check_manifest.py
get_one_file_in
def get_one_file_in(dirname): """Return the pathname of the one file in a directory. Raises if the directory has no files or more than one file. """ files = os.listdir(dirname) if len(files) > 1: raise Failure('More than one file exists in %s:\n%s' % (dirname, '\n'.joi...
python
def get_one_file_in(dirname): """Return the pathname of the one file in a directory. Raises if the directory has no files or more than one file. """ files = os.listdir(dirname) if len(files) > 1: raise Failure('More than one file exists in %s:\n%s' % (dirname, '\n'.joi...
[ "def", "get_one_file_in", "(", "dirname", ")", ":", "files", "=", "os", ".", "listdir", "(", "dirname", ")", "if", "len", "(", "files", ")", ">", "1", ":", "raise", "Failure", "(", "'More than one file exists in %s:\\n%s'", "%", "(", "dirname", ",", "'\\n'...
Return the pathname of the one file in a directory. Raises if the directory has no files or more than one file.
[ "Return", "the", "pathname", "of", "the", "one", "file", "in", "a", "directory", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L239-L250
train
mgedmin/check-manifest
check_manifest.py
unicodify
def unicodify(filename): """Make sure filename is Unicode. Because the tarfile module on Python 2 doesn't return Unicode. """ if isinstance(filename, bytes): return filename.decode(locale.getpreferredencoding()) else: return filename
python
def unicodify(filename): """Make sure filename is Unicode. Because the tarfile module on Python 2 doesn't return Unicode. """ if isinstance(filename, bytes): return filename.decode(locale.getpreferredencoding()) else: return filename
[ "def", "unicodify", "(", "filename", ")", ":", "if", "isinstance", "(", "filename", ",", "bytes", ")", ":", "return", "filename", ".", "decode", "(", "locale", ".", "getpreferredencoding", "(", ")", ")", "else", ":", "return", "filename" ]
Make sure filename is Unicode. Because the tarfile module on Python 2 doesn't return Unicode.
[ "Make", "sure", "filename", "is", "Unicode", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L253-L261
train
mgedmin/check-manifest
check_manifest.py
get_archive_file_list
def get_archive_file_list(archive_filename): """Return the list of files in an archive. Supports .tar.gz and .zip. """ if archive_filename.endswith('.zip'): with closing(zipfile.ZipFile(archive_filename)) as zf: return add_directories(zf.namelist()) elif archive_filename.endswit...
python
def get_archive_file_list(archive_filename): """Return the list of files in an archive. Supports .tar.gz and .zip. """ if archive_filename.endswith('.zip'): with closing(zipfile.ZipFile(archive_filename)) as zf: return add_directories(zf.namelist()) elif archive_filename.endswit...
[ "def", "get_archive_file_list", "(", "archive_filename", ")", ":", "if", "archive_filename", ".", "endswith", "(", "'.zip'", ")", ":", "with", "closing", "(", "zipfile", ".", "ZipFile", "(", "archive_filename", ")", ")", "as", "zf", ":", "return", "add_directo...
Return the list of files in an archive. Supports .tar.gz and .zip.
[ "Return", "the", "list", "of", "files", "in", "an", "archive", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L264-L277
train
mgedmin/check-manifest
check_manifest.py
strip_toplevel_name
def strip_toplevel_name(filelist): """Strip toplevel name from a file list. >>> strip_toplevel_name(['a', 'a/b', 'a/c', 'a/c/d']) ['b', 'c', 'c/d'] >>> strip_toplevel_name(['a/b', 'a/c', 'a/c/d']) ['b', 'c', 'c/d'] """ if not filelist: return filelist prefix = ...
python
def strip_toplevel_name(filelist): """Strip toplevel name from a file list. >>> strip_toplevel_name(['a', 'a/b', 'a/c', 'a/c/d']) ['b', 'c', 'c/d'] >>> strip_toplevel_name(['a/b', 'a/c', 'a/c/d']) ['b', 'c', 'c/d'] """ if not filelist: return filelist prefix = ...
[ "def", "strip_toplevel_name", "(", "filelist", ")", ":", "if", "not", "filelist", ":", "return", "filelist", "prefix", "=", "filelist", "[", "0", "]", "if", "'/'", "in", "prefix", ":", "prefix", "=", "prefix", ".", "partition", "(", "'/'", ")", "[", "0...
Strip toplevel name from a file list. >>> strip_toplevel_name(['a', 'a/b', 'a/c', 'a/c/d']) ['b', 'c', 'c/d'] >>> strip_toplevel_name(['a/b', 'a/c', 'a/c/d']) ['b', 'c', 'c/d']
[ "Strip", "toplevel", "name", "from", "a", "file", "list", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L280-L303
train
mgedmin/check-manifest
check_manifest.py
detect_vcs
def detect_vcs(): """Detect the version control system used for the current directory.""" location = os.path.abspath('.') while True: for vcs in Git, Mercurial, Bazaar, Subversion: if vcs.detect(location): return vcs parent = os.path.dirname(location) if p...
python
def detect_vcs(): """Detect the version control system used for the current directory.""" location = os.path.abspath('.') while True: for vcs in Git, Mercurial, Bazaar, Subversion: if vcs.detect(location): return vcs parent = os.path.dirname(location) if p...
[ "def", "detect_vcs", "(", ")", ":", "location", "=", "os", ".", "path", ".", "abspath", "(", "'.'", ")", "while", "True", ":", "for", "vcs", "in", "Git", ",", "Mercurial", ",", "Bazaar", ",", "Subversion", ":", "if", "vcs", ".", "detect", "(", "loc...
Detect the version control system used for the current directory.
[ "Detect", "the", "version", "control", "system", "used", "for", "the", "current", "directory", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L465-L476
train
mgedmin/check-manifest
check_manifest.py
normalize_name
def normalize_name(name): """Some VCS print directory names with trailing slashes. Strip them. Easiest is to normalize the path. And encodings may trip us up too, especially when comparing lists of files. Plus maybe lowercase versus uppercase. """ name = os.path.normpath(name) name = uni...
python
def normalize_name(name): """Some VCS print directory names with trailing slashes. Strip them. Easiest is to normalize the path. And encodings may trip us up too, especially when comparing lists of files. Plus maybe lowercase versus uppercase. """ name = os.path.normpath(name) name = uni...
[ "def", "normalize_name", "(", "name", ")", ":", "name", "=", "os", ".", "path", ".", "normpath", "(", "name", ")", "name", "=", "unicodify", "(", "name", ")", "if", "sys", ".", "platform", "==", "'darwin'", ":", "name", "=", "unicodedata", ".", "norm...
Some VCS print directory names with trailing slashes. Strip them. Easiest is to normalize the path. And encodings may trip us up too, especially when comparing lists of files. Plus maybe lowercase versus uppercase.
[ "Some", "VCS", "print", "directory", "names", "with", "trailing", "slashes", ".", "Strip", "them", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L490-L504
train
mgedmin/check-manifest
check_manifest.py
read_config
def read_config(): """Read configuration from file if possible.""" # XXX modifies global state, which is kind of evil config = _load_config() if config.get(CFG_IGNORE_DEFAULT_RULES[1], False): del IGNORE[:] if CFG_IGNORE[1] in config: IGNORE.extend(p for p in config[CFG_IGNORE[1]] if...
python
def read_config(): """Read configuration from file if possible.""" # XXX modifies global state, which is kind of evil config = _load_config() if config.get(CFG_IGNORE_DEFAULT_RULES[1], False): del IGNORE[:] if CFG_IGNORE[1] in config: IGNORE.extend(p for p in config[CFG_IGNORE[1]] if...
[ "def", "read_config", "(", ")", ":", "config", "=", "_load_config", "(", ")", "if", "config", ".", "get", "(", "CFG_IGNORE_DEFAULT_RULES", "[", "1", "]", ",", "False", ")", ":", "del", "IGNORE", "[", ":", "]", "if", "CFG_IGNORE", "[", "1", "]", "in",...
Read configuration from file if possible.
[ "Read", "configuration", "from", "file", "if", "possible", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L593-L602
train
mgedmin/check-manifest
check_manifest.py
_load_config
def _load_config(): """Searches for config files, reads them and returns a dictionary Looks for a ``check-manifest`` section in ``pyproject.toml``, ``setup.cfg``, and ``tox.ini``, in that order. The first file that exists and has that section will be loaded and returned as a dictionary. """ ...
python
def _load_config(): """Searches for config files, reads them and returns a dictionary Looks for a ``check-manifest`` section in ``pyproject.toml``, ``setup.cfg``, and ``tox.ini``, in that order. The first file that exists and has that section will be loaded and returned as a dictionary. """ ...
[ "def", "_load_config", "(", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "\"pyproject.toml\"", ")", ":", "config", "=", "toml", ".", "load", "(", "\"pyproject.toml\"", ")", "if", "CFG_SECTION_CHECK_MANIFEST", "in", "config", ".", "get", "(", "\"t...
Searches for config files, reads them and returns a dictionary Looks for a ``check-manifest`` section in ``pyproject.toml``, ``setup.cfg``, and ``tox.ini``, in that order. The first file that exists and has that section will be loaded and returned as a dictionary.
[ "Searches", "for", "config", "files", "reads", "them", "and", "returns", "a", "dictionary" ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L605-L646
train
mgedmin/check-manifest
check_manifest.py
read_manifest
def read_manifest(): """Read existing configuration from MANIFEST.in. We use that to ignore anything the MANIFEST.in ignores. """ # XXX modifies global state, which is kind of evil if not os.path.isfile('MANIFEST.in'): return ignore, ignore_regexps = _get_ignore_from_manifest('MANIFEST....
python
def read_manifest(): """Read existing configuration from MANIFEST.in. We use that to ignore anything the MANIFEST.in ignores. """ # XXX modifies global state, which is kind of evil if not os.path.isfile('MANIFEST.in'): return ignore, ignore_regexps = _get_ignore_from_manifest('MANIFEST....
[ "def", "read_manifest", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "'MANIFEST.in'", ")", ":", "return", "ignore", ",", "ignore_regexps", "=", "_get_ignore_from_manifest", "(", "'MANIFEST.in'", ")", "IGNORE", ".", "extend", "(", "ignor...
Read existing configuration from MANIFEST.in. We use that to ignore anything the MANIFEST.in ignores.
[ "Read", "existing", "configuration", "from", "MANIFEST", ".", "in", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L649-L659
train
mgedmin/check-manifest
check_manifest.py
file_matches
def file_matches(filename, patterns): """Does this filename match any of the patterns?""" return any(fnmatch.fnmatch(filename, pat) or fnmatch.fnmatch(os.path.basename(filename), pat) for pat in patterns)
python
def file_matches(filename, patterns): """Does this filename match any of the patterns?""" return any(fnmatch.fnmatch(filename, pat) or fnmatch.fnmatch(os.path.basename(filename), pat) for pat in patterns)
[ "def", "file_matches", "(", "filename", ",", "patterns", ")", ":", "return", "any", "(", "fnmatch", ".", "fnmatch", "(", "filename", ",", "pat", ")", "or", "fnmatch", ".", "fnmatch", "(", "os", ".", "path", ".", "basename", "(", "filename", ")", ",", ...
Does this filename match any of the patterns?
[ "Does", "this", "filename", "match", "any", "of", "the", "patterns?" ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L774-L778
train
mgedmin/check-manifest
check_manifest.py
file_matches_regexps
def file_matches_regexps(filename, patterns): """Does this filename match any of the regular expressions?""" return any(re.match(pat, filename) for pat in patterns)
python
def file_matches_regexps(filename, patterns): """Does this filename match any of the regular expressions?""" return any(re.match(pat, filename) for pat in patterns)
[ "def", "file_matches_regexps", "(", "filename", ",", "patterns", ")", ":", "return", "any", "(", "re", ".", "match", "(", "pat", ",", "filename", ")", "for", "pat", "in", "patterns", ")" ]
Does this filename match any of the regular expressions?
[ "Does", "this", "filename", "match", "any", "of", "the", "regular", "expressions?" ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L781-L783
train
mgedmin/check-manifest
check_manifest.py
strip_sdist_extras
def strip_sdist_extras(filelist): """Strip generated files that are only present in source distributions. We also strip files that are ignored for other reasons, like command line arguments, setup.cfg rules or MANIFEST.in rules. """ return [name for name in filelist if not file_matches(...
python
def strip_sdist_extras(filelist): """Strip generated files that are only present in source distributions. We also strip files that are ignored for other reasons, like command line arguments, setup.cfg rules or MANIFEST.in rules. """ return [name for name in filelist if not file_matches(...
[ "def", "strip_sdist_extras", "(", "filelist", ")", ":", "return", "[", "name", "for", "name", "in", "filelist", "if", "not", "file_matches", "(", "name", ",", "IGNORE", ")", "and", "not", "file_matches_regexps", "(", "name", ",", "IGNORE_REGEXPS", ")", "]" ]
Strip generated files that are only present in source distributions. We also strip files that are ignored for other reasons, like command line arguments, setup.cfg rules or MANIFEST.in rules.
[ "Strip", "generated", "files", "that", "are", "only", "present", "in", "source", "distributions", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L786-L794
train
mgedmin/check-manifest
check_manifest.py
find_suggestions
def find_suggestions(filelist): """Suggest MANIFEST.in patterns for missing files.""" suggestions = set() unknowns = [] for filename in filelist: if os.path.isdir(filename): # it's impossible to add empty directories via MANIFEST.in anyway, # and non-empty directories wil...
python
def find_suggestions(filelist): """Suggest MANIFEST.in patterns for missing files.""" suggestions = set() unknowns = [] for filename in filelist: if os.path.isdir(filename): # it's impossible to add empty directories via MANIFEST.in anyway, # and non-empty directories wil...
[ "def", "find_suggestions", "(", "filelist", ")", ":", "suggestions", "=", "set", "(", ")", "unknowns", "=", "[", "]", "for", "filename", "in", "filelist", ":", "if", "os", ".", "path", ".", "isdir", "(", "filename", ")", ":", "continue", "for", "patter...
Suggest MANIFEST.in patterns for missing files.
[ "Suggest", "MANIFEST", ".", "in", "patterns", "for", "missing", "files", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L803-L820
train
mgedmin/check-manifest
check_manifest.py
extract_version_from_filename
def extract_version_from_filename(filename): """Extract version number from sdist filename.""" filename = os.path.splitext(os.path.basename(filename))[0] if filename.endswith('.tar'): filename = os.path.splitext(filename)[0] return filename.partition('-')[2]
python
def extract_version_from_filename(filename): """Extract version number from sdist filename.""" filename = os.path.splitext(os.path.basename(filename))[0] if filename.endswith('.tar'): filename = os.path.splitext(filename)[0] return filename.partition('-')[2]
[ "def", "extract_version_from_filename", "(", "filename", ")", ":", "filename", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "filename", ")", ")", "[", "0", "]", "if", "filename", ".", "endswith", "(", "'.tar'", ...
Extract version number from sdist filename.
[ "Extract", "version", "number", "from", "sdist", "filename", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L832-L837
train
mgedmin/check-manifest
check_manifest.py
zest_releaser_check
def zest_releaser_check(data): """Check the completeness of MANIFEST.in before the release. This is an entry point for zest.releaser. See the documentation at https://zestreleaser.readthedocs.io/en/latest/entrypoints.html """ from zest.releaser.utils import ask source_tree = data['workingdir']...
python
def zest_releaser_check(data): """Check the completeness of MANIFEST.in before the release. This is an entry point for zest.releaser. See the documentation at https://zestreleaser.readthedocs.io/en/latest/entrypoints.html """ from zest.releaser.utils import ask source_tree = data['workingdir']...
[ "def", "zest_releaser_check", "(", "data", ")", ":", "from", "zest", ".", "releaser", ".", "utils", "import", "ask", "source_tree", "=", "data", "[", "'workingdir'", "]", "if", "not", "is_package", "(", "source_tree", ")", ":", "return", "if", "not", "ask"...
Check the completeness of MANIFEST.in before the release. This is an entry point for zest.releaser. See the documentation at https://zestreleaser.readthedocs.io/en/latest/entrypoints.html
[ "Check", "the", "completeness", "of", "MANIFEST", ".", "in", "before", "the", "release", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L1000-L1024
train
mgedmin/check-manifest
check_manifest.py
Git.get_versioned_files
def get_versioned_files(cls): """List all files versioned by git in the current directory.""" files = cls._git_ls_files() submodules = cls._list_submodules() for subdir in submodules: subdir = os.path.relpath(subdir).replace(os.path.sep, '/') files += add_prefix_t...
python
def get_versioned_files(cls): """List all files versioned by git in the current directory.""" files = cls._git_ls_files() submodules = cls._list_submodules() for subdir in submodules: subdir = os.path.relpath(subdir).replace(os.path.sep, '/') files += add_prefix_t...
[ "def", "get_versioned_files", "(", "cls", ")", ":", "files", "=", "cls", ".", "_git_ls_files", "(", ")", "submodules", "=", "cls", ".", "_list_submodules", "(", ")", "for", "subdir", "in", "submodules", ":", "subdir", "=", "os", ".", "path", ".", "relpat...
List all files versioned by git in the current directory.
[ "List", "all", "files", "versioned", "by", "git", "in", "the", "current", "directory", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L337-L344
train
mgedmin/check-manifest
check_manifest.py
Bazaar.get_versioned_files
def get_versioned_files(cls): """List all files versioned in Bazaar in the current directory.""" encoding = cls._get_terminal_encoding() output = run(['bzr', 'ls', '-VR'], encoding=encoding) return output.splitlines()
python
def get_versioned_files(cls): """List all files versioned in Bazaar in the current directory.""" encoding = cls._get_terminal_encoding() output = run(['bzr', 'ls', '-VR'], encoding=encoding) return output.splitlines()
[ "def", "get_versioned_files", "(", "cls", ")", ":", "encoding", "=", "cls", ".", "_get_terminal_encoding", "(", ")", "output", "=", "run", "(", "[", "'bzr'", ",", "'ls'", ",", "'-VR'", "]", ",", "encoding", "=", "encoding", ")", "return", "output", ".", ...
List all files versioned in Bazaar in the current directory.
[ "List", "all", "files", "versioned", "in", "Bazaar", "in", "the", "current", "directory", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L404-L408
train
mgedmin/check-manifest
check_manifest.py
Subversion.get_versioned_files
def get_versioned_files(cls): """List all files under SVN control in the current directory.""" output = run(['svn', 'st', '-vq', '--xml'], decode=False) tree = ET.XML(output) return sorted(entry.get('path') for entry in tree.findall('.//entry') if cls.is_interesting...
python
def get_versioned_files(cls): """List all files under SVN control in the current directory.""" output = run(['svn', 'st', '-vq', '--xml'], decode=False) tree = ET.XML(output) return sorted(entry.get('path') for entry in tree.findall('.//entry') if cls.is_interesting...
[ "def", "get_versioned_files", "(", "cls", ")", ":", "output", "=", "run", "(", "[", "'svn'", ",", "'st'", ",", "'-vq'", ",", "'--xml'", "]", ",", "decode", "=", "False", ")", "tree", "=", "ET", ".", "XML", "(", "output", ")", "return", "sorted", "(...
List all files under SVN control in the current directory.
[ "List", "all", "files", "under", "SVN", "control", "in", "the", "current", "directory", "." ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L415-L420
train
mgedmin/check-manifest
check_manifest.py
Subversion.is_interesting
def is_interesting(entry): """Is this entry interesting? ``entry`` is an XML node representing one entry of the svn status XML output. It looks like this:: <entry path="unchanged.txt"> <wc-status item="normal" revision="1" props="none"> <commit revisi...
python
def is_interesting(entry): """Is this entry interesting? ``entry`` is an XML node representing one entry of the svn status XML output. It looks like this:: <entry path="unchanged.txt"> <wc-status item="normal" revision="1" props="none"> <commit revisi...
[ "def", "is_interesting", "(", "entry", ")", ":", "if", "entry", ".", "get", "(", "'path'", ")", "==", "'.'", ":", "return", "False", "status", "=", "entry", ".", "find", "(", "'wc-status'", ")", "if", "status", "is", "None", ":", "warning", "(", "'sv...
Is this entry interesting? ``entry`` is an XML node representing one entry of the svn status XML output. It looks like this:: <entry path="unchanged.txt"> <wc-status item="normal" revision="1" props="none"> <commit revision="1"> <author>mg</...
[ "Is", "this", "entry", "interesting?" ]
7f787e8272f56c5750670bfb3223509e0df72708
https://github.com/mgedmin/check-manifest/blob/7f787e8272f56c5750670bfb3223509e0df72708/check_manifest.py#L423-L462
train
awslabs/aws-serverlessrepo-python
serverlessrepo/application_policy.py
ApplicationPolicy.validate
def validate(self): """ Check if the formats of principals and actions are valid. :return: True, if the policy is valid :raises: InvalidApplicationPolicyError """ if not self.principals: raise InvalidApplicationPolicyError(error_message='principals not provid...
python
def validate(self): """ Check if the formats of principals and actions are valid. :return: True, if the policy is valid :raises: InvalidApplicationPolicyError """ if not self.principals: raise InvalidApplicationPolicyError(error_message='principals not provid...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "self", ".", "principals", ":", "raise", "InvalidApplicationPolicyError", "(", "error_message", "=", "'principals not provided'", ")", "if", "not", "self", ".", "actions", ":", "raise", "InvalidApplicationPoli...
Check if the formats of principals and actions are valid. :return: True, if the policy is valid :raises: InvalidApplicationPolicyError
[ "Check", "if", "the", "formats", "of", "principals", "and", "actions", "are", "valid", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/application_policy.py#L44-L66
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
publish_application
def publish_application(template, sar_client=None): """ Create a new application or new application version in SAR. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client ...
python
def publish_application(template, sar_client=None): """ Create a new application or new application version in SAR. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client ...
[ "def", "publish_application", "(", "template", ",", "sar_client", "=", "None", ")", ":", "if", "not", "template", ":", "raise", "ValueError", "(", "'Require SAM template to publish the application'", ")", "if", "not", "sar_client", ":", "sar_client", "=", "boto3", ...
Create a new application or new application version in SAR. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client :return: Dictionary containing application id, actions taken...
[ "Create", "a", "new", "application", "or", "new", "application", "version", "in", "SAR", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L21-L76
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
update_application_metadata
def update_application_metadata(template, application_id, sar_client=None): """ Update the application metadata. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :param application_id: The Amazon Resource Name (ARN) of the application :type applicatio...
python
def update_application_metadata(template, application_id, sar_client=None): """ Update the application metadata. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :param application_id: The Amazon Resource Name (ARN) of the application :type applicatio...
[ "def", "update_application_metadata", "(", "template", ",", "application_id", ",", "sar_client", "=", "None", ")", ":", "if", "not", "template", "or", "not", "application_id", ":", "raise", "ValueError", "(", "'Require SAM template and application ID to update application...
Update the application metadata. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param sar_client: The boto3 client used to access SAR :type sar_clien...
[ "Update", "the", "application", "metadata", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L79-L100
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
_get_template_dict
def _get_template_dict(template): """ Parse string template and or copy dictionary template. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :return: Template as a dictionary :rtype: dict :raises ValueError """ if isinstance(template, str...
python
def _get_template_dict(template): """ Parse string template and or copy dictionary template. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :return: Template as a dictionary :rtype: dict :raises ValueError """ if isinstance(template, str...
[ "def", "_get_template_dict", "(", "template", ")", ":", "if", "isinstance", "(", "template", ",", "str", ")", ":", "return", "parse_template", "(", "template", ")", "if", "isinstance", "(", "template", ",", "dict", ")", ":", "return", "copy", ".", "deepcop...
Parse string template and or copy dictionary template. :param template: Content of a packaged YAML or JSON SAM template :type template: str_or_dict :return: Template as a dictionary :rtype: dict :raises ValueError
[ "Parse", "string", "template", "and", "or", "copy", "dictionary", "template", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L103-L119
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
_create_application_request
def _create_application_request(app_metadata, template): """ Construct the request body to create application. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param template: A packaged YAML or JSON SAM template :type template: str :return: SAR C...
python
def _create_application_request(app_metadata, template): """ Construct the request body to create application. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param template: A packaged YAML or JSON SAM template :type template: str :return: SAR C...
[ "def", "_create_application_request", "(", "app_metadata", ",", "template", ")", ":", "app_metadata", ".", "validate", "(", "[", "'author'", ",", "'description'", ",", "'name'", "]", ")", "request", "=", "{", "'Author'", ":", "app_metadata", ".", "author", ","...
Construct the request body to create application. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param template: A packaged YAML or JSON SAM template :type template: str :return: SAR CreateApplication request body :rtype: dict
[ "Construct", "the", "request", "body", "to", "create", "application", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L122-L148
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
_update_application_request
def _update_application_request(app_metadata, application_id): """ Construct the request body to update application. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param application_id: The Amazon Resource Name (ARN) of the application :type applica...
python
def _update_application_request(app_metadata, application_id): """ Construct the request body to update application. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param application_id: The Amazon Resource Name (ARN) of the application :type applica...
[ "def", "_update_application_request", "(", "app_metadata", ",", "application_id", ")", ":", "request", "=", "{", "'ApplicationId'", ":", "application_id", ",", "'Author'", ":", "app_metadata", ".", "author", ",", "'Description'", ":", "app_metadata", ".", "descripti...
Construct the request body to update application. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :return: SAR UpdateApplication request body :rtype: di...
[ "Construct", "the", "request", "body", "to", "update", "application", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L151-L170
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
_create_application_version_request
def _create_application_version_request(app_metadata, application_id, template): """ Construct the request body to create application version. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param application_id: The Amazon Resource Name (ARN) of the app...
python
def _create_application_version_request(app_metadata, application_id, template): """ Construct the request body to create application version. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param application_id: The Amazon Resource Name (ARN) of the app...
[ "def", "_create_application_version_request", "(", "app_metadata", ",", "application_id", ",", "template", ")", ":", "app_metadata", ".", "validate", "(", "[", "'semantic_version'", "]", ")", "request", "=", "{", "'ApplicationId'", ":", "application_id", ",", "'Sema...
Construct the request body to create application version. :param app_metadata: Object containing app metadata :type app_metadata: ApplicationMetadata :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param template: A packaged YAML or JSON SAM templ...
[ "Construct", "the", "request", "body", "to", "create", "application", "version", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L173-L193
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
_wrap_client_error
def _wrap_client_error(e): """ Wrap botocore ClientError exception into ServerlessRepoClientError. :param e: botocore exception :type e: ClientError :return: S3PermissionsRequired or InvalidS3UriError or general ServerlessRepoClientError """ error_code = e.response['Error']['Code'] mess...
python
def _wrap_client_error(e): """ Wrap botocore ClientError exception into ServerlessRepoClientError. :param e: botocore exception :type e: ClientError :return: S3PermissionsRequired or InvalidS3UriError or general ServerlessRepoClientError """ error_code = e.response['Error']['Code'] mess...
[ "def", "_wrap_client_error", "(", "e", ")", ":", "error_code", "=", "e", ".", "response", "[", "'Error'", "]", "[", "'Code'", "]", "message", "=", "e", ".", "response", "[", "'Error'", "]", "[", "'Message'", "]", "if", "error_code", "==", "'BadRequestExc...
Wrap botocore ClientError exception into ServerlessRepoClientError. :param e: botocore exception :type e: ClientError :return: S3PermissionsRequired or InvalidS3UriError or general ServerlessRepoClientError
[ "Wrap", "botocore", "ClientError", "exception", "into", "ServerlessRepoClientError", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L208-L227
train
awslabs/aws-serverlessrepo-python
serverlessrepo/publish.py
_get_publish_details
def _get_publish_details(actions, app_metadata_template): """ Get the changed application details after publishing. :param actions: Actions taken during publishing :type actions: list of str :param app_metadata_template: Original template definitions of app metadata :type app_metadata_template:...
python
def _get_publish_details(actions, app_metadata_template): """ Get the changed application details after publishing. :param actions: Actions taken during publishing :type actions: list of str :param app_metadata_template: Original template definitions of app metadata :type app_metadata_template:...
[ "def", "_get_publish_details", "(", "actions", ",", "app_metadata_template", ")", ":", "if", "actions", "==", "[", "CREATE_APPLICATION", "]", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "app_metadata_template", ".", "items", "(", ")", "i...
Get the changed application details after publishing. :param actions: Actions taken during publishing :type actions: list of str :param app_metadata_template: Original template definitions of app metadata :type app_metadata_template: dict :return: Updated fields and values of the application :r...
[ "Get", "the", "changed", "application", "details", "after", "publishing", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/publish.py#L230-L256
train
awslabs/aws-serverlessrepo-python
serverlessrepo/application_metadata.py
ApplicationMetadata.validate
def validate(self, required_props): """ Check if the required application metadata properties have been populated. :param required_props: List of required properties :type required_props: list :return: True, if the metadata is valid :raises: InvalidApplicationMetadataErr...
python
def validate(self, required_props): """ Check if the required application metadata properties have been populated. :param required_props: List of required properties :type required_props: list :return: True, if the metadata is valid :raises: InvalidApplicationMetadataErr...
[ "def", "validate", "(", "self", ",", "required_props", ")", ":", "missing_props", "=", "[", "p", "for", "p", "in", "required_props", "if", "not", "getattr", "(", "self", ",", "p", ")", "]", "if", "missing_props", ":", "missing_props_str", "=", "', '", "....
Check if the required application metadata properties have been populated. :param required_props: List of required properties :type required_props: list :return: True, if the metadata is valid :raises: InvalidApplicationMetadataError
[ "Check", "if", "the", "required", "application", "metadata", "properties", "have", "been", "populated", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/application_metadata.py#L44-L57
train
awslabs/aws-serverlessrepo-python
serverlessrepo/parser.py
yaml_dump
def yaml_dump(dict_to_dump): """ Dump the dictionary as a YAML document. :param dict_to_dump: Data to be serialized as YAML :type dict_to_dump: dict :return: YAML document :rtype: str """ yaml.SafeDumper.add_representer(OrderedDict, _dict_representer) return yaml.safe_dump(dict_to_d...
python
def yaml_dump(dict_to_dump): """ Dump the dictionary as a YAML document. :param dict_to_dump: Data to be serialized as YAML :type dict_to_dump: dict :return: YAML document :rtype: str """ yaml.SafeDumper.add_representer(OrderedDict, _dict_representer) return yaml.safe_dump(dict_to_d...
[ "def", "yaml_dump", "(", "dict_to_dump", ")", ":", "yaml", ".", "SafeDumper", ".", "add_representer", "(", "OrderedDict", ",", "_dict_representer", ")", "return", "yaml", ".", "safe_dump", "(", "dict_to_dump", ",", "default_flow_style", "=", "False", ")" ]
Dump the dictionary as a YAML document. :param dict_to_dump: Data to be serialized as YAML :type dict_to_dump: dict :return: YAML document :rtype: str
[ "Dump", "the", "dictionary", "as", "a", "YAML", "document", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/parser.py#L61-L71
train
awslabs/aws-serverlessrepo-python
serverlessrepo/parser.py
parse_template
def parse_template(template_str): """ Parse the SAM template. :param template_str: A packaged YAML or json CloudFormation template :type template_str: str :return: Dictionary with keys defined in the template :rtype: dict """ try: # PyYAML doesn't support json as well as it shou...
python
def parse_template(template_str): """ Parse the SAM template. :param template_str: A packaged YAML or json CloudFormation template :type template_str: str :return: Dictionary with keys defined in the template :rtype: dict """ try: # PyYAML doesn't support json as well as it shou...
[ "def", "parse_template", "(", "template_str", ")", ":", "try", ":", "return", "json", ".", "loads", "(", "template_str", ",", "object_pairs_hook", "=", "OrderedDict", ")", "except", "ValueError", ":", "yaml", ".", "SafeLoader", ".", "add_constructor", "(", "ya...
Parse the SAM template. :param template_str: A packaged YAML or json CloudFormation template :type template_str: str :return: Dictionary with keys defined in the template :rtype: dict
[ "Parse", "the", "SAM", "template", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/parser.py#L78-L95
train
awslabs/aws-serverlessrepo-python
serverlessrepo/parser.py
get_app_metadata
def get_app_metadata(template_dict): """ Get the application metadata from a SAM template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: Application metadata as defined in the template :rtype: ApplicationMetadata :raises ApplicationMetadataNotFoundErr...
python
def get_app_metadata(template_dict): """ Get the application metadata from a SAM template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: Application metadata as defined in the template :rtype: ApplicationMetadata :raises ApplicationMetadataNotFoundErr...
[ "def", "get_app_metadata", "(", "template_dict", ")", ":", "if", "SERVERLESS_REPO_APPLICATION", "in", "template_dict", ".", "get", "(", "METADATA", ",", "{", "}", ")", ":", "app_metadata_dict", "=", "template_dict", ".", "get", "(", "METADATA", ")", ".", "get"...
Get the application metadata from a SAM template. :param template_dict: SAM template as a dictionary :type template_dict: dict :return: Application metadata as defined in the template :rtype: ApplicationMetadata :raises ApplicationMetadataNotFoundError
[ "Get", "the", "application", "metadata", "from", "a", "SAM", "template", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/parser.py#L98-L113
train
awslabs/aws-serverlessrepo-python
serverlessrepo/parser.py
parse_application_id
def parse_application_id(text): """ Extract the application id from input text. :param text: text to parse :type text: str :return: application id if found in the input :rtype: str """ result = re.search(APPLICATION_ID_PATTERN, text) return result.group(0) if result else None
python
def parse_application_id(text): """ Extract the application id from input text. :param text: text to parse :type text: str :return: application id if found in the input :rtype: str """ result = re.search(APPLICATION_ID_PATTERN, text) return result.group(0) if result else None
[ "def", "parse_application_id", "(", "text", ")", ":", "result", "=", "re", ".", "search", "(", "APPLICATION_ID_PATTERN", ",", "text", ")", "return", "result", ".", "group", "(", "0", ")", "if", "result", "else", "None" ]
Extract the application id from input text. :param text: text to parse :type text: str :return: application id if found in the input :rtype: str
[ "Extract", "the", "application", "id", "from", "input", "text", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/parser.py#L116-L126
train
awslabs/aws-serverlessrepo-python
serverlessrepo/permission_helper.py
make_application_private
def make_application_private(application_id, sar_client=None): """ Set the application to be private. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client :rai...
python
def make_application_private(application_id, sar_client=None): """ Set the application to be private. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client :rai...
[ "def", "make_application_private", "(", "application_id", ",", "sar_client", "=", "None", ")", ":", "if", "not", "application_id", ":", "raise", "ValueError", "(", "'Require application id to make the app private'", ")", "if", "not", "sar_client", ":", "sar_client", "...
Set the application to be private. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param sar_client: The boto3 client used to access SAR :type sar_client: boto3.client :raises ValueError
[ "Set", "the", "application", "to", "be", "private", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/permission_helper.py#L32-L51
train
awslabs/aws-serverlessrepo-python
serverlessrepo/permission_helper.py
share_application_with_accounts
def share_application_with_accounts(application_id, account_ids, sar_client=None): """ Share the application privately with given AWS account IDs. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param account_ids: List of AWS account IDs, or * ...
python
def share_application_with_accounts(application_id, account_ids, sar_client=None): """ Share the application privately with given AWS account IDs. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param account_ids: List of AWS account IDs, or * ...
[ "def", "share_application_with_accounts", "(", "application_id", ",", "account_ids", ",", "sar_client", "=", "None", ")", ":", "if", "not", "application_id", "or", "not", "account_ids", ":", "raise", "ValueError", "(", "'Require application id and list of AWS account IDs ...
Share the application privately with given AWS account IDs. :param application_id: The Amazon Resource Name (ARN) of the application :type application_id: str :param account_ids: List of AWS account IDs, or * :type account_ids: list of str :param sar_client: The boto3 client used to access SAR ...
[ "Share", "the", "application", "privately", "with", "given", "AWS", "account", "IDs", "." ]
e2126cee0191266cfb8a3a2bc3270bf50330907c
https://github.com/awslabs/aws-serverlessrepo-python/blob/e2126cee0191266cfb8a3a2bc3270bf50330907c/serverlessrepo/permission_helper.py#L54-L77
train
asifpy/django-crudbuilder
crudbuilder/registry.py
CrudBuilderRegistry.extract_args
def extract_args(cls, *args): """ Takes any arguments like a model and crud, or just one of those, in any order, and return a model and crud. """ model = None crudbuilder = None for arg in args: if issubclass(arg, models.Model): model ...
python
def extract_args(cls, *args): """ Takes any arguments like a model and crud, or just one of those, in any order, and return a model and crud. """ model = None crudbuilder = None for arg in args: if issubclass(arg, models.Model): model ...
[ "def", "extract_args", "(", "cls", ",", "*", "args", ")", ":", "model", "=", "None", "crudbuilder", "=", "None", "for", "arg", "in", "args", ":", "if", "issubclass", "(", "arg", ",", "models", ".", "Model", ")", ":", "model", "=", "arg", "else", ":...
Takes any arguments like a model and crud, or just one of those, in any order, and return a model and crud.
[ "Takes", "any", "arguments", "like", "a", "model", "and", "crud", "or", "just", "one", "of", "those", "in", "any", "order", "and", "return", "a", "model", "and", "crud", "." ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/registry.py#L18-L32
train
asifpy/django-crudbuilder
crudbuilder/registry.py
CrudBuilderRegistry.register
def register(self, *args, **kwargs): """ Register a crud. Two unordered arguments are accepted, at least one should be passed: - a model, - a crudbuilder class """ assert len(args) <= 2, 'register takes at most 2 args' assert len(args) > 0, 'register tak...
python
def register(self, *args, **kwargs): """ Register a crud. Two unordered arguments are accepted, at least one should be passed: - a model, - a crudbuilder class """ assert len(args) <= 2, 'register takes at most 2 args' assert len(args) > 0, 'register tak...
[ "def", "register", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "assert", "len", "(", "args", ")", "<=", "2", ",", "'register takes at most 2 args'", "assert", "len", "(", "args", ")", ">", "0", ",", "'register takes at least 1 arg'", "mod...
Register a crud. Two unordered arguments are accepted, at least one should be passed: - a model, - a crudbuilder class
[ "Register", "a", "crud", "." ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/registry.py#L34-L61
train
asifpy/django-crudbuilder
crudbuilder/formset.py
BaseInlineFormset.construct_formset
def construct_formset(self): """ Returns an instance of the inline formset """ if not self.inline_model or not self.parent_model: msg = "Parent and Inline models are required in {}".format(self.__class__.__name__) raise NotModelException(msg) return inlin...
python
def construct_formset(self): """ Returns an instance of the inline formset """ if not self.inline_model or not self.parent_model: msg = "Parent and Inline models are required in {}".format(self.__class__.__name__) raise NotModelException(msg) return inlin...
[ "def", "construct_formset", "(", "self", ")", ":", "if", "not", "self", ".", "inline_model", "or", "not", "self", ".", "parent_model", ":", "msg", "=", "\"Parent and Inline models are required in {}\"", ".", "format", "(", "self", ".", "__class__", ".", "__name_...
Returns an instance of the inline formset
[ "Returns", "an", "instance", "of", "the", "inline", "formset" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/formset.py#L18-L29
train
asifpy/django-crudbuilder
crudbuilder/formset.py
BaseInlineFormset.get_factory_kwargs
def get_factory_kwargs(self): """ Returns the keyword arguments for calling the formset factory """ kwargs = {} kwargs.update({ 'can_delete': self.can_delete, 'extra': self.extra, 'exclude': self.exclude, 'fields': self.fields, ...
python
def get_factory_kwargs(self): """ Returns the keyword arguments for calling the formset factory """ kwargs = {} kwargs.update({ 'can_delete': self.can_delete, 'extra': self.extra, 'exclude': self.exclude, 'fields': self.fields, ...
[ "def", "get_factory_kwargs", "(", "self", ")", ":", "kwargs", "=", "{", "}", "kwargs", ".", "update", "(", "{", "'can_delete'", ":", "self", ".", "can_delete", ",", "'extra'", ":", "self", ".", "extra", ",", "'exclude'", ":", "self", ".", "exclude", ",...
Returns the keyword arguments for calling the formset factory
[ "Returns", "the", "keyword", "arguments", "for", "calling", "the", "formset", "factory" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/formset.py#L31-L49
train
asifpy/django-crudbuilder
crudbuilder/helpers.py
import_crud
def import_crud(app): ''' Import crud module and register all model cruds which it contains ''' try: app_path = import_module(app).__path__ except (AttributeError, ImportError): return None try: imp.find_module('crud', app_path) except ImportError: return No...
python
def import_crud(app): ''' Import crud module and register all model cruds which it contains ''' try: app_path = import_module(app).__path__ except (AttributeError, ImportError): return None try: imp.find_module('crud', app_path) except ImportError: return No...
[ "def", "import_crud", "(", "app", ")", ":", "try", ":", "app_path", "=", "import_module", "(", "app", ")", ".", "__path__", "except", "(", "AttributeError", ",", "ImportError", ")", ":", "return", "None", "try", ":", "imp", ".", "find_module", "(", "'cru...
Import crud module and register all model cruds which it contains
[ "Import", "crud", "module", "and", "register", "all", "model", "cruds", "which", "it", "contains" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/helpers.py#L162-L179
train
asifpy/django-crudbuilder
crudbuilder/abstract.py
BaseBuilder.get_model_class
def get_model_class(self): """Returns model class""" try: c = ContentType.objects.get(app_label=self.app, model=self.model) except ContentType.DoesNotExist: # try another kind of resolution # fixes a situation where a proxy model is defined in some external ap...
python
def get_model_class(self): """Returns model class""" try: c = ContentType.objects.get(app_label=self.app, model=self.model) except ContentType.DoesNotExist: # try another kind of resolution # fixes a situation where a proxy model is defined in some external ap...
[ "def", "get_model_class", "(", "self", ")", ":", "try", ":", "c", "=", "ContentType", ".", "objects", ".", "get", "(", "app_label", "=", "self", ".", "app", ",", "model", "=", "self", ".", "model", ")", "except", "ContentType", ".", "DoesNotExist", ":"...
Returns model class
[ "Returns", "model", "class" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/abstract.py#L53-L63
train
asifpy/django-crudbuilder
crudbuilder/templatetags/crudbuilder.py
get_verbose_field_name
def get_verbose_field_name(instance, field_name): """ Returns verbose_name for a field. """ fields = [field.name for field in instance._meta.fields] if field_name in fields: return instance._meta.get_field(field_name).verbose_name else: return field_name
python
def get_verbose_field_name(instance, field_name): """ Returns verbose_name for a field. """ fields = [field.name for field in instance._meta.fields] if field_name in fields: return instance._meta.get_field(field_name).verbose_name else: return field_name
[ "def", "get_verbose_field_name", "(", "instance", ",", "field_name", ")", ":", "fields", "=", "[", "field", ".", "name", "for", "field", "in", "instance", ".", "_meta", ".", "fields", "]", "if", "field_name", "in", "fields", ":", "return", "instance", ".",...
Returns verbose_name for a field.
[ "Returns", "verbose_name", "for", "a", "field", "." ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/templatetags/crudbuilder.py#L63-L71
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.generate_modelform
def generate_modelform(self): """Generate modelform from Django modelform_factory""" model_class = self.get_model_class excludes = self.modelform_excludes if self.modelform_excludes else [] _ObjectForm = modelform_factory(model_class, exclude=excludes) return _ObjectForm
python
def generate_modelform(self): """Generate modelform from Django modelform_factory""" model_class = self.get_model_class excludes = self.modelform_excludes if self.modelform_excludes else [] _ObjectForm = modelform_factory(model_class, exclude=excludes) return _ObjectForm
[ "def", "generate_modelform", "(", "self", ")", ":", "model_class", "=", "self", ".", "get_model_class", "excludes", "=", "self", ".", "modelform_excludes", "if", "self", ".", "modelform_excludes", "else", "[", "]", "_ObjectForm", "=", "modelform_factory", "(", "...
Generate modelform from Django modelform_factory
[ "Generate", "modelform", "from", "Django", "modelform_factory" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L58-L64
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.get_template
def get_template(self, tname): """ - Get custom template from CRUD class, if it is defined in it - No custom template in CRUD class, then use the default template """ if self.custom_templates and self.custom_templates.get(tname, None): return self.custom_templates.ge...
python
def get_template(self, tname): """ - Get custom template from CRUD class, if it is defined in it - No custom template in CRUD class, then use the default template """ if self.custom_templates and self.custom_templates.get(tname, None): return self.custom_templates.ge...
[ "def", "get_template", "(", "self", ",", "tname", ")", ":", "if", "self", ".", "custom_templates", "and", "self", ".", "custom_templates", ".", "get", "(", "tname", ",", "None", ")", ":", "return", "self", ".", "custom_templates", ".", "get", "(", "tname...
- Get custom template from CRUD class, if it is defined in it - No custom template in CRUD class, then use the default template
[ "-", "Get", "custom", "template", "from", "CRUD", "class", "if", "it", "is", "defined", "in", "it", "-", "No", "custom", "template", "in", "CRUD", "class", "then", "use", "the", "default", "template" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L66-L77
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.generate_list_view
def generate_list_view(self): """Generate class based view for ListView""" name = model_class_form(self.model + 'ListView') list_args = dict( model=self.get_model_class, context_object_name=plural(self.model), template_name=self.get_template('list'), ...
python
def generate_list_view(self): """Generate class based view for ListView""" name = model_class_form(self.model + 'ListView') list_args = dict( model=self.get_model_class, context_object_name=plural(self.model), template_name=self.get_template('list'), ...
[ "def", "generate_list_view", "(", "self", ")", ":", "name", "=", "model_class_form", "(", "self", ".", "model", "+", "'ListView'", ")", "list_args", "=", "dict", "(", "model", "=", "self", ".", "get_model_class", ",", "context_object_name", "=", "plural", "(...
Generate class based view for ListView
[ "Generate", "class", "based", "view", "for", "ListView" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L85-L111
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.generate_create_view
def generate_create_view(self): """Generate class based view for CreateView""" name = model_class_form(self.model + 'CreateView') create_args = dict( form_class=self.get_actual_form('create'), model=self.get_model_class, template_name=self.get_template('creat...
python
def generate_create_view(self): """Generate class based view for CreateView""" name = model_class_form(self.model + 'CreateView') create_args = dict( form_class=self.get_actual_form('create'), model=self.get_model_class, template_name=self.get_template('creat...
[ "def", "generate_create_view", "(", "self", ")", ":", "name", "=", "model_class_form", "(", "self", ".", "model", "+", "'CreateView'", ")", "create_args", "=", "dict", "(", "form_class", "=", "self", ".", "get_actual_form", "(", "'create'", ")", ",", "model"...
Generate class based view for CreateView
[ "Generate", "class", "based", "view", "for", "CreateView" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L113-L141
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.generate_detail_view
def generate_detail_view(self): """Generate class based view for DetailView""" name = model_class_form(self.model + 'DetailView') detail_args = dict( detailview_excludes=self.detailview_excludes, model=self.get_model_class, template_name=self.get_template('de...
python
def generate_detail_view(self): """Generate class based view for DetailView""" name = model_class_form(self.model + 'DetailView') detail_args = dict( detailview_excludes=self.detailview_excludes, model=self.get_model_class, template_name=self.get_template('de...
[ "def", "generate_detail_view", "(", "self", ")", ":", "name", "=", "model_class_form", "(", "self", ".", "model", "+", "'DetailView'", ")", "detail_args", "=", "dict", "(", "detailview_excludes", "=", "self", ".", "detailview_excludes", ",", "model", "=", "sel...
Generate class based view for DetailView
[ "Generate", "class", "based", "view", "for", "DetailView" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L143-L160
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.generate_update_view
def generate_update_view(self): """Generate class based view for UpdateView""" name = model_class_form(self.model + 'UpdateView') update_args = dict( form_class=self.get_actual_form('update'), model=self.get_model_class, template_name=self.get_template('updat...
python
def generate_update_view(self): """Generate class based view for UpdateView""" name = model_class_form(self.model + 'UpdateView') update_args = dict( form_class=self.get_actual_form('update'), model=self.get_model_class, template_name=self.get_template('updat...
[ "def", "generate_update_view", "(", "self", ")", ":", "name", "=", "model_class_form", "(", "self", ".", "model", "+", "'UpdateView'", ")", "update_args", "=", "dict", "(", "form_class", "=", "self", ".", "get_actual_form", "(", "'update'", ")", ",", "model"...
Generate class based view for UpdateView
[ "Generate", "class", "based", "view", "for", "UpdateView" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L162-L189
train
asifpy/django-crudbuilder
crudbuilder/views.py
ViewBuilder.generate_delete_view
def generate_delete_view(self): """Generate class based view for DeleteView""" name = model_class_form(self.model + 'DeleteView') delete_args = dict( model=self.get_model_class, template_name=self.get_template('delete'), permissions=self.view_permission('dele...
python
def generate_delete_view(self): """Generate class based view for DeleteView""" name = model_class_form(self.model + 'DeleteView') delete_args = dict( model=self.get_model_class, template_name=self.get_template('delete'), permissions=self.view_permission('dele...
[ "def", "generate_delete_view", "(", "self", ")", ":", "name", "=", "model_class_form", "(", "self", ".", "model", "+", "'DeleteView'", ")", "delete_args", "=", "dict", "(", "model", "=", "self", ".", "get_model_class", ",", "template_name", "=", "self", ".",...
Generate class based view for DeleteView
[ "Generate", "class", "based", "view", "for", "DeleteView" ]
9de1c6fa555086673dd7ccc351d4b771c6192489
https://github.com/asifpy/django-crudbuilder/blob/9de1c6fa555086673dd7ccc351d4b771c6192489/crudbuilder/views.py#L191-L207
train
contentful/contentful.py
contentful/entry.py
Entry.incoming_references
def incoming_references(self, client=None, query={}): """Fetches all entries referencing the entry API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/links-to-asset :param client Client instance :param query: (optiona...
python
def incoming_references(self, client=None, query={}): """Fetches all entries referencing the entry API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/links-to-asset :param client Client instance :param query: (optiona...
[ "def", "incoming_references", "(", "self", ",", "client", "=", "None", ",", "query", "=", "{", "}", ")", ":", "if", "client", "is", "None", ":", "return", "False", "query", ".", "update", "(", "{", "'links_to_entry'", ":", "self", ".", "id", "}", ")"...
Fetches all entries referencing the entry API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/links-to-asset :param client Client instance :param query: (optional) Dict with API options. :return: List of :class:`Entry ...
[ "Fetches", "all", "entries", "referencing", "the", "entry" ]
73fe01d6ae5a1f8818880da65199107b584681dd
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/entry.py#L118-L137
train
contentful/contentful.py
contentful/resource_builder.py
ResourceBuilder.build
def build(self): """Creates the objects from the JSON response""" if self.json['sys']['type'] == 'Array': if any(k in self.json for k in ['nextSyncUrl', 'nextPageUrl']): return SyncPage( self.json, default_locale=self.default_locale, ...
python
def build(self): """Creates the objects from the JSON response""" if self.json['sys']['type'] == 'Array': if any(k in self.json for k in ['nextSyncUrl', 'nextPageUrl']): return SyncPage( self.json, default_locale=self.default_locale, ...
[ "def", "build", "(", "self", ")", ":", "if", "self", ".", "json", "[", "'sys'", "]", "[", "'type'", "]", "==", "'Array'", ":", "if", "any", "(", "k", "in", "self", ".", "json", "for", "k", "in", "[", "'nextSyncUrl'", ",", "'nextPageUrl'", "]", ")...
Creates the objects from the JSON response
[ "Creates", "the", "objects", "from", "the", "JSON", "response" ]
73fe01d6ae5a1f8818880da65199107b584681dd
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/resource_builder.py#L51-L62
train
contentful/contentful.py
contentful/content_type_cache.py
ContentTypeCache.get
def get(cls, content_type_id): """ Fetches a Content Type from the Cache. """ for content_type in cls.__CACHE__: if content_type.sys.get('id') == content_type_id: return content_type return None
python
def get(cls, content_type_id): """ Fetches a Content Type from the Cache. """ for content_type in cls.__CACHE__: if content_type.sys.get('id') == content_type_id: return content_type return None
[ "def", "get", "(", "cls", ",", "content_type_id", ")", ":", "for", "content_type", "in", "cls", ".", "__CACHE__", ":", "if", "content_type", ".", "sys", ".", "get", "(", "'id'", ")", "==", "content_type_id", ":", "return", "content_type", "return", "None" ...
Fetches a Content Type from the Cache.
[ "Fetches", "a", "Content", "Type", "from", "the", "Cache", "." ]
73fe01d6ae5a1f8818880da65199107b584681dd
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/content_type_cache.py#L22-L30
train
contentful/contentful.py
contentful/errors.py
get_error
def get_error(response): """Gets Error by HTTP Status Code""" errors = { 400: BadRequestError, 401: UnauthorizedError, 403: AccessDeniedError, 404: NotFoundError, 429: RateLimitExceededError, 500: ServerError, 502: BadGatewayError, 503: ServiceUna...
python
def get_error(response): """Gets Error by HTTP Status Code""" errors = { 400: BadRequestError, 401: UnauthorizedError, 403: AccessDeniedError, 404: NotFoundError, 429: RateLimitExceededError, 500: ServerError, 502: BadGatewayError, 503: ServiceUna...
[ "def", "get_error", "(", "response", ")", ":", "errors", "=", "{", "400", ":", "BadRequestError", ",", "401", ":", "UnauthorizedError", ",", "403", ":", "AccessDeniedError", ",", "404", ":", "NotFoundError", ",", "429", ":", "RateLimitExceededError", ",", "5...
Gets Error by HTTP Status Code
[ "Gets", "Error", "by", "HTTP", "Status", "Code" ]
73fe01d6ae5a1f8818880da65199107b584681dd
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/errors.py#L203-L221
train
contentful/contentful.py
contentful/content_type.py
ContentType.field_for
def field_for(self, field_id): """Fetches the field for the given Field ID. :param field_id: ID for Field to fetch. :return: :class:`ContentTypeField <ContentTypeField>` object. :rtype: contentful.ContentTypeField """ for field in self.fields: if field.id ==...
python
def field_for(self, field_id): """Fetches the field for the given Field ID. :param field_id: ID for Field to fetch. :return: :class:`ContentTypeField <ContentTypeField>` object. :rtype: contentful.ContentTypeField """ for field in self.fields: if field.id ==...
[ "def", "field_for", "(", "self", ",", "field_id", ")", ":", "for", "field", "in", "self", ".", "fields", ":", "if", "field", ".", "id", "==", "field_id", ":", "return", "field", "return", "None" ]
Fetches the field for the given Field ID. :param field_id: ID for Field to fetch. :return: :class:`ContentTypeField <ContentTypeField>` object. :rtype: contentful.ContentTypeField
[ "Fetches", "the", "field", "for", "the", "given", "Field", "ID", "." ]
73fe01d6ae5a1f8818880da65199107b584681dd
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/content_type.py#L31-L42
train
contentful/contentful.py
contentful/content_type_field_types.py
LocationField.coerce
def coerce(self, value, **kwargs): """Coerces value to Location object""" Location = namedtuple('Location', ['lat', 'lon']) return Location(float(value.get('lat')), float(value.get('lon')))
python
def coerce(self, value, **kwargs): """Coerces value to Location object""" Location = namedtuple('Location', ['lat', 'lon']) return Location(float(value.get('lat')), float(value.get('lon')))
[ "def", "coerce", "(", "self", ",", "value", ",", "**", "kwargs", ")", ":", "Location", "=", "namedtuple", "(", "'Location'", ",", "[", "'lat'", ",", "'lon'", "]", ")", "return", "Location", "(", "float", "(", "value", ".", "get", "(", "'lat'", ")", ...
Coerces value to Location object
[ "Coerces", "value", "to", "Location", "object" ]
73fe01d6ae5a1f8818880da65199107b584681dd
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/content_type_field_types.py#L96-L100
train