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
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__response_message_descriptor
def __response_message_descriptor(self, message_type, method_id): """Describes the response. Args: message_type: messages.Message class, The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') Returns: Dictionary describing the response. """ ...
python
def __response_message_descriptor(self, message_type, method_id): """Describes the response. Args: message_type: messages.Message class, The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') Returns: Dictionary describing the response. """ ...
[ "def", "__response_message_descriptor", "(", "self", ",", "message_type", ",", "method_id", ")", ":", "descriptor", "=", "{", "'200'", ":", "{", "'description'", ":", "'A successful response'", "}", "}", "if", "message_type", "!=", "message_types", ".", "VoidMessa...
Describes the response. Args: message_type: messages.Message class, The message to describe. method_id: string, Unique method identifier (e.g. 'myapi.items.method') Returns: Dictionary describing the response.
[ "Describes", "the", "response", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L649-L670
train
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__x_google_quota_descriptor
def __x_google_quota_descriptor(self, metric_costs): """Describes the metric costs for a call. Args: metric_costs: Dict of metric definitions to the integer cost value against that metric. Returns: A dict descriptor describing the Quota limits for the endpoint. """ return { ...
python
def __x_google_quota_descriptor(self, metric_costs): """Describes the metric costs for a call. Args: metric_costs: Dict of metric definitions to the integer cost value against that metric. Returns: A dict descriptor describing the Quota limits for the endpoint. """ return { ...
[ "def", "__x_google_quota_descriptor", "(", "self", ",", "metric_costs", ")", ":", "return", "{", "'metricCosts'", ":", "{", "metric", ":", "cost", "for", "(", "metric", ",", "cost", ")", "in", "metric_costs", ".", "items", "(", ")", "}", "}", "if", "metr...
Describes the metric costs for a call. Args: metric_costs: Dict of metric definitions to the integer cost value against that metric. Returns: A dict descriptor describing the Quota limits for the endpoint.
[ "Describes", "the", "metric", "costs", "for", "a", "call", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L672-L686
train
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__x_google_quota_definitions_descriptor
def __x_google_quota_definitions_descriptor(self, limit_definitions): """Describes the quota limit definitions for an API. Args: limit_definitions: List of endpoints.LimitDefinition tuples Returns: A dict descriptor of the API's quota limit definitions. """ if not limit_definitions: ...
python
def __x_google_quota_definitions_descriptor(self, limit_definitions): """Describes the quota limit definitions for an API. Args: limit_definitions: List of endpoints.LimitDefinition tuples Returns: A dict descriptor of the API's quota limit definitions. """ if not limit_definitions: ...
[ "def", "__x_google_quota_definitions_descriptor", "(", "self", ",", "limit_definitions", ")", ":", "if", "not", "limit_definitions", ":", "return", "None", "definitions_list", "=", "[", "{", "'name'", ":", "ld", ".", "metric_name", ",", "'metric'", ":", "ld", "....
Describes the quota limit definitions for an API. Args: limit_definitions: List of endpoints.LimitDefinition tuples Returns: A dict descriptor of the API's quota limit definitions.
[ "Describes", "the", "quota", "limit", "definitions", "for", "an", "API", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L688-L717
train
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__security_definitions_descriptor
def __security_definitions_descriptor(self, issuers): """Create a descriptor for the security definitions. Args: issuers: dict, mapping issuer names to Issuer tuples Returns: The dict representing the security definitions descriptor. """ if not issuers: result = { _DEFA...
python
def __security_definitions_descriptor(self, issuers): """Create a descriptor for the security definitions. Args: issuers: dict, mapping issuer names to Issuer tuples Returns: The dict representing the security definitions descriptor. """ if not issuers: result = { _DEFA...
[ "def", "__security_definitions_descriptor", "(", "self", ",", "issuers", ")", ":", "if", "not", "issuers", ":", "result", "=", "{", "_DEFAULT_SECURITY_DEFINITION", ":", "{", "'authorizationUrl'", ":", "''", ",", "'flow'", ":", "'implicit'", ",", "'type'", ":", ...
Create a descriptor for the security definitions. Args: issuers: dict, mapping issuer names to Issuer tuples Returns: The dict representing the security definitions descriptor.
[ "Create", "a", "descriptor", "for", "the", "security", "definitions", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L818-L854
train
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.__api_openapi_descriptor
def __api_openapi_descriptor(self, services, hostname=None, x_google_api_name=False): """Builds an OpenAPI description of an API. Args: services: List of protorpc.remote.Service instances implementing an api/version. hostname: string, Hostname of the API, to override the value set on the ...
python
def __api_openapi_descriptor(self, services, hostname=None, x_google_api_name=False): """Builds an OpenAPI description of an API. Args: services: List of protorpc.remote.Service instances implementing an api/version. hostname: string, Hostname of the API, to override the value set on the ...
[ "def", "__api_openapi_descriptor", "(", "self", ",", "services", ",", "hostname", "=", "None", ",", "x_google_api_name", "=", "False", ")", ":", "merged_api_info", "=", "self", ".", "__get_merged_api_info", "(", "services", ")", "descriptor", "=", "self", ".", ...
Builds an OpenAPI description of an API. Args: services: List of protorpc.remote.Service instances implementing an api/version. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. Returns: A dictionary that can be deseria...
[ "Builds", "an", "OpenAPI", "description", "of", "an", "API", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L883-L993
train
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.get_openapi_dict
def get_openapi_dict(self, services, hostname=None, x_google_api_name=False): """JSON dict description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the ...
python
def get_openapi_dict(self, services, hostname=None, x_google_api_name=False): """JSON dict description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the ...
[ "def", "get_openapi_dict", "(", "self", ",", "services", ",", "hostname", "=", "None", ",", "x_google_api_name", "=", "False", ")", ":", "if", "not", "isinstance", "(", "services", ",", "(", "tuple", ",", "list", ")", ")", ":", "services", "=", "[", "s...
JSON dict description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. ...
[ "JSON", "dict", "description", "of", "a", "protorpc", ".", "remote", ".", "Service", "in", "OpenAPI", "format", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L1031-L1053
train
cloudendpoints/endpoints-python
endpoints/openapi_generator.py
OpenApiGenerator.pretty_print_config_to_json
def pretty_print_config_to_json(self, services, hostname=None, x_google_api_name=False): """JSON string description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hos...
python
def pretty_print_config_to_json(self, services, hostname=None, x_google_api_name=False): """JSON string description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hos...
[ "def", "pretty_print_config_to_json", "(", "self", ",", "services", ",", "hostname", "=", "None", ",", "x_google_api_name", "=", "False", ")", ":", "descriptor", "=", "self", ".", "get_openapi_dict", "(", "services", ",", "hostname", ",", "x_google_api_name", "=...
JSON string description of a protorpc.remote.Service in OpenAPI format. Args: services: Either a single protorpc.remote.Service or a list of them that implements an api/version. hostname: string, Hostname of the API, to override the value set on the current service. Defaults to None. ...
[ "JSON", "string", "description", "of", "a", "protorpc", ".", "remote", ".", "Service", "in", "OpenAPI", "format", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/openapi_generator.py#L1055-L1069
train
cloudendpoints/endpoints-python
endpoints/protojson.py
EndpointsProtoJson.__pad_value
def __pad_value(value, pad_len_multiple, pad_char): """Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Return...
python
def __pad_value(value, pad_len_multiple, pad_char): """Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Return...
[ "def", "__pad_value", "(", "value", ",", "pad_len_multiple", ",", "pad_char", ")", ":", "assert", "pad_len_multiple", ">", "0", "assert", "len", "(", "pad_char", ")", "==", "1", "padding_length", "=", "(", "pad_len_multiple", "-", "(", "len", "(", "value", ...
Add padding characters to the value if needed. Args: value: The string value to be padded. pad_len_multiple: Pad the result so its length is a multiple of pad_len_multiple. pad_char: The character to use for padding. Returns: The string value with padding characters added.
[ "Add", "padding", "characters", "to", "the", "value", "if", "needed", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/protojson.py#L68-L84
train
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.add_message
def add_message(self, message_type): """Add a new message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError if the Schema id for this message_type would collide with the Schema id of a different message_type...
python
def add_message(self, message_type): """Add a new message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError if the Schema id for this message_type would collide with the Schema id of a different message_type...
[ "def", "add_message", "(", "self", ",", "message_type", ")", ":", "name", "=", "self", ".", "__normalized_name", "(", "message_type", ")", "if", "name", "not", "in", "self", ".", "__schemas", ":", "self", ".", "__schemas", "[", "name", "]", "=", "None", ...
Add a new message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError if the Schema id for this message_type would collide with the Schema id of a different message_type that was already added.
[ "Add", "a", "new", "message", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L74-L93
train
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.ref_for_message_type
def ref_for_message_type(self, message_type): """Returns the JSON Schema id for the given message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError: if the message hasn't been parsed via add_message(). """ ...
python
def ref_for_message_type(self, message_type): """Returns the JSON Schema id for the given message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError: if the message hasn't been parsed via add_message(). """ ...
[ "def", "ref_for_message_type", "(", "self", ",", "message_type", ")", ":", "name", "=", "self", ".", "__normalized_name", "(", "message_type", ")", "if", "name", "not", "in", "self", ".", "__schemas", ":", "raise", "KeyError", "(", "'Message has not been parsed:...
Returns the JSON Schema id for the given message. Args: message_type: protorpc.message.Message class to be parsed. Returns: string, The JSON Schema id. Raises: KeyError: if the message hasn't been parsed via add_message().
[ "Returns", "the", "JSON", "Schema", "id", "for", "the", "given", "message", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L95-L110
train
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.__normalized_name
def __normalized_name(self, message_type): """Normalized schema name. Generate a normalized schema name, taking the class name and stripping out everything but alphanumerics, and camel casing the remaining words. A normalized schema name is a name that matches [a-zA-Z][a-zA-Z0-9]* Args: mess...
python
def __normalized_name(self, message_type): """Normalized schema name. Generate a normalized schema name, taking the class name and stripping out everything but alphanumerics, and camel casing the remaining words. A normalized schema name is a name that matches [a-zA-Z][a-zA-Z0-9]* Args: mess...
[ "def", "__normalized_name", "(", "self", ",", "message_type", ")", ":", "name", "=", "message_type", ".", "definition_name", "(", ")", "split_name", "=", "re", ".", "split", "(", "r'[^0-9a-zA-Z]'", ",", "name", ")", "normalized", "=", "''", ".", "join", "(...
Normalized schema name. Generate a normalized schema name, taking the class name and stripping out everything but alphanumerics, and camel casing the remaining words. A normalized schema name is a name that matches [a-zA-Z][a-zA-Z0-9]* Args: message_type: protorpc.message.Message class being par...
[ "Normalized", "schema", "name", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L120-L152
train
cloudendpoints/endpoints-python
endpoints/message_parser.py
MessageTypeToJsonSchema.__message_to_schema
def __message_to_schema(self, message_type): """Parse a single message into JSON Schema. Will recursively descend the message structure and also parse other messages references via MessageFields. Args: message_type: protorpc.messages.Message class to parse. Returns: An object represen...
python
def __message_to_schema(self, message_type): """Parse a single message into JSON Schema. Will recursively descend the message structure and also parse other messages references via MessageFields. Args: message_type: protorpc.messages.Message class to parse. Returns: An object represen...
[ "def", "__message_to_schema", "(", "self", ",", "message_type", ")", ":", "name", "=", "self", ".", "__normalized_name", "(", "message_type", ")", "schema", "=", "{", "'id'", ":", "name", ",", "'type'", ":", "'object'", ",", "}", "if", "message_type", ".",...
Parse a single message into JSON Schema. Will recursively descend the message structure and also parse other messages references via MessageFields. Args: message_type: protorpc.messages.Message class to parse. Returns: An object representation of the schema.
[ "Parse", "a", "single", "message", "into", "JSON", "Schema", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/message_parser.py#L154-L227
train
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
_check_enum
def _check_enum(parameter_name, value, parameter_config): """Checks if an enum value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This verifies that the value of an enum parameter is valid. Args: parameter_name: A string containing the name of the...
python
def _check_enum(parameter_name, value, parameter_config): """Checks if an enum value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This verifies that the value of an enum parameter is valid. Args: parameter_name: A string containing the name of the...
[ "def", "_check_enum", "(", "parameter_name", ",", "value", ",", "parameter_config", ")", ":", "enum_values", "=", "[", "enum", "[", "'backendValue'", "]", "for", "enum", "in", "parameter_config", "[", "'enum'", "]", ".", "values", "(", ")", "if", "'backendVa...
Checks if an enum value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This verifies that the value of an enum parameter is valid. Args: parameter_name: A string containing the name of the parameter, which is either just a variable name or the n...
[ "Checks", "if", "an", "enum", "value", "is", "valid", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L30-L55
train
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
_check_boolean
def _check_boolean(parameter_name, value, parameter_config): """Checks if a boolean value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This checks that the string value passed in can be converted to a valid boolean value. Args: parameter_name: A...
python
def _check_boolean(parameter_name, value, parameter_config): """Checks if a boolean value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This checks that the string value passed in can be converted to a valid boolean value. Args: parameter_name: A...
[ "def", "_check_boolean", "(", "parameter_name", ",", "value", ",", "parameter_config", ")", ":", "if", "parameter_config", ".", "get", "(", "'type'", ")", "!=", "'boolean'", ":", "return", "if", "value", ".", "lower", "(", ")", "not", "in", "(", "'1'", "...
Checks if a boolean value is valid. This is called by the transform_parameter_value function and shouldn't be called directly. This checks that the string value passed in can be converted to a valid boolean value. Args: parameter_name: A string containing the name of the parameter, which is eithe...
[ "Checks", "if", "a", "boolean", "value", "is", "valid", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L58-L84
train
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
_get_parameter_conversion_entry
def _get_parameter_conversion_entry(parameter_config): """Get information needed to convert the given parameter to its API type. Args: parameter_config: The dictionary containing information specific to the parameter in question. This is retrieved from request.parameters in the method config. Re...
python
def _get_parameter_conversion_entry(parameter_config): """Get information needed to convert the given parameter to its API type. Args: parameter_config: The dictionary containing information specific to the parameter in question. This is retrieved from request.parameters in the method config. Re...
[ "def", "_get_parameter_conversion_entry", "(", "parameter_config", ")", ":", "entry", "=", "_PARAM_CONVERSION_MAP", ".", "get", "(", "parameter_config", ".", "get", "(", "'type'", ")", ")", "if", "entry", "is", "None", "and", "'enum'", "in", "parameter_config", ...
Get information needed to convert the given parameter to its API type. Args: parameter_config: The dictionary containing information specific to the parameter in question. This is retrieved from request.parameters in the method config. Returns: The entry from _PARAM_CONVERSION_MAP with functio...
[ "Get", "information", "needed", "to", "convert", "the", "given", "parameter", "to", "its", "API", "type", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L126-L147
train
cloudendpoints/endpoints-python
endpoints/parameter_converter.py
transform_parameter_value
def transform_parameter_value(parameter_name, value, parameter_config): """Validates and transforms parameters to the type expected by the API. If the value is a list this will recursively call _transform_parameter_value on the values in the list. Otherwise, it checks all parameter rules for the the current va...
python
def transform_parameter_value(parameter_name, value, parameter_config): """Validates and transforms parameters to the type expected by the API. If the value is a list this will recursively call _transform_parameter_value on the values in the list. Otherwise, it checks all parameter rules for the the current va...
[ "def", "transform_parameter_value", "(", "parameter_name", ",", "value", ",", "parameter_config", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "return", "[", "transform_parameter_value", "(", "'%s[%d]'", "%", "(", "parameter_name", ",", "in...
Validates and transforms parameters to the type expected by the API. If the value is a list this will recursively call _transform_parameter_value on the values in the list. Otherwise, it checks all parameter rules for the the current value and converts its type from a string to whatever format the API expects....
[ "Validates", "and", "transforms", "parameters", "to", "the", "type", "expected", "by", "the", "API", "." ]
00dd7c7a52a9ee39d5923191c2604b8eafdb3f24
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/parameter_converter.py#L150-L200
train
django-leonardo/django-leonardo
leonardo/module/nav/mixins.py
NavigationWidgetMixin.filter_items
def filter_items(self, items): '''perform filtering items by specific criteria''' items = self._filter_active(items) items = self._filter_in_nav(items) return items
python
def filter_items(self, items): '''perform filtering items by specific criteria''' items = self._filter_active(items) items = self._filter_in_nav(items) return items
[ "def", "filter_items", "(", "self", ",", "items", ")", ":", "items", "=", "self", ".", "_filter_active", "(", "items", ")", "items", "=", "self", ".", "_filter_in_nav", "(", "items", ")", "return", "items" ]
perform filtering items by specific criteria
[ "perform", "filtering", "items", "by", "specific", "criteria" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/mixins.py#L38-L42
train
django-leonardo/django-leonardo
leonardo/utils/__init__.py
is_leonardo_module
def is_leonardo_module(mod): """returns True if is leonardo module """ if hasattr(mod, 'default') \ or hasattr(mod, 'leonardo_module_conf'): return True for key in dir(mod): if 'LEONARDO' in key: return True return False
python
def is_leonardo_module(mod): """returns True if is leonardo module """ if hasattr(mod, 'default') \ or hasattr(mod, 'leonardo_module_conf'): return True for key in dir(mod): if 'LEONARDO' in key: return True return False
[ "def", "is_leonardo_module", "(", "mod", ")", ":", "if", "hasattr", "(", "mod", ",", "'default'", ")", "or", "hasattr", "(", "mod", ",", "'leonardo_module_conf'", ")", ":", "return", "True", "for", "key", "in", "dir", "(", "mod", ")", ":", "if", "'LEON...
returns True if is leonardo module
[ "returns", "True", "if", "is", "leonardo", "module" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/__init__.py#L12-L22
train
django-leonardo/django-leonardo
leonardo/module/nav/templatetags/webcms_nav_tags.py
_translate_page_into
def _translate_page_into(page, language, default=None): """ Return the translation for a given page """ # Optimisation shortcut: No need to dive into translations if page already what we want if page.language == language: return page translations = dict((t.language, t) for t in page.ava...
python
def _translate_page_into(page, language, default=None): """ Return the translation for a given page """ # Optimisation shortcut: No need to dive into translations if page already what we want if page.language == language: return page translations = dict((t.language, t) for t in page.ava...
[ "def", "_translate_page_into", "(", "page", ",", "language", ",", "default", "=", "None", ")", ":", "if", "page", ".", "language", "==", "language", ":", "return", "page", "translations", "=", "dict", "(", "(", "t", ".", "language", ",", "t", ")", "for...
Return the translation for a given page
[ "Return", "the", "translation", "for", "a", "given", "page" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/templatetags/webcms_nav_tags.py#L182-L198
train
django-leonardo/django-leonardo
leonardo/module/nav/templatetags/webcms_nav_tags.py
feincms_breadcrumbs
def feincms_breadcrumbs(page, include_self=True): """ Generate a list of the page's ancestors suitable for use as breadcrumb navigation. By default, generates an unordered list with the id "breadcrumbs" - override breadcrumbs.html to change this. :: {% feincms_breadcrumbs feincms_page %} ...
python
def feincms_breadcrumbs(page, include_self=True): """ Generate a list of the page's ancestors suitable for use as breadcrumb navigation. By default, generates an unordered list with the id "breadcrumbs" - override breadcrumbs.html to change this. :: {% feincms_breadcrumbs feincms_page %} ...
[ "def", "feincms_breadcrumbs", "(", "page", ",", "include_self", "=", "True", ")", ":", "if", "not", "page", "or", "not", "isinstance", "(", "page", ",", "Page", ")", ":", "raise", "ValueError", "(", "\"feincms_breadcrumbs must be called with a valid Page object\"", ...
Generate a list of the page's ancestors suitable for use as breadcrumb navigation. By default, generates an unordered list with the id "breadcrumbs" - override breadcrumbs.html to change this. :: {% feincms_breadcrumbs feincms_page %}
[ "Generate", "a", "list", "of", "the", "page", "s", "ancestors", "suitable", "for", "use", "as", "breadcrumb", "navigation", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/templatetags/webcms_nav_tags.py#L245-L267
train
django-leonardo/django-leonardo
leonardo/module/nav/templatetags/webcms_nav_tags.py
is_parent_of
def is_parent_of(page1, page2): """ Determines whether a given page is the parent of another page Example:: {% if page|is_parent_of:feincms_page %} ... {% endif %} """ try: return page1.tree_id == page2.tree_id and page1.lft < page2.lft and page1.rght > page2.rght except Attri...
python
def is_parent_of(page1, page2): """ Determines whether a given page is the parent of another page Example:: {% if page|is_parent_of:feincms_page %} ... {% endif %} """ try: return page1.tree_id == page2.tree_id and page1.lft < page2.lft and page1.rght > page2.rght except Attri...
[ "def", "is_parent_of", "(", "page1", ",", "page2", ")", ":", "try", ":", "return", "page1", ".", "tree_id", "==", "page2", ".", "tree_id", "and", "page1", ".", "lft", "<", "page2", ".", "lft", "and", "page1", ".", "rght", ">", "page2", ".", "rght", ...
Determines whether a given page is the parent of another page Example:: {% if page|is_parent_of:feincms_page %} ... {% endif %}
[ "Determines", "whether", "a", "given", "page", "is", "the", "parent", "of", "another", "page" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/nav/templatetags/webcms_nav_tags.py#L271-L283
train
django-leonardo/django-leonardo
leonardo/module/web/page/views.py
PageCreateView.parent
def parent(self): '''We use parent for some initial data''' if not hasattr(self, '_parent'): if 'parent' in self.kwargs: try: self._parent = Page.objects.get(id=self.kwargs["parent"]) except Exception as e: raise e ...
python
def parent(self): '''We use parent for some initial data''' if not hasattr(self, '_parent'): if 'parent' in self.kwargs: try: self._parent = Page.objects.get(id=self.kwargs["parent"]) except Exception as e: raise e ...
[ "def", "parent", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_parent'", ")", ":", "if", "'parent'", "in", "self", ".", "kwargs", ":", "try", ":", "self", ".", "_parent", "=", "Page", ".", "objects", ".", "get", "(", "id", "...
We use parent for some initial data
[ "We", "use", "parent", "for", "some", "initial", "data" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/views.py#L23-L40
train
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.tree_label
def tree_label(self): '''render tree label like as `root > child > child`''' titles = [] page = self while page: titles.append(page.title) page = page.parent return smart_text(' > '.join(reversed(titles)))
python
def tree_label(self): '''render tree label like as `root > child > child`''' titles = [] page = self while page: titles.append(page.title) page = page.parent return smart_text(' > '.join(reversed(titles)))
[ "def", "tree_label", "(", "self", ")", ":", "titles", "=", "[", "]", "page", "=", "self", "while", "page", ":", "titles", ".", "append", "(", "page", ".", "title", ")", "page", "=", "page", ".", "parent", "return", "smart_text", "(", "' > '", ".", ...
render tree label like as `root > child > child`
[ "render", "tree", "label", "like", "as", "root", ">", "child", ">", "child" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L104-L111
train
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.flush_ct_inventory
def flush_ct_inventory(self): """internal method used only if ct_inventory is enabled """ if hasattr(self, '_ct_inventory'): # skip self from update self._ct_inventory = None self.update_view = False self.save()
python
def flush_ct_inventory(self): """internal method used only if ct_inventory is enabled """ if hasattr(self, '_ct_inventory'): # skip self from update self._ct_inventory = None self.update_view = False self.save()
[ "def", "flush_ct_inventory", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_ct_inventory'", ")", ":", "self", ".", "_ct_inventory", "=", "None", "self", ".", "update_view", "=", "False", "self", ".", "save", "(", ")" ]
internal method used only if ct_inventory is enabled
[ "internal", "method", "used", "only", "if", "ct_inventory", "is", "enabled" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L164-L172
train
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.register_default_processors
def register_default_processors(cls, frontend_editing=None): """ Register our default request processors for the out-of-the-box Page experience. Since FeinCMS 1.11 was removed from core. """ super(Page, cls).register_default_processors() if frontend_editing: ...
python
def register_default_processors(cls, frontend_editing=None): """ Register our default request processors for the out-of-the-box Page experience. Since FeinCMS 1.11 was removed from core. """ super(Page, cls).register_default_processors() if frontend_editing: ...
[ "def", "register_default_processors", "(", "cls", ",", "frontend_editing", "=", "None", ")", ":", "super", "(", "Page", ",", "cls", ")", ".", "register_default_processors", "(", ")", "if", "frontend_editing", ":", "cls", ".", "register_request_processor", "(", "...
Register our default request processors for the out-of-the-box Page experience. Since FeinCMS 1.11 was removed from core.
[ "Register", "our", "default", "request", "processors", "for", "the", "out", "-", "of", "-", "the", "-", "box", "Page", "experience", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L179-L195
train
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.run_request_processors
def run_request_processors(self, request): """ Before rendering a page, run all registered request processors. A request processor may peruse and modify the page or the request. It can also return a ``HttpResponse`` for shortcutting the rendering and returning that response immed...
python
def run_request_processors(self, request): """ Before rendering a page, run all registered request processors. A request processor may peruse and modify the page or the request. It can also return a ``HttpResponse`` for shortcutting the rendering and returning that response immed...
[ "def", "run_request_processors", "(", "self", ",", "request", ")", ":", "if", "not", "getattr", "(", "self", ",", "'request_processors'", ",", "None", ")", ":", "return", "for", "fn", "in", "reversed", "(", "list", "(", "self", ".", "request_processors", "...
Before rendering a page, run all registered request processors. A request processor may peruse and modify the page or the request. It can also return a ``HttpResponse`` for shortcutting the rendering and returning that response immediately to the client.
[ "Before", "rendering", "a", "page", "run", "all", "registered", "request", "processors", ".", "A", "request", "processor", "may", "peruse", "and", "modify", "the", "page", "or", "the", "request", ".", "It", "can", "also", "return", "a", "HttpResponse", "for"...
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L197-L210
train
django-leonardo/django-leonardo
leonardo/module/web/models/page.py
Page.as_text
def as_text(self): '''Fetch and render all regions For search and test purposes just a prototype ''' from leonardo.templatetags.leonardo_tags import _render_content request = get_anonymous_request(self) content = '' try: for region in [re...
python
def as_text(self): '''Fetch and render all regions For search and test purposes just a prototype ''' from leonardo.templatetags.leonardo_tags import _render_content request = get_anonymous_request(self) content = '' try: for region in [re...
[ "def", "as_text", "(", "self", ")", ":", "from", "leonardo", ".", "templatetags", ".", "leonardo_tags", "import", "_render_content", "request", "=", "get_anonymous_request", "(", "self", ")", "content", "=", "''", "try", ":", "for", "region", "in", "[", "reg...
Fetch and render all regions For search and test purposes just a prototype
[ "Fetch", "and", "render", "all", "regions" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/models/page.py#L213-L238
train
django-leonardo/django-leonardo
leonardo/views/debug.py
technical_404_response
def technical_404_response(request, exception): "Create a technical 404 error response. The exception should be the Http404." try: error_url = exception.args[0]['path'] except (IndexError, TypeError, KeyError): error_url = request.path_info[1:] # Trim leading slash try: tried =...
python
def technical_404_response(request, exception): "Create a technical 404 error response. The exception should be the Http404." try: error_url = exception.args[0]['path'] except (IndexError, TypeError, KeyError): error_url = request.path_info[1:] # Trim leading slash try: tried =...
[ "def", "technical_404_response", "(", "request", ",", "exception", ")", ":", "\"Create a technical 404 error response. The exception should be the Http404.\"", "try", ":", "error_url", "=", "exception", ".", "args", "[", "0", "]", "[", "'path'", "]", "except", "(", "I...
Create a technical 404 error response. The exception should be the Http404.
[ "Create", "a", "technical", "404", "error", "response", ".", "The", "exception", "should", "be", "the", "Http404", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/debug.py#L21-L98
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.items
def items(self): '''access for filtered items''' if hasattr(self, '_items'): return self.filter_items(self._items) self._items = self.get_items() return self.filter_items(self._items)
python
def items(self): '''access for filtered items''' if hasattr(self, '_items'): return self.filter_items(self._items) self._items = self.get_items() return self.filter_items(self._items)
[ "def", "items", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_items'", ")", ":", "return", "self", ".", "filter_items", "(", "self", ".", "_items", ")", "self", ".", "_items", "=", "self", ".", "get_items", "(", ")", "return", "self", ...
access for filtered items
[ "access", "for", "filtered", "items" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L77-L82
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.populate_items
def populate_items(self, request): '''populate and returns filtered items''' self._items = self.get_items(request) return self.items
python
def populate_items(self, request): '''populate and returns filtered items''' self._items = self.get_items(request) return self.items
[ "def", "populate_items", "(", "self", ",", "request", ")", ":", "self", ".", "_items", "=", "self", ".", "get_items", "(", "request", ")", "return", "self", ".", "items" ]
populate and returns filtered items
[ "populate", "and", "returns", "filtered", "items" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L84-L87
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.columns_classes
def columns_classes(self): '''returns columns count''' md = 12 / self.objects_per_row sm = None if self.objects_per_row > 2: sm = 12 / (self.objects_per_row / 2) return md, (sm or md), 12
python
def columns_classes(self): '''returns columns count''' md = 12 / self.objects_per_row sm = None if self.objects_per_row > 2: sm = 12 / (self.objects_per_row / 2) return md, (sm or md), 12
[ "def", "columns_classes", "(", "self", ")", ":", "md", "=", "12", "/", "self", ".", "objects_per_row", "sm", "=", "None", "if", "self", ".", "objects_per_row", ">", "2", ":", "sm", "=", "12", "/", "(", "self", ".", "objects_per_row", "/", "2", ")", ...
returns columns count
[ "returns", "columns", "count" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L104-L110
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.get_pages
def get_pages(self): '''returns pages with rows''' pages = [] page = [] for i, item in enumerate(self.get_rows): if i > 0 and i % self.objects_per_page == 0: pages.append(page) page = [] page.append(item) pages.append(page) ...
python
def get_pages(self): '''returns pages with rows''' pages = [] page = [] for i, item in enumerate(self.get_rows): if i > 0 and i % self.objects_per_page == 0: pages.append(page) page = [] page.append(item) pages.append(page) ...
[ "def", "get_pages", "(", "self", ")", ":", "pages", "=", "[", "]", "page", "=", "[", "]", "for", "i", ",", "item", "in", "enumerate", "(", "self", ".", "get_rows", ")", ":", "if", "i", ">", "0", "and", "i", "%", "self", ".", "objects_per_page", ...
returns pages with rows
[ "returns", "pages", "with", "rows" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L120-L130
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.needs_pagination
def needs_pagination(self): """Calculate needs pagination""" if self.objects_per_page == 0: return False if len(self.items) > self.objects_per_page \ or len(self.get_pages[0]) > self.objects_per_page: return True return False
python
def needs_pagination(self): """Calculate needs pagination""" if self.objects_per_page == 0: return False if len(self.items) > self.objects_per_page \ or len(self.get_pages[0]) > self.objects_per_page: return True return False
[ "def", "needs_pagination", "(", "self", ")", ":", "if", "self", ".", "objects_per_page", "==", "0", ":", "return", "False", "if", "len", "(", "self", ".", "items", ")", ">", "self", ".", "objects_per_page", "or", "len", "(", "self", ".", "get_pages", "...
Calculate needs pagination
[ "Calculate", "needs", "pagination" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L133-L140
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ListMixin.get_item_template
def get_item_template(self): '''returns template for signle object from queryset If you have a template name my_list_template.html then template for a single object will be _my_list_template.html Now only for default generates _item.html _item.html is obsolete use _defau...
python
def get_item_template(self): '''returns template for signle object from queryset If you have a template name my_list_template.html then template for a single object will be _my_list_template.html Now only for default generates _item.html _item.html is obsolete use _defau...
[ "def", "get_item_template", "(", "self", ")", ":", "content_template", "=", "self", ".", "content_theme", ".", "name", "if", "content_template", "==", "\"default\"", ":", "return", "\"widget/%s/_item.html\"", "%", "self", ".", "widget_name", "return", "\"widget/%s/_...
returns template for signle object from queryset If you have a template name my_list_template.html then template for a single object will be _my_list_template.html Now only for default generates _item.html _item.html is obsolete use _default.html
[ "returns", "template", "for", "signle", "object", "from", "queryset", "If", "you", "have", "a", "template", "name", "my_list_template", ".", "html", "then", "template", "for", "a", "single", "object", "will", "be", "_my_list_template", ".", "html" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L148-L165
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ContentProxyWidgetMixin.is_obsolete
def is_obsolete(self): """returns True is data is obsolete and needs revalidation """ if self.cache_updated: now = timezone.now() delta = now - self.cache_updated if delta.seconds < self.cache_validity: return False return True
python
def is_obsolete(self): """returns True is data is obsolete and needs revalidation """ if self.cache_updated: now = timezone.now() delta = now - self.cache_updated if delta.seconds < self.cache_validity: return False return True
[ "def", "is_obsolete", "(", "self", ")", ":", "if", "self", ".", "cache_updated", ":", "now", "=", "timezone", ".", "now", "(", ")", "delta", "=", "now", "-", "self", ".", "cache_updated", "if", "delta", ".", "seconds", "<", "self", ".", "cache_validity...
returns True is data is obsolete and needs revalidation
[ "returns", "True", "is", "data", "is", "obsolete", "and", "needs", "revalidation" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L224-L232
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ContentProxyWidgetMixin.update_cache
def update_cache(self, data=None): """call with new data or set data to self.cache_data and call this """ if data: self.cache_data = data self.cache_updated = timezone.now() self.save()
python
def update_cache(self, data=None): """call with new data or set data to self.cache_data and call this """ if data: self.cache_data = data self.cache_updated = timezone.now() self.save()
[ "def", "update_cache", "(", "self", ",", "data", "=", "None", ")", ":", "if", "data", ":", "self", ".", "cache_data", "=", "data", "self", ".", "cache_updated", "=", "timezone", ".", "now", "(", ")", "self", ".", "save", "(", ")" ]
call with new data or set data to self.cache_data and call this
[ "call", "with", "new", "data", "or", "set", "data", "to", "self", ".", "cache_data", "and", "call", "this" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L234-L240
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
ContentProxyWidgetMixin.data
def data(self): """this property just calls ``get_data`` but here you can serilalize your data or render as html these data will be saved to self.cached_content also will be accessable from template """ if self.is_obsolete(): self.update_cache(self.get_data())...
python
def data(self): """this property just calls ``get_data`` but here you can serilalize your data or render as html these data will be saved to self.cached_content also will be accessable from template """ if self.is_obsolete(): self.update_cache(self.get_data())...
[ "def", "data", "(", "self", ")", ":", "if", "self", ".", "is_obsolete", "(", ")", ":", "self", ".", "update_cache", "(", "self", ".", "get_data", "(", ")", ")", "return", "self", ".", "cache_data" ]
this property just calls ``get_data`` but here you can serilalize your data or render as html these data will be saved to self.cached_content also will be accessable from template
[ "this", "property", "just", "calls", "get_data", "but", "here", "you", "can", "serilalize", "your", "data", "or", "render", "as", "html", "these", "data", "will", "be", "saved", "to", "self", ".", "cached_content", "also", "will", "be", "accessable", "from",...
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L251-L259
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/mixins.py
JSONContentMixin.data
def data(self): """load and cache data in json format """ if self.is_obsolete(): data = self.get_data() for datum in data: if 'published_parsed' in datum: datum['published_parsed'] = \ self.parse_time(datum['pub...
python
def data(self): """load and cache data in json format """ if self.is_obsolete(): data = self.get_data() for datum in data: if 'published_parsed' in datum: datum['published_parsed'] = \ self.parse_time(datum['pub...
[ "def", "data", "(", "self", ")", ":", "if", "self", ".", "is_obsolete", "(", ")", ":", "data", "=", "self", ".", "get_data", "(", ")", "for", "datum", "in", "data", ":", "if", "'published_parsed'", "in", "datum", ":", "datum", "[", "'published_parsed'"...
load and cache data in json format
[ "load", "and", "cache", "data", "in", "json", "format" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/mixins.py#L274-L298
train
django-leonardo/django-leonardo
leonardo/utils/settings.py
get_loaded_modules
def get_loaded_modules(modules): '''load modules and order it by ordering key''' _modules = [] for mod in modules: mod_cfg = get_conf_from_module(mod) _modules.append((mod, mod_cfg,)) _modules = sorted(_modules, key=lambda m: m[1].get('ordering')) return _modules
python
def get_loaded_modules(modules): '''load modules and order it by ordering key''' _modules = [] for mod in modules: mod_cfg = get_conf_from_module(mod) _modules.append((mod, mod_cfg,)) _modules = sorted(_modules, key=lambda m: m[1].get('ordering')) return _modules
[ "def", "get_loaded_modules", "(", "modules", ")", ":", "_modules", "=", "[", "]", "for", "mod", "in", "modules", ":", "mod_cfg", "=", "get_conf_from_module", "(", "mod", ")", "_modules", ".", "append", "(", "(", "mod", ",", "mod_cfg", ",", ")", ")", "_...
load modules and order it by ordering key
[ "load", "modules", "and", "order", "it", "by", "ordering", "key" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L14-L25
train
django-leonardo/django-leonardo
leonardo/utils/settings.py
_is_leonardo_module
def _is_leonardo_module(whatever): '''check if is leonardo module''' # check if is python module if hasattr(whatever, 'default') \ or hasattr(whatever, 'leonardo_module_conf'): return True # check if is python object for key in dir(whatever): if 'LEONARDO' in key: ...
python
def _is_leonardo_module(whatever): '''check if is leonardo module''' # check if is python module if hasattr(whatever, 'default') \ or hasattr(whatever, 'leonardo_module_conf'): return True # check if is python object for key in dir(whatever): if 'LEONARDO' in key: ...
[ "def", "_is_leonardo_module", "(", "whatever", ")", ":", "if", "hasattr", "(", "whatever", ",", "'default'", ")", "or", "hasattr", "(", "whatever", ",", "'leonardo_module_conf'", ")", ":", "return", "True", "for", "key", "in", "dir", "(", "whatever", ")", ...
check if is leonardo module
[ "check", "if", "is", "leonardo", "module" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L69-L80
train
django-leonardo/django-leonardo
leonardo/utils/settings.py
extract_conf_from
def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2): """recursively extract keys from module or object by passed config scheme """ # extract config keys from module or object for key, default_value in six.iteritems(conf): conf[key] = _get_key_from_module(mod, key,...
python
def extract_conf_from(mod, conf=ModuleConfig(CONF_SPEC), depth=0, max_depth=2): """recursively extract keys from module or object by passed config scheme """ # extract config keys from module or object for key, default_value in six.iteritems(conf): conf[key] = _get_key_from_module(mod, key,...
[ "def", "extract_conf_from", "(", "mod", ",", "conf", "=", "ModuleConfig", "(", "CONF_SPEC", ")", ",", "depth", "=", "0", ",", "max_depth", "=", "2", ")", ":", "for", "key", ",", "default_value", "in", "six", ".", "iteritems", "(", "conf", ")", ":", "...
recursively extract keys from module or object by passed config scheme
[ "recursively", "extract", "keys", "from", "module", "or", "object", "by", "passed", "config", "scheme" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L83-L118
train
django-leonardo/django-leonardo
leonardo/utils/settings.py
_get_correct_module
def _get_correct_module(mod): """returns imported module check if is ``leonardo_module_conf`` specified and then import them """ module_location = getattr( mod, 'leonardo_module_conf', getattr(mod, "LEONARDO_MODULE_CONF", None)) if module_location: mod = import_module(module...
python
def _get_correct_module(mod): """returns imported module check if is ``leonardo_module_conf`` specified and then import them """ module_location = getattr( mod, 'leonardo_module_conf', getattr(mod, "LEONARDO_MODULE_CONF", None)) if module_location: mod = import_module(module...
[ "def", "_get_correct_module", "(", "mod", ")", ":", "module_location", "=", "getattr", "(", "mod", ",", "'leonardo_module_conf'", ",", "getattr", "(", "mod", ",", "\"LEONARDO_MODULE_CONF\"", ",", "None", ")", ")", "if", "module_location", ":", "mod", "=", "imp...
returns imported module check if is ``leonardo_module_conf`` specified and then import them
[ "returns", "imported", "module", "check", "if", "is", "leonardo_module_conf", "specified", "and", "then", "import", "them" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L121-L141
train
django-leonardo/django-leonardo
leonardo/utils/settings.py
get_conf_from_module
def get_conf_from_module(mod): """return configuration from module with defaults no worry about None type """ conf = ModuleConfig(CONF_SPEC) # get imported module mod = _get_correct_module(mod) conf.set_module(mod) # extarct from default object or from module if hasattr(mod, 'defaul...
python
def get_conf_from_module(mod): """return configuration from module with defaults no worry about None type """ conf = ModuleConfig(CONF_SPEC) # get imported module mod = _get_correct_module(mod) conf.set_module(mod) # extarct from default object or from module if hasattr(mod, 'defaul...
[ "def", "get_conf_from_module", "(", "mod", ")", ":", "conf", "=", "ModuleConfig", "(", "CONF_SPEC", ")", "mod", "=", "_get_correct_module", "(", "mod", ")", "conf", ".", "set_module", "(", "mod", ")", "if", "hasattr", "(", "mod", ",", "'default'", ")", "...
return configuration from module with defaults no worry about None type
[ "return", "configuration", "from", "module", "with", "defaults", "no", "worry", "about", "None", "type" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/settings.py#L144-L162
train
django-leonardo/django-leonardo
leonardo/module/web/page/utils.py
get_anonymous_request
def get_anonymous_request(leonardo_page): """returns inicialized request """ request_factory = RequestFactory() request = request_factory.get( leonardo_page.get_absolute_url(), data={}) request.feincms_page = request.leonardo_page = leonardo_page request.frontend_editing = False req...
python
def get_anonymous_request(leonardo_page): """returns inicialized request """ request_factory = RequestFactory() request = request_factory.get( leonardo_page.get_absolute_url(), data={}) request.feincms_page = request.leonardo_page = leonardo_page request.frontend_editing = False req...
[ "def", "get_anonymous_request", "(", "leonardo_page", ")", ":", "request_factory", "=", "RequestFactory", "(", ")", "request", "=", "request_factory", ".", "get", "(", "leonardo_page", ".", "get_absolute_url", "(", ")", ",", "data", "=", "{", "}", ")", "reques...
returns inicialized request
[ "returns", "inicialized", "request" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/utils.py#L8-L43
train
django-leonardo/django-leonardo
leonardo/module/web/processors/font.py
webfont_cookie
def webfont_cookie(request): '''Adds WEBFONT Flag to the context''' if hasattr(request, 'COOKIES') and request.COOKIES.get(WEBFONT_COOKIE_NAME, None): return { WEBFONT_COOKIE_NAME.upper(): True } return { WEBFONT_COOKIE_NAME.upper(): False }
python
def webfont_cookie(request): '''Adds WEBFONT Flag to the context''' if hasattr(request, 'COOKIES') and request.COOKIES.get(WEBFONT_COOKIE_NAME, None): return { WEBFONT_COOKIE_NAME.upper(): True } return { WEBFONT_COOKIE_NAME.upper(): False }
[ "def", "webfont_cookie", "(", "request", ")", ":", "if", "hasattr", "(", "request", ",", "'COOKIES'", ")", "and", "request", ".", "COOKIES", ".", "get", "(", "WEBFONT_COOKIE_NAME", ",", "None", ")", ":", "return", "{", "WEBFONT_COOKIE_NAME", ".", "upper", ...
Adds WEBFONT Flag to the context
[ "Adds", "WEBFONT", "Flag", "to", "the", "context" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/processors/font.py#L10-L21
train
django-leonardo/django-leonardo
leonardo/utils/widgets.py
get_all_widget_classes
def get_all_widget_classes(): """returns collected Leonardo Widgets if not declared in settings is used __subclasses__ which not supports widget subclassing """ from leonardo.module.web.models import Widget _widgets = getattr(settings, 'WIDGETS', Widget.__subclasses__())...
python
def get_all_widget_classes(): """returns collected Leonardo Widgets if not declared in settings is used __subclasses__ which not supports widget subclassing """ from leonardo.module.web.models import Widget _widgets = getattr(settings, 'WIDGETS', Widget.__subclasses__())...
[ "def", "get_all_widget_classes", "(", ")", ":", "from", "leonardo", ".", "module", ".", "web", ".", "models", "import", "Widget", "_widgets", "=", "getattr", "(", "settings", ",", "'WIDGETS'", ",", "Widget", ".", "__subclasses__", "(", ")", ")", "widgets", ...
returns collected Leonardo Widgets if not declared in settings is used __subclasses__ which not supports widget subclassing
[ "returns", "collected", "Leonardo", "Widgets" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/widgets.py#L45-L61
train
django-leonardo/django-leonardo
leonardo/utils/widgets.py
render_region
def render_region(widget=None, request=None, view=None, page=None, region=None): """returns rendered content this is not too clear and little tricky, because external apps needs calling process method """ # change the request if not isinstance(request, dict): request.q...
python
def render_region(widget=None, request=None, view=None, page=None, region=None): """returns rendered content this is not too clear and little tricky, because external apps needs calling process method """ # change the request if not isinstance(request, dict): request.q...
[ "def", "render_region", "(", "widget", "=", "None", ",", "request", "=", "None", ",", "view", "=", "None", ",", "page", "=", "None", ",", "region", "=", "None", ")", ":", "if", "not", "isinstance", "(", "request", ",", "dict", ")", ":", "request", ...
returns rendered content this is not too clear and little tricky, because external apps needs calling process method
[ "returns", "rendered", "content", "this", "is", "not", "too", "clear", "and", "little", "tricky", "because", "external", "apps", "needs", "calling", "process", "method" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/widgets.py#L124-L173
train
django-leonardo/django-leonardo
leonardo/module/web/admin.py
PageAdmin.get_feincms_inlines
def get_feincms_inlines(self, model, request): """ Generate genuine django inlines for registered content types. """ model._needs_content_types() inlines = [] for content_type in model._feincms_content_types: if not self.can_add_content(request, content_type): ...
python
def get_feincms_inlines(self, model, request): """ Generate genuine django inlines for registered content types. """ model._needs_content_types() inlines = [] for content_type in model._feincms_content_types: if not self.can_add_content(request, content_type): ...
[ "def", "get_feincms_inlines", "(", "self", ",", "model", ",", "request", ")", ":", "model", ".", "_needs_content_types", "(", ")", "inlines", "=", "[", "]", "for", "content_type", "in", "model", ".", "_feincms_content_types", ":", "if", "not", "self", ".", ...
Generate genuine django inlines for registered content types.
[ "Generate", "genuine", "django", "inlines", "for", "registered", "content", "types", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/admin.py#L49-L82
train
django-leonardo/django-leonardo
leonardo/module/web/admin.py
PageAdmin.get_changeform_initial_data
def get_changeform_initial_data(self, request): '''Copy initial data from parent''' initial = super(PageAdmin, self).get_changeform_initial_data(request) if ('translation_of' in request.GET): original = self.model._tree_manager.get( pk=request.GET.get('translation_of'...
python
def get_changeform_initial_data(self, request): '''Copy initial data from parent''' initial = super(PageAdmin, self).get_changeform_initial_data(request) if ('translation_of' in request.GET): original = self.model._tree_manager.get( pk=request.GET.get('translation_of'...
[ "def", "get_changeform_initial_data", "(", "self", ",", "request", ")", ":", "initial", "=", "super", "(", "PageAdmin", ",", "self", ")", ".", "get_changeform_initial_data", "(", "request", ")", "if", "(", "'translation_of'", "in", "request", ".", "GET", ")", ...
Copy initial data from parent
[ "Copy", "initial", "data", "from", "parent" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/admin.py#L84-L103
train
django-leonardo/django-leonardo
leonardo/utils/package.py
install_package
def install_package(package, upgrade=True, target=None): """Install a package on PyPi. Accepts pip compatible package strings. Return boolean if install successful. """ # Not using 'import pip; pip.main([])' because it breaks the logger with INSTALL_LOCK: if check_packag...
python
def install_package(package, upgrade=True, target=None): """Install a package on PyPi. Accepts pip compatible package strings. Return boolean if install successful. """ # Not using 'import pip; pip.main([])' because it breaks the logger with INSTALL_LOCK: if check_packag...
[ "def", "install_package", "(", "package", ",", "upgrade", "=", "True", ",", "target", "=", "None", ")", ":", "with", "INSTALL_LOCK", ":", "if", "check_package_exists", "(", "package", ",", "target", ")", ":", "return", "True", "_LOGGER", ".", "info", "(", ...
Install a package on PyPi. Accepts pip compatible package strings. Return boolean if install successful.
[ "Install", "a", "package", "on", "PyPi", ".", "Accepts", "pip", "compatible", "package", "strings", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/package.py#L19-L41
train
django-leonardo/django-leonardo
leonardo/utils/package.py
check_package_exists
def check_package_exists(package, lib_dir): """Check if a package is installed globally or in lib_dir. Returns True when the requirement is met. Returns False when the package is not installed or doesn't meet req. """ try: req = pkg_resources.Requirement.parse(package) except ValueError...
python
def check_package_exists(package, lib_dir): """Check if a package is installed globally or in lib_dir. Returns True when the requirement is met. Returns False when the package is not installed or doesn't meet req. """ try: req = pkg_resources.Requirement.parse(package) except ValueError...
[ "def", "check_package_exists", "(", "package", ",", "lib_dir", ")", ":", "try", ":", "req", "=", "pkg_resources", ".", "Requirement", ".", "parse", "(", "package", ")", "except", "ValueError", ":", "req", "=", "pkg_resources", ".", "Requirement", ".", "parse...
Check if a package is installed globally or in lib_dir. Returns True when the requirement is met. Returns False when the package is not installed or doesn't meet req.
[ "Check", "if", "a", "package", "is", "installed", "globally", "or", "in", "lib_dir", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/package.py#L44-L64
train
django-leonardo/django-leonardo
leonardo/views/ajax.py
AJAXMixin.render_widget
def render_widget(self, request, widget_id): '''Returns rendered widget in JSON response''' widget = get_widget_from_id(widget_id) response = widget.render(**{'request': request}) return JsonResponse({'result': response, 'id': widget_id})
python
def render_widget(self, request, widget_id): '''Returns rendered widget in JSON response''' widget = get_widget_from_id(widget_id) response = widget.render(**{'request': request}) return JsonResponse({'result': response, 'id': widget_id})
[ "def", "render_widget", "(", "self", ",", "request", ",", "widget_id", ")", ":", "widget", "=", "get_widget_from_id", "(", "widget_id", ")", "response", "=", "widget", ".", "render", "(", "**", "{", "'request'", ":", "request", "}", ")", "return", "JsonRes...
Returns rendered widget in JSON response
[ "Returns", "rendered", "widget", "in", "JSON", "response" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/ajax.py#L31-L38
train
django-leonardo/django-leonardo
leonardo/views/ajax.py
AJAXMixin.render_region
def render_region(self, request): '''Returns rendered region in JSON response''' page = self.get_object() try: region = request.POST['region'] except KeyError: region = request.GET['region'] request.query_string = None from leonardo.utils.widge...
python
def render_region(self, request): '''Returns rendered region in JSON response''' page = self.get_object() try: region = request.POST['region'] except KeyError: region = request.GET['region'] request.query_string = None from leonardo.utils.widge...
[ "def", "render_region", "(", "self", ",", "request", ")", ":", "page", "=", "self", ".", "get_object", "(", ")", "try", ":", "region", "=", "request", ".", "POST", "[", "'region'", "]", "except", "KeyError", ":", "region", "=", "request", ".", "GET", ...
Returns rendered region in JSON response
[ "Returns", "rendered", "region", "in", "JSON", "response" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/ajax.py#L40-L56
train
django-leonardo/django-leonardo
leonardo/views/ajax.py
AJAXMixin.handle_ajax_method
def handle_ajax_method(self, request, method): """handle ajax methods and return serialized reponse in the default state allows only authentificated users - Depends on method parameter render whole region or single widget - If widget_id is present then try to load this widget ...
python
def handle_ajax_method(self, request, method): """handle ajax methods and return serialized reponse in the default state allows only authentificated users - Depends on method parameter render whole region or single widget - If widget_id is present then try to load this widget ...
[ "def", "handle_ajax_method", "(", "self", ",", "request", ",", "method", ")", ":", "response", "=", "{", "}", "def", "get_param", "(", "request", ",", "name", ")", ":", "try", ":", "return", "request", ".", "POST", "[", "name", "]", "except", "KeyError...
handle ajax methods and return serialized reponse in the default state allows only authentificated users - Depends on method parameter render whole region or single widget - If widget_id is present then try to load this widget and call method on them - If class_name is prese...
[ "handle", "ajax", "methods", "and", "return", "serialized", "reponse", "in", "the", "default", "state", "allows", "only", "authentificated", "users" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/ajax.py#L59-L160
train
django-leonardo/django-leonardo
leonardo/templatetags/form_helpers.py
add_bootstrap_class
def add_bootstrap_class(field): """Add a "form-control" CSS class to the field's widget. This is so that Bootstrap styles it properly. """ if not isinstance(field.field.widget, ( django.forms.widgets.CheckboxInput, django.forms.widgets.CheckboxSelectMultiple, django.forms.widget...
python
def add_bootstrap_class(field): """Add a "form-control" CSS class to the field's widget. This is so that Bootstrap styles it properly. """ if not isinstance(field.field.widget, ( django.forms.widgets.CheckboxInput, django.forms.widgets.CheckboxSelectMultiple, django.forms.widget...
[ "def", "add_bootstrap_class", "(", "field", ")", ":", "if", "not", "isinstance", "(", "field", ".", "field", ".", "widget", ",", "(", "django", ".", "forms", ".", "widgets", ".", "CheckboxInput", ",", "django", ".", "forms", ".", "widgets", ".", "Checkbo...
Add a "form-control" CSS class to the field's widget. This is so that Bootstrap styles it properly.
[ "Add", "a", "form", "-", "control", "CSS", "class", "to", "the", "field", "s", "widget", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/form_helpers.py#L20-L35
train
django-leonardo/django-leonardo
leonardo/module/media/admin/clipboardadmin.py
ClipboardAdmin.ajax_upload
def ajax_upload(self, request, folder_id=None): """ receives an upload from the uploader. Receives only one file at the time. """ mimetype = "application/json" if request.is_ajax() else "text/html" content_type_key = 'content_type' response_params = {content_type_key: mim...
python
def ajax_upload(self, request, folder_id=None): """ receives an upload from the uploader. Receives only one file at the time. """ mimetype = "application/json" if request.is_ajax() else "text/html" content_type_key = 'content_type' response_params = {content_type_key: mim...
[ "def", "ajax_upload", "(", "self", ",", "request", ",", "folder_id", "=", "None", ")", ":", "mimetype", "=", "\"application/json\"", "if", "request", ".", "is_ajax", "(", ")", "else", "\"text/html\"", "content_type_key", "=", "'content_type'", "response_params", ...
receives an upload from the uploader. Receives only one file at the time.
[ "receives", "an", "upload", "from", "the", "uploader", ".", "Receives", "only", "one", "file", "at", "the", "time", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/admin/clipboardadmin.py#L62-L135
train
django-leonardo/django-leonardo
leonardo/module/web/management/commands/sync_page_themes.py
Command.set_options
def set_options(self, **options): """ Set instance variables based on an options dict """ self.interactive = False self.verbosity = options['verbosity'] self.symlink = "" self.clear = False ignore_patterns = [] self.ignore_patterns = list(set(ignor...
python
def set_options(self, **options): """ Set instance variables based on an options dict """ self.interactive = False self.verbosity = options['verbosity'] self.symlink = "" self.clear = False ignore_patterns = [] self.ignore_patterns = list(set(ignor...
[ "def", "set_options", "(", "self", ",", "**", "options", ")", ":", "self", ".", "interactive", "=", "False", "self", ".", "verbosity", "=", "options", "[", "'verbosity'", "]", "self", ".", "symlink", "=", "\"\"", "self", ".", "clear", "=", "False", "ig...
Set instance variables based on an options dict
[ "Set", "instance", "variables", "based", "on", "an", "options", "dict" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/management/commands/sync_page_themes.py#L30-L41
train
django-leonardo/django-leonardo
leonardo/module/web/management/commands/sync_page_themes.py
Command.collect
def collect(self): """ Load and save ``PageColorScheme`` for every ``PageTheme`` .. code-block:: bash static/themes/bootswatch/united/variables.scss static/themes/bootswatch/united/styles.scss """ self.ignore_patterns = [ '*.png', '*.jpg', ...
python
def collect(self): """ Load and save ``PageColorScheme`` for every ``PageTheme`` .. code-block:: bash static/themes/bootswatch/united/variables.scss static/themes/bootswatch/united/styles.scss """ self.ignore_patterns = [ '*.png', '*.jpg', ...
[ "def", "collect", "(", "self", ")", ":", "self", ".", "ignore_patterns", "=", "[", "'*.png'", ",", "'*.jpg'", ",", "'*.js'", ",", "'*.gif'", ",", "'*.ttf'", ",", "'*.md'", ",", "'*.rst'", ",", "'*.svg'", "]", "page_themes", "=", "PageTheme", ".", "object...
Load and save ``PageColorScheme`` for every ``PageTheme`` .. code-block:: bash static/themes/bootswatch/united/variables.scss static/themes/bootswatch/united/styles.scss
[ "Load", "and", "save", "PageColorScheme", "for", "every", "PageTheme" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/management/commands/sync_page_themes.py#L43-L91
train
django-leonardo/django-leonardo
leonardo/module/media/models/abstract.py
BaseImage.has_generic_permission
def has_generic_permission(self, request, permission_type): """ Return true if the current user has permission on this image. Return the string 'ALL' if the user has all rights. """ user = request.user if not user.is_authenticated(): return False elif ...
python
def has_generic_permission(self, request, permission_type): """ Return true if the current user has permission on this image. Return the string 'ALL' if the user has all rights. """ user = request.user if not user.is_authenticated(): return False elif ...
[ "def", "has_generic_permission", "(", "self", ",", "request", ",", "permission_type", ")", ":", "user", "=", "request", ".", "user", "if", "not", "user", ".", "is_authenticated", "(", ")", ":", "return", "False", "elif", "user", ".", "is_superuser", ":", "...
Return true if the current user has permission on this image. Return the string 'ALL' if the user has all rights.
[ "Return", "true", "if", "the", "current", "user", "has", "permission", "on", "this", "image", ".", "Return", "the", "string", "ALL", "if", "the", "user", "has", "all", "rights", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/models/abstract.py#L101-L116
train
django-leonardo/django-leonardo
leonardo/module/media/widget/mediagallery/models.py
MediaGalleryWidget.get_template_data
def get_template_data(self, request, *args, **kwargs): '''Add image dimensions''' # little tricky with vertical centering dimension = int(self.get_size().split('x')[0]) data = {} if dimension <= 356: data['image_dimension'] = "row-md-13" if self.get_templa...
python
def get_template_data(self, request, *args, **kwargs): '''Add image dimensions''' # little tricky with vertical centering dimension = int(self.get_size().split('x')[0]) data = {} if dimension <= 356: data['image_dimension'] = "row-md-13" if self.get_templa...
[ "def", "get_template_data", "(", "self", ",", "request", ",", "*", "args", ",", "**", "kwargs", ")", ":", "dimension", "=", "int", "(", "self", ".", "get_size", "(", ")", ".", "split", "(", "'x'", ")", "[", "0", "]", ")", "data", "=", "{", "}", ...
Add image dimensions
[ "Add", "image", "dimensions" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/widget/mediagallery/models.py#L81-L95
train
django-leonardo/django-leonardo
leonardo/decorators.py
_decorate_urlconf
def _decorate_urlconf(urlpatterns, decorator=require_auth, *args, **kwargs): '''Decorate all urlpatterns by specified decorator''' if isinstance(urlpatterns, (list, tuple)): for pattern in urlpatterns: if getattr(pattern, 'callback', None): pattern._callback = decorator( ...
python
def _decorate_urlconf(urlpatterns, decorator=require_auth, *args, **kwargs): '''Decorate all urlpatterns by specified decorator''' if isinstance(urlpatterns, (list, tuple)): for pattern in urlpatterns: if getattr(pattern, 'callback', None): pattern._callback = decorator( ...
[ "def", "_decorate_urlconf", "(", "urlpatterns", ",", "decorator", "=", "require_auth", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "isinstance", "(", "urlpatterns", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "pattern", "in", "urlpat...
Decorate all urlpatterns by specified decorator
[ "Decorate", "all", "urlpatterns", "by", "specified", "decorator" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/decorators.py#L53-L68
train
django-leonardo/django-leonardo
leonardo/decorators.py
catch_result
def catch_result(task_func): """Catch printed result from Celery Task and return it in task response """ @functools.wraps(task_func, assigned=available_attrs(task_func)) def dec(*args, **kwargs): # inicialize orig_stdout = sys.stdout sys.stdout = content = StringIO() tas...
python
def catch_result(task_func): """Catch printed result from Celery Task and return it in task response """ @functools.wraps(task_func, assigned=available_attrs(task_func)) def dec(*args, **kwargs): # inicialize orig_stdout = sys.stdout sys.stdout = content = StringIO() tas...
[ "def", "catch_result", "(", "task_func", ")", ":", "@", "functools", ".", "wraps", "(", "task_func", ",", "assigned", "=", "available_attrs", "(", "task_func", ")", ")", "def", "dec", "(", "*", "args", ",", "**", "kwargs", ")", ":", "orig_stdout", "=", ...
Catch printed result from Celery Task and return it in task response
[ "Catch", "printed", "result", "from", "Celery", "Task", "and", "return", "it", "in", "task", "response" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/decorators.py#L74-L90
train
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
compress_monkey_patch
def compress_monkey_patch(): """patch all compress we need access to variables from widget scss for example we have:: /themes/bootswatch/cyborg/_variables but only if is cyborg active for this reasone we need dynamically append import to every scss file """ from compressor.templ...
python
def compress_monkey_patch(): """patch all compress we need access to variables from widget scss for example we have:: /themes/bootswatch/cyborg/_variables but only if is cyborg active for this reasone we need dynamically append import to every scss file """ from compressor.templ...
[ "def", "compress_monkey_patch", "(", ")", ":", "from", "compressor", ".", "templatetags", "import", "compress", "as", "compress_tags", "from", "compressor", "import", "base", "as", "compress_base", "compress_base", ".", "Compressor", ".", "filter_input", "=", "filte...
patch all compress we need access to variables from widget scss for example we have:: /themes/bootswatch/cyborg/_variables but only if is cyborg active for this reasone we need dynamically append import to every scss file
[ "patch", "all", "compress" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L37-L62
train
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
output
def output(self, mode='file', forced=False, context=None): """ The general output method, override in subclass if you need to do any custom modification. Calls other mode specific methods or simply returns the content directly. """ output = '\n'.join(self.filter_input(forced, context=context)) ...
python
def output(self, mode='file', forced=False, context=None): """ The general output method, override in subclass if you need to do any custom modification. Calls other mode specific methods or simply returns the content directly. """ output = '\n'.join(self.filter_input(forced, context=context)) ...
[ "def", "output", "(", "self", ",", "mode", "=", "'file'", ",", "forced", "=", "False", ",", "context", "=", "None", ")", ":", "output", "=", "'\\n'", ".", "join", "(", "self", ".", "filter_input", "(", "forced", ",", "context", "=", "context", ")", ...
The general output method, override in subclass if you need to do any custom modification. Calls other mode specific methods or simply returns the content directly.
[ "The", "general", "output", "method", "override", "in", "subclass", "if", "you", "need", "to", "do", "any", "custom", "modification", ".", "Calls", "other", "mode", "specific", "methods", "or", "simply", "returns", "the", "content", "directly", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L165-L180
train
django-leonardo/django-leonardo
leonardo/utils/compress_patch.py
precompile
def precompile(self, content, kind=None, elem=None, filename=None, charset=None, **kwargs): """ Processes file using a pre compiler. This is the place where files like coffee script are processed. """ if not kind: return False, content attrs = self.parser.elem_attribs(elem...
python
def precompile(self, content, kind=None, elem=None, filename=None, charset=None, **kwargs): """ Processes file using a pre compiler. This is the place where files like coffee script are processed. """ if not kind: return False, content attrs = self.parser.elem_attribs(elem...
[ "def", "precompile", "(", "self", ",", "content", ",", "kind", "=", "None", ",", "elem", "=", "None", ",", "filename", "=", "None", ",", "charset", "=", "None", ",", "**", "kwargs", ")", ":", "if", "not", "kind", ":", "return", "False", ",", "conte...
Processes file using a pre compiler. This is the place where files like coffee script are processed.
[ "Processes", "file", "using", "a", "pre", "compiler", ".", "This", "is", "the", "place", "where", "files", "like", "coffee", "script", "are", "processed", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/compress_patch.py#L194-L230
train
frawau/aioblescan
aioblescan/aioblescan.py
MACAddr.decode
def decode(self,data): """Decode the MAC address from a byte array. This will take the first 6 bytes from data and transform them into a MAC address string representation. This will be assigned to the attribute "val". It then returns the data stream minus the bytes consumed ...
python
def decode(self,data): """Decode the MAC address from a byte array. This will take the first 6 bytes from data and transform them into a MAC address string representation. This will be assigned to the attribute "val". It then returns the data stream minus the bytes consumed ...
[ "def", "decode", "(", "self", ",", "data", ")", ":", "self", ".", "val", "=", "':'", ".", "join", "(", "\"%02x\"", "%", "x", "for", "x", "in", "reversed", "(", "data", "[", ":", "6", "]", ")", ")", "return", "data", "[", "6", ":", "]" ]
Decode the MAC address from a byte array. This will take the first 6 bytes from data and transform them into a MAC address string representation. This will be assigned to the attribute "val". It then returns the data stream minus the bytes consumed :param data: The data stream cont...
[ "Decode", "the", "MAC", "address", "from", "a", "byte", "array", "." ]
02d12e90db3ee6df7be6513fec171f20dc533de3
https://github.com/frawau/aioblescan/blob/02d12e90db3ee6df7be6513fec171f20dc533de3/aioblescan/aioblescan.py#L75-L88
train
django-leonardo/django-leonardo
leonardo/templatetags/thumbnail.py
thumbnail
def thumbnail(parser, token): ''' This template tag supports both syntax for declare thumbanil in template ''' thumb = None if SORL: try: thumb = sorl_thumb(parser, token) except Exception: thumb = False if EASY and not thumb: thumb = easy_thumb...
python
def thumbnail(parser, token): ''' This template tag supports both syntax for declare thumbanil in template ''' thumb = None if SORL: try: thumb = sorl_thumb(parser, token) except Exception: thumb = False if EASY and not thumb: thumb = easy_thumb...
[ "def", "thumbnail", "(", "parser", ",", "token", ")", ":", "thumb", "=", "None", "if", "SORL", ":", "try", ":", "thumb", "=", "sorl_thumb", "(", "parser", ",", "token", ")", "except", "Exception", ":", "thumb", "=", "False", "if", "EASY", "and", "not...
This template tag supports both syntax for declare thumbanil in template
[ "This", "template", "tag", "supports", "both", "syntax", "for", "declare", "thumbanil", "in", "template" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/templatetags/thumbnail.py#L18-L34
train
django-leonardo/django-leonardo
leonardo/module/media/utils.py
handle_uploaded_file
def handle_uploaded_file(file, folder=None, is_public=True): '''handle uploaded file to folder match first media type and create media object and returns it file: File object folder: str or Folder isinstance is_public: boolean ''' _folder = None if folder and isinstance(folder, Folder)...
python
def handle_uploaded_file(file, folder=None, is_public=True): '''handle uploaded file to folder match first media type and create media object and returns it file: File object folder: str or Folder isinstance is_public: boolean ''' _folder = None if folder and isinstance(folder, Folder)...
[ "def", "handle_uploaded_file", "(", "file", ",", "folder", "=", "None", ",", "is_public", "=", "True", ")", ":", "_folder", "=", "None", "if", "folder", "and", "isinstance", "(", "folder", ",", "Folder", ")", ":", "_folder", "=", "folder", "elif", "folde...
handle uploaded file to folder match first media type and create media object and returns it file: File object folder: str or Folder isinstance is_public: boolean
[ "handle", "uploaded", "file", "to", "folder", "match", "first", "media", "type", "and", "create", "media", "object", "and", "returns", "it" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/utils.py#L5-L33
train
django-leonardo/django-leonardo
leonardo/module/media/utils.py
handle_uploaded_files
def handle_uploaded_files(files, folder=None, is_public=True): '''handle uploaded files to folder files: array of File objects or single object folder: str or Folder isinstance is_public: boolean ''' results = [] for f in files: result = handle_uploaded_file(f, folder, is_public) ...
python
def handle_uploaded_files(files, folder=None, is_public=True): '''handle uploaded files to folder files: array of File objects or single object folder: str or Folder isinstance is_public: boolean ''' results = [] for f in files: result = handle_uploaded_file(f, folder, is_public) ...
[ "def", "handle_uploaded_files", "(", "files", ",", "folder", "=", "None", ",", "is_public", "=", "True", ")", ":", "results", "=", "[", "]", "for", "f", "in", "files", ":", "result", "=", "handle_uploaded_file", "(", "f", ",", "folder", ",", "is_public",...
handle uploaded files to folder files: array of File objects or single object folder: str or Folder isinstance is_public: boolean
[ "handle", "uploaded", "files", "to", "folder" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/utils.py#L36-L48
train
django-leonardo/django-leonardo
leonardo/module/media/server/views.py
serve_protected_file
def serve_protected_file(request, path): """ Serve protected files to authenticated users with read permissions. """ path = path.rstrip('/') try: file_obj = File.objects.get(file=path) except File.DoesNotExist: raise Http404('File not found %s' % path) if not file_obj.has_rea...
python
def serve_protected_file(request, path): """ Serve protected files to authenticated users with read permissions. """ path = path.rstrip('/') try: file_obj = File.objects.get(file=path) except File.DoesNotExist: raise Http404('File not found %s' % path) if not file_obj.has_rea...
[ "def", "serve_protected_file", "(", "request", ",", "path", ")", ":", "path", "=", "path", ".", "rstrip", "(", "'/'", ")", "try", ":", "file_obj", "=", "File", ".", "objects", ".", "get", "(", "file", "=", "path", ")", "except", "File", ".", "DoesNot...
Serve protected files to authenticated users with read permissions.
[ "Serve", "protected", "files", "to", "authenticated", "users", "with", "read", "permissions", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/server/views.py#L14-L28
train
django-leonardo/django-leonardo
leonardo/module/media/server/views.py
serve_protected_thumbnail
def serve_protected_thumbnail(request, path): """ Serve protected thumbnails to authenticated users. If the user doesn't have read permissions, redirect to a static image. """ source_path = thumbnail_to_original_filename(path) if not source_path: raise Http404('File not found') try: ...
python
def serve_protected_thumbnail(request, path): """ Serve protected thumbnails to authenticated users. If the user doesn't have read permissions, redirect to a static image. """ source_path = thumbnail_to_original_filename(path) if not source_path: raise Http404('File not found') try: ...
[ "def", "serve_protected_thumbnail", "(", "request", ",", "path", ")", ":", "source_path", "=", "thumbnail_to_original_filename", "(", "path", ")", "if", "not", "source_path", ":", "raise", "Http404", "(", "'File not found'", ")", "try", ":", "file_obj", "=", "Fi...
Serve protected thumbnails to authenticated users. If the user doesn't have read permissions, redirect to a static image.
[ "Serve", "protected", "thumbnails", "to", "authenticated", "users", ".", "If", "the", "user", "doesn", "t", "have", "read", "permissions", "redirect", "to", "a", "static", "image", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/server/views.py#L31-L52
train
django-leonardo/django-leonardo
leonardo/base.py
Leonardo.get_app_modules
def get_app_modules(self, apps): """return array of imported leonardo modules for apps """ modules = getattr(self, "_modules", []) if not modules: from django.utils.module_loading import module_has_submodule # Try importing a modules from the module package ...
python
def get_app_modules(self, apps): """return array of imported leonardo modules for apps """ modules = getattr(self, "_modules", []) if not modules: from django.utils.module_loading import module_has_submodule # Try importing a modules from the module package ...
[ "def", "get_app_modules", "(", "self", ",", "apps", ")", ":", "modules", "=", "getattr", "(", "self", ",", "\"_modules\"", ",", "[", "]", ")", "if", "not", "modules", ":", "from", "django", ".", "utils", ".", "module_loading", "import", "module_has_submodu...
return array of imported leonardo modules for apps
[ "return", "array", "of", "imported", "leonardo", "modules", "for", "apps" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/base.py#L47-L80
train
django-leonardo/django-leonardo
leonardo/base.py
Leonardo.urlpatterns
def urlpatterns(self): '''load and decorate urls from all modules then store it as cached property for less loading ''' if not hasattr(self, '_urlspatterns'): urlpatterns = [] # load all urls # support .urls file and urls_conf = 'elephantblog.urls' on ...
python
def urlpatterns(self): '''load and decorate urls from all modules then store it as cached property for less loading ''' if not hasattr(self, '_urlspatterns'): urlpatterns = [] # load all urls # support .urls file and urls_conf = 'elephantblog.urls' on ...
[ "def", "urlpatterns", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_urlspatterns'", ")", ":", "urlpatterns", "=", "[", "]", "for", "mod", "in", "leonardo", ".", "modules", ":", "if", "is_leonardo_module", "(", "mod", ")", ":", "co...
load and decorate urls from all modules then store it as cached property for less loading
[ "load", "and", "decorate", "urls", "from", "all", "modules", "then", "store", "it", "as", "cached", "property", "for", "less", "loading" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/base.py#L83-L132
train
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
cycle_app_reverse_cache
def cycle_app_reverse_cache(*args, **kwargs): """Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys""" value = '%07x' % (SystemRandom().randint(0, 0x10000000)) cache.se...
python
def cycle_app_reverse_cache(*args, **kwargs): """Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys""" value = '%07x' % (SystemRandom().randint(0, 0x10000000)) cache.se...
[ "def", "cycle_app_reverse_cache", "(", "*", "args", ",", "**", "kwargs", ")", ":", "value", "=", "'%07x'", "%", "(", "SystemRandom", "(", ")", ".", "randint", "(", "0", ",", "0x10000000", ")", ")", "cache", ".", "set", "(", "APP_REVERSE_CACHE_GENERATION_KE...
Does not really empty the cache; instead it adds a random element to the cache key generation which guarantees that the cache does not yet contain values for all newly generated keys
[ "Does", "not", "really", "empty", "the", "cache", ";", "instead", "it", "adds", "a", "random", "element", "to", "the", "cache", "key", "generation", "which", "guarantees", "that", "the", "cache", "does", "not", "yet", "contain", "values", "for", "all", "ne...
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L31-L37
train
django-leonardo/django-leonardo
leonardo/module/web/widget/application/reverse.py
reverse
def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None): """monkey patched reverse path supports easy patching 3rd party urls if 3rd party app has namespace for example ``catalogue`` and you create FeinCMS plugin with same name as this namespace reverse returns url from Applic...
python
def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None): """monkey patched reverse path supports easy patching 3rd party urls if 3rd party app has namespace for example ``catalogue`` and you create FeinCMS plugin with same name as this namespace reverse returns url from Applic...
[ "def", "reverse", "(", "viewname", ",", "urlconf", "=", "None", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "current_app", "=", "None", ")", ":", "if", "not", "urlconf", ":", "urlconf", "=", "get_urlconf", "(", ")", "resolver", "=", "g...
monkey patched reverse path supports easy patching 3rd party urls if 3rd party app has namespace for example ``catalogue`` and you create FeinCMS plugin with same name as this namespace reverse returns url from ApplicationContent !
[ "monkey", "patched", "reverse" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widget/application/reverse.py#L128-L209
train
django-leonardo/django-leonardo
leonardo/module/web/processors/page.py
add_page_if_missing
def add_page_if_missing(request): """ Returns ``feincms_page`` for request. """ try: page = Page.objects.for_request(request, best_match=True) return { 'leonardo_page': page, # DEPRECATED 'feincms_page': page, } except Page.DoesNotExist: ...
python
def add_page_if_missing(request): """ Returns ``feincms_page`` for request. """ try: page = Page.objects.for_request(request, best_match=True) return { 'leonardo_page': page, # DEPRECATED 'feincms_page': page, } except Page.DoesNotExist: ...
[ "def", "add_page_if_missing", "(", "request", ")", ":", "try", ":", "page", "=", "Page", ".", "objects", ".", "for_request", "(", "request", ",", "best_match", "=", "True", ")", "return", "{", "'leonardo_page'", ":", "page", ",", "'feincms_page'", ":", "pa...
Returns ``feincms_page`` for request.
[ "Returns", "feincms_page", "for", "request", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/processors/page.py#L5-L18
train
django-leonardo/django-leonardo
leonardo/views/defaults.py
render_in_page
def render_in_page(request, template): """return rendered template in standalone mode or ``False`` """ from leonardo.module.web.models import Page page = request.leonardo_page if hasattr( request, 'leonardo_page') else Page.objects.filter(parent=None).first() if page: try: ...
python
def render_in_page(request, template): """return rendered template in standalone mode or ``False`` """ from leonardo.module.web.models import Page page = request.leonardo_page if hasattr( request, 'leonardo_page') else Page.objects.filter(parent=None).first() if page: try: ...
[ "def", "render_in_page", "(", "request", ",", "template", ")", ":", "from", "leonardo", ".", "module", ".", "web", ".", "models", "import", "Page", "page", "=", "request", ".", "leonardo_page", "if", "hasattr", "(", "request", ",", "'leonardo_page'", ")", ...
return rendered template in standalone mode or ``False``
[ "return", "rendered", "template", "in", "standalone", "mode", "or", "False" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L11-L38
train
django-leonardo/django-leonardo
leonardo/views/defaults.py
page_not_found
def page_not_found(request, template_name='404.html'): """ Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ response = render_in_page(request, template_name) if response: ...
python
def page_not_found(request, template_name='404.html'): """ Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ response = render_in_page(request, template_name) if response: ...
[ "def", "page_not_found", "(", "request", ",", "template_name", "=", "'404.html'", ")", ":", "response", "=", "render_in_page", "(", "request", ",", "template_name", ")", "if", "response", ":", "return", "response", "template", "=", "Template", "(", "'<h1>Not Fou...
Default 404 handler. Templates: :template:`404.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/')
[ "Default", "404", "handler", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L45-L64
train
django-leonardo/django-leonardo
leonardo/views/defaults.py
bad_request
def bad_request(request, template_name='400.html'): """ 400 error handler. Templates: :template:`400.html` Context: None """ response = render_in_page(request, template_name) if response: return response try: template = loader.get_template(template_name) except Te...
python
def bad_request(request, template_name='400.html'): """ 400 error handler. Templates: :template:`400.html` Context: None """ response = render_in_page(request, template_name) if response: return response try: template = loader.get_template(template_name) except Te...
[ "def", "bad_request", "(", "request", ",", "template_name", "=", "'400.html'", ")", ":", "response", "=", "render_in_page", "(", "request", ",", "template_name", ")", "if", "response", ":", "return", "response", "try", ":", "template", "=", "loader", ".", "g...
400 error handler. Templates: :template:`400.html` Context: None
[ "400", "error", "handler", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/views/defaults.py#L89-L106
train
django-leonardo/django-leonardo
leonardo/module/web/middlewares/horizon.py
HorizonMiddleware.process_response
def process_response(self, request, response): """Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url """ if request.is_ajax() and hasattr(request, 'horizon'): queued_msgs = request.horizon['async_messages'] i...
python
def process_response(self, request, response): """Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url """ if request.is_ajax() and hasattr(request, 'horizon'): queued_msgs = request.horizon['async_messages'] i...
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ")", ":", "if", "request", ".", "is_ajax", "(", ")", "and", "hasattr", "(", "request", ",", "'horizon'", ")", ":", "queued_msgs", "=", "request", ".", "horizon", "[", "'async_messages...
Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url
[ "Convert", "HttpResponseRedirect", "to", "HttpResponse", "if", "request", "is", "via", "ajax", "to", "allow", "ajax", "request", "to", "redirect", "url" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/middlewares/horizon.py#L96-L143
train
django-leonardo/django-leonardo
leonardo/module/web/middlewares/horizon.py
HorizonMiddleware.process_exception
def process_exception(self, request, exception): """Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully. """ if isinstance(exception, (exceptions.NotAuthorized, exceptions.NotAuthenticated))...
python
def process_exception(self, request, exception): """Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully. """ if isinstance(exception, (exceptions.NotAuthorized, exceptions.NotAuthenticated))...
[ "def", "process_exception", "(", "self", ",", "request", ",", "exception", ")", ":", "if", "isinstance", "(", "exception", ",", "(", "exceptions", ".", "NotAuthorized", ",", "exceptions", ".", "NotAuthenticated", ")", ")", ":", "auth_url", "=", "settings", "...
Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully.
[ "Catches", "internal", "Horizon", "exception", "classes", "such", "as", "NotAuthorized", "NotFound", "and", "Http302", "and", "handles", "them", "gracefully", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/middlewares/horizon.py#L145-L195
train
django-leonardo/django-leonardo
leonardo/module/media/views.py
canonical
def canonical(request, uploaded_at, file_id): """ Redirect to the current url of a public file """ filer_file = get_object_or_404(File, pk=file_id, is_public=True) if (uploaded_at != filer_file.uploaded_at.strftime('%s') or not filer_file.file): raise Http404('No %s matches the g...
python
def canonical(request, uploaded_at, file_id): """ Redirect to the current url of a public file """ filer_file = get_object_or_404(File, pk=file_id, is_public=True) if (uploaded_at != filer_file.uploaded_at.strftime('%s') or not filer_file.file): raise Http404('No %s matches the g...
[ "def", "canonical", "(", "request", ",", "uploaded_at", ",", "file_id", ")", ":", "filer_file", "=", "get_object_or_404", "(", "File", ",", "pk", "=", "file_id", ",", "is_public", "=", "True", ")", "if", "(", "uploaded_at", "!=", "filer_file", ".", "upload...
Redirect to the current url of a public file
[ "Redirect", "to", "the", "current", "url", "of", "a", "public", "file" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/media/views.py#L77-L86
train
django-leonardo/django-leonardo
leonardo/exceptions.py
check_message
def check_message(keywords, message): """Checks an exception for given keywords and raises a new ``ActionError`` with the desired message if the keywords are found. This allows selective control over API error messages. """ exc_type, exc_value, exc_traceback = sys.exc_info() if set(str(exc_value...
python
def check_message(keywords, message): """Checks an exception for given keywords and raises a new ``ActionError`` with the desired message if the keywords are found. This allows selective control over API error messages. """ exc_type, exc_value, exc_traceback = sys.exc_info() if set(str(exc_value...
[ "def", "check_message", "(", "keywords", ",", "message", ")", ":", "exc_type", ",", "exc_value", ",", "exc_traceback", "=", "sys", ".", "exc_info", "(", ")", "if", "set", "(", "str", "(", "exc_value", ")", ".", "split", "(", "\" \"", ")", ")", ".", "...
Checks an exception for given keywords and raises a new ``ActionError`` with the desired message if the keywords are found. This allows selective control over API error messages.
[ "Checks", "an", "exception", "for", "given", "keywords", "and", "raises", "a", "new", "ActionError", "with", "the", "desired", "message", "if", "the", "keywords", "are", "found", ".", "This", "allows", "selective", "control", "over", "API", "error", "messages"...
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/exceptions.py#L142-L150
train
django-leonardo/django-leonardo
leonardo/module/web/page/forms.py
SwitchableFormFieldMixin.get_switched_form_field_attrs
def get_switched_form_field_attrs(self, prefix, input_type, name): """Creates attribute dicts for the switchable theme form """ attributes = {'class': 'switched', 'data-switch-on': prefix + 'field'} attributes['data-' + prefix + 'field-' + input_type] = name return attributes
python
def get_switched_form_field_attrs(self, prefix, input_type, name): """Creates attribute dicts for the switchable theme form """ attributes = {'class': 'switched', 'data-switch-on': prefix + 'field'} attributes['data-' + prefix + 'field-' + input_type] = name return attributes
[ "def", "get_switched_form_field_attrs", "(", "self", ",", "prefix", ",", "input_type", ",", "name", ")", ":", "attributes", "=", "{", "'class'", ":", "'switched'", ",", "'data-switch-on'", ":", "prefix", "+", "'field'", "}", "attributes", "[", "'data-'", "+", ...
Creates attribute dicts for the switchable theme form
[ "Creates", "attribute", "dicts", "for", "the", "switchable", "theme", "form" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/forms.py#L23-L28
train
django-leonardo/django-leonardo
leonardo/module/web/page/forms.py
PageCreateForm.clean_slug
def clean_slug(self): """slug title if is not provided """ slug = self.cleaned_data.get('slug', None) if slug is None or len(slug) == 0 and 'title' in self.cleaned_data: slug = slugify(self.cleaned_data['title']) return slug
python
def clean_slug(self): """slug title if is not provided """ slug = self.cleaned_data.get('slug', None) if slug is None or len(slug) == 0 and 'title' in self.cleaned_data: slug = slugify(self.cleaned_data['title']) return slug
[ "def", "clean_slug", "(", "self", ")", ":", "slug", "=", "self", ".", "cleaned_data", ".", "get", "(", "'slug'", ",", "None", ")", "if", "slug", "is", "None", "or", "len", "(", "slug", ")", "==", "0", "and", "'title'", "in", "self", ".", "cleaned_d...
slug title if is not provided
[ "slug", "title", "if", "is", "not", "provided" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/page/forms.py#L90-L96
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/utils.py
get_widget_from_id
def get_widget_from_id(id): """returns widget object by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[0], res[1]) obj = model_cls.objects.get(parent=res[2], id=res[3]) except: obj = None return obj
python
def get_widget_from_id(id): """returns widget object by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[0], res[1]) obj = model_cls.objects.get(parent=res[2], id=res[3]) except: obj = None return obj
[ "def", "get_widget_from_id", "(", "id", ")", ":", "res", "=", "id", ".", "split", "(", "'-'", ")", "try", ":", "model_cls", "=", "apps", ".", "get_model", "(", "res", "[", "0", "]", ",", "res", "[", "1", "]", ")", "obj", "=", "model_cls", ".", ...
returns widget object by id example web-htmltextwidget-2-2
[ "returns", "widget", "object", "by", "id" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/utils.py#L4-L16
train
django-leonardo/django-leonardo
leonardo/module/web/widgets/utils.py
get_widget_class_from_id
def get_widget_class_from_id(id): """returns widget class by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[1], res[2]) except: model_cls = None return model_cls
python
def get_widget_class_from_id(id): """returns widget class by id example web-htmltextwidget-2-2 """ res = id.split('-') try: model_cls = apps.get_model(res[1], res[2]) except: model_cls = None return model_cls
[ "def", "get_widget_class_from_id", "(", "id", ")", ":", "res", "=", "id", ".", "split", "(", "'-'", ")", "try", ":", "model_cls", "=", "apps", ".", "get_model", "(", "res", "[", "1", "]", ",", "res", "[", "2", "]", ")", "except", ":", "model_cls", ...
returns widget class by id example web-htmltextwidget-2-2
[ "returns", "widget", "class", "by", "id" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/widgets/utils.py#L19-L30
train
django-leonardo/django-leonardo
leonardo/module/web/processors/edit.py
frontendediting_request_processor
def frontendediting_request_processor(page, request): """ Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions. """ if 'frontend_editing' not in request.GET: return response = HttpResponseRedirect(request.path) ...
python
def frontendediting_request_processor(page, request): """ Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions. """ if 'frontend_editing' not in request.GET: return response = HttpResponseRedirect(request.path) ...
[ "def", "frontendediting_request_processor", "(", "page", ",", "request", ")", ":", "if", "'frontend_editing'", "not", "in", "request", ".", "GET", ":", "return", "response", "=", "HttpResponseRedirect", "(", "request", ".", "path", ")", "if", "request", ".", "...
Sets the frontend editing state in the cookie depending on the ``frontend_editing`` GET parameter and the user's permissions.
[ "Sets", "the", "frontend", "editing", "state", "in", "the", "cookie", "depending", "on", "the", "frontend_editing", "GET", "parameter", "and", "the", "user", "s", "permissions", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/processors/edit.py#L11-L40
train
django-leonardo/django-leonardo
leonardo/module/web/__init__.py
Default.extra_context
def extra_context(self): """Add site_name to context """ from django.conf import settings return { "site_name": (lambda r: settings.LEONARDO_SITE_NAME if getattr(settings, 'LEONARDO_SITE_NAME', '') != '' else settings.SITE_...
python
def extra_context(self): """Add site_name to context """ from django.conf import settings return { "site_name": (lambda r: settings.LEONARDO_SITE_NAME if getattr(settings, 'LEONARDO_SITE_NAME', '') != '' else settings.SITE_...
[ "def", "extra_context", "(", "self", ")", ":", "from", "django", ".", "conf", "import", "settings", "return", "{", "\"site_name\"", ":", "(", "lambda", "r", ":", "settings", ".", "LEONARDO_SITE_NAME", "if", "getattr", "(", "settings", ",", "'LEONARDO_SITE_NAME...
Add site_name to context
[ "Add", "site_name", "to", "context" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/module/web/__init__.py#L113-L123
train
django-leonardo/django-leonardo
leonardo/conf/base.py
ModuleConfig.get_property
def get_property(self, key): """Expect Django Conf property""" _key = DJANGO_CONF[key] return getattr(self, _key, CONF_SPEC[_key])
python
def get_property(self, key): """Expect Django Conf property""" _key = DJANGO_CONF[key] return getattr(self, _key, CONF_SPEC[_key])
[ "def", "get_property", "(", "self", ",", "key", ")", ":", "_key", "=", "DJANGO_CONF", "[", "key", "]", "return", "getattr", "(", "self", ",", "_key", ",", "CONF_SPEC", "[", "_key", "]", ")" ]
Expect Django Conf property
[ "Expect", "Django", "Conf", "property" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L21-L24
train
django-leonardo/django-leonardo
leonardo/conf/base.py
ModuleConfig.needs_sync
def needs_sync(self): """Indicates whater module needs templates, static etc.""" affected_attributes = [ 'css_files', 'js_files', 'scss_files', 'widgets'] for attr in affected_attributes: if len(getattr(self, attr)) > 0: return True r...
python
def needs_sync(self): """Indicates whater module needs templates, static etc.""" affected_attributes = [ 'css_files', 'js_files', 'scss_files', 'widgets'] for attr in affected_attributes: if len(getattr(self, attr)) > 0: return True r...
[ "def", "needs_sync", "(", "self", ")", ":", "affected_attributes", "=", "[", "'css_files'", ",", "'js_files'", ",", "'scss_files'", ",", "'widgets'", "]", "for", "attr", "in", "affected_attributes", ":", "if", "len", "(", "getattr", "(", "self", ",", "attr",...
Indicates whater module needs templates, static etc.
[ "Indicates", "whater", "module", "needs", "templates", "static", "etc", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L60-L70
train
django-leonardo/django-leonardo
leonardo/conf/base.py
LeonardoConfig.get_attr
def get_attr(self, name, default=None, fail_silently=True): """try extra context """ try: return getattr(self, name) except KeyError: extra_context = getattr(self, "extra_context") if name in extra_context: value = extra_context[name] ...
python
def get_attr(self, name, default=None, fail_silently=True): """try extra context """ try: return getattr(self, name) except KeyError: extra_context = getattr(self, "extra_context") if name in extra_context: value = extra_context[name] ...
[ "def", "get_attr", "(", "self", ",", "name", ",", "default", "=", "None", ",", "fail_silently", "=", "True", ")", ":", "try", ":", "return", "getattr", "(", "self", ",", "name", ")", "except", "KeyError", ":", "extra_context", "=", "getattr", "(", "sel...
try extra context
[ "try", "extra", "context" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/conf/base.py#L93-L107
train
django-leonardo/django-leonardo
leonardo/utils/templates.py
find_all_templates
def find_all_templates(pattern='*.html', ignore_private=True): """ Finds all Django templates matching given glob in all TEMPLATE_LOADERS :param str pattern: `glob <http://docs.python.org/2/library/glob.html>`_ to match .. important:: At the moment egg loader is not supported. ...
python
def find_all_templates(pattern='*.html', ignore_private=True): """ Finds all Django templates matching given glob in all TEMPLATE_LOADERS :param str pattern: `glob <http://docs.python.org/2/library/glob.html>`_ to match .. important:: At the moment egg loader is not supported. ...
[ "def", "find_all_templates", "(", "pattern", "=", "'*.html'", ",", "ignore_private", "=", "True", ")", ":", "templates", "=", "[", "]", "template_loaders", "=", "flatten_template_loaders", "(", "settings", ".", "TEMPLATE_LOADERS", ")", "for", "loader_name", "in", ...
Finds all Django templates matching given glob in all TEMPLATE_LOADERS :param str pattern: `glob <http://docs.python.org/2/library/glob.html>`_ to match .. important:: At the moment egg loader is not supported.
[ "Finds", "all", "Django", "templates", "matching", "given", "glob", "in", "all", "TEMPLATE_LOADERS" ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/templates.py#L40-L75
train
django-leonardo/django-leonardo
leonardo/utils/templates.py
flatten_template_loaders
def flatten_template_loaders(templates): """ Given a collection of template loaders, unwrap them into one flat iterable. :param templates: template loaders to unwrap :return: template loaders as an iterable of strings. :rtype: generator expression """ for loader in templates: if not...
python
def flatten_template_loaders(templates): """ Given a collection of template loaders, unwrap them into one flat iterable. :param templates: template loaders to unwrap :return: template loaders as an iterable of strings. :rtype: generator expression """ for loader in templates: if not...
[ "def", "flatten_template_loaders", "(", "templates", ")", ":", "for", "loader", "in", "templates", ":", "if", "not", "isinstance", "(", "loader", ",", "string_types", ")", ":", "for", "subloader", "in", "flatten_template_loaders", "(", "loader", ")", ":", "yie...
Given a collection of template loaders, unwrap them into one flat iterable. :param templates: template loaders to unwrap :return: template loaders as an iterable of strings. :rtype: generator expression
[ "Given", "a", "collection", "of", "template", "loaders", "unwrap", "them", "into", "one", "flat", "iterable", "." ]
4b933e1792221a13b4028753d5f1d3499b0816d4
https://github.com/django-leonardo/django-leonardo/blob/4b933e1792221a13b4028753d5f1d3499b0816d4/leonardo/utils/templates.py#L78-L91
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/file.py
SeekableFileProxy.seek
def seek(self, offset, whence=os.SEEK_SET): """Sets the file's current position. :param offset: the offset to set :type offset: :class:`numbers.Integral` :param whence: see the docs of :meth:`file.seek()`. default is :const:`os.SEEK_SET` """ self....
python
def seek(self, offset, whence=os.SEEK_SET): """Sets the file's current position. :param offset: the offset to set :type offset: :class:`numbers.Integral` :param whence: see the docs of :meth:`file.seek()`. default is :const:`os.SEEK_SET` """ self....
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "os", ".", "SEEK_SET", ")", ":", "self", ".", "wrapped", ".", "seek", "(", "offset", ",", "whence", ")" ]
Sets the file's current position. :param offset: the offset to set :type offset: :class:`numbers.Integral` :param whence: see the docs of :meth:`file.seek()`. default is :const:`os.SEEK_SET`
[ "Sets", "the", "file", "s", "current", "position", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/file.py#L138-L147
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.put_file
def put_file(self, file, object_type, object_id, width, height, mimetype, reproducible): """Puts the ``file`` of the image. :param file: the image file to put :type file: file-like object, :class:`file` :param object_type: the object type of the image to put ...
python
def put_file(self, file, object_type, object_id, width, height, mimetype, reproducible): """Puts the ``file`` of the image. :param file: the image file to put :type file: file-like object, :class:`file` :param object_type: the object type of the image to put ...
[ "def", "put_file", "(", "self", ",", "file", ",", "object_type", ",", "object_id", ",", "width", ",", "height", ",", "mimetype", ",", "reproducible", ")", ":", "raise", "NotImplementedError", "(", "'put_file() has to be implemented'", ")" ]
Puts the ``file`` of the image. :param file: the image file to put :type file: file-like object, :class:`file` :param object_type: the object type of the image to put e.g. ``'comics.cover'`` :type object_type: :class:`str` :param object_id: the object...
[ "Puts", "the", "file", "of", "the", "image", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L29-L62
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.delete
def delete(self, image): """Delete the file of the given ``image``. :param image: the image to delete :type image: :class:`sqlalchemy_imageattach.entity.Image` """ from .entity import Image if not isinstance(image, Image): raise TypeError('image must be a sq...
python
def delete(self, image): """Delete the file of the given ``image``. :param image: the image to delete :type image: :class:`sqlalchemy_imageattach.entity.Image` """ from .entity import Image if not isinstance(image, Image): raise TypeError('image must be a sq...
[ "def", "delete", "(", "self", ",", "image", ")", ":", "from", ".", "entity", "import", "Image", "if", "not", "isinstance", "(", "image", ",", "Image", ")", ":", "raise", "TypeError", "(", "'image must be a sqlalchemy_imageattach.entity.'", "'Image instance, not '"...
Delete the file of the given ``image``. :param image: the image to delete :type image: :class:`sqlalchemy_imageattach.entity.Image`
[ "Delete", "the", "file", "of", "the", "given", "image", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L167-L179
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/store.py
Store.locate
def locate(self, image): """Gets the URL of the given ``image``. :param image: the image to get its url :type image: :class:`sqlalchemy_imageattach.entity.Image` :returns: the url of the image :rtype: :class:`str` """ from .entity import Image if not isi...
python
def locate(self, image): """Gets the URL of the given ``image``. :param image: the image to get its url :type image: :class:`sqlalchemy_imageattach.entity.Image` :returns: the url of the image :rtype: :class:`str` """ from .entity import Image if not isi...
[ "def", "locate", "(", "self", ",", "image", ")", ":", "from", ".", "entity", "import", "Image", "if", "not", "isinstance", "(", "image", ",", "Image", ")", ":", "raise", "TypeError", "(", "'image must be a sqlalchemy_imageattach.entity.'", "'Image instance, not '"...
Gets the URL of the given ``image``. :param image: the image to get its url :type image: :class:`sqlalchemy_imageattach.entity.Image` :returns: the url of the image :rtype: :class:`str`
[ "Gets", "the", "URL", "of", "the", "given", "image", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/store.py#L256-L275
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.identity_attributes
def identity_attributes(cls): """A list of the names of primary key fields. :returns: A list of the names of primary key fields :rtype: :class:`typing.Sequence`\ [:class:`str`] .. versionadded:: 1.0.0 """ columns = inspect(cls).primary_key names = [c.name for c...
python
def identity_attributes(cls): """A list of the names of primary key fields. :returns: A list of the names of primary key fields :rtype: :class:`typing.Sequence`\ [:class:`str`] .. versionadded:: 1.0.0 """ columns = inspect(cls).primary_key names = [c.name for c...
[ "def", "identity_attributes", "(", "cls", ")", ":", "columns", "=", "inspect", "(", "cls", ")", ".", "primary_key", "names", "=", "[", "c", ".", "name", "for", "c", "in", "columns", "if", "c", ".", "name", "not", "in", "(", "'width'", ",", "'height'"...
A list of the names of primary key fields. :returns: A list of the names of primary key fields :rtype: :class:`typing.Sequence`\ [:class:`str`] .. versionadded:: 1.0.0
[ "A", "list", "of", "the", "names", "of", "primary", "key", "fields", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L215-L226
train
dahlia/sqlalchemy-imageattach
sqlalchemy_imageattach/entity.py
Image.make_blob
def make_blob(self, store=current_store): """Gets the byte string of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_im...
python
def make_blob(self, store=current_store): """Gets the byte string of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_im...
[ "def", "make_blob", "(", "self", ",", "store", "=", "current_store", ")", ":", "with", "self", ".", "open_file", "(", "store", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Gets the byte string of the image from the ``store``. :param store: the storage which contains the image. :data:`~sqlalchemy_imageattach.context.current_store` by default :type store: :class:`~sqlalchemy_imageattach.store.Store` :returns: the binary d...
[ "Gets", "the", "byte", "string", "of", "the", "image", "from", "the", "store", "." ]
b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8
https://github.com/dahlia/sqlalchemy-imageattach/blob/b4bafa73f3bb576ecf67ed7b40b702704a0fbdc8/sqlalchemy_imageattach/entity.py#L275-L287
train