partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
JsLinkProvider.build_default_filepath
Called when 'filepath' is not defined in the settings
django_mako_plus/provider/link.py
def build_default_filepath(self): '''Called when 'filepath' is not defined in the settings''' return os.path.join( self.app_config.name, 'scripts', self.template_relpath + '.js', )
def build_default_filepath(self): '''Called when 'filepath' is not defined in the settings''' return os.path.join( self.app_config.name, 'scripts', self.template_relpath + '.js', )
[ "Called", "when", "filepath", "is", "not", "defined", "in", "the", "settings" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/link.py#L180-L186
[ "def", "build_default_filepath", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "app_config", ".", "name", ",", "'scripts'", ",", "self", ".", "template_relpath", "+", "'.js'", ",", ")" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
django_include
Mako tag to include a Django template withing the current DMP (Mako) template. Since this is a Django template, it is search for using the Django search algorithm (instead of the DMP app-based concept). See https://docs.djangoproject.com/en/2.1/topics/templates/. The current context is sent to the incl...
django_mako_plus/tags.py
def django_include(context, template_name, **kwargs): ''' Mako tag to include a Django template withing the current DMP (Mako) template. Since this is a Django template, it is search for using the Django search algorithm (instead of the DMP app-based concept). See https://docs.djangoproject.com/en/2...
def django_include(context, template_name, **kwargs): ''' Mako tag to include a Django template withing the current DMP (Mako) template. Since this is a Django template, it is search for using the Django search algorithm (instead of the DMP app-based concept). See https://docs.djangoproject.com/en/2...
[ "Mako", "tag", "to", "include", "a", "Django", "template", "withing", "the", "current", "DMP", "(", "Mako", ")", "template", ".", "Since", "this", "is", "a", "Django", "template", "it", "is", "search", "for", "using", "the", "Django", "search", "algorithm"...
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/tags.py#L14-L33
[ "def", "django_include", "(", "context", ",", "template_name", ",", "*", "*", "kwargs", ")", ":", "try", ":", "djengine", "=", "engines", "[", "'django'", "]", "except", "KeyError", "as", "e", ":", "raise", "TemplateDoesNotExist", "(", "\"Django template engin...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
_toggle_autoescape
Internal method to toggle autoescaping on or off. This function needs access to the caller, so the calling method must be decorated with @supports_caller.
django_mako_plus/tags.py
def _toggle_autoescape(context, escape_on=True): ''' Internal method to toggle autoescaping on or off. This function needs access to the caller, so the calling method must be decorated with @supports_caller. ''' previous = is_autoescape(context) setattr(context.caller_stack, AUTOESCAPE_KEY, ...
def _toggle_autoescape(context, escape_on=True): ''' Internal method to toggle autoescaping on or off. This function needs access to the caller, so the calling method must be decorated with @supports_caller. ''' previous = is_autoescape(context) setattr(context.caller_stack, AUTOESCAPE_KEY, ...
[ "Internal", "method", "to", "toggle", "autoescaping", "on", "or", "off", ".", "This", "function", "needs", "access", "to", "the", "caller", "so", "the", "calling", "method", "must", "be", "decorated", "with" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/tags.py#L48-L59
[ "def", "_toggle_autoescape", "(", "context", ",", "escape_on", "=", "True", ")", ":", "previous", "=", "is_autoescape", "(", "context", ")", "setattr", "(", "context", ".", "caller_stack", ",", "AUTOESCAPE_KEY", ",", "escape_on", ")", "try", ":", "context", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
pretty_relpath
Returns a relative path, but only if it doesn't start with a non-pretty parent directory ".."
django_mako_plus/management/commands/dmp_cleanup.py
def pretty_relpath(path, start): ''' Returns a relative path, but only if it doesn't start with a non-pretty parent directory ".." ''' relpath = os.path.relpath(path, start) if relpath.startswith('..'): return path return relpath
def pretty_relpath(path, start): ''' Returns a relative path, but only if it doesn't start with a non-pretty parent directory ".." ''' relpath = os.path.relpath(path, start) if relpath.startswith('..'): return path return relpath
[ "Returns", "a", "relative", "path", "but", "only", "if", "it", "doesn", "t", "start", "with", "a", "non", "-", "pretty", "parent", "directory", ".." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_cleanup.py#L84-L91
[ "def", "pretty_relpath", "(", "path", ",", "start", ")", ":", "relpath", "=", "os", ".", "path", ".", "relpath", "(", "path", ",", "start", ")", "if", "relpath", ".", "startswith", "(", "'..'", ")", ":", "return", "path", "return", "relpath" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
view_function.is_decorated
Returns True if the given function is decorated with @view_function
django_mako_plus/router/decorators.py
def is_decorated(cls, f): '''Returns True if the given function is decorated with @view_function''' real_func = inspect.unwrap(f) return real_func in cls.DECORATED_FUNCTIONS
def is_decorated(cls, f): '''Returns True if the given function is decorated with @view_function''' real_func = inspect.unwrap(f) return real_func in cls.DECORATED_FUNCTIONS
[ "Returns", "True", "if", "the", "given", "function", "is", "decorated", "with" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/decorators.py#L56-L59
[ "def", "is_decorated", "(", "cls", ",", "f", ")", ":", "real_func", "=", "inspect", ".", "unwrap", "(", "f", ")", "return", "real_func", "in", "cls", ".", "DECORATED_FUNCTIONS" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
ProviderRun.initialize_providers
Initializes the providers (called from dmp app ready())
django_mako_plus/provider/runner.py
def initialize_providers(cls): '''Initializes the providers (called from dmp app ready())''' dmp = apps.get_app_config('django_mako_plus') # regular content providers cls.CONTENT_PROVIDERS = [] for provider_settings in dmp.options[cls.SETTINGS_KEY]: # import the class...
def initialize_providers(cls): '''Initializes the providers (called from dmp app ready())''' dmp = apps.get_app_config('django_mako_plus') # regular content providers cls.CONTENT_PROVIDERS = [] for provider_settings in dmp.options[cls.SETTINGS_KEY]: # import the class...
[ "Initializes", "the", "providers", "(", "called", "from", "dmp", "app", "ready", "()", ")" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/runner.py#L34-L52
[ "def", "initialize_providers", "(", "cls", ")", ":", "dmp", "=", "apps", ".", "get_app_config", "(", "'django_mako_plus'", ")", "# regular content providers", "cls", ".", "CONTENT_PROVIDERS", "=", "[", "]", "for", "provider_settings", "in", "dmp", ".", "options", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
ProviderRun.run
Performs the run through the templates and their providers
django_mako_plus/provider/runner.py
def run(self): '''Performs the run through the templates and their providers''' for tpl in self.templates: for provider in tpl.providers: provider.provide()
def run(self): '''Performs the run through the templates and their providers''' for tpl in self.templates: for provider in tpl.providers: provider.provide()
[ "Performs", "the", "run", "through", "the", "templates", "and", "their", "providers" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/runner.py#L87-L91
[ "def", "run", "(", "self", ")", ":", "for", "tpl", "in", "self", ".", "templates", ":", "for", "provider", "in", "tpl", ".", "providers", ":", "provider", ".", "provide", "(", ")" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
ProviderRun.write
Provider instances use this to write to the buffer
django_mako_plus/provider/runner.py
def write(self, content): '''Provider instances use this to write to the buffer''' self.buffer.write(content) if settings.DEBUG: self.buffer.write('\n')
def write(self, content): '''Provider instances use this to write to the buffer''' self.buffer.write(content) if settings.DEBUG: self.buffer.write('\n')
[ "Provider", "instances", "use", "this", "to", "write", "to", "the", "buffer" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/runner.py#L93-L97
[ "def", "write", "(", "self", ",", "content", ")", ":", "self", ".", "buffer", ".", "write", "(", "content", ")", "if", "settings", ".", "DEBUG", ":", "self", ".", "buffer", ".", "write", "(", "'\\n'", ")" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
ConverterFunctionInfo.prepare_sort_key
Triggered by view_function._sort_converters when our sort key should be created. This can't be called in the constructor because Django models might not be ready yet.
django_mako_plus/converter/info.py
def prepare_sort_key(self): ''' Triggered by view_function._sort_converters when our sort key should be created. This can't be called in the constructor because Django models might not be ready yet. ''' if isinstance(self.convert_type, str): try: app_n...
def prepare_sort_key(self): ''' Triggered by view_function._sort_converters when our sort key should be created. This can't be called in the constructor because Django models might not be ready yet. ''' if isinstance(self.convert_type, str): try: app_n...
[ "Triggered", "by", "view_function", ".", "_sort_converters", "when", "our", "sort", "key", "should", "be", "created", ".", "This", "can", "t", "be", "called", "in", "the", "constructor", "because", "Django", "models", "might", "not", "be", "ready", "yet", "....
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/info.py#L19-L36
[ "def", "prepare_sort_key", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "convert_type", ",", "str", ")", ":", "try", ":", "app_name", ",", "model_name", "=", "self", ".", "convert_type", ".", "split", "(", "'.'", ")", "except", "ValueErro...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
CompileProvider.build_command
Returns the command to run, as a list (see subprocess module)
django_mako_plus/provider/compile.py
def build_command(self): '''Returns the command to run, as a list (see subprocess module)''' # if defined in settings, run the function or return the string if self.options['command']: return self.options['command'](self) if callable(self.options['command']) else self.options['comman...
def build_command(self): '''Returns the command to run, as a list (see subprocess module)''' # if defined in settings, run the function or return the string if self.options['command']: return self.options['command'](self) if callable(self.options['command']) else self.options['comman...
[ "Returns", "the", "command", "to", "run", "as", "a", "list", "(", "see", "subprocess", "module", ")" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/compile.py#L104-L110
[ "def", "build_command", "(", "self", ")", ":", "# if defined in settings, run the function or return the string", "if", "self", ".", "options", "[", "'command'", "]", ":", "return", "self", ".", "options", "[", "'command'", "]", "(", "self", ")", "if", "callable",...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
CompileProvider.needs_compile
Returns True if self.sourcepath is newer than self.targetpath
django_mako_plus/provider/compile.py
def needs_compile(self): '''Returns True if self.sourcepath is newer than self.targetpath''' try: source_mtime = os.stat(self.sourcepath).st_mtime except OSError: # no source for this template, so just return return False try: target_mtime = os.stat(s...
def needs_compile(self): '''Returns True if self.sourcepath is newer than self.targetpath''' try: source_mtime = os.stat(self.sourcepath).st_mtime except OSError: # no source for this template, so just return return False try: target_mtime = os.stat(s...
[ "Returns", "True", "if", "self", ".", "sourcepath", "is", "newer", "than", "self", ".", "targetpath" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/provider/compile.py#L117-L128
[ "def", "needs_compile", "(", "self", ")", ":", "try", ":", "source_mtime", "=", "os", ".", "stat", "(", "self", ".", "sourcepath", ")", ".", "st_mtime", "except", "OSError", ":", "# no source for this template, so just return", "return", "False", "try", ":", "...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
template_inheritance
Generator that iterates the template and its ancestors. The order is from most specialized (furthest descendant) to most general (furthest ancestor). obj can be either: 1. Mako Template object 2. Mako `self` object (available within a rendering template)
django_mako_plus/template/util.py
def template_inheritance(obj): ''' Generator that iterates the template and its ancestors. The order is from most specialized (furthest descendant) to most general (furthest ancestor). obj can be either: 1. Mako Template object 2. Mako `self` object (available within a rendering tem...
def template_inheritance(obj): ''' Generator that iterates the template and its ancestors. The order is from most specialized (furthest descendant) to most general (furthest ancestor). obj can be either: 1. Mako Template object 2. Mako `self` object (available within a rendering tem...
[ "Generator", "that", "iterates", "the", "template", "and", "its", "ancestors", ".", "The", "order", "is", "from", "most", "specialized", "(", "furthest", "descendant", ")", "to", "most", "general", "(", "furthest", "ancestor", ")", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/util.py#L11-L27
[ "def", "template_inheritance", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "MakoTemplate", ")", ":", "obj", "=", "create_mako_context", "(", "obj", ")", "[", "'self'", "]", "elif", "isinstance", "(", "obj", ",", "MakoContext", ")", ":", "o...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
get_template_debug
This structure is what Django wants when errors occur in templates. It gives the user a nice stack trace in the error page during debug.
django_mako_plus/template/util.py
def get_template_debug(template_name, error): ''' This structure is what Django wants when errors occur in templates. It gives the user a nice stack trace in the error page during debug. ''' # This is taken from mako.exceptions.html_error_template(), which has an issue # in Py3 where files get l...
def get_template_debug(template_name, error): ''' This structure is what Django wants when errors occur in templates. It gives the user a nice stack trace in the error page during debug. ''' # This is taken from mako.exceptions.html_error_template(), which has an issue # in Py3 where files get l...
[ "This", "structure", "is", "what", "Django", "wants", "when", "errors", "occur", "in", "templates", ".", "It", "gives", "the", "user", "a", "nice", "stack", "trace", "in", "the", "error", "page", "during", "debug", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/util.py#L40-L170
[ "def", "get_template_debug", "(", "template_name", ",", "error", ")", ":", "# This is taken from mako.exceptions.html_error_template(), which has an issue", "# in Py3 where files get loaded as bytes but `lines = src.split('\\n')` below", "# splits with a string. Not sure if this is a bug or if I...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
MakoTemplateAdapter.name
Returns the name of this template (if created from a file) or "string" if not
django_mako_plus/template/adapter.py
def name(self): '''Returns the name of this template (if created from a file) or "string" if not''' if self.mako_template.filename: return os.path.basename(self.mako_template.filename) return 'string'
def name(self): '''Returns the name of this template (if created from a file) or "string" if not''' if self.mako_template.filename: return os.path.basename(self.mako_template.filename) return 'string'
[ "Returns", "the", "name", "of", "this", "template", "(", "if", "created", "from", "a", "file", ")", "or", "string", "if", "not" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/adapter.py#L39-L43
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "mako_template", ".", "filename", ":", "return", "os", ".", "path", ".", "basename", "(", "self", ".", "mako_template", ".", "filename", ")", "return", "'string'" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
MakoTemplateAdapter.render
Renders a template using the Mako system. This method signature conforms to the Django template API, which specifies that template.render() returns a string. @context A dictionary of name=value variables to send to the template page. This can be a real dictionary or a Djang...
django_mako_plus/template/adapter.py
def render(self, context=None, request=None, def_name=None): ''' Renders a template using the Mako system. This method signature conforms to the Django template API, which specifies that template.render() returns a string. @context A dictionary of name=value variables to send to t...
def render(self, context=None, request=None, def_name=None): ''' Renders a template using the Mako system. This method signature conforms to the Django template API, which specifies that template.render() returns a string. @context A dictionary of name=value variables to send to t...
[ "Renders", "a", "template", "using", "the", "Mako", "system", ".", "This", "method", "signature", "conforms", "to", "the", "Django", "template", "API", "which", "specifies", "that", "template", ".", "render", "()", "returns", "a", "string", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/adapter.py#L57-L131
[ "def", "render", "(", "self", ",", "context", "=", "None", ",", "request", "=", "None", ",", "def_name", "=", "None", ")", ":", "dmp", "=", "apps", ".", "get_app_config", "(", "'django_mako_plus'", ")", "# set up the context dictionary, which is the variables avai...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
MakoTemplateAdapter.render_to_response
Renders the template and returns an HttpRequest object containing its content. This method returns a django.http.Http404 exception if the template is not found. If the template raises a django_mako_plus.RedirectException, the browser is redirected to the given page, and a new request from the b...
django_mako_plus/template/adapter.py
def render_to_response(self, context=None, request=None, def_name=None, content_type=None, status=None, charset=None): ''' Renders the template and returns an HttpRequest object containing its content. This method returns a django.http.Http404 exception if the template is not found. If ...
def render_to_response(self, context=None, request=None, def_name=None, content_type=None, status=None, charset=None): ''' Renders the template and returns an HttpRequest object containing its content. This method returns a django.http.Http404 exception if the template is not found. If ...
[ "Renders", "the", "template", "and", "returns", "an", "HttpRequest", "object", "containing", "its", "content", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/template/adapter.py#L134-L184
[ "def", "render_to_response", "(", "self", ",", "context", "=", "None", ",", "request", "=", "None", ",", "def_name", "=", "None", ",", "content_type", "=", "None", ",", "status", "=", "None", ",", "charset", "=", "None", ")", ":", "try", ":", "if", "...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
DMPCommandMixIn.get_action_by_dest
Retrieves the given parser action object by its dest= attribute
django_mako_plus/management/mixins.py
def get_action_by_dest(self, parser, dest): '''Retrieves the given parser action object by its dest= attribute''' for action in parser._actions: if action.dest == dest: return action return None
def get_action_by_dest(self, parser, dest): '''Retrieves the given parser action object by its dest= attribute''' for action in parser._actions: if action.dest == dest: return action return None
[ "Retrieves", "the", "given", "parser", "action", "object", "by", "its", "dest", "=", "attribute" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/mixins.py#L34-L39
[ "def", "get_action_by_dest", "(", "self", ",", "parser", ",", "dest", ")", ":", "for", "action", "in", "parser", ".", "_actions", ":", "if", "action", ".", "dest", "==", "dest", ":", "return", "action", "return", "None" ]
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
DMPCommandMixIn.execute
Placing this in execute because then subclass handle() don't have to call super
django_mako_plus/management/mixins.py
def execute(self, *args, **options): '''Placing this in execute because then subclass handle() don't have to call super''' if options['verbose']: options['verbosity'] = 3 if options['quiet']: options['verbosity'] = 0 self.verbosity = options.get('verbosity', 1) ...
def execute(self, *args, **options): '''Placing this in execute because then subclass handle() don't have to call super''' if options['verbose']: options['verbosity'] = 3 if options['quiet']: options['verbosity'] = 0 self.verbosity = options.get('verbosity', 1) ...
[ "Placing", "this", "in", "execute", "because", "then", "subclass", "handle", "()", "don", "t", "have", "to", "call", "super" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/mixins.py#L42-L49
[ "def", "execute", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "if", "options", "[", "'verbose'", "]", ":", "options", "[", "'verbosity'", "]", "=", "3", "if", "options", "[", "'quiet'", "]", ":", "options", "[", "'verbosity'", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
DMPCommandMixIn.message
Print a message to the console
django_mako_plus/management/mixins.py
def message(self, msg='', level=1, tab=0): '''Print a message to the console''' if self.verbosity >= level: self.stdout.write('{}{}'.format(' ' * tab, msg))
def message(self, msg='', level=1, tab=0): '''Print a message to the console''' if self.verbosity >= level: self.stdout.write('{}{}'.format(' ' * tab, msg))
[ "Print", "a", "message", "to", "the", "console" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/mixins.py#L57-L60
[ "def", "message", "(", "self", ",", "msg", "=", "''", ",", "level", "=", "1", ",", "tab", "=", "0", ")", ":", "if", "self", ".", "verbosity", ">=", "level", ":", "self", ".", "stdout", ".", "write", "(", "'{}{}'", ".", "format", "(", "' '", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
b58enc
Encodes a UID to an 11-length string, encoded using base58 url-safe alphabet
django_mako_plus/util/base58.py
def b58enc(uid): '''Encodes a UID to an 11-length string, encoded using base58 url-safe alphabet''' # note: i tested a buffer array too, but string concat was 2x faster if not isinstance(uid, int): raise ValueError('Invalid integer: {}'.format(uid)) if uid == 0: return BASE58CHARS[0] ...
def b58enc(uid): '''Encodes a UID to an 11-length string, encoded using base58 url-safe alphabet''' # note: i tested a buffer array too, but string concat was 2x faster if not isinstance(uid, int): raise ValueError('Invalid integer: {}'.format(uid)) if uid == 0: return BASE58CHARS[0] ...
[ "Encodes", "a", "UID", "to", "an", "11", "-", "length", "string", "encoded", "using", "base58", "url", "-", "safe", "alphabet" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/util/base58.py#L9-L20
[ "def", "b58enc", "(", "uid", ")", ":", "# note: i tested a buffer array too, but string concat was 2x faster", "if", "not", "isinstance", "(", "uid", ",", "int", ")", ":", "raise", "ValueError", "(", "'Invalid integer: {}'", ".", "format", "(", "uid", ")", ")", "i...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
b58dec
Decodes a UID from base58, url-safe alphabet back to int.
django_mako_plus/util/base58.py
def b58dec(enc_uid): '''Decodes a UID from base58, url-safe alphabet back to int.''' if isinstance(enc_uid, str): pass elif isinstance(enc_uid, bytes): enc_uid = enc_uid.decode('utf8') else: raise ValueError('Cannot decode this type: {}'.format(enc_uid)) uid = 0 try: ...
def b58dec(enc_uid): '''Decodes a UID from base58, url-safe alphabet back to int.''' if isinstance(enc_uid, str): pass elif isinstance(enc_uid, bytes): enc_uid = enc_uid.decode('utf8') else: raise ValueError('Cannot decode this type: {}'.format(enc_uid)) uid = 0 try: ...
[ "Decodes", "a", "UID", "from", "base58", "url", "-", "safe", "alphabet", "back", "to", "int", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/util/base58.py#L22-L36
[ "def", "b58dec", "(", "enc_uid", ")", ":", "if", "isinstance", "(", "enc_uid", ",", "str", ")", ":", "pass", "elif", "isinstance", "(", "enc_uid", ",", "bytes", ")", ":", "enc_uid", "=", "enc_uid", ".", "decode", "(", "'utf8'", ")", "else", ":", "rai...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
minify
Minifies the source text (if needed)
django_mako_plus/management/commands/dmp_collectstatic.py
def minify(text, minifier): '''Minifies the source text (if needed)''' # there really isn't a good way to know if a file is already minified. # our heuristic is if source is more than 50 bytes greater of dest OR # if a hard return is found in the first 50 chars, we assume it is not minified. minifie...
def minify(text, minifier): '''Minifies the source text (if needed)''' # there really isn't a good way to know if a file is already minified. # our heuristic is if source is more than 50 bytes greater of dest OR # if a hard return is found in the first 50 chars, we assume it is not minified. minifie...
[ "Minifies", "the", "source", "text", "(", "if", "needed", ")" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_collectstatic.py#L235-L243
[ "def", "minify", "(", "text", ",", "minifier", ")", ":", "# there really isn't a good way to know if a file is already minified.", "# our heuristic is if source is more than 50 bytes greater of dest OR", "# if a hard return is found in the first 50 chars, we assume it is not minified.", "minif...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
Rule.match
Returns the result score if the file matches this rule
django_mako_plus/management/commands/dmp_collectstatic.py
def match(self, fname, flevel, ftype): '''Returns the result score if the file matches this rule''' # if filetype is the same # and level isn't set or level is the same # and pattern matche the filename if self.filetype == ftype and (self.level is None or self.level == flevel) an...
def match(self, fname, flevel, ftype): '''Returns the result score if the file matches this rule''' # if filetype is the same # and level isn't set or level is the same # and pattern matche the filename if self.filetype == ftype and (self.level is None or self.level == flevel) an...
[ "Returns", "the", "result", "score", "if", "the", "file", "matches", "this", "rule" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_collectstatic.py#L31-L38
[ "def", "match", "(", "self", ",", "fname", ",", "flevel", ",", "ftype", ")", ":", "# if filetype is the same", "# and level isn't set or level is the same", "# and pattern matche the filename", "if", "self", ".", "filetype", "==", "ftype", "and", "(", "self", ".", "...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
Command.create_rules
Adds rules for the command line options
django_mako_plus/management/commands/dmp_collectstatic.py
def create_rules(self): '''Adds rules for the command line options''' dmp = apps.get_app_config('django_mako_plus') # the default rules = [ # files are included by default Rule('*', level=None, filetype=TYPE_FILE, score=1), ...
def create_rules(self): '''Adds rules for the command line options''' dmp = apps.get_app_config('django_mako_plus') # the default rules = [ # files are included by default Rule('*', level=None, filetype=TYPE_FILE, score=1), ...
[ "Adds", "rules", "for", "the", "command", "line", "options" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_collectstatic.py#L125-L165
[ "def", "create_rules", "(", "self", ")", ":", "dmp", "=", "apps", ".", "get_app_config", "(", "'django_mako_plus'", ")", "# the default", "rules", "=", "[", "# files are included by default", "Rule", "(", "'*'", ",", "level", "=", "None", ",", "filetype", "=",...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
Command.copy_dir
Copies the static files from one directory to another. If this command is run, we assume the user wants to overwrite any existing files.
django_mako_plus/management/commands/dmp_collectstatic.py
def copy_dir(self, source, dest, level=0): '''Copies the static files from one directory to another. If this command is run, we assume the user wants to overwrite any existing files.''' encoding = settings.DEFAULT_CHARSET or 'utf8' msglevel = 2 if level == 0 else 3 self.message('Directo...
def copy_dir(self, source, dest, level=0): '''Copies the static files from one directory to another. If this command is run, we assume the user wants to overwrite any existing files.''' encoding = settings.DEFAULT_CHARSET or 'utf8' msglevel = 2 if level == 0 else 3 self.message('Directo...
[ "Copies", "the", "static", "files", "from", "one", "directory", "to", "another", ".", "If", "this", "command", "is", "run", "we", "assume", "the", "user", "wants", "to", "overwrite", "any", "existing", "files", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_collectstatic.py#L168-L228
[ "def", "copy_dir", "(", "self", ",", "source", ",", "dest", ",", "level", "=", "0", ")", ":", "encoding", "=", "settings", ".", "DEFAULT_CHARSET", "or", "'utf8'", "msglevel", "=", "2", "if", "level", "==", "0", "else", "3", "self", ".", "message", "(...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
dmp_include
Includes a DMP (Mako) template into a normal django template. context: automatically provided template_name: specified as "app/template" def_name: optional block to render within the template Example: {% load django_mako_plus %} {% dmp_include "homepage/bsnav_dj.html" %} ...
django_mako_plus/templatetags/django_mako_plus.py
def dmp_include(context, template_name, def_name=None, **kwargs): ''' Includes a DMP (Mako) template into a normal django template. context: automatically provided template_name: specified as "app/template" def_name: optional block to render within the template Example: {...
def dmp_include(context, template_name, def_name=None, **kwargs): ''' Includes a DMP (Mako) template into a normal django template. context: automatically provided template_name: specified as "app/template" def_name: optional block to render within the template Example: {...
[ "Includes", "a", "DMP", "(", "Mako", ")", "template", "into", "a", "normal", "django", "template", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/templatetags/django_mako_plus.py#L17-L39
[ "def", "dmp_include", "(", "context", ",", "template_name", ",", "def_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "dmp", "=", "apps", ".", "get_app_config", "(", "'django_mako_plus'", ")", "template", "=", "dmp", ".", "engine", ".", "get_templat...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
RoutingData.render
App-specific render function that renders templates in the *current app*, attached to the request for convenience
django_mako_plus/router/data.py
def render(self, template, context=None, def_name=None, subdir='templates', content_type=None, status=None, charset=None): '''App-specific render function that renders templates in the *current app*, attached to the request for convenience''' template_adapter = self.get_template_loader(subdir).get_templ...
def render(self, template, context=None, def_name=None, subdir='templates', content_type=None, status=None, charset=None): '''App-specific render function that renders templates in the *current app*, attached to the request for convenience''' template_adapter = self.get_template_loader(subdir).get_templ...
[ "App", "-", "specific", "render", "function", "that", "renders", "templates", "in", "the", "*", "current", "app", "*", "attached", "to", "the", "request", "for", "convenience" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/data.py#L87-L90
[ "def", "render", "(", "self", ",", "template", ",", "context", "=", "None", ",", "def_name", "=", "None", ",", "subdir", "=", "'templates'", ",", "content_type", "=", "None", ",", "status", "=", "None", ",", "charset", "=", "None", ")", ":", "template_...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
RoutingData.render_to_string
App-specific render function that renders templates in the *current app*, attached to the request for convenience
django_mako_plus/router/data.py
def render_to_string(self, template, context=None, def_name=None, subdir='templates'): '''App-specific render function that renders templates in the *current app*, attached to the request for convenience''' template_adapter = self.get_template_loader(subdir).get_template(template) return getattr...
def render_to_string(self, template, context=None, def_name=None, subdir='templates'): '''App-specific render function that renders templates in the *current app*, attached to the request for convenience''' template_adapter = self.get_template_loader(subdir).get_template(template) return getattr...
[ "App", "-", "specific", "render", "function", "that", "renders", "templates", "in", "the", "*", "current", "app", "*", "attached", "to", "the", "request", "for", "convenience" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/data.py#L93-L96
[ "def", "render_to_string", "(", "self", ",", "template", ",", "context", "=", "None", ",", "def_name", "=", "None", ",", "subdir", "=", "'templates'", ")", ":", "template_adapter", "=", "self", ".", "get_template_loader", "(", "subdir", ")", ".", "get_templa...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
RoutingData.get_template_loader
App-specific function to get the current app's template loader
django_mako_plus/router/data.py
def get_template_loader(self, subdir='templates'): '''App-specific function to get the current app's template loader''' if self.request is None: raise ValueError("this method can only be called after the view middleware is run. Check that `django_mako_plus.middleware` is in MIDDLEWARE.") ...
def get_template_loader(self, subdir='templates'): '''App-specific function to get the current app's template loader''' if self.request is None: raise ValueError("this method can only be called after the view middleware is run. Check that `django_mako_plus.middleware` is in MIDDLEWARE.") ...
[ "App", "-", "specific", "function", "to", "get", "the", "current", "app", "s", "template", "loader" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/data.py#L104-L109
[ "def", "get_template_loader", "(", "self", ",", "subdir", "=", "'templates'", ")", ":", "if", "self", ".", "request", "is", "None", ":", "raise", "ValueError", "(", "\"this method can only be called after the view middleware is run. Check that `django_mako_plus.middleware` is...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
Config.ready
Called by Django when the app is ready for use.
django_mako_plus/apps.py
def ready(self): '''Called by Django when the app is ready for use.''' # set up the options self.options = {} self.options.update(DEFAULT_OPTIONS) for template_engine in settings.TEMPLATES: if template_engine.get('BACKEND', '').startswith('django_mako_plus'): ...
def ready(self): '''Called by Django when the app is ready for use.''' # set up the options self.options = {} self.options.update(DEFAULT_OPTIONS) for template_engine in settings.TEMPLATES: if template_engine.get('BACKEND', '').startswith('django_mako_plus'): ...
[ "Called", "by", "Django", "when", "the", "app", "is", "ready", "for", "use", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/apps.py#L18-L46
[ "def", "ready", "(", "self", ")", ":", "# set up the options", "self", ".", "options", "=", "{", "}", "self", ".", "options", ".", "update", "(", "DEFAULT_OPTIONS", ")", "for", "template_engine", "in", "settings", ".", "TEMPLATES", ":", "if", "template_engin...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
Config.register_app
Registers an app as a "DMP-enabled" app. Normally, DMP does this automatically when included in urls.py. If app is None, the DEFAULT_APP is registered.
django_mako_plus/apps.py
def register_app(self, app=None): ''' Registers an app as a "DMP-enabled" app. Normally, DMP does this automatically when included in urls.py. If app is None, the DEFAULT_APP is registered. ''' app = app or self.options['DEFAULT_APP'] if not app: rai...
def register_app(self, app=None): ''' Registers an app as a "DMP-enabled" app. Normally, DMP does this automatically when included in urls.py. If app is None, the DEFAULT_APP is registered. ''' app = app or self.options['DEFAULT_APP'] if not app: rai...
[ "Registers", "an", "app", "as", "a", "DMP", "-", "enabled", "app", ".", "Normally", "DMP", "does", "this", "automatically", "when", "included", "in", "urls", ".", "py", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/apps.py#L49-L80
[ "def", "register_app", "(", "self", ",", "app", "=", "None", ")", ":", "app", "=", "app", "or", "self", ".", "options", "[", "'DEFAULT_APP'", "]", "if", "not", "app", ":", "raise", "ImproperlyConfigured", "(", "'An app name is required because DEFAULT_APP is emp...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
Config.is_registered_app
Returns true if the given app/app name is registered with DMP
django_mako_plus/apps.py
def is_registered_app(self, app): '''Returns true if the given app/app name is registered with DMP''' if app is None: return False if isinstance(app, AppConfig): app = app.name return app in self.registered_apps
def is_registered_app(self, app): '''Returns true if the given app/app name is registered with DMP''' if app is None: return False if isinstance(app, AppConfig): app = app.name return app in self.registered_apps
[ "Returns", "true", "if", "the", "given", "app", "/", "app", "name", "is", "registered", "with", "DMP" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/apps.py#L88-L94
[ "def", "is_registered_app", "(", "self", ",", "app", ")", ":", "if", "app", "is", "None", ":", "return", "False", "if", "isinstance", "(", "app", ",", "AppConfig", ")", ":", "app", "=", "app", ".", "name", "return", "app", "in", "self", ".", "registe...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
URLParamList.get
Returns the element at idx, or default if idx is beyond the length of the list
django_mako_plus/router/urlparams.py
def get(self, idx, default=''): '''Returns the element at idx, or default if idx is beyond the length of the list''' # if the index is beyond the length of the list, return '' if isinstance(idx, int) and (idx >= len(self) or idx < -1 * len(self)): return default # else do the...
def get(self, idx, default=''): '''Returns the element at idx, or default if idx is beyond the length of the list''' # if the index is beyond the length of the list, return '' if isinstance(idx, int) and (idx >= len(self) or idx < -1 * len(self)): return default # else do the...
[ "Returns", "the", "element", "at", "idx", "or", "default", "if", "idx", "is", "beyond", "the", "length", "of", "the", "list" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/router/urlparams.py#L16-L22
[ "def", "get", "(", "self", ",", "idx", ",", "default", "=", "''", ")", ":", "# if the index is beyond the length of the list, return ''", "if", "isinstance", "(", "idx", ",", "int", ")", "and", "(", "idx", ">=", "len", "(", "self", ")", "or", "idx", "<", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_int
Converts to int or float: '', '-', None convert to parameter default Anything else uses int() or float() constructor
django_mako_plus/converter/converters.py
def convert_int(value, parameter): ''' Converts to int or float: '', '-', None convert to parameter default Anything else uses int() or float() constructor ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(value, int): return value...
def convert_int(value, parameter): ''' Converts to int or float: '', '-', None convert to parameter default Anything else uses int() or float() constructor ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(value, int): return value...
[ "Converts", "to", "int", "or", "float", ":", "-", "None", "convert", "to", "parameter", "default", "Anything", "else", "uses", "int", "()", "or", "float", "()", "constructor" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L41-L53
[ "def", "convert_int", "(", "value", ",", "parameter", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "None", ")", ")", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", "in...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_float
Converts to int or float: '', '-', None convert to parameter default Anything else uses int() or float() constructor
django_mako_plus/converter/converters.py
def convert_float(value, parameter): ''' Converts to int or float: '', '-', None convert to parameter default Anything else uses int() or float() constructor ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(value, float): return v...
def convert_float(value, parameter): ''' Converts to int or float: '', '-', None convert to parameter default Anything else uses int() or float() constructor ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(value, float): return v...
[ "Converts", "to", "int", "or", "float", ":", "-", "None", "convert", "to", "parameter", "default", "Anything", "else", "uses", "int", "()", "or", "float", "()", "constructor" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L59-L71
[ "def", "convert_float", "(", "value", ",", "parameter", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "None", ")", ")", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", "...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_decimal
Converts to decimal.Decimal: '', '-', None convert to parameter default Anything else uses Decimal constructor
django_mako_plus/converter/converters.py
def convert_decimal(value, parameter): ''' Converts to decimal.Decimal: '', '-', None convert to parameter default Anything else uses Decimal constructor ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(value, decimal.Decimal): re...
def convert_decimal(value, parameter): ''' Converts to decimal.Decimal: '', '-', None convert to parameter default Anything else uses Decimal constructor ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(value, decimal.Decimal): re...
[ "Converts", "to", "decimal", ".", "Decimal", ":", "-", "None", "convert", "to", "parameter", "default", "Anything", "else", "uses", "Decimal", "constructor" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L77-L89
[ "def", "convert_decimal", "(", "value", ",", "parameter", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "None", ")", ")", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_boolean
Converts to boolean (only the first char of the value is used): '', '-', None convert to parameter default 'f', 'F', '0', False always convert to False Anything else converts to True.
django_mako_plus/converter/converters.py
def convert_boolean(value, parameter, default=False): ''' Converts to boolean (only the first char of the value is used): '', '-', None convert to parameter default 'f', 'F', '0', False always convert to False Anything else converts to True. ''' value = _check_default(value, para...
def convert_boolean(value, parameter, default=False): ''' Converts to boolean (only the first char of the value is used): '', '-', None convert to parameter default 'f', 'F', '0', False always convert to False Anything else converts to True. ''' value = _check_default(value, para...
[ "Converts", "to", "boolean", "(", "only", "the", "first", "char", "of", "the", "value", "is", "used", ")", ":", "-", "None", "convert", "to", "parameter", "default", "f", "F", "0", "False", "always", "convert", "to", "False", "Anything", "else", "convert...
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L95-L107
[ "def", "convert_boolean", "(", "value", ",", "parameter", ",", "default", "=", "False", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "None", ")", ")", "if", "isinstance", "(", "value", ",", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_datetime
Converts to datetime.datetime: '', '-', None convert to parameter default The first matching format in settings.DATETIME_INPUT_FORMATS converts to datetime
django_mako_plus/converter/converters.py
def convert_datetime(value, parameter): ''' Converts to datetime.datetime: '', '-', None convert to parameter default The first matching format in settings.DATETIME_INPUT_FORMATS converts to datetime ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or ...
def convert_datetime(value, parameter): ''' Converts to datetime.datetime: '', '-', None convert to parameter default The first matching format in settings.DATETIME_INPUT_FORMATS converts to datetime ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or ...
[ "Converts", "to", "datetime", ".", "datetime", ":", "-", "None", "convert", "to", "parameter", "default", "The", "first", "matching", "format", "in", "settings", ".", "DATETIME_INPUT_FORMATS", "converts", "to", "datetime" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L113-L127
[ "def", "convert_datetime", "(", "value", ",", "parameter", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "None", ")", ")", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_date
Converts to datetime.date: '', '-', None convert to parameter default The first matching format in settings.DATE_INPUT_FORMATS converts to datetime
django_mako_plus/converter/converters.py
def convert_date(value, parameter): ''' Converts to datetime.date: '', '-', None convert to parameter default The first matching format in settings.DATE_INPUT_FORMATS converts to datetime ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(v...
def convert_date(value, parameter): ''' Converts to datetime.date: '', '-', None convert to parameter default The first matching format in settings.DATE_INPUT_FORMATS converts to datetime ''' value = _check_default(value, parameter, ( '', '-', None )) if value is None or isinstance(v...
[ "Converts", "to", "datetime", ".", "date", ":", "-", "None", "convert", "to", "parameter", "default", "The", "first", "matching", "format", "in", "settings", ".", "DATE_INPUT_FORMATS", "converts", "to", "datetime" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L133-L147
[ "def", "convert_date", "(", "value", ",", "parameter", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "None", ")", ")", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", "d...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
convert_id_to_model
Converts to a Model object. '', '-', '0', None convert to parameter default Anything else is assumed an object id and sent to `.get(id=value)`.
django_mako_plus/converter/converters.py
def convert_id_to_model(value, parameter): ''' Converts to a Model object. '', '-', '0', None convert to parameter default Anything else is assumed an object id and sent to `.get(id=value)`. ''' value = _check_default(value, parameter, ( '', '-', '0', None )) if isinstance(value, (in...
def convert_id_to_model(value, parameter): ''' Converts to a Model object. '', '-', '0', None convert to parameter default Anything else is assumed an object id and sent to `.get(id=value)`. ''' value = _check_default(value, parameter, ( '', '-', '0', None )) if isinstance(value, (in...
[ "Converts", "to", "a", "Model", "object", ".", "-", "0", "None", "convert", "to", "parameter", "default", "Anything", "else", "is", "assumed", "an", "object", "id", "and", "sent", "to", ".", "get", "(", "id", "=", "value", ")", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L153-L165
[ "def", "convert_id_to_model", "(", "value", ",", "parameter", ")", ":", "value", "=", "_check_default", "(", "value", ",", "parameter", ",", "(", "''", ",", "'-'", ",", "'0'", ",", "None", ")", ")", "if", "isinstance", "(", "value", ",", "(", "int", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
_check_default
Returns the default if the value is "empty"
django_mako_plus/converter/converters.py
def _check_default(value, parameter, default_chars): '''Returns the default if the value is "empty"''' # not using a set here because it fails when value is unhashable if value in default_chars: if parameter.default is inspect.Parameter.empty: raise ValueError('Value was empty, but no de...
def _check_default(value, parameter, default_chars): '''Returns the default if the value is "empty"''' # not using a set here because it fails when value is unhashable if value in default_chars: if parameter.default is inspect.Parameter.empty: raise ValueError('Value was empty, but no de...
[ "Returns", "the", "default", "if", "the", "value", "is", "empty" ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/converters.py#L171-L178
[ "def", "_check_default", "(", "value", ",", "parameter", ",", "default_chars", ")", ":", "# not using a set here because it fails when value is unhashable", "if", "value", "in", "default_chars", ":", "if", "parameter", ".", "default", "is", "inspect", ".", "Parameter", ...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
parameter_converter
Decorator that denotes a function as a url parameter converter.
django_mako_plus/converter/decorators.py
def parameter_converter(*convert_types): ''' Decorator that denotes a function as a url parameter converter. ''' def inner(func): for ct in convert_types: ParameterConverter._register_converter(func, ct) return func return inner
def parameter_converter(*convert_types): ''' Decorator that denotes a function as a url parameter converter. ''' def inner(func): for ct in convert_types: ParameterConverter._register_converter(func, ct) return func return inner
[ "Decorator", "that", "denotes", "a", "function", "as", "a", "url", "parameter", "converter", "." ]
doconix/django-mako-plus
python
https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/converter/decorators.py#L5-L13
[ "def", "parameter_converter", "(", "*", "convert_types", ")", ":", "def", "inner", "(", "func", ")", ":", "for", "ct", "in", "convert_types", ":", "ParameterConverter", ".", "_register_converter", "(", "func", ",", "ct", ")", "return", "func", "return", "inn...
a90f9b4af19e5fa9f83452989cdcaed21569a181
train
protocol
Run all the stages in protocol Parameters ---------- handler : SystemHandler Container of initial conditions of simulation cfg : dict Imported YAML file.
ommprotocol/md.py
def protocol(handler, cfg): """ Run all the stages in protocol Parameters ---------- handler : SystemHandler Container of initial conditions of simulation cfg : dict Imported YAML file. """ # Stages if 'stages' not in cfg: raise ValueError('Protocol must inc...
def protocol(handler, cfg): """ Run all the stages in protocol Parameters ---------- handler : SystemHandler Container of initial conditions of simulation cfg : dict Imported YAML file. """ # Stages if 'stages' not in cfg: raise ValueError('Protocol must inc...
[ "Run", "all", "the", "stages", "in", "protocol" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L65-L92
[ "def", "protocol", "(", "handler", ",", "cfg", ")", ":", "# Stages", "if", "'stages'", "not", "in", "cfg", ":", "raise", "ValueError", "(", "'Protocol must include stages of simulation'", ")", "pos", ",", "vel", ",", "box", "=", "handler", ".", "positions", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.run
Launch MD simulation, which may consist of: 1. Optional minimization 2. Actual MD simulation, with n steps. This method also handles reporters. Returns ------- positions, velocities : unit.Quantity([natoms, 3]) Position, velocity of each atom in the system ...
ommprotocol/md.py
def run(self): """ Launch MD simulation, which may consist of: 1. Optional minimization 2. Actual MD simulation, with n steps. This method also handles reporters. Returns ------- positions, velocities : unit.Quantity([natoms, 3]) Position, ve...
def run(self): """ Launch MD simulation, which may consist of: 1. Optional minimization 2. Actual MD simulation, with n steps. This method also handles reporters. Returns ------- positions, velocities : unit.Quantity([natoms, 3]) Position, ve...
[ "Launch", "MD", "simulation", "which", "may", "consist", "of", ":", "1", ".", "Optional", "minimization", "2", ".", "Actual", "MD", "simulation", "with", "n", "steps", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L272-L352
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "verbose", ":", "status", "=", "'#{}'", ".", "format", "(", "self", ".", "stage_index", ")", "if", "self", ".", "total_stages", "is", "not", "None", ":", "status", "+=", "'/{}'", ".", "format", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.minimize
Minimize energy of the system until meeting `tolerance` or performing `max_iterations`.
ommprotocol/md.py
def minimize(self, tolerance=None, max_iterations=None): """ Minimize energy of the system until meeting `tolerance` or performing `max_iterations`. """ if tolerance is None: tolerance = self.minimization_tolerance if max_iterations is None: max_it...
def minimize(self, tolerance=None, max_iterations=None): """ Minimize energy of the system until meeting `tolerance` or performing `max_iterations`. """ if tolerance is None: tolerance = self.minimization_tolerance if max_iterations is None: max_it...
[ "Minimize", "energy", "of", "the", "system", "until", "meeting", "tolerance", "or", "performing", "max_iterations", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L354-L363
[ "def", "minimize", "(", "self", ",", "tolerance", "=", "None", ",", "max_iterations", "=", "None", ")", ":", "if", "tolerance", "is", "None", ":", "tolerance", "=", "self", ".", "minimization_tolerance", "if", "max_iterations", "is", "None", ":", "max_iterat...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.simulate
Advance simulation n steps
ommprotocol/md.py
def simulate(self, steps=None): """ Advance simulation n steps """ if steps is None: steps = self.steps self.simulation.step(steps)
def simulate(self, steps=None): """ Advance simulation n steps """ if steps is None: steps = self.steps self.simulation.step(steps)
[ "Advance", "simulation", "n", "steps" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L365-L371
[ "def", "simulate", "(", "self", ",", "steps", "=", "None", ")", ":", "if", "steps", "is", "None", ":", "steps", "=", "self", ".", "steps", "self", ".", "simulation", ".", "step", "(", "steps", ")" ]
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.restraint_force
Force that restrains atoms to fix their positions, while allowing tiny movement to resolve severe clashes and so on. Returns ------- force : simtk.openmm.CustomExternalForce A custom force to restrain the selected atoms
ommprotocol/md.py
def restraint_force(self, indices=None, strength=5.0): """ Force that restrains atoms to fix their positions, while allowing tiny movement to resolve severe clashes and so on. Returns ------- force : simtk.openmm.CustomExternalForce A custom force to restrain...
def restraint_force(self, indices=None, strength=5.0): """ Force that restrains atoms to fix their positions, while allowing tiny movement to resolve severe clashes and so on. Returns ------- force : simtk.openmm.CustomExternalForce A custom force to restrain...
[ "Force", "that", "restrains", "atoms", "to", "fix", "their", "positions", "while", "allowing", "tiny", "movement", "to", "resolve", "severe", "clashes", "and", "so", "on", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L511-L535
[ "def", "restraint_force", "(", "self", ",", "indices", "=", "None", ",", "strength", "=", "5.0", ")", ":", "if", "self", ".", "system", ".", "usesPeriodicBoundaryConditions", "(", ")", ":", "expression", "=", "'k*periodicdistance(x, y, z, x0, y0, z0)^2'", "else", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.distance_restraint_force
Parameters ---------- atoms : tuple of tuple of int or str Pair of atom indices to be restrained, with shape (n, 2), like ((a1, a2), (a3, a4)). Items can be str compatible with MDTraj DSL. distances : tuple of float Equilibrium distances for each pair ...
ommprotocol/md.py
def distance_restraint_force(self, atoms, distances, strengths): """ Parameters ---------- atoms : tuple of tuple of int or str Pair of atom indices to be restrained, with shape (n, 2), like ((a1, a2), (a3, a4)). Items can be str compatible with MDTraj DSL. ...
def distance_restraint_force(self, atoms, distances, strengths): """ Parameters ---------- atoms : tuple of tuple of int or str Pair of atom indices to be restrained, with shape (n, 2), like ((a1, a2), (a3, a4)). Items can be str compatible with MDTraj DSL. ...
[ "Parameters", "----------", "atoms", ":", "tuple", "of", "tuple", "of", "int", "or", "str", "Pair", "of", "atom", "indices", "to", "be", "restrained", "with", "shape", "(", "n", "2", ")", "like", "((", "a1", "a2", ")", "(", "a3", "a4", "))", ".", "...
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L537-L571
[ "def", "distance_restraint_force", "(", "self", ",", "atoms", ",", "distances", ",", "strengths", ")", ":", "system", "=", "self", ".", "system", "force", "=", "mm", ".", "HarmonicBondForce", "(", ")", "force", ".", "setUsesPeriodicBoundaryConditions", "(", "s...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.subset
Returns a list of atom indices corresponding to a MDTraj DSL query. Also will accept list of numbers, which will be coerced to int and returned.
ommprotocol/md.py
def subset(self, selector): """ Returns a list of atom indices corresponding to a MDTraj DSL query. Also will accept list of numbers, which will be coerced to int and returned. """ if isinstance(selector, (list, tuple)): return map(int, selector) selec...
def subset(self, selector): """ Returns a list of atom indices corresponding to a MDTraj DSL query. Also will accept list of numbers, which will be coerced to int and returned. """ if isinstance(selector, (list, tuple)): return map(int, selector) selec...
[ "Returns", "a", "list", "of", "atom", "indices", "corresponding", "to", "a", "MDTraj", "DSL", "query", ".", "Also", "will", "accept", "list", "of", "numbers", "which", "will", "be", "coerced", "to", "int", "and", "returned", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L573-L583
[ "def", "subset", "(", "self", ",", "selector", ")", ":", "if", "isinstance", "(", "selector", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "map", "(", "int", ",", "selector", ")", "selector", "=", "SELECTORS", ".", "get", "(", "selector",...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.handle_exceptions
Handle Ctrl+C and accidental exceptions and attempt to save the current state of the simulation
ommprotocol/md.py
def handle_exceptions(self, verbose=True): """ Handle Ctrl+C and accidental exceptions and attempt to save the current state of the simulation """ try: yield except (KeyboardInterrupt, Exception) as ex: if not self.attempt_rescue: r...
def handle_exceptions(self, verbose=True): """ Handle Ctrl+C and accidental exceptions and attempt to save the current state of the simulation """ try: yield except (KeyboardInterrupt, Exception) as ex: if not self.attempt_rescue: r...
[ "Handle", "Ctrl", "+", "C", "and", "accidental", "exceptions", "and", "attempt", "to", "save", "the", "current", "state", "of", "the", "simulation" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L694-L726
[ "def", "handle_exceptions", "(", "self", ",", "verbose", "=", "True", ")", ":", "try", ":", "yield", "except", "(", "KeyboardInterrupt", ",", "Exception", ")", "as", "ex", ":", "if", "not", "self", ".", "attempt_rescue", ":", "raise", "ex", "if", "isinst...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
Stage.backup_simulation
Creates an emergency report run, .state included
ommprotocol/md.py
def backup_simulation(self): """ Creates an emergency report run, .state included """ path = self.new_filename(suffix='_emergency.state') self.simulation.saveState(path) uses_pbc = self.system.usesPeriodicBoundaryConditions() state_kw = dict(getPositions=True, get...
def backup_simulation(self): """ Creates an emergency report run, .state included """ path = self.new_filename(suffix='_emergency.state') self.simulation.saveState(path) uses_pbc = self.system.usesPeriodicBoundaryConditions() state_kw = dict(getPositions=True, get...
[ "Creates", "an", "emergency", "report", "run", ".", "state", "included" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/md.py#L728-L741
[ "def", "backup_simulation", "(", "self", ")", ":", "path", "=", "self", ".", "new_filename", "(", "suffix", "=", "'_emergency.state'", ")", "self", ".", "simulation", ".", "saveState", "(", "path", ")", "uses_pbc", "=", "self", ".", "system", ".", "usesPer...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
prepare_input
Get, parse and prepare input file.
ommprotocol/io.py
def prepare_input(argv=None): """ Get, parse and prepare input file. """ p = ArgumentParser(description='InsiliChem Ommprotocol: ' 'easy to deploy MD protocols for OpenMM') p.add_argument('input', metavar='INPUT FILE', type=extant_file, help='YAML input file...
def prepare_input(argv=None): """ Get, parse and prepare input file. """ p = ArgumentParser(description='InsiliChem Ommprotocol: ' 'easy to deploy MD protocols for OpenMM') p.add_argument('input', metavar='INPUT FILE', type=extant_file, help='YAML input file...
[ "Get", "parse", "and", "prepare", "input", "file", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L883-L913
[ "def", "prepare_input", "(", "argv", "=", "None", ")", ":", "p", "=", "ArgumentParser", "(", "description", "=", "'InsiliChem Ommprotocol: '", "'easy to deploy MD protocols for OpenMM'", ")", "p", ".", "add_argument", "(", "'input'", ",", "metavar", "=", "'INPUT FIL...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
prepare_handler
Load all files into single object.
ommprotocol/io.py
def prepare_handler(cfg): """ Load all files into single object. """ positions, velocities, box = None, None, None _path = cfg.get('_path', './') forcefield = cfg.pop('forcefield', None) topology_args = sanitize_args_for_file(cfg.pop('topology'), _path) if 'checkpoint' in cfg: r...
def prepare_handler(cfg): """ Load all files into single object. """ positions, velocities, box = None, None, None _path = cfg.get('_path', './') forcefield = cfg.pop('forcefield', None) topology_args = sanitize_args_for_file(cfg.pop('topology'), _path) if 'checkpoint' in cfg: r...
[ "Load", "all", "files", "into", "single", "object", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L916-L951
[ "def", "prepare_handler", "(", "cfg", ")", ":", "positions", ",", "velocities", ",", "box", "=", "None", ",", "None", ",", "None", "_path", "=", "cfg", ".", "get", "(", "'_path'", ",", "'./'", ")", "forcefield", "=", "cfg", ".", "pop", "(", "'forcefi...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
prepare_system_options
Retrieve and delete (pop) system options from input configuration.
ommprotocol/io.py
def prepare_system_options(cfg, defaults=None): """ Retrieve and delete (pop) system options from input configuration. """ d = {} if defaults is None else defaults.copy() if 'nonbondedMethod' in cfg: d['nonbondedMethod'] = warned_getattr(openmm_app, cfg.pop('nonbondedMethod'), None) if '...
def prepare_system_options(cfg, defaults=None): """ Retrieve and delete (pop) system options from input configuration. """ d = {} if defaults is None else defaults.copy() if 'nonbondedMethod' in cfg: d['nonbondedMethod'] = warned_getattr(openmm_app, cfg.pop('nonbondedMethod'), None) if '...
[ "Retrieve", "and", "delete", "(", "pop", ")", "system", "options", "from", "input", "configuration", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L954-L974
[ "def", "prepare_system_options", "(", "cfg", ",", "defaults", "=", "None", ")", ":", "d", "=", "{", "}", "if", "defaults", "is", "None", "else", "defaults", ".", "copy", "(", ")", "if", "'nonbondedMethod'", "in", "cfg", ":", "d", "[", "'nonbondedMethod'"...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
process_forcefield
Given a list of filenames, check which ones are `frcmods`. If so, convert them to ffxml. Else, just return them.
ommprotocol/io.py
def process_forcefield(*forcefields): """ Given a list of filenames, check which ones are `frcmods`. If so, convert them to ffxml. Else, just return them. """ for forcefield in forcefields: if forcefield.endswith('.frcmod'): gaffmol2 = os.path.splitext(forcefield)[0] + '.gaff.mol...
def process_forcefield(*forcefields): """ Given a list of filenames, check which ones are `frcmods`. If so, convert them to ffxml. Else, just return them. """ for forcefield in forcefields: if forcefield.endswith('.frcmod'): gaffmol2 = os.path.splitext(forcefield)[0] + '.gaff.mol...
[ "Given", "a", "list", "of", "filenames", "check", "which", "ones", "are", "frcmods", ".", "If", "so", "convert", "them", "to", "ffxml", ".", "Else", "just", "return", "them", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L981-L991
[ "def", "process_forcefield", "(", "*", "forcefields", ")", ":", "for", "forcefield", "in", "forcefields", ":", "if", "forcefield", ".", "endswith", "(", "'.frcmod'", ")", ":", "gaffmol2", "=", "os", ".", "path", ".", "splitext", "(", "forcefield", ")", "["...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
statexml2pdb
Given an OpenMM xml file containing the state of the simulation, generate a PDB snapshot for easy visualization.
ommprotocol/io.py
def statexml2pdb(topology, state, output=None): """ Given an OpenMM xml file containing the state of the simulation, generate a PDB snapshot for easy visualization. """ state = Restart.from_xml(state) system = SystemHandler.load(topology, positions=state.positions) if output is None: ...
def statexml2pdb(topology, state, output=None): """ Given an OpenMM xml file containing the state of the simulation, generate a PDB snapshot for easy visualization. """ state = Restart.from_xml(state) system = SystemHandler.load(topology, positions=state.positions) if output is None: ...
[ "Given", "an", "OpenMM", "xml", "file", "containing", "the", "state", "of", "the", "simulation", "generate", "a", "PDB", "snapshot", "for", "easy", "visualization", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L994-L1003
[ "def", "statexml2pdb", "(", "topology", ",", "state", ",", "output", "=", "None", ")", ":", "state", "=", "Restart", ".", "from_xml", "(", "state", ")", "system", "=", "SystemHandler", ".", "load", "(", "topology", ",", "positions", "=", "state", ".", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
export_frame_coordinates
Extract a single frame structure from a trajectory.
ommprotocol/io.py
def export_frame_coordinates(topology, trajectory, nframe, output=None): """ Extract a single frame structure from a trajectory. """ if output is None: basename, ext = os.path.splitext(trajectory) output = '{}.frame{}.inpcrd'.format(basename, nframe) # ParmEd sometimes struggles wit...
def export_frame_coordinates(topology, trajectory, nframe, output=None): """ Extract a single frame structure from a trajectory. """ if output is None: basename, ext = os.path.splitext(trajectory) output = '{}.frame{}.inpcrd'.format(basename, nframe) # ParmEd sometimes struggles wit...
[ "Extract", "a", "single", "frame", "structure", "from", "a", "trajectory", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L1006-L1031
[ "def", "export_frame_coordinates", "(", "topology", ",", "trajectory", ",", "nframe", ",", "output", "=", "None", ")", ":", "if", "output", "is", "None", ":", "basename", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "trajectory", ")", "outpu...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
YamlLoader.construct_include
Include file referenced at node.
ommprotocol/io.py
def construct_include(self, node): """Include file referenced at node.""" filename = os.path.join(self._root, self.construct_scalar(node)) filename = os.path.abspath(filename) extension = os.path.splitext(filename)[1].lstrip('.') with open(filename, 'r') as f: if ex...
def construct_include(self, node): """Include file referenced at node.""" filename = os.path.join(self._root, self.construct_scalar(node)) filename = os.path.abspath(filename) extension = os.path.splitext(filename)[1].lstrip('.') with open(filename, 'r') as f: if ex...
[ "Include", "file", "referenced", "at", "node", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L81-L92
[ "def", "construct_include", "(", "self", ",", "node", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_root", ",", "self", ".", "construct_scalar", "(", "node", ")", ")", "filename", "=", "os", ".", "path", ".", "abspath...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.from_pdb
Loads topology, positions and, potentially, velocities and vectors, from a PDB or PDBx file Parameters ---------- path : str Path to PDB/PDBx file forcefields : list of str Paths to FFXML and/or FRCMOD forcefields. REQUIRED. Returns -----...
ommprotocol/io.py
def from_pdb(cls, path, forcefield=None, loader=PDBFile, strict=True, **kwargs): """ Loads topology, positions and, potentially, velocities and vectors, from a PDB or PDBx file Parameters ---------- path : str Path to PDB/PDBx file forcefields : list ...
def from_pdb(cls, path, forcefield=None, loader=PDBFile, strict=True, **kwargs): """ Loads topology, positions and, potentially, velocities and vectors, from a PDB or PDBx file Parameters ---------- path : str Path to PDB/PDBx file forcefields : list ...
[ "Loads", "topology", "positions", "and", "potentially", "velocities", "and", "vectors", "from", "a", "PDB", "or", "PDBx", "file" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L222-L252
[ "def", "from_pdb", "(", "cls", ",", "path", ",", "forcefield", "=", "None", ",", "loader", "=", "PDBFile", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "pdb", "=", "loader", "(", "path", ")", "box", "=", "kwargs", ".", "pop", "(...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.from_amber
Loads Amber Parm7 parameters and topology file Parameters ---------- path : str Path to *.prmtop or *.top file positions : simtk.unit.Quantity Atomic positions Returns ------- prmtop : SystemHandler SystemHandler with topology
ommprotocol/io.py
def from_amber(cls, path, positions=None, strict=True, **kwargs): """ Loads Amber Parm7 parameters and topology file Parameters ---------- path : str Path to *.prmtop or *.top file positions : simtk.unit.Quantity Atomic positions Returns ...
def from_amber(cls, path, positions=None, strict=True, **kwargs): """ Loads Amber Parm7 parameters and topology file Parameters ---------- path : str Path to *.prmtop or *.top file positions : simtk.unit.Quantity Atomic positions Returns ...
[ "Loads", "Amber", "Parm7", "parameters", "and", "topology", "file" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L260-L281
[ "def", "from_amber", "(", "cls", ",", "path", ",", "positions", "=", "None", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "strict", "and", "positions", "is", "None", ":", "raise", "ValueError", "(", "'Amber TOP/PRMTOP files require ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.from_charmm
Loads PSF Charmm structure from `path`. Requires `charmm_parameters`. Parameters ---------- path : str Path to PSF file forcefield : list of str Paths to Charmm parameters files, such as *.par or *.str. REQUIRED Returns ------- psf : Syst...
ommprotocol/io.py
def from_charmm(cls, path, positions=None, forcefield=None, strict=True, **kwargs): """ Loads PSF Charmm structure from `path`. Requires `charmm_parameters`. Parameters ---------- path : str Path to PSF file forcefield : list of str Paths to Charm...
def from_charmm(cls, path, positions=None, forcefield=None, strict=True, **kwargs): """ Loads PSF Charmm structure from `path`. Requires `charmm_parameters`. Parameters ---------- path : str Path to PSF file forcefield : list of str Paths to Charm...
[ "Loads", "PSF", "Charmm", "structure", "from", "path", ".", "Requires", "charmm_parameters", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L284-L309
[ "def", "from_charmm", "(", "cls", ",", "path", ",", "positions", "=", "None", ",", "forcefield", "=", "None", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "psf", "=", "CharmmPsfFile", "(", "path", ")", "if", "strict", "and", "forcef...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.from_desmond
Loads a topology from a Desmond DMS file located at `path`. Arguments --------- path : str Path to a Desmond DMS file
ommprotocol/io.py
def from_desmond(cls, path, **kwargs): """ Loads a topology from a Desmond DMS file located at `path`. Arguments --------- path : str Path to a Desmond DMS file """ dms = DesmondDMSFile(path) pos = kwargs.pop('positions', dms.getPositions()) ...
def from_desmond(cls, path, **kwargs): """ Loads a topology from a Desmond DMS file located at `path`. Arguments --------- path : str Path to a Desmond DMS file """ dms = DesmondDMSFile(path) pos = kwargs.pop('positions', dms.getPositions()) ...
[ "Loads", "a", "topology", "from", "a", "Desmond", "DMS", "file", "located", "at", "path", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L312-L324
[ "def", "from_desmond", "(", "cls", ",", "path", ",", "*", "*", "kwargs", ")", ":", "dms", "=", "DesmondDMSFile", "(", "path", ")", "pos", "=", "kwargs", ".", "pop", "(", "'positions'", ",", "dms", ".", "getPositions", "(", ")", ")", "return", "cls", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.from_gromacs
Loads a topology from a Gromacs TOP file located at `path`. Additional root directory for parameters can be specified with `forcefield`. Arguments --------- path : str Path to a Gromacs TOP file positions : simtk.unit.Quantity Atomic positions fo...
ommprotocol/io.py
def from_gromacs(cls, path, positions=None, forcefield=None, strict=True, **kwargs): """ Loads a topology from a Gromacs TOP file located at `path`. Additional root directory for parameters can be specified with `forcefield`. Arguments --------- path : str P...
def from_gromacs(cls, path, positions=None, forcefield=None, strict=True, **kwargs): """ Loads a topology from a Gromacs TOP file located at `path`. Additional root directory for parameters can be specified with `forcefield`. Arguments --------- path : str P...
[ "Loads", "a", "topology", "from", "a", "Gromacs", "TOP", "file", "located", "at", "path", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L327-L347
[ "def", "from_gromacs", "(", "cls", ",", "path", ",", "positions", "=", "None", ",", "forcefield", "=", "None", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "strict", "and", "positions", "is", "None", ":", "raise", "ValueError", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.from_parmed
Try to load a file automatically with ParmEd. Not guaranteed to work, but might be useful if it succeeds. Arguments --------- path : str Path to file that ParmEd can load
ommprotocol/io.py
def from_parmed(cls, path, *args, **kwargs): """ Try to load a file automatically with ParmEd. Not guaranteed to work, but might be useful if it succeeds. Arguments --------- path : str Path to file that ParmEd can load """ st = parmed.load_fi...
def from_parmed(cls, path, *args, **kwargs): """ Try to load a file automatically with ParmEd. Not guaranteed to work, but might be useful if it succeeds. Arguments --------- path : str Path to file that ParmEd can load """ st = parmed.load_fi...
[ "Try", "to", "load", "a", "file", "automatically", "with", "ParmEd", ".", "Not", "guaranteed", "to", "work", "but", "might", "be", "useful", "if", "it", "succeeds", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L350-L365
[ "def", "from_parmed", "(", "cls", ",", "path", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "st", "=", "parmed", ".", "load_file", "(", "path", ",", "structure", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", "box", "=", "...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler._pickle_load
Loads pickled topology. Careful with Python versions though!
ommprotocol/io.py
def _pickle_load(path): """ Loads pickled topology. Careful with Python versions though! """ _, ext = os.path.splitext(path) topology = None if sys.version_info.major == 2: if ext == '.pickle2': with open(path, 'rb') as f: t...
def _pickle_load(path): """ Loads pickled topology. Careful with Python versions though! """ _, ext = os.path.splitext(path) topology = None if sys.version_info.major == 2: if ext == '.pickle2': with open(path, 'rb') as f: t...
[ "Loads", "pickled", "topology", ".", "Careful", "with", "Python", "versions", "though!" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L380-L402
[ "def", "_pickle_load", "(", "path", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "path", ")", "topology", "=", "None", "if", "sys", ".", "version_info", ".", "major", "==", "2", ":", "if", "ext", "==", "'.pickle2'", ":",...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.create_system
Create an OpenMM system for every supported topology file with given system options
ommprotocol/io.py
def create_system(self, **system_options): """ Create an OpenMM system for every supported topology file with given system options """ if self.master is None: raise ValueError('Handler {} is not able to create systems.'.format(self)) if isinstance(self.master, ForceF...
def create_system(self, **system_options): """ Create an OpenMM system for every supported topology file with given system options """ if self.master is None: raise ValueError('Handler {} is not able to create systems.'.format(self)) if isinstance(self.master, ForceF...
[ "Create", "an", "OpenMM", "system", "for", "every", "supported", "topology", "file", "with", "given", "system", "options" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L412-L432
[ "def", "create_system", "(", "self", ",", "*", "*", "system_options", ")", ":", "if", "self", ".", "master", "is", "None", ":", "raise", "ValueError", "(", "'Handler {} is not able to create systems.'", ".", "format", "(", "self", ")", ")", "if", "isinstance",...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SystemHandler.write_pdb
Outputs a PDB file with the current contents of the system
ommprotocol/io.py
def write_pdb(self, path): """ Outputs a PDB file with the current contents of the system """ if self.master is None and self.positions is None: raise ValueError('Topology and positions are needed to write output files.') with open(path, 'w') as f: PDBFile...
def write_pdb(self, path): """ Outputs a PDB file with the current contents of the system """ if self.master is None and self.positions is None: raise ValueError('Topology and positions are needed to write output files.') with open(path, 'w') as f: PDBFile...
[ "Outputs", "a", "PDB", "file", "with", "the", "current", "contents", "of", "the", "system" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L434-L441
[ "def", "write_pdb", "(", "self", ",", "path", ")", ":", "if", "self", ".", "master", "is", "None", "and", "self", ".", "positions", "is", "None", ":", "raise", "ValueError", "(", "'Topology and positions are needed to write output files.'", ")", "with", "open", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
BoxVectors.from_xsc
Returns u.Quantity with box vectors from XSC file
ommprotocol/io.py
def from_xsc(cls, path): """ Returns u.Quantity with box vectors from XSC file """ def parse(path): """ Open and parses an XSC file into its fields Parameters ---------- path : str Path to XSC file Returns ...
def from_xsc(cls, path): """ Returns u.Quantity with box vectors from XSC file """ def parse(path): """ Open and parses an XSC file into its fields Parameters ---------- path : str Path to XSC file Returns ...
[ "Returns", "u", ".", "Quantity", "with", "box", "vectors", "from", "XSC", "file" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L554-L579
[ "def", "from_xsc", "(", "cls", ",", "path", ")", ":", "def", "parse", "(", "path", ")", ":", "\"\"\"\n Open and parses an XSC file into its fields\n\n Parameters\n ----------\n path : str\n Path to XSC file\n\n Returns...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
BoxVectors.from_csv
Get box vectors from comma-separated values in file `path`. The csv file must containt only one line, which in turn can contain three values (orthogonal vectors) or nine values (triclinic box). The values should be in nanometers. Parameters ---------- path : str ...
ommprotocol/io.py
def from_csv(cls, path): """ Get box vectors from comma-separated values in file `path`. The csv file must containt only one line, which in turn can contain three values (orthogonal vectors) or nine values (triclinic box). The values should be in nanometers. Parameters...
def from_csv(cls, path): """ Get box vectors from comma-separated values in file `path`. The csv file must containt only one line, which in turn can contain three values (orthogonal vectors) or nine values (triclinic box). The values should be in nanometers. Parameters...
[ "Get", "box", "vectors", "from", "comma", "-", "separated", "values", "in", "file", "path", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L582-L613
[ "def", "from_csv", "(", "cls", ",", "path", ")", ":", "with", "open", "(", "path", ")", "as", "f", ":", "fields", "=", "map", "(", "float", ",", "next", "(", "f", ")", ".", "split", "(", "','", ")", ")", "if", "len", "(", "fields", ")", "==",...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
ProgressBarReporter.describeNextReport
Get information about the next report this object will generate. Parameters ---------- simulation : Simulation The Simulation to generate a report for Returns ------- tuple A five element tuple. The first element is the number of steps ...
ommprotocol/io.py
def describeNextReport(self, simulation): """Get information about the next report this object will generate. Parameters ---------- simulation : Simulation The Simulation to generate a report for Returns ------- tuple A five element tuple...
def describeNextReport(self, simulation): """Get information about the next report this object will generate. Parameters ---------- simulation : Simulation The Simulation to generate a report for Returns ------- tuple A five element tuple...
[ "Get", "information", "about", "the", "next", "report", "this", "object", "will", "generate", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L720-L737
[ "def", "describeNextReport", "(", "self", ",", "simulation", ")", ":", "steps", "=", "self", ".", "interval", "-", "simulation", ".", "currentStep", "%", "self", ".", "interval", "return", "steps", ",", "False", ",", "False", ",", "False", ",", "False" ]
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
ProgressBarReporter.report
Generate a report. Parameters ---------- simulation : Simulation The Simulation to generate a report for state : State The current state of the simulation
ommprotocol/io.py
def report(self, simulation, state): """Generate a report. Parameters ---------- simulation : Simulation The Simulation to generate a report for state : State The current state of the simulation """ if not self._initialized: se...
def report(self, simulation, state): """Generate a report. Parameters ---------- simulation : Simulation The Simulation to generate a report for state : State The current state of the simulation """ if not self._initialized: se...
[ "Generate", "a", "report", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L739-L773
[ "def", "report", "(", "self", ",", "simulation", ",", "state", ")", ":", "if", "not", "self", ".", "_initialized", ":", "self", ".", "_initial_clock_time", "=", "datetime", ".", "now", "(", ")", "self", ".", "_initial_simulation_time", "=", "state", ".", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
SerializedReporter.report
Generate a report. Parameters ---------- simulation : Simulation The Simulation to generate a report for state : State The current state of the simulation
ommprotocol/io.py
def report(self, simulation, state): """Generate a report. Parameters ---------- simulation : Simulation The Simulation to generate a report for state : State The current state of the simulation """ if not self._initialized: se...
def report(self, simulation, state): """Generate a report. Parameters ---------- simulation : Simulation The Simulation to generate a report for state : State The current state of the simulation """ if not self._initialized: se...
[ "Generate", "a", "report", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L827-L848
[ "def", "report", "(", "self", ",", "simulation", ",", "state", ")", ":", "if", "not", "self", ".", "_initialized", ":", "self", ".", "_initialized", "=", "True", "self", ".", "_steps", "[", "0", "]", "+=", "self", ".", "interval", "positions", "=", "...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
assert_not_exists
If path exists, modify to add a counter in the filename. Useful for preventing accidental overrides. For example, if `file.txt` exists, check if `file.1.txt` also exists. Repeat until we find a non-existing version, such as `file.12.txt`. Parameters ---------- path : str Path to be chec...
ommprotocol/utils.py
def assert_not_exists(path, sep='.'): """ If path exists, modify to add a counter in the filename. Useful for preventing accidental overrides. For example, if `file.txt` exists, check if `file.1.txt` also exists. Repeat until we find a non-existing version, such as `file.12.txt`. Parameters ...
def assert_not_exists(path, sep='.'): """ If path exists, modify to add a counter in the filename. Useful for preventing accidental overrides. For example, if `file.txt` exists, check if `file.1.txt` also exists. Repeat until we find a non-existing version, such as `file.12.txt`. Parameters ...
[ "If", "path", "exists", "modify", "to", "add", "a", "counter", "in", "the", "filename", ".", "Useful", "for", "preventing", "accidental", "overrides", ".", "For", "example", "if", "file", ".", "txt", "exists", "check", "if", "file", ".", "1", ".", "txt",...
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/utils.py#L34-L56
[ "def", "assert_not_exists", "(", "path", ",", "sep", "=", "'.'", ")", ":", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "path", ")", "i", "=", "1", "while", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "path", "...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
assertinstance
Make sure object `obj` is of type `types`. Else, raise TypeError.
ommprotocol/utils.py
def assertinstance(obj, types): """ Make sure object `obj` is of type `types`. Else, raise TypeError. """ if isinstance(obj, types): return obj raise TypeError('{} must be instance of {}'.format(obj, types))
def assertinstance(obj, types): """ Make sure object `obj` is of type `types`. Else, raise TypeError. """ if isinstance(obj, types): return obj raise TypeError('{} must be instance of {}'.format(obj, types))
[ "Make", "sure", "object", "obj", "is", "of", "type", "types", ".", "Else", "raise", "TypeError", "." ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/utils.py#L59-L65
[ "def", "assertinstance", "(", "obj", ",", "types", ")", ":", "if", "isinstance", "(", "obj", ",", "types", ")", ":", "return", "obj", "raise", "TypeError", "(", "'{} must be instance of {}'", ".", "format", "(", "obj", ",", "types", ")", ")" ]
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
extant_file
Check if file exists with argparse
ommprotocol/utils.py
def extant_file(path): """ Check if file exists with argparse """ if not os.path.exists(path): raise argparse.ArgumentTypeError("{} does not exist".format(path)) return path
def extant_file(path): """ Check if file exists with argparse """ if not os.path.exists(path): raise argparse.ArgumentTypeError("{} does not exist".format(path)) return path
[ "Check", "if", "file", "exists", "with", "argparse" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/utils.py#L89-L95
[ "def", "extant_file", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "argparse", ".", "ArgumentTypeError", "(", "\"{} does not exist\"", ".", "format", "(", "path", ")", ")", "return", "path" ]
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
sort_key_for_numeric_suffixes
Sort files taking into account potentially absent suffixes like somefile.dcd somefile.1000.dcd somefile.2000.dcd To be used with sorted(..., key=callable).
ommprotocol/utils.py
def sort_key_for_numeric_suffixes(path, sep='.', suffix_index=-2): """ Sort files taking into account potentially absent suffixes like somefile.dcd somefile.1000.dcd somefile.2000.dcd To be used with sorted(..., key=callable). """ chunks = path.split(sep) # Remove suffix...
def sort_key_for_numeric_suffixes(path, sep='.', suffix_index=-2): """ Sort files taking into account potentially absent suffixes like somefile.dcd somefile.1000.dcd somefile.2000.dcd To be used with sorted(..., key=callable). """ chunks = path.split(sep) # Remove suffix...
[ "Sort", "files", "taking", "into", "account", "potentially", "absent", "suffixes", "like", "somefile", ".", "dcd", "somefile", ".", "1000", ".", "dcd", "somefile", ".", "2000", ".", "dcd" ]
insilichem/ommprotocol
python
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/utils.py#L123-L136
[ "def", "sort_key_for_numeric_suffixes", "(", "path", ",", "sep", "=", "'.'", ",", "suffix_index", "=", "-", "2", ")", ":", "chunks", "=", "path", ".", "split", "(", "sep", ")", "# Remove suffix from path and convert to int", "if", "chunks", "[", "suffix_index", ...
7283fddba7203e5ac3542fdab41fc1279d3b444e
train
json_response
Wrap a view in JSON. This decorator runs the given function and looks out for ajax.AJAXError's, which it encodes into a proper HttpResponse object. If an unknown error is thrown it's encoded as a 500. All errors are then packaged up with an appropriate Content-Type and a JSON body that you can ins...
ajax/decorators.py
def json_response(f, *args, **kwargs): """Wrap a view in JSON. This decorator runs the given function and looks out for ajax.AJAXError's, which it encodes into a proper HttpResponse object. If an unknown error is thrown it's encoded as a 500. All errors are then packaged up with an appropriate Con...
def json_response(f, *args, **kwargs): """Wrap a view in JSON. This decorator runs the given function and looks out for ajax.AJAXError's, which it encodes into a proper HttpResponse object. If an unknown error is thrown it's encoded as a 500. All errors are then packaged up with an appropriate Con...
[ "Wrap", "a", "view", "in", "JSON", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/decorators.py#L43-L100
[ "def", "json_response", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "result", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "result", ",", "AJAXError", ")", ":", "raise", "result...
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
import_by_path
Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImproperlyConfigured if something goes wrong. This has come straight from Django 1.6
ajax/utils.py
def import_by_path(dotted_path, error_prefix=''): """ Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImproperlyConfigured if something goes wrong. This has come straight from Django 1.6 """ try: module_path, class_name = dotted_p...
def import_by_path(dotted_path, error_prefix=''): """ Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImproperlyConfigured if something goes wrong. This has come straight from Django 1.6 """ try: module_path, class_name = dotted_p...
[ "Import", "a", "dotted", "module", "path", "and", "return", "the", "attribute", "/", "class", "designated", "by", "the", "last", "name", "in", "the", "path", ".", "Raise", "ImproperlyConfigured", "if", "something", "goes", "wrong", ".", "This", "has", "come"...
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/utils.py#L8-L32
[ "def", "import_by_path", "(", "dotted_path", ",", "error_prefix", "=", "''", ")", ":", "try", ":", "module_path", ",", "class_name", "=", "dotted_path", ".", "rsplit", "(", "'.'", ",", "1", ")", "except", "ValueError", ":", "raise", "ImproperlyConfigured", "...
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
endpoint_loader
Load an AJAX endpoint. This will load either an ad-hoc endpoint or it will load up a model endpoint depending on what it finds. It first attempts to load ``model`` as if it were an ad-hoc endpoint. Alternatively, it will attempt to see if there is a ``ModelEndpoint`` for the given ``model``.
ajax/views.py
def endpoint_loader(request, application, model, **kwargs): """Load an AJAX endpoint. This will load either an ad-hoc endpoint or it will load up a model endpoint depending on what it finds. It first attempts to load ``model`` as if it were an ad-hoc endpoint. Alternatively, it will attempt to see if ...
def endpoint_loader(request, application, model, **kwargs): """Load an AJAX endpoint. This will load either an ad-hoc endpoint or it will load up a model endpoint depending on what it finds. It first attempts to load ``model`` as if it were an ad-hoc endpoint. Alternatively, it will attempt to see if ...
[ "Load", "an", "AJAX", "endpoint", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/views.py#L32-L92
[ "def", "endpoint_loader", "(", "request", ",", "application", ",", "model", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "method", "!=", "\"POST\"", ":", "raise", "AJAXError", "(", "400", ",", "_", "(", "'Invalid HTTP method used.'", ")", ")", ...
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
ModelEndpoint.list
List objects of a model. By default will show page 1 with 20 objects on it. **Usage**:: params = {"items_per_page":10,"page":2} //all params are optional $.post("/ajax/{app}/{model}/list.json"),params)
ajax/endpoints.py
def list(self, request): """ List objects of a model. By default will show page 1 with 20 objects on it. **Usage**:: params = {"items_per_page":10,"page":2} //all params are optional $.post("/ajax/{app}/{model}/list.json"),params) """ max_items_per_pag...
def list(self, request): """ List objects of a model. By default will show page 1 with 20 objects on it. **Usage**:: params = {"items_per_page":10,"page":2} //all params are optional $.post("/ajax/{app}/{model}/list.json"),params) """ max_items_per_pag...
[ "List", "objects", "of", "a", "model", ".", "By", "default", "will", "show", "page", "1", "with", "20", "objects", "on", "it", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/endpoints.py#L84-L118
[ "def", "list", "(", "self", ",", "request", ")", ":", "max_items_per_page", "=", "getattr", "(", "self", ",", "'max_per_page'", ",", "getattr", "(", "settings", ",", "'AJAX_MAX_PER_PAGE'", ",", "100", ")", ")", "requested_items_per_page", "=", "request", ".", ...
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
ModelEndpoint._extract_data
Extract data from POST. Handles extracting a vanilla Python dict of values that are present in the given model. This also handles instances of ``ForeignKey`` and will convert those to the appropriate object instances from the database. In other words, it will see that user is a ``Foreig...
ajax/endpoints.py
def _extract_data(self, request): """Extract data from POST. Handles extracting a vanilla Python dict of values that are present in the given model. This also handles instances of ``ForeignKey`` and will convert those to the appropriate object instances from the database. In oth...
def _extract_data(self, request): """Extract data from POST. Handles extracting a vanilla Python dict of values that are present in the given model. This also handles instances of ``ForeignKey`` and will convert those to the appropriate object instances from the database. In oth...
[ "Extract", "data", "from", "POST", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/endpoints.py#L202-L229
[ "def", "_extract_data", "(", "self", ",", "request", ")", ":", "data", "=", "{", "}", "for", "field", ",", "val", "in", "six", ".", "iteritems", "(", "request", ".", "POST", ")", ":", "if", "field", "in", "self", ".", "immutable_fields", ":", "contin...
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
ModelEndpoint._extract_value
If the value is true/false/null replace with Python equivalent.
ajax/endpoints.py
def _extract_value(self, value): """If the value is true/false/null replace with Python equivalent.""" return ModelEndpoint._value_map.get(smart_str(value).lower(), value)
def _extract_value(self, value): """If the value is true/false/null replace with Python equivalent.""" return ModelEndpoint._value_map.get(smart_str(value).lower(), value)
[ "If", "the", "value", "is", "true", "/", "false", "/", "null", "replace", "with", "Python", "equivalent", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/endpoints.py#L231-L233
[ "def", "_extract_value", "(", "self", ",", "value", ")", ":", "return", "ModelEndpoint", ".", "_value_map", ".", "get", "(", "smart_str", "(", "value", ")", ".", "lower", "(", ")", ",", "value", ")" ]
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
ModelEndpoint._get_record
Fetch a given record. Handles fetching a record from the database along with throwing an appropriate instance of ``AJAXError`.
ajax/endpoints.py
def _get_record(self): """Fetch a given record. Handles fetching a record from the database along with throwing an appropriate instance of ``AJAXError`. """ if not self.pk: raise AJAXError(400, _('Invalid request for record.')) try: return self.m...
def _get_record(self): """Fetch a given record. Handles fetching a record from the database along with throwing an appropriate instance of ``AJAXError`. """ if not self.pk: raise AJAXError(400, _('Invalid request for record.')) try: return self.m...
[ "Fetch", "a", "given", "record", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/endpoints.py#L235-L248
[ "def", "_get_record", "(", "self", ")", ":", "if", "not", "self", ".", "pk", ":", "raise", "AJAXError", "(", "400", ",", "_", "(", "'Invalid request for record.'", ")", ")", "try", ":", "return", "self", ".", "model", ".", "objects", ".", "get", "(", ...
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
ModelEndpoint.authenticate
Authenticate the AJAX request. By default any request to fetch a model is allowed for any user, including anonymous users. All other methods minimally require that the user is already logged in. Most likely you will want to lock down who can edit and delete various models. To d...
ajax/endpoints.py
def authenticate(self, request, application, method): """Authenticate the AJAX request. By default any request to fetch a model is allowed for any user, including anonymous users. All other methods minimally require that the user is already logged in. Most likely you will want ...
def authenticate(self, request, application, method): """Authenticate the AJAX request. By default any request to fetch a model is allowed for any user, including anonymous users. All other methods minimally require that the user is already logged in. Most likely you will want ...
[ "Authenticate", "the", "AJAX", "request", "." ]
joestump/django-ajax
python
https://github.com/joestump/django-ajax/blob/b71619d5c00d8e0bb990ddbea2c93cf303dc2c80/ajax/endpoints.py#L261-L271
[ "def", "authenticate", "(", "self", ",", "request", ",", "application", ",", "method", ")", ":", "return", "self", ".", "authentication", ".", "is_authenticated", "(", "request", ",", "application", ",", "method", ")" ]
b71619d5c00d8e0bb990ddbea2c93cf303dc2c80
train
EntriesProxy.all
Gets all entries of a space.
contentful_management/entries_proxy.py
def all(self, query=None): """ Gets all entries of a space. """ if query is None: query = {} if self.content_type_id is not None: query['content_type'] = self.content_type_id normalize_select(query) return super(EntriesProxy, self).all(...
def all(self, query=None): """ Gets all entries of a space. """ if query is None: query = {} if self.content_type_id is not None: query['content_type'] = self.content_type_id normalize_select(query) return super(EntriesProxy, self).all(...
[ "Gets", "all", "entries", "of", "a", "space", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/entries_proxy.py#L32-L45
[ "def", "all", "(", "self", ",", "query", "=", "None", ")", ":", "if", "query", "is", "None", ":", "query", "=", "{", "}", "if", "self", ".", "content_type_id", "is", "not", "None", ":", "query", "[", "'content_type'", "]", "=", "self", ".", "conten...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
EntriesProxy.find
Gets a single entry by ID.
contentful_management/entries_proxy.py
def find(self, entry_id, query=None): """ Gets a single entry by ID. """ if query is None: query = {} if self.content_type_id is not None: query['content_type'] = self.content_type_id normalize_select(query) return super(EntriesProxy, s...
def find(self, entry_id, query=None): """ Gets a single entry by ID. """ if query is None: query = {} if self.content_type_id is not None: query['content_type'] = self.content_type_id normalize_select(query) return super(EntriesProxy, s...
[ "Gets", "a", "single", "entry", "by", "ID", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/entries_proxy.py#L47-L60
[ "def", "find", "(", "self", ",", "entry_id", ",", "query", "=", "None", ")", ":", "if", "query", "is", "None", ":", "query", "=", "{", "}", "if", "self", ".", "content_type_id", "is", "not", "None", ":", "query", "[", "'content_type'", "]", "=", "s...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
EntriesProxy.create
Creates an entry with a given ID (optional) and attributes.
contentful_management/entries_proxy.py
def create(self, resource_id=None, attributes=None, **kwargs): """ Creates an entry with a given ID (optional) and attributes. """ if self.content_type_id is not None: if attributes is None: attributes = {} attributes['content_type_id'] = self.con...
def create(self, resource_id=None, attributes=None, **kwargs): """ Creates an entry with a given ID (optional) and attributes. """ if self.content_type_id is not None: if attributes is None: attributes = {} attributes['content_type_id'] = self.con...
[ "Creates", "an", "entry", "with", "a", "given", "ID", "(", "optional", ")", "and", "attributes", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/entries_proxy.py#L62-L72
[ "def", "create", "(", "self", ",", "resource_id", "=", "None", ",", "attributes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "content_type_id", "is", "not", "None", ":", "if", "attributes", "is", "None", ":", "attributes", "=", ...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
WebhooksProxy.create
Creates a webhook with given attributes.
contentful_management/webhooks_proxy.py
def create(self, attributes=None, **kwargs): """ Creates a webhook with given attributes. """ return super(WebhooksProxy, self).create(resource_id=None, attributes=attributes)
def create(self, attributes=None, **kwargs): """ Creates a webhook with given attributes. """ return super(WebhooksProxy, self).create(resource_id=None, attributes=attributes)
[ "Creates", "a", "webhook", "with", "given", "attributes", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/webhooks_proxy.py#L27-L32
[ "def", "create", "(", "self", ",", "attributes", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "WebhooksProxy", ",", "self", ")", ".", "create", "(", "resource_id", "=", "None", ",", "attributes", "=", "attributes", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
camel_case
Returns a camel-cased version of a string. :param a_string: any :class:`str` object. Usage: >>> camel_case('foo_bar') "fooBar"
contentful_management/utils.py
def camel_case(snake_str): """ Returns a camel-cased version of a string. :param a_string: any :class:`str` object. Usage: >>> camel_case('foo_bar') "fooBar" """ components = snake_str.split('_') # We capitalize the first letter of each component except the first one #...
def camel_case(snake_str): """ Returns a camel-cased version of a string. :param a_string: any :class:`str` object. Usage: >>> camel_case('foo_bar') "fooBar" """ components = snake_str.split('_') # We capitalize the first letter of each component except the first one #...
[ "Returns", "a", "camel", "-", "cased", "version", "of", "a", "string", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/utils.py#L73-L87
[ "def", "camel_case", "(", "snake_str", ")", ":", "components", "=", "snake_str", ".", "split", "(", "'_'", ")", "# We capitalize the first letter of each component except the first one", "# with the 'title' method and join them together.", "return", "components", "[", "0", "]...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
normalize_select
If the query contains the :select operator, we enforce :sys properties. The SDK requires sys.type to function properly, but as other of our SDKs require more parts of the :sys properties, we decided that every SDK should include the complete :sys block to provide consistency accross our SDKs.
contentful_management/utils.py
def normalize_select(query): """ If the query contains the :select operator, we enforce :sys properties. The SDK requires sys.type to function properly, but as other of our SDKs require more parts of the :sys properties, we decided that every SDK should include the complete :sys block to provide con...
def normalize_select(query): """ If the query contains the :select operator, we enforce :sys properties. The SDK requires sys.type to function properly, but as other of our SDKs require more parts of the :sys properties, we decided that every SDK should include the complete :sys block to provide con...
[ "If", "the", "query", "contains", "the", ":", "select", "operator", "we", "enforce", ":", "sys", "properties", ".", "The", "SDK", "requires", "sys", ".", "type", "to", "function", "properly", "but", "as", "other", "of", "our", "SDKs", "require", "more", ...
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/utils.py#L154-L176
[ "def", "normalize_select", "(", "query", ")", ":", "if", "'select'", "not", "in", "query", ":", "return", "if", "isinstance", "(", "query", "[", "'select'", "]", ",", "str_type", "(", ")", ")", ":", "query", "[", "'select'", "]", "=", "[", "s", ".", ...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Environment.to_json
Returns the JSON representation of the environment.
contentful_management/environment.py
def to_json(self): """ Returns the JSON representation of the environment. """ result = super(Environment, self).to_json() result.update({ 'name': self.name }) return result
def to_json(self): """ Returns the JSON representation of the environment. """ result = super(Environment, self).to_json() result.update({ 'name': self.name }) return result
[ "Returns", "the", "JSON", "representation", "of", "the", "environment", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/environment.py#L56-L66
[ "def", "to_json", "(", "self", ")", ":", "result", "=", "super", "(", "Environment", ",", "self", ")", ".", "to_json", "(", ")", "result", ".", "update", "(", "{", "'name'", ":", "self", ".", "name", "}", ")", "return", "result" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Environment.content_types
Provides access to content type management methods for content types of an environment. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types :return: :class:`EnvironmentContentTypesProxy <contentful_management.space_content_types_proxy.E...
contentful_management/environment.py
def content_types(self): """ Provides access to content type management methods for content types of an environment. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types :return: :class:`EnvironmentContentTypesProxy <cont...
def content_types(self): """ Provides access to content type management methods for content types of an environment. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types :return: :class:`EnvironmentContentTypesProxy <cont...
[ "Provides", "access", "to", "content", "type", "management", "methods", "for", "content", "types", "of", "an", "environment", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/environment.py#L68-L83
[ "def", "content_types", "(", "self", ")", ":", "return", "EnvironmentContentTypesProxy", "(", "self", ".", "_client", ",", "self", ".", "space", ".", "id", ",", "self", ".", "id", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Environment.entries
Provides access to entry management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries :return: :class:`EnvironmentEntriesProxy <contentful_management.environment_entries_proxy.EnvironmentEntriesProxy>` object. :rtype: conte...
contentful_management/environment.py
def entries(self): """ Provides access to entry management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries :return: :class:`EnvironmentEntriesProxy <contentful_management.environment_entries_proxy.EnvironmentEntri...
def entries(self): """ Provides access to entry management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/entries :return: :class:`EnvironmentEntriesProxy <contentful_management.environment_entries_proxy.EnvironmentEntri...
[ "Provides", "access", "to", "entry", "management", "methods", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/environment.py#L85-L100
[ "def", "entries", "(", "self", ")", ":", "return", "EnvironmentEntriesProxy", "(", "self", ".", "_client", ",", "self", ".", "space", ".", "id", ",", "self", ".", "id", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Environment.assets
Provides access to asset management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets :return: :class:`EnvironmentAssetsProxy <contentful_management.environment_assets_proxy.EnvironmentAssetsProxy>` object. :rtype: contentfu...
contentful_management/environment.py
def assets(self): """ Provides access to asset management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets :return: :class:`EnvironmentAssetsProxy <contentful_management.environment_assets_proxy.EnvironmentAssetsPro...
def assets(self): """ Provides access to asset management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/assets :return: :class:`EnvironmentAssetsProxy <contentful_management.environment_assets_proxy.EnvironmentAssetsPro...
[ "Provides", "access", "to", "asset", "management", "methods", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/environment.py#L102-L117
[ "def", "assets", "(", "self", ")", ":", "return", "EnvironmentAssetsProxy", "(", "self", ".", "_client", ",", "self", ".", "space", ".", "id", ",", "self", ".", "id", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Environment.locales
Provides access to locale management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/locales :return: :class:`EnvironmentLocalesProxy <contentful_management.environment_locales_proxy.EnvironmentLocalesProxy>` object. :rtype: cont...
contentful_management/environment.py
def locales(self): """ Provides access to locale management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/locales :return: :class:`EnvironmentLocalesProxy <contentful_management.environment_locales_proxy.EnvironmentLoca...
def locales(self): """ Provides access to locale management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/locales :return: :class:`EnvironmentLocalesProxy <contentful_management.environment_locales_proxy.EnvironmentLoca...
[ "Provides", "access", "to", "locale", "management", "methods", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/environment.py#L119-L134
[ "def", "locales", "(", "self", ")", ":", "return", "EnvironmentLocalesProxy", "(", "self", ".", "_client", ",", "self", ".", "space", ".", "id", ",", "self", ".", "id", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Environment.ui_extensions
Provides access to UI extensions management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/ui-extensions :return: :class:`EnvironmentUIExtensionsProxy <contentful_management.ui_extensions_proxy.EnvironmentUIExtensionsProxy>` object. ...
contentful_management/environment.py
def ui_extensions(self): """ Provides access to UI extensions management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/ui-extensions :return: :class:`EnvironmentUIExtensionsProxy <contentful_management.ui_extensions_pro...
def ui_extensions(self): """ Provides access to UI extensions management methods. API reference: https://www.contentful.com/developers/docs/references/content-management-api/#/reference/ui-extensions :return: :class:`EnvironmentUIExtensionsProxy <contentful_management.ui_extensions_pro...
[ "Provides", "access", "to", "UI", "extensions", "management", "methods", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/environment.py#L136-L151
[ "def", "ui_extensions", "(", "self", ")", ":", "return", "EnvironmentUIExtensionsProxy", "(", "self", ".", "_client", ",", "self", ".", "space", ".", "id", ",", "self", ".", "id", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
PersonalAccessTokensProxy.delete
Revokes a personal access token.
contentful_management/personal_access_tokens_proxy.py
def delete(self, token_id, *args, **kwargs): """ Revokes a personal access token. """ return self.client._put( "{0}/revoked".format( self._url(token_id) ), None, *args, **kwargs )
def delete(self, token_id, *args, **kwargs): """ Revokes a personal access token. """ return self.client._put( "{0}/revoked".format( self._url(token_id) ), None, *args, **kwargs )
[ "Revokes", "a", "personal", "access", "token", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/personal_access_tokens_proxy.py#L39-L51
[ "def", "delete", "(", "self", ",", "token_id", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "client", ".", "_put", "(", "\"{0}/revoked\"", ".", "format", "(", "self", ".", "_url", "(", "token_id", ")", ")", ",", "None...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
PersonalAccessTokensProxy.revoke
Revokes a personal access token.
contentful_management/personal_access_tokens_proxy.py
def revoke(self, token_id, *args, **kwargs): """ Revokes a personal access token. """ return self.delete(token_id, *args, **kwargs)
def revoke(self, token_id, *args, **kwargs): """ Revokes a personal access token. """ return self.delete(token_id, *args, **kwargs)
[ "Revokes", "a", "personal", "access", "token", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/personal_access_tokens_proxy.py#L53-L58
[ "def", "revoke", "(", "self", ",", "token_id", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "delete", "(", "token_id", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Resource.base_url
Returns the URI for the resource.
contentful_management/resource.py
def base_url(klass, space_id='', resource_id=None, environment_id=None, **kwargs): """ Returns the URI for the resource. """ url = "spaces/{0}".format( space_id) if environment_id is not None: url = url = "{0}/environments/{1}".format(url, environment_id...
def base_url(klass, space_id='', resource_id=None, environment_id=None, **kwargs): """ Returns the URI for the resource. """ url = "spaces/{0}".format( space_id) if environment_id is not None: url = url = "{0}/environments/{1}".format(url, environment_id...
[ "Returns", "the", "URI", "for", "the", "resource", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/resource.py#L37-L56
[ "def", "base_url", "(", "klass", ",", "space_id", "=", "''", ",", "resource_id", "=", "None", ",", "environment_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "\"spaces/{0}\"", ".", "format", "(", "space_id", ")", "if", "environment_id"...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
train
Resource.create_attributes
Attributes for resource creation.
contentful_management/resource.py
def create_attributes(klass, attributes, previous_object=None): """ Attributes for resource creation. """ result = {} if previous_object is not None: result = {k: v for k, v in previous_object.to_json().items() if k != 'sys'} result.update(attributes) ...
def create_attributes(klass, attributes, previous_object=None): """ Attributes for resource creation. """ result = {} if previous_object is not None: result = {k: v for k, v in previous_object.to_json().items() if k != 'sys'} result.update(attributes) ...
[ "Attributes", "for", "resource", "creation", "." ]
contentful/contentful-management.py
python
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/resource.py#L59-L71
[ "def", "create_attributes", "(", "klass", ",", "attributes", ",", "previous_object", "=", "None", ")", ":", "result", "=", "{", "}", "if", "previous_object", "is", "not", "None", ":", "result", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "pr...
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0