repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.add_phase
def add_phase(self): """Context manager for when adding all the tokens""" # add stuff yield self # Make sure we output eveything self.finish_hanging() # Remove trailing indents and dedents while len(self.result) > 1 and self.result[-2][0] in (INDENT, ERRORTOKEN,...
python
def add_phase(self): """Context manager for when adding all the tokens""" # add stuff yield self # Make sure we output eveything self.finish_hanging() # Remove trailing indents and dedents while len(self.result) > 1 and self.result[-2][0] in (INDENT, ERRORTOKEN,...
[ "def", "add_phase", "(", "self", ")", ":", "# add stuff", "yield", "self", "# Make sure we output eveything", "self", ".", "finish_hanging", "(", ")", "# Remove trailing indents and dedents", "while", "len", "(", "self", ".", "result", ")", ">", "1", "and", "self"...
Context manager for when adding all the tokens
[ "Context", "manager", "for", "when", "adding", "all", "the", "tokens" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L45-L55
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.next_token
def next_token(self, tokenum, value, scol): """Determine what to do with the next token""" # Make self.current reflect these values self.current.set(tokenum, value, scol) # Determine indent_type based on this token if self.current.tokenum == INDENT and self.current.value: ...
python
def next_token(self, tokenum, value, scol): """Determine what to do with the next token""" # Make self.current reflect these values self.current.set(tokenum, value, scol) # Determine indent_type based on this token if self.current.tokenum == INDENT and self.current.value: ...
[ "def", "next_token", "(", "self", ",", "tokenum", ",", "value", ",", "scol", ")", ":", "# Make self.current reflect these values", "self", ".", "current", ".", "set", "(", "tokenum", ",", "value", ",", "scol", ")", "# Determine indent_type based on this token", "i...
Determine what to do with the next token
[ "Determine", "what", "to", "do", "with", "the", "next", "token" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L57-L101
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.progress
def progress(self): """ Deal with next token Used to create, fillout and end groups and singles As well as just append everything else """ tokenum, value, scol = self.current.values() # Default to not appending anything just_append = False ...
python
def progress(self): """ Deal with next token Used to create, fillout and end groups and singles As well as just append everything else """ tokenum, value, scol = self.current.values() # Default to not appending anything just_append = False ...
[ "def", "progress", "(", "self", ")", ":", "tokenum", ",", "value", ",", "scol", "=", "self", ".", "current", ".", "values", "(", ")", "# Default to not appending anything", "just_append", "=", "False", "# Prevent from group having automatic pass given to it", "# If it...
Deal with next token Used to create, fillout and end groups and singles As well as just append everything else
[ "Deal", "with", "next", "token", "Used", "to", "create", "fillout", "and", "end", "groups", "and", "singles", "As", "well", "as", "just", "append", "everything", "else" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L107-L205
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.reset_indentation
def reset_indentation(self, amount): """Replace previous indentation with desired amount""" while self.result and self.result[-1][0] == INDENT: self.result.pop() self.result.append((INDENT, amount))
python
def reset_indentation(self, amount): """Replace previous indentation with desired amount""" while self.result and self.result[-1][0] == INDENT: self.result.pop() self.result.append((INDENT, amount))
[ "def", "reset_indentation", "(", "self", ",", "amount", ")", ":", "while", "self", ".", "result", "and", "self", ".", "result", "[", "-", "1", "]", "[", "0", "]", "==", "INDENT", ":", "self", ".", "result", ".", "pop", "(", ")", "self", ".", "res...
Replace previous indentation with desired amount
[ "Replace", "previous", "indentation", "with", "desired", "amount" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L215-L219
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.ignore_token
def ignore_token(self): """Determine if we should ignore current token""" def get_next_ignore(remove=False): """Get next ignore from ignore_next and remove from ignore_next""" next_ignore = self.ignore_next # Just want to return it, don't want to remove yet ...
python
def ignore_token(self): """Determine if we should ignore current token""" def get_next_ignore(remove=False): """Get next ignore from ignore_next and remove from ignore_next""" next_ignore = self.ignore_next # Just want to return it, don't want to remove yet ...
[ "def", "ignore_token", "(", "self", ")", ":", "def", "get_next_ignore", "(", "remove", "=", "False", ")", ":", "\"\"\"Get next ignore from ignore_next and remove from ignore_next\"\"\"", "next_ignore", "=", "self", ".", "ignore_next", "# Just want to return it, don't want to ...
Determine if we should ignore current token
[ "Determine", "if", "we", "should", "ignore", "current", "token" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L221-L271
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.wrapped_setups
def wrapped_setups(self): """Create tokens for Described.setup = noy_wrap_setup(Described, Described.setup) for setup/teardown""" lst = [] for group in self.all_groups: if not group.root: if group.has_after_each: lst.extend(self.tokens.wrap_after_e...
python
def wrapped_setups(self): """Create tokens for Described.setup = noy_wrap_setup(Described, Described.setup) for setup/teardown""" lst = [] for group in self.all_groups: if not group.root: if group.has_after_each: lst.extend(self.tokens.wrap_after_e...
[ "def", "wrapped_setups", "(", "self", ")", ":", "lst", "=", "[", "]", "for", "group", "in", "self", ".", "all_groups", ":", "if", "not", "group", ".", "root", ":", "if", "group", ".", "has_after_each", ":", "lst", ".", "extend", "(", "self", ".", "...
Create tokens for Described.setup = noy_wrap_setup(Described, Described.setup) for setup/teardown
[ "Create", "tokens", "for", "Described", ".", "setup", "=", "noy_wrap_setup", "(", "Described", "Described", ".", "setup", ")", "for", "setup", "/", "teardown" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L273-L291
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.make_method_names
def make_method_names(self): """Create tokens for setting __testname__ on functions""" lst = [] for group in self.all_groups: for single in group.singles: name, english = single.name, single.english if english[1:-1] != name.replace('_', ' '): ...
python
def make_method_names(self): """Create tokens for setting __testname__ on functions""" lst = [] for group in self.all_groups: for single in group.singles: name, english = single.name, single.english if english[1:-1] != name.replace('_', ' '): ...
[ "def", "make_method_names", "(", "self", ")", ":", "lst", "=", "[", "]", "for", "group", "in", "self", ".", "all_groups", ":", "for", "single", "in", "group", ".", "singles", ":", "name", ",", "english", "=", "single", ".", "name", ",", "single", "."...
Create tokens for setting __testname__ on functions
[ "Create", "tokens", "for", "setting", "__testname__", "on", "functions" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L293-L301
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.make_describe_attrs
def make_describe_attrs(self): """Create tokens for setting is_noy_spec on describes""" lst = [] if self.all_groups: lst.append((NEWLINE, '\n')) lst.append((INDENT, '')) for group in self.all_groups: if group.name: lst.exte...
python
def make_describe_attrs(self): """Create tokens for setting is_noy_spec on describes""" lst = [] if self.all_groups: lst.append((NEWLINE, '\n')) lst.append((INDENT, '')) for group in self.all_groups: if group.name: lst.exte...
[ "def", "make_describe_attrs", "(", "self", ")", ":", "lst", "=", "[", "]", "if", "self", ".", "all_groups", ":", "lst", ".", "append", "(", "(", "NEWLINE", ",", "'\\n'", ")", ")", "lst", ".", "append", "(", "(", "INDENT", ",", "''", ")", ")", "fo...
Create tokens for setting is_noy_spec on describes
[ "Create", "tokens", "for", "setting", "is_noy_spec", "on", "describes" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L303-L314
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.forced_insert
def forced_insert(self): """ Insert tokens if self.insert_till hasn't been reached yet Will respect self.inserted_line and make sure token is inserted before it Returns True if it appends anything or if it reached the insert_till token """ # If we have any tok...
python
def forced_insert(self): """ Insert tokens if self.insert_till hasn't been reached yet Will respect self.inserted_line and make sure token is inserted before it Returns True if it appends anything or if it reached the insert_till token """ # If we have any tok...
[ "def", "forced_insert", "(", "self", ")", ":", "# If we have any tokens we are waiting for", "if", "self", ".", "insert_till", ":", "# Determine where to append this token", "append_at", "=", "-", "1", "if", "self", ".", "inserted_line", ":", "append_at", "=", "-", ...
Insert tokens if self.insert_till hasn't been reached yet Will respect self.inserted_line and make sure token is inserted before it Returns True if it appends anything or if it reached the insert_till token
[ "Insert", "tokens", "if", "self", ".", "insert_till", "hasn", "t", "been", "reached", "yet", "Will", "respect", "self", ".", "inserted_line", "and", "make", "sure", "token", "is", "inserted", "before", "it", "Returns", "True", "if", "it", "appends", "anythin...
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L316-L342
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.add_tokens_for_pass
def add_tokens_for_pass(self): """Add tokens for a pass to result""" # Make sure pass not added to group again self.groups.empty = False # Remove existing newline/indentation while self.result[-1][0] in (INDENT, NEWLINE): self.result.pop() # Add pass and ind...
python
def add_tokens_for_pass(self): """Add tokens for a pass to result""" # Make sure pass not added to group again self.groups.empty = False # Remove existing newline/indentation while self.result[-1][0] in (INDENT, NEWLINE): self.result.pop() # Add pass and ind...
[ "def", "add_tokens_for_pass", "(", "self", ")", ":", "# Make sure pass not added to group again", "self", ".", "groups", ".", "empty", "=", "False", "# Remove existing newline/indentation", "while", "self", ".", "result", "[", "-", "1", "]", "[", "0", "]", "in", ...
Add tokens for a pass to result
[ "Add", "tokens", "for", "a", "pass", "to", "result" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L348-L363
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.add_tokens_for_group
def add_tokens_for_group(self, with_pass=False): """Add the tokens for the group signature""" kls = self.groups.super_kls name = self.groups.kls_name # Reset indentation to beginning and add signature self.reset_indentation('') self.result.extend(self.tokens.make_describ...
python
def add_tokens_for_group(self, with_pass=False): """Add the tokens for the group signature""" kls = self.groups.super_kls name = self.groups.kls_name # Reset indentation to beginning and add signature self.reset_indentation('') self.result.extend(self.tokens.make_describ...
[ "def", "add_tokens_for_group", "(", "self", ",", "with_pass", "=", "False", ")", ":", "kls", "=", "self", ".", "groups", ".", "super_kls", "name", "=", "self", ".", "groups", ".", "kls_name", "# Reset indentation to beginning and add signature", "self", ".", "re...
Add the tokens for the group signature
[ "Add", "the", "tokens", "for", "the", "group", "signature" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L387-L400
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.add_tokens_for_single
def add_tokens_for_single(self, ignore=False): """Add the tokens for the single signature""" args = self.single.args name = self.single.python_name # Reset indentation to proper amount and add signature self.reset_indentation(self.indent_type * self.single.indent) self.r...
python
def add_tokens_for_single(self, ignore=False): """Add the tokens for the single signature""" args = self.single.args name = self.single.python_name # Reset indentation to proper amount and add signature self.reset_indentation(self.indent_type * self.single.indent) self.r...
[ "def", "add_tokens_for_single", "(", "self", ",", "ignore", "=", "False", ")", ":", "args", "=", "self", ".", "single", ".", "args", "name", "=", "self", ".", "single", ".", "python_name", "# Reset indentation to proper amount and add signature", "self", ".", "r...
Add the tokens for the single signature
[ "Add", "the", "tokens", "for", "the", "single", "signature" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L402-L416
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.finish_hanging
def finish_hanging(self): """Add tokens for hanging singature if any""" if self.groups.starting_signature: if self.groups.starting_group: self.add_tokens_for_group(with_pass=True) elif self.groups.starting_single: self.add_tokens_for_single(ignore...
python
def finish_hanging(self): """Add tokens for hanging singature if any""" if self.groups.starting_signature: if self.groups.starting_group: self.add_tokens_for_group(with_pass=True) elif self.groups.starting_single: self.add_tokens_for_single(ignore...
[ "def", "finish_hanging", "(", "self", ")", ":", "if", "self", ".", "groups", ".", "starting_signature", ":", "if", "self", ".", "groups", ".", "starting_group", ":", "self", ".", "add_tokens_for_group", "(", "with_pass", "=", "True", ")", "elif", "self", "...
Add tokens for hanging singature if any
[ "Add", "tokens", "for", "hanging", "singature", "if", "any" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L418-L425
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.determine_if_whitespace
def determine_if_whitespace(self): """ Set is_space if current token is whitespace Is space if value is: * Newline * Empty String * Something that matches regexes['whitespace'] """ value = self.current.value if value == '\n'...
python
def determine_if_whitespace(self): """ Set is_space if current token is whitespace Is space if value is: * Newline * Empty String * Something that matches regexes['whitespace'] """ value = self.current.value if value == '\n'...
[ "def", "determine_if_whitespace", "(", "self", ")", ":", "value", "=", "self", ".", "current", ".", "value", "if", "value", "==", "'\\n'", ":", "self", ".", "is_space", "=", "True", "else", ":", "self", ".", "is_space", "=", "False", "if", "(", "value"...
Set is_space if current token is whitespace Is space if value is: * Newline * Empty String * Something that matches regexes['whitespace']
[ "Set", "is_space", "if", "current", "token", "is", "whitespace", "Is", "space", "if", "value", "is", ":", "*", "Newline", "*", "Empty", "String", "*", "Something", "that", "matches", "regexes", "[", "whitespace", "]" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L431-L446
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.determine_inside_container
def determine_inside_container(self): """ Set self.in_container if we're inside a container * Inside container * Current token starts a new container * Current token ends all containers """ tokenum, value = self.current.tokenum, self.current.val...
python
def determine_inside_container(self): """ Set self.in_container if we're inside a container * Inside container * Current token starts a new container * Current token ends all containers """ tokenum, value = self.current.tokenum, self.current.val...
[ "def", "determine_inside_container", "(", "self", ")", ":", "tokenum", ",", "value", "=", "self", ".", "current", ".", "tokenum", ",", "self", ".", "current", ".", "value", "ending_container", "=", "False", "starting_container", "=", "False", "if", "tokenum", ...
Set self.in_container if we're inside a container * Inside container * Current token starts a new container * Current token ends all containers
[ "Set", "self", ".", "in_container", "if", "we", "re", "inside", "a", "container", "*", "Inside", "container", "*", "Current", "token", "starts", "a", "new", "container", "*", "Current", "token", "ends", "all", "containers" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L448-L474
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.determine_indentation
def determine_indentation(self): """Reset indentation for current token and in self.result to be consistent and normalized""" # Ensuring NEWLINE tokens are actually specified as such if self.current.tokenum != NEWLINE and self.current.value == '\n': self.current.tokenum = NEWLINE ...
python
def determine_indentation(self): """Reset indentation for current token and in self.result to be consistent and normalized""" # Ensuring NEWLINE tokens are actually specified as such if self.current.tokenum != NEWLINE and self.current.value == '\n': self.current.tokenum = NEWLINE ...
[ "def", "determine_indentation", "(", "self", ")", ":", "# Ensuring NEWLINE tokens are actually specified as such", "if", "self", ".", "current", ".", "tokenum", "!=", "NEWLINE", "and", "self", ".", "current", ".", "value", "==", "'\\n'", ":", "self", ".", "current...
Reset indentation for current token and in self.result to be consistent and normalized
[ "Reset", "indentation", "for", "current", "token", "and", "in", "self", ".", "result", "to", "be", "consistent", "and", "normalized" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L476-L503
delfick/nose-of-yeti
noseOfYeti/tokeniser/tracker.py
Tracker.convert_dedent
def convert_dedent(self): """Convert a dedent into an indent""" # Dedent means go back to last indentation if self.indent_amounts: self.indent_amounts.pop() # Change the token tokenum = INDENT # Get last indent amount last_indent = 0 if self....
python
def convert_dedent(self): """Convert a dedent into an indent""" # Dedent means go back to last indentation if self.indent_amounts: self.indent_amounts.pop() # Change the token tokenum = INDENT # Get last indent amount last_indent = 0 if self....
[ "def", "convert_dedent", "(", "self", ")", ":", "# Dedent means go back to last indentation", "if", "self", ".", "indent_amounts", ":", "self", ".", "indent_amounts", ".", "pop", "(", ")", "# Change the token", "tokenum", "=", "INDENT", "# Get last indent amount", "la...
Convert a dedent into an indent
[ "Convert", "a", "dedent", "into", "an", "indent" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tracker.py#L505-L524
rh-marketingops/dwm
dwm/wrappers.py
lookupAll
def lookupAll(data, configFields, lookupType, db, histObj={}): """ Return a record after having cleaning rules of specified type applied to all fields in the config :param dict data: single record (dictionary) to which cleaning rules should be applied :param dict configFields: "fields" object from DWM ...
python
def lookupAll(data, configFields, lookupType, db, histObj={}): """ Return a record after having cleaning rules of specified type applied to all fields in the config :param dict data: single record (dictionary) to which cleaning rules should be applied :param dict configFields: "fields" object from DWM ...
[ "def", "lookupAll", "(", "data", ",", "configFields", ",", "lookupType", ",", "db", ",", "histObj", "=", "{", "}", ")", ":", "for", "field", "in", "data", ".", "keys", "(", ")", ":", "if", "field", "in", "configFields", ".", "keys", "(", ")", "and"...
Return a record after having cleaning rules of specified type applied to all fields in the config :param dict data: single record (dictionary) to which cleaning rules should be applied :param dict configFields: "fields" object from DWM config (see DataDictionary) :param string lookupType: Type of lookup to...
[ "Return", "a", "record", "after", "having", "cleaning", "rules", "of", "specified", "type", "applied", "to", "all", "fields", "in", "the", "config" ]
train
https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/wrappers.py#L6-L37
rh-marketingops/dwm
dwm/wrappers.py
DeriveDataLookupAll
def DeriveDataLookupAll(data, configFields, db, histObj={}): """ Return a record after performing derive rules for all fields, based on config :param dict data: single record (dictionary) to which cleaning rules should be applied :param dict configFields: "fields" object from DWM config (see DataDictio...
python
def DeriveDataLookupAll(data, configFields, db, histObj={}): """ Return a record after performing derive rules for all fields, based on config :param dict data: single record (dictionary) to which cleaning rules should be applied :param dict configFields: "fields" object from DWM config (see DataDictio...
[ "def", "DeriveDataLookupAll", "(", "data", ",", "configFields", ",", "db", ",", "histObj", "=", "{", "}", ")", ":", "def", "checkDeriveOptions", "(", "option", ",", "derive_set_config", ")", ":", "\"\"\"\n Check derive option is exist into options list and return...
Return a record after performing derive rules for all fields, based on config :param dict data: single record (dictionary) to which cleaning rules should be applied :param dict configFields: "fields" object from DWM config (see DataDictionary) :param MongoClient db: MongoClient instance connected to MongoD...
[ "Return", "a", "record", "after", "performing", "derive", "rules", "for", "all", "fields", "based", "on", "config" ]
train
https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/wrappers.py#L40-L103
finklabs/banana
banana/router.py
Router._get_generators
def _get_generators(self): """Get installed banana plugins. :return: dictionary of installed generators name: distribution """ # on using entrypoints: # http://stackoverflow.com/questions/774824/explain-python-entry-points # TODO: make sure we do not have conflicting gen...
python
def _get_generators(self): """Get installed banana plugins. :return: dictionary of installed generators name: distribution """ # on using entrypoints: # http://stackoverflow.com/questions/774824/explain-python-entry-points # TODO: make sure we do not have conflicting gen...
[ "def", "_get_generators", "(", "self", ")", ":", "# on using entrypoints:", "# http://stackoverflow.com/questions/774824/explain-python-entry-points", "# TODO: make sure we do not have conflicting generators installed!", "generators", "=", "[", "ep", ".", "name", "for", "ep", "in",...
Get installed banana plugins. :return: dictionary of installed generators name: distribution
[ "Get", "installed", "banana", "plugins", "." ]
train
https://github.com/finklabs/banana/blob/bc416b5a3971fba0b0a90644760ccaddb95b0149/banana/router.py#L29-L39
finklabs/banana
banana/router.py
Router._get_generator
def _get_generator(self, name): """Load the generator plugin and execute its lifecycle. :param dist: distribution """ for ep in pkg_resources.iter_entry_points(self.group, name=None): if ep.name == name: generator = ep.load() return generator
python
def _get_generator(self, name): """Load the generator plugin and execute its lifecycle. :param dist: distribution """ for ep in pkg_resources.iter_entry_points(self.group, name=None): if ep.name == name: generator = ep.load() return generator
[ "def", "_get_generator", "(", "self", ",", "name", ")", ":", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "self", ".", "group", ",", "name", "=", "None", ")", ":", "if", "ep", ".", "name", "==", "name", ":", "generator", "=", "e...
Load the generator plugin and execute its lifecycle. :param dist: distribution
[ "Load", "the", "generator", "plugin", "and", "execute", "its", "lifecycle", "." ]
train
https://github.com/finklabs/banana/blob/bc416b5a3971fba0b0a90644760ccaddb95b0149/banana/router.py#L41-L49
finklabs/banana
banana/router.py
Router.execute
def execute(self, name): """Orchestrate the work of the generator plugin. It is split into multiple phases: * initializing * prompting * configuring * writing :param gen: the generator you want to run :return: """ generator = self._get_gen...
python
def execute(self, name): """Orchestrate the work of the generator plugin. It is split into multiple phases: * initializing * prompting * configuring * writing :param gen: the generator you want to run :return: """ generator = self._get_gen...
[ "def", "execute", "(", "self", ",", "name", ")", ":", "generator", "=", "self", ".", "_get_generator", "(", "name", ")", "generator", ".", "initializing", "(", ")", "answers", "=", "generator", ".", "prompting", "(", "create_store_prompt", "(", "name", ")"...
Orchestrate the work of the generator plugin. It is split into multiple phases: * initializing * prompting * configuring * writing :param gen: the generator you want to run :return:
[ "Orchestrate", "the", "work", "of", "the", "generator", "plugin", ".", "It", "is", "split", "into", "multiple", "phases", ":", "*", "initializing", "*", "prompting", "*", "configuring", "*", "writing" ]
train
https://github.com/finklabs/banana/blob/bc416b5a3971fba0b0a90644760ccaddb95b0149/banana/router.py#L51-L68
finklabs/banana
banana/router.py
Router.parse_args
def parse_args(self, doc, argv): """Parse ba arguments :param args: sys.argv[1:] :return: arguments """ # first a little sneak peak if we have a generator arguments = docopt(doc, argv=argv, help=False) if arguments.get('<generator>'): name = arguments...
python
def parse_args(self, doc, argv): """Parse ba arguments :param args: sys.argv[1:] :return: arguments """ # first a little sneak peak if we have a generator arguments = docopt(doc, argv=argv, help=False) if arguments.get('<generator>'): name = arguments...
[ "def", "parse_args", "(", "self", ",", "doc", ",", "argv", ")", ":", "# first a little sneak peak if we have a generator", "arguments", "=", "docopt", "(", "doc", ",", "argv", "=", "argv", ",", "help", "=", "False", ")", "if", "arguments", ".", "get", "(", ...
Parse ba arguments :param args: sys.argv[1:] :return: arguments
[ "Parse", "ba", "arguments" ]
train
https://github.com/finklabs/banana/blob/bc416b5a3971fba0b0a90644760ccaddb95b0149/banana/router.py#L70-L111
finklabs/banana
banana/router.py
Router.navigate
def navigate(self, name, *args): """Navigate to a route * * @param {String} name Route name * @param {*} arg A single argument to pass to the route handler */ """ if name not in self.routes: raise Exception('invalid route name \'%s\'' % name) ...
python
def navigate(self, name, *args): """Navigate to a route * * @param {String} name Route name * @param {*} arg A single argument to pass to the route handler */ """ if name not in self.routes: raise Exception('invalid route name \'%s\'' % name) ...
[ "def", "navigate", "(", "self", ",", "name", ",", "*", "args", ")", ":", "if", "name", "not", "in", "self", ".", "routes", ":", "raise", "Exception", "(", "'invalid route name \\'%s\\''", "%", "name", ")", "elif", "callable", "(", "self", ".", "routes", ...
Navigate to a route * * @param {String} name Route name * @param {*} arg A single argument to pass to the route handler */
[ "Navigate", "to", "a", "route", "*", "*" ]
train
https://github.com/finklabs/banana/blob/bc416b5a3971fba0b0a90644760ccaddb95b0149/banana/router.py#L113-L124
finklabs/banana
banana/router.py
Router.register_route
def register_route(self, name, route): """Register a route handler :param name: Name of the route :param route: Route handler """ try: self.routes[name] = route.handle except Exception as e: print('could not import handle, maybe something wrong ',...
python
def register_route(self, name, route): """Register a route handler :param name: Name of the route :param route: Route handler """ try: self.routes[name] = route.handle except Exception as e: print('could not import handle, maybe something wrong ',...
[ "def", "register_route", "(", "self", ",", "name", ",", "route", ")", ":", "try", ":", "self", ".", "routes", "[", "name", "]", "=", "route", ".", "handle", "except", "Exception", "as", "e", ":", "print", "(", "'could not import handle, maybe something wrong...
Register a route handler :param name: Name of the route :param route: Route handler
[ "Register", "a", "route", "handler" ]
train
https://github.com/finklabs/banana/blob/bc416b5a3971fba0b0a90644760ccaddb95b0149/banana/router.py#L126-L137
klahnakoski/pyLibrary
jx_elasticsearch/es52/painless.py
box
def box(script): """ :param es_script: :return: TEXT EXPRESSION WITH NON OBJECTS BOXED """ if script.type is BOOLEAN: return "Boolean.valueOf(" + text_type(script.expr) + ")" elif script.type is INTEGER: return "Integer.valueOf(" + text_type(script.expr) + ")" elif script.typ...
python
def box(script): """ :param es_script: :return: TEXT EXPRESSION WITH NON OBJECTS BOXED """ if script.type is BOOLEAN: return "Boolean.valueOf(" + text_type(script.expr) + ")" elif script.type is INTEGER: return "Integer.valueOf(" + text_type(script.expr) + ")" elif script.typ...
[ "def", "box", "(", "script", ")", ":", "if", "script", ".", "type", "is", "BOOLEAN", ":", "return", "\"Boolean.valueOf(\"", "+", "text_type", "(", "script", ".", "expr", ")", "+", "\")\"", "elif", "script", ".", "type", "is", "INTEGER", ":", "return", ...
:param es_script: :return: TEXT EXPRESSION WITH NON OBJECTS BOXED
[ ":", "param", "es_script", ":", ":", "return", ":", "TEXT", "EXPRESSION", "WITH", "NON", "OBJECTS", "BOXED" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/painless.py#L118-L130
klahnakoski/pyLibrary
mo_parquet/schema.py
SchemaTree.add
def add(self, full_name, repetition_type, type): """ :param full_name: dot delimited path to the property (use dot (".") for none) :param repetition_type: one of OPTIONAL or NESTED (REQUIRED is not possible) :param json_type: the json type to store :return: """ ba...
python
def add(self, full_name, repetition_type, type): """ :param full_name: dot delimited path to the property (use dot (".") for none) :param repetition_type: one of OPTIONAL or NESTED (REQUIRED is not possible) :param json_type: the json type to store :return: """ ba...
[ "def", "add", "(", "self", ",", "full_name", ",", "repetition_type", ",", "type", ")", ":", "base_name", "=", "self", ".", "element", ".", "name", "simple_name", "=", "relative_field", "(", "full_name", ",", "base_name", ")", "path", "=", "split_field", "(...
:param full_name: dot delimited path to the property (use dot (".") for none) :param repetition_type: one of OPTIONAL or NESTED (REQUIRED is not possible) :param json_type: the json type to store :return:
[ ":", "param", "full_name", ":", "dot", "delimited", "path", "to", "the", "property", "(", "use", "dot", "(", ".", ")", "for", "none", ")", ":", "param", "repetition_type", ":", "one", "of", "OPTIONAL", "or", "NESTED", "(", "REQUIRED", "is", "not", "pos...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_parquet/schema.py#L43-L64
klahnakoski/pyLibrary
mo_parquet/schema.py
SchemaTree.get_parquet_metadata
def get_parquet_metadata( self, path='.' ): """ OUTPUT PARQUET METADATA COLUMNS :param path: FOR INTERNAL USE :return: LIST OF SchemaElement """ children = [] for name, child_schema in sort_using_key(self.more.items(), lambda p: p[0]): ...
python
def get_parquet_metadata( self, path='.' ): """ OUTPUT PARQUET METADATA COLUMNS :param path: FOR INTERNAL USE :return: LIST OF SchemaElement """ children = [] for name, child_schema in sort_using_key(self.more.items(), lambda p: p[0]): ...
[ "def", "get_parquet_metadata", "(", "self", ",", "path", "=", "'.'", ")", ":", "children", "=", "[", "]", "for", "name", ",", "child_schema", "in", "sort_using_key", "(", "self", ".", "more", ".", "items", "(", ")", ",", "lambda", "p", ":", "p", "[",...
OUTPUT PARQUET METADATA COLUMNS :param path: FOR INTERNAL USE :return: LIST OF SchemaElement
[ "OUTPUT", "PARQUET", "METADATA", "COLUMNS", ":", "param", "path", ":", "FOR", "INTERNAL", "USE", ":", "return", ":", "LIST", "OF", "SchemaElement" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_parquet/schema.py#L202-L219
Galarzaa90/tibia.py
tibiapy/abc.py
Serializable.to_json
def to_json(self, *, indent=None, sort_keys = False): """Gets the object's JSON representation. Parameters ---------- indent: :class:`int`, optional Number of spaces used as indentation, ``None`` will return the shortest possible string. sort_keys: :class:`bool`, opt...
python
def to_json(self, *, indent=None, sort_keys = False): """Gets the object's JSON representation. Parameters ---------- indent: :class:`int`, optional Number of spaces used as indentation, ``None`` will return the shortest possible string. sort_keys: :class:`bool`, opt...
[ "def", "to_json", "(", "self", ",", "*", ",", "indent", "=", "None", ",", "sort_keys", "=", "False", ")", ":", "return", "json", ".", "dumps", "(", "{", "k", ":", "v", "for", "k", ",", "v", "in", "dict", "(", "self", ")", ".", "items", "(", "...
Gets the object's JSON representation. Parameters ---------- indent: :class:`int`, optional Number of spaces used as indentation, ``None`` will return the shortest possible string. sort_keys: :class:`bool`, optional Whether keys should be sorted alphabetically or...
[ "Gets", "the", "object", "s", "JSON", "representation", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/abc.py#L66-L82
Galarzaa90/tibia.py
tibiapy/abc.py
BaseHouseWithId.url
def url(self): """:class:`str`: The URL to the Tibia.com page of the house.""" return self.get_url(self.id, self.world) if self.id and self.world else None
python
def url(self): """:class:`str`: The URL to the Tibia.com page of the house.""" return self.get_url(self.id, self.world) if self.id and self.world else None
[ "def", "url", "(", "self", ")", ":", "return", "self", ".", "get_url", "(", "self", ".", "id", ",", "self", ".", "world", ")", "if", "self", ".", "id", "and", "self", ".", "world", "else", "None" ]
:class:`str`: The URL to the Tibia.com page of the house.
[ ":", "class", ":", "str", ":", "The", "URL", "to", "the", "Tibia", ".", "com", "page", "of", "the", "house", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/abc.py#L312-L314
Galarzaa90/tibia.py
tibiapy/abc.py
BaseHouseWithId.url_tibiadata
def url_tibiadata(self): """:class:`str`: The URL to the TibiaData.com page of the house.""" return self.get_url_tibiadata(self.id, self.world) if self.id and self.world else None
python
def url_tibiadata(self): """:class:`str`: The URL to the TibiaData.com page of the house.""" return self.get_url_tibiadata(self.id, self.world) if self.id and self.world else None
[ "def", "url_tibiadata", "(", "self", ")", ":", "return", "self", ".", "get_url_tibiadata", "(", "self", ".", "id", ",", "self", ".", "world", ")", "if", "self", ".", "id", "and", "self", ".", "world", "else", "None" ]
:class:`str`: The URL to the TibiaData.com page of the house.
[ ":", "class", ":", "str", ":", "The", "URL", "to", "the", "TibiaData", ".", "com", "page", "of", "the", "house", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/abc.py#L317-L319
klahnakoski/pyLibrary
tuid/client.py
TuidClient.get_tuid
def get_tuid(self, branch, revision, file): """ :param branch: BRANCH TO FIND THE REVISION/FILE :param revision: THE REVISION NUNMBER :param file: THE FULL PATH TO A SINGLE FILE :return: A LIST OF TUIDS """ service_response = wrap(self.get_tuids(branch, revision, ...
python
def get_tuid(self, branch, revision, file): """ :param branch: BRANCH TO FIND THE REVISION/FILE :param revision: THE REVISION NUNMBER :param file: THE FULL PATH TO A SINGLE FILE :return: A LIST OF TUIDS """ service_response = wrap(self.get_tuids(branch, revision, ...
[ "def", "get_tuid", "(", "self", ",", "branch", ",", "revision", ",", "file", ")", ":", "service_response", "=", "wrap", "(", "self", ".", "get_tuids", "(", "branch", ",", "revision", ",", "[", "file", "]", ")", ")", "for", "f", ",", "t", "in", "ser...
:param branch: BRANCH TO FIND THE REVISION/FILE :param revision: THE REVISION NUNMBER :param file: THE FULL PATH TO A SINGLE FILE :return: A LIST OF TUIDS
[ ":", "param", "branch", ":", "BRANCH", "TO", "FIND", "THE", "REVISION", "/", "FILE", ":", "param", "revision", ":", "THE", "REVISION", "NUNMBER", ":", "param", "file", ":", "THE", "FULL", "PATH", "TO", "A", "SINGLE", "FILE", ":", "return", ":", "A", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/tuid/client.py#L56-L65
klahnakoski/pyLibrary
tuid/client.py
TuidClient.get_tuids
def get_tuids(self, branch, revision, files): """ GET TUIDS FROM ENDPOINT, AND STORE IN DB :param branch: BRANCH TO FIND THE REVISION/FILE :param revision: THE REVISION NUNMBER :param files: THE FULL PATHS TO THE FILES :return: MAP FROM FILENAME TO TUID LIST """ ...
python
def get_tuids(self, branch, revision, files): """ GET TUIDS FROM ENDPOINT, AND STORE IN DB :param branch: BRANCH TO FIND THE REVISION/FILE :param revision: THE REVISION NUNMBER :param files: THE FULL PATHS TO THE FILES :return: MAP FROM FILENAME TO TUID LIST """ ...
[ "def", "get_tuids", "(", "self", ",", "branch", ",", "revision", ",", "files", ")", ":", "# SCRUB INPUTS", "revision", "=", "revision", "[", ":", "12", "]", "files", "=", "[", "file", ".", "lstrip", "(", "'/'", ")", "for", "file", "in", "files", "]",...
GET TUIDS FROM ENDPOINT, AND STORE IN DB :param branch: BRANCH TO FIND THE REVISION/FILE :param revision: THE REVISION NUNMBER :param files: THE FULL PATHS TO THE FILES :return: MAP FROM FILENAME TO TUID LIST
[ "GET", "TUIDS", "FROM", "ENDPOINT", "AND", "STORE", "IN", "DB", ":", "param", "branch", ":", "BRANCH", "TO", "FIND", "THE", "REVISION", "/", "FILE", ":", "param", "revision", ":", "THE", "REVISION", "NUNMBER", ":", "param", "files", ":", "THE", "FULL", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/tuid/client.py#L67-L156
camsci/meteor-pi
src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py
add_routes
def add_routes(meteor_app, url_path='/importv2'): """ Add two routes to the specified instance of :class:`meteorpi_server.MeteorApp` to implement the import API and allow for replication of data to this server. :param meteorpi_server.MeteorApp meteor_app: The :class:`meteorpi_server.MeteorApp` ...
python
def add_routes(meteor_app, url_path='/importv2'): """ Add two routes to the specified instance of :class:`meteorpi_server.MeteorApp` to implement the import API and allow for replication of data to this server. :param meteorpi_server.MeteorApp meteor_app: The :class:`meteorpi_server.MeteorApp` ...
[ "def", "add_routes", "(", "meteor_app", ",", "url_path", "=", "'/importv2'", ")", ":", "app", "=", "meteor_app", ".", "app", "@", "app", ".", "route", "(", "url_path", ",", "methods", "=", "[", "'POST'", "]", ")", "@", "meteor_app", ".", "requires_auth",...
Add two routes to the specified instance of :class:`meteorpi_server.MeteorApp` to implement the import API and allow for replication of data to this server. :param meteorpi_server.MeteorApp meteor_app: The :class:`meteorpi_server.MeteorApp` to which import routes should be added :param meteorpi_ser...
[ "Add", "two", "routes", "to", "the", "specified", "instance", "of", ":", "class", ":", "meteorpi_server", ".", "MeteorApp", "to", "implement", "the", "import", "API", "and", "allow", "for", "replication", "of", "data", "to", "this", "server", "." ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py#L247-L325
camsci/meteor-pi
src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py
ImportRequest.response_complete
def response_complete(self): """ Signal that this particular entity has been fully processed. The exporter will not send it to this target again under this particular export configuration (there is no guarantee another export configuration on the same server won't send it, or that it won...
python
def response_complete(self): """ Signal that this particular entity has been fully processed. The exporter will not send it to this target again under this particular export configuration (there is no guarantee another export configuration on the same server won't send it, or that it won...
[ "def", "response_complete", "(", "self", ")", ":", "ImportRequest", ".", "logger", ".", "info", "(", "\"Completed import for {0} with id {1}\"", ".", "format", "(", "self", ".", "entity_type", ",", "self", ".", "entity_id", ")", ")", "ImportRequest", ".", "logge...
Signal that this particular entity has been fully processed. The exporter will not send it to this target again under this particular export configuration (there is no guarantee another export configuration on the same server won't send it, or that it won't be received from another server though, so you...
[ "Signal", "that", "this", "particular", "entity", "has", "been", "fully", "processed", ".", "The", "exporter", "will", "not", "send", "it", "to", "this", "target", "again", "under", "this", "particular", "export", "configuration", "(", "there", "is", "no", "...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py#L129-L141
camsci/meteor-pi
src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py
ImportRequest.response_continue
def response_continue(self): """ Signals that a partial reception of data has occurred and that the exporter should continue to send data for this entity. This should also be used if import-side caching has missed, in which case the response will direct the exporter to re-send the full d...
python
def response_continue(self): """ Signals that a partial reception of data has occurred and that the exporter should continue to send data for this entity. This should also be used if import-side caching has missed, in which case the response will direct the exporter to re-send the full d...
[ "def", "response_continue", "(", "self", ")", ":", "if", "self", ".", "entity", "is", "not", "None", ":", "ImportRequest", ".", "logger", ".", "debug", "(", "\"Sending: continue\"", ")", "return", "jsonify", "(", "{", "'state'", ":", "'continue'", "}", ")"...
Signals that a partial reception of data has occurred and that the exporter should continue to send data for this entity. This should also be used if import-side caching has missed, in which case the response will direct the exporter to re-send the full data for the entity (otherwise it will send back t...
[ "Signals", "that", "a", "partial", "reception", "of", "data", "has", "occurred", "and", "that", "the", "exporter", "should", "continue", "to", "send", "data", "for", "this", "entity", ".", "This", "should", "also", "be", "used", "if", "import", "-", "side"...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py#L159-L176
camsci/meteor-pi
src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py
ImportRequest.process_request
def process_request(): """ Retrieve a CameraStatus, Event or FileRecord from the request, based on the supplied type and ID. If the type is 'cached_request' then the ID must be specified in 'cached_request_id' - if this ID is not for an entity in the cache this method will return None an...
python
def process_request(): """ Retrieve a CameraStatus, Event or FileRecord from the request, based on the supplied type and ID. If the type is 'cached_request' then the ID must be specified in 'cached_request_id' - if this ID is not for an entity in the cache this method will return None an...
[ "def", "process_request", "(", ")", ":", "g", ".", "request_dict", "=", "safe_load", "(", "request", ".", "get_data", "(", ")", ")", "entity_type", "=", "g", ".", "request_dict", "[", "'type'", "]", "entity_id", "=", "g", ".", "request_dict", "[", "entit...
Retrieve a CameraStatus, Event or FileRecord from the request, based on the supplied type and ID. If the type is 'cached_request' then the ID must be specified in 'cached_request_id' - if this ID is not for an entity in the cache this method will return None and clear the cache (this should only happen ...
[ "Retrieve", "a", "CameraStatus", "Event", "or", "FileRecord", "from", "the", "request", "based", "on", "the", "supplied", "type", "and", "ID", ".", "If", "the", "type", "is", "cached_request", "then", "the", "ID", "must", "be", "specified", "in", "cached_req...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py#L204-L223
camsci/meteor-pi
src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py
ImportRequest._get_entity
def _get_entity(entity_id): """ Uses the request context to retrieve a :class:`meteorpi_model.CameraStatus`, :class:`meteorpi_model.Event` or :class:`meteorpi_model.FileRecord` from the POSTed JSON string. :param string entity_id: The ID of a CameraStatus, Event or FileRecor...
python
def _get_entity(entity_id): """ Uses the request context to retrieve a :class:`meteorpi_model.CameraStatus`, :class:`meteorpi_model.Event` or :class:`meteorpi_model.FileRecord` from the POSTed JSON string. :param string entity_id: The ID of a CameraStatus, Event or FileRecor...
[ "def", "_get_entity", "(", "entity_id", ")", ":", "entity_type", "=", "g", ".", "request_dict", "[", "'type'", "]", "if", "entity_type", "==", "'file'", ":", "return", "model", ".", "FileRecord", ".", "from_dict", "(", "g", ".", "request_dict", "[", "'file...
Uses the request context to retrieve a :class:`meteorpi_model.CameraStatus`, :class:`meteorpi_model.Event` or :class:`meteorpi_model.FileRecord` from the POSTed JSON string. :param string entity_id: The ID of a CameraStatus, Event or FileRecord contained within the request :return: ...
[ "Uses", "the", "request", "context", "to", "retrieve", "a", ":", "class", ":", "meteorpi_model", ".", "CameraStatus", ":", "class", ":", "meteorpi_model", ".", "Event", "or", ":", "class", ":", "meteorpi_model", ".", "FileRecord", "from", "the", "POSTed", "J...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/importer_api.py#L226-L244
allo-/django-bingo
bingo/models.py
get_game
def get_game(site, description="", create=False): """ get the current game, if its still active, else creates a new game, if the current time is inside the GAME_START_TIMES interval and create=True @param create: create a game, if there is no active game @returns: None if the...
python
def get_game(site, description="", create=False): """ get the current game, if its still active, else creates a new game, if the current time is inside the GAME_START_TIMES interval and create=True @param create: create a game, if there is no active game @returns: None if the...
[ "def", "get_game", "(", "site", ",", "description", "=", "\"\"", ",", "create", "=", "False", ")", ":", "game", "=", "None", "games", "=", "Game", ".", "objects", ".", "filter", "(", "site", "=", "site", ")", ".", "order_by", "(", "\"-created\"", ")"...
get the current game, if its still active, else creates a new game, if the current time is inside the GAME_START_TIMES interval and create=True @param create: create a game, if there is no active game @returns: None if there is no active Game, and none shoul be created or the (ne...
[ "get", "the", "current", "game", "if", "its", "still", "active", "else", "creates", "a", "new", "game", "if", "the", "current", "time", "is", "inside", "the", "GAME_START_TIMES", "interval", "and", "create", "=", "True" ]
train
https://github.com/allo-/django-bingo/blob/16adcabbb91f227cb007f62b19f904ab1b751419/bingo/models.py#L68-L101
allo-/django-bingo
bingo/models.py
Game.words_with_votes
def words_with_votes(self, only_topics=True): """ returns a list with words ordered by the number of votes annotated with the number of votes in the "votes" property. """ result = Word.objects.filter( bingofield__board__game__id=self.id).exclude( t...
python
def words_with_votes(self, only_topics=True): """ returns a list with words ordered by the number of votes annotated with the number of votes in the "votes" property. """ result = Word.objects.filter( bingofield__board__game__id=self.id).exclude( t...
[ "def", "words_with_votes", "(", "self", ",", "only_topics", "=", "True", ")", ":", "result", "=", "Word", ".", "objects", ".", "filter", "(", "bingofield__board__game__id", "=", "self", ".", "id", ")", ".", "exclude", "(", "type", "=", "WORD_TYPE_MIDDLE", ...
returns a list with words ordered by the number of votes annotated with the number of votes in the "votes" property.
[ "returns", "a", "list", "with", "words", "ordered", "by", "the", "number", "of", "votes", "annotated", "with", "the", "number", "of", "votes", "in", "the", "votes", "property", "." ]
train
https://github.com/allo-/django-bingo/blob/16adcabbb91f227cb007f62b19f904ab1b751419/bingo/models.py#L179-L200
klahnakoski/pyLibrary
mo_dots/nones.py
_assign_to_null
def _assign_to_null(obj, path, value, force=True): """ value IS ASSIGNED TO obj[self.path][key] path IS AN ARRAY OF PROPERTY NAMES force=False IF YOU PREFER TO use setDefault() """ try: if obj is Null: return if _get(obj, CLASS) is NullType: d = _get(obj, ...
python
def _assign_to_null(obj, path, value, force=True): """ value IS ASSIGNED TO obj[self.path][key] path IS AN ARRAY OF PROPERTY NAMES force=False IF YOU PREFER TO use setDefault() """ try: if obj is Null: return if _get(obj, CLASS) is NullType: d = _get(obj, ...
[ "def", "_assign_to_null", "(", "obj", ",", "path", ",", "value", ",", "force", "=", "True", ")", ":", "try", ":", "if", "obj", "is", "Null", ":", "return", "if", "_get", "(", "obj", ",", "CLASS", ")", "is", "NullType", ":", "d", "=", "_get", "(",...
value IS ASSIGNED TO obj[self.path][key] path IS AN ARRAY OF PROPERTY NAMES force=False IF YOU PREFER TO use setDefault()
[ "value", "IS", "ASSIGNED", "TO", "obj", "[", "self", ".", "path", "]", "[", "key", "]", "path", "IS", "AN", "ARRAY", "OF", "PROPERTY", "NAMES", "force", "=", "False", "IF", "YOU", "PREFER", "TO", "use", "setDefault", "()" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/nones.py#L235-L269
tetframework/Tonnikala
tonnikala/languages/javascript/jslex.py
literals
def literals(choices, prefix="", suffix=""): """Create a regex from a space-separated list of literal `choices`. If provided, `prefix` and `suffix` will be attached to each choice individually. """ return "|".join(prefix + re.escape(c) + suffix for c in choices.split())
python
def literals(choices, prefix="", suffix=""): """Create a regex from a space-separated list of literal `choices`. If provided, `prefix` and `suffix` will be attached to each choice individually. """ return "|".join(prefix + re.escape(c) + suffix for c in choices.split())
[ "def", "literals", "(", "choices", ",", "prefix", "=", "\"\"", ",", "suffix", "=", "\"\"", ")", ":", "return", "\"|\"", ".", "join", "(", "prefix", "+", "re", ".", "escape", "(", "c", ")", "+", "suffix", "for", "c", "in", "choices", ".", "split", ...
Create a regex from a space-separated list of literal `choices`. If provided, `prefix` and `suffix` will be attached to each choice individually.
[ "Create", "a", "regex", "from", "a", "space", "-", "separated", "list", "of", "literal", "choices", "." ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/languages/javascript/jslex.py#L24-L31
tetframework/Tonnikala
tonnikala/languages/javascript/jslex.py
Lexer.lex
def lex(self, text, start=0): """Lexically analyze `text`. Yields pairs (`name`, `tokentext`). """ max = len(text) eaten = start s = self.state r = self.regexes toks = self.toks while eaten < max: for match in r[s].finditer(text, eate...
python
def lex(self, text, start=0): """Lexically analyze `text`. Yields pairs (`name`, `tokentext`). """ max = len(text) eaten = start s = self.state r = self.regexes toks = self.toks while eaten < max: for match in r[s].finditer(text, eate...
[ "def", "lex", "(", "self", ",", "text", ",", "start", "=", "0", ")", ":", "max", "=", "len", "(", "text", ")", "eaten", "=", "start", "s", "=", "self", ".", "state", "r", "=", "self", ".", "regexes", "toks", "=", "self", ".", "toks", "while", ...
Lexically analyze `text`. Yields pairs (`name`, `tokentext`).
[ "Lexically", "analyze", "text", "." ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/languages/javascript/jslex.py#L52-L75
klahnakoski/pyLibrary
pyLibrary/meta.py
new_instance
def new_instance(settings): """ MAKE A PYTHON INSTANCE `settings` HAS ALL THE `kwargs`, PLUS `class` ATTRIBUTE TO INDICATE THE CLASS TO CREATE """ settings = set_default({}, settings) if not settings["class"]: Log.error("Expecting 'class' attribute with fully qualified class name") ...
python
def new_instance(settings): """ MAKE A PYTHON INSTANCE `settings` HAS ALL THE `kwargs`, PLUS `class` ATTRIBUTE TO INDICATE THE CLASS TO CREATE """ settings = set_default({}, settings) if not settings["class"]: Log.error("Expecting 'class' attribute with fully qualified class name") ...
[ "def", "new_instance", "(", "settings", ")", ":", "settings", "=", "set_default", "(", "{", "}", ",", "settings", ")", "if", "not", "settings", "[", "\"class\"", "]", ":", "Log", ".", "error", "(", "\"Expecting 'class' attribute with fully qualified class name\"",...
MAKE A PYTHON INSTANCE `settings` HAS ALL THE `kwargs`, PLUS `class` ATTRIBUTE TO INDICATE THE CLASS TO CREATE
[ "MAKE", "A", "PYTHON", "INSTANCE" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/meta.py#L39-L69
klahnakoski/pyLibrary
pyLibrary/meta.py
get_function_by_name
def get_function_by_name(full_name): """ RETURN FUNCTION """ # IMPORT MODULE FOR HANDLER path = full_name.split(".") function_name = path[-1] path = ".".join(path[:-1]) constructor = None try: temp = __import__(path, globals(), locals(), [function_name], -1) output =...
python
def get_function_by_name(full_name): """ RETURN FUNCTION """ # IMPORT MODULE FOR HANDLER path = full_name.split(".") function_name = path[-1] path = ".".join(path[:-1]) constructor = None try: temp = __import__(path, globals(), locals(), [function_name], -1) output =...
[ "def", "get_function_by_name", "(", "full_name", ")", ":", "# IMPORT MODULE FOR HANDLER", "path", "=", "full_name", ".", "split", "(", "\".\"", ")", "function_name", "=", "path", "[", "-", "1", "]", "path", "=", "\".\"", ".", "join", "(", "path", "[", ":",...
RETURN FUNCTION
[ "RETURN", "FUNCTION" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/meta.py#L72-L87
klahnakoski/pyLibrary
pyLibrary/meta.py
extend
def extend(cls): """ DECORATOR TO ADD METHODS TO CLASSES :param cls: THE CLASS TO ADD THE METHOD TO :return: """ def extender(func): setattr(cls, get_function_name(func), func) return func return extender
python
def extend(cls): """ DECORATOR TO ADD METHODS TO CLASSES :param cls: THE CLASS TO ADD THE METHOD TO :return: """ def extender(func): setattr(cls, get_function_name(func), func) return func return extender
[ "def", "extend", "(", "cls", ")", ":", "def", "extender", "(", "func", ")", ":", "setattr", "(", "cls", ",", "get_function_name", "(", "func", ")", ",", "func", ")", "return", "func", "return", "extender" ]
DECORATOR TO ADD METHODS TO CLASSES :param cls: THE CLASS TO ADD THE METHOD TO :return:
[ "DECORATOR", "TO", "ADD", "METHODS", "TO", "CLASSES", ":", "param", "cls", ":", "THE", "CLASS", "TO", "ADD", "THE", "METHOD", "TO", ":", "return", ":" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/meta.py#L222-L231
ff0000/scarlet
scarlet/cms/helpers.py
normalize_fieldsets
def normalize_fieldsets(fieldsets): """ Make sure the keys in fieldset dictionaries are strings. Returns the normalized data. """ result = [] for name, options in fieldsets: result.append((name, normalize_dictionary(options))) return result
python
def normalize_fieldsets(fieldsets): """ Make sure the keys in fieldset dictionaries are strings. Returns the normalized data. """ result = [] for name, options in fieldsets: result.append((name, normalize_dictionary(options))) return result
[ "def", "normalize_fieldsets", "(", "fieldsets", ")", ":", "result", "=", "[", "]", "for", "name", ",", "options", "in", "fieldsets", ":", "result", ".", "append", "(", "(", "name", ",", "normalize_dictionary", "(", "options", ")", ")", ")", "return", "re...
Make sure the keys in fieldset dictionaries are strings. Returns the normalized data.
[ "Make", "sure", "the", "keys", "in", "fieldset", "dictionaries", "are", "strings", ".", "Returns", "the", "normalized", "data", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/helpers.py#L329-L337
ff0000/scarlet
scarlet/cms/helpers.py
normalize_dictionary
def normalize_dictionary(data_dict): """ Converts all the keys in "data_dict" to strings. The keys must be convertible using str(). """ for key, value in data_dict.items(): if not isinstance(key, str): del data_dict[key] data_dict[str(key)] = value return data_dic...
python
def normalize_dictionary(data_dict): """ Converts all the keys in "data_dict" to strings. The keys must be convertible using str(). """ for key, value in data_dict.items(): if not isinstance(key, str): del data_dict[key] data_dict[str(key)] = value return data_dic...
[ "def", "normalize_dictionary", "(", "data_dict", ")", ":", "for", "key", ",", "value", "in", "data_dict", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "key", ",", "str", ")", ":", "del", "data_dict", "[", "key", "]", "data_dict", "[", ...
Converts all the keys in "data_dict" to strings. The keys must be convertible using str().
[ "Converts", "all", "the", "keys", "in", "data_dict", "to", "strings", ".", "The", "keys", "must", "be", "convertible", "using", "str", "()", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/helpers.py#L340-L349
ff0000/scarlet
scarlet/cms/helpers.py
get_sort_field
def get_sort_field(attr, model): """ Get's the field to sort on for the given attr. Currently returns attr if it is a field on the given model. If the models has an attribute matching that name and that value has an attribute 'sort_field' than that value is used. TODO: Provide a w...
python
def get_sort_field(attr, model): """ Get's the field to sort on for the given attr. Currently returns attr if it is a field on the given model. If the models has an attribute matching that name and that value has an attribute 'sort_field' than that value is used. TODO: Provide a w...
[ "def", "get_sort_field", "(", "attr", ",", "model", ")", ":", "try", ":", "if", "model", ".", "_meta", ".", "get_field", "(", "attr", ")", ":", "return", "attr", "except", "FieldDoesNotExist", ":", "if", "isinstance", "(", "attr", ",", "basestring", ")",...
Get's the field to sort on for the given attr. Currently returns attr if it is a field on the given model. If the models has an attribute matching that name and that value has an attribute 'sort_field' than that value is used. TODO: Provide a way to sort based on a non field attribute...
[ "Get", "s", "the", "field", "to", "sort", "on", "for", "the", "given", "attr", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/helpers.py#L352-L376
ff0000/scarlet
scarlet/cms/helpers.py
AdminList.labels
def labels(self): """ Get field label for fields """ if type(self.object_list) == type([]): model = self.formset.model else: model = self.object_list.model for field in self.visible_fields: name = None if self.formset: ...
python
def labels(self): """ Get field label for fields """ if type(self.object_list) == type([]): model = self.formset.model else: model = self.object_list.model for field in self.visible_fields: name = None if self.formset: ...
[ "def", "labels", "(", "self", ")", ":", "if", "type", "(", "self", ".", "object_list", ")", "==", "type", "(", "[", "]", ")", ":", "model", "=", "self", ".", "formset", ".", "model", "else", ":", "model", "=", "self", ".", "object_list", ".", "mo...
Get field label for fields
[ "Get", "field", "label", "for", "fields" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/helpers.py#L59-L104
ralphbean/raptorizemw
examples/tg2-raptorized/ez_setup/__init__.py
use_setuptools
def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `downlo...
python
def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `downlo...
[ "def", "use_setuptools", "(", "version", "=", "DEFAULT_VERSION", ",", "download_base", "=", "DEFAULT_URL", ",", "to_dir", "=", "os", ".", "curdir", ",", "download_delay", "=", "15", ")", ":", "try", ":", "import", "setuptools", "if", "setuptools", ".", "__ve...
Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where setuptools will be downloaded, if it is n...
[ "Automatically", "find", "/", "download", "setuptools", "and", "make", "it", "available", "on", "sys", ".", "path" ]
train
https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/examples/tg2-raptorized/ez_setup/__init__.py#L65-L104
ff0000/scarlet
scarlet/accounts/views.py
activate
def activate(request, activation_key, template_name='accounts/activate_fail.html', success_url=None, extra_context=None): """ Activate a user with an activation key. The key is a SHA1 string. When the SHA1 is found with an :class:`AccountsSignup`, the :class:`User` of that acc...
python
def activate(request, activation_key, template_name='accounts/activate_fail.html', success_url=None, extra_context=None): """ Activate a user with an activation key. The key is a SHA1 string. When the SHA1 is found with an :class:`AccountsSignup`, the :class:`User` of that acc...
[ "def", "activate", "(", "request", ",", "activation_key", ",", "template_name", "=", "'accounts/activate_fail.html'", ",", "success_url", "=", "None", ",", "extra_context", "=", "None", ")", ":", "user", "=", "AccountsSignup", ".", "objects", ".", "activate_user",...
Activate a user with an activation key. The key is a SHA1 string. When the SHA1 is found with an :class:`AccountsSignup`, the :class:`User` of that account will be activated. After a successful activation the view will redirect to ``success_url``. If the SHA1 is not found, the user will be shown the ...
[ "Activate", "a", "user", "with", "an", "activation", "key", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L40-L95
ff0000/scarlet
scarlet/accounts/views.py
email_confirm
def email_confirm(request, confirmation_key, template_name='accounts/email_confirm_fail.html', success_url=None, extra_context=None): """ Confirms an email address with a confirmation key. Confirms a new email address by running :func:`User.objects.confirm_email` met...
python
def email_confirm(request, confirmation_key, template_name='accounts/email_confirm_fail.html', success_url=None, extra_context=None): """ Confirms an email address with a confirmation key. Confirms a new email address by running :func:`User.objects.confirm_email` met...
[ "def", "email_confirm", "(", "request", ",", "confirmation_key", ",", "template_name", "=", "'accounts/email_confirm_fail.html'", ",", "success_url", "=", "None", ",", "extra_context", "=", "None", ")", ":", "user", "=", "AccountsSignup", ".", "objects", ".", "con...
Confirms an email address with a confirmation key. Confirms a new email address by running :func:`User.objects.confirm_email` method. If the method returns an :class:`User` the user will have his new e-mail address set and redirected to ``success_url``. If no ``User`` is returned the user will be repre...
[ "Confirms", "an", "email", "address", "with", "a", "confirmation", "key", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L99-L147
ff0000/scarlet
scarlet/accounts/views.py
direct_to_user_template
def direct_to_user_template(request, username, template_name, extra_context=None): """ Simple wrapper for Django's :func:`direct_to_template` view. This view is used when you want to show a template to a specific user. A wrapper for :func:`direct_to_template` where the templ...
python
def direct_to_user_template(request, username, template_name, extra_context=None): """ Simple wrapper for Django's :func:`direct_to_template` view. This view is used when you want to show a template to a specific user. A wrapper for :func:`direct_to_template` where the templ...
[ "def", "direct_to_user_template", "(", "request", ",", "username", ",", "template_name", ",", "extra_context", "=", "None", ")", ":", "user", "=", "get_object_or_404", "(", "get_user_model", "(", ")", ",", "username__iexact", "=", "username", ")", "if", "not", ...
Simple wrapper for Django's :func:`direct_to_template` view. This view is used when you want to show a template to a specific user. A wrapper for :func:`direct_to_template` where the template also has access to the user that is found with ``username``. For ex. used after signup, activation and confirma...
[ "Simple", "wrapper", "for", "Django", "s", ":", "func", ":", "direct_to_template", "view", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L150-L187
ff0000/scarlet
scarlet/accounts/views.py
signin
def signin(request, auth_form=AuthenticationForm, template_name='accounts/signin_form.html', redirect_field_name=REDIRECT_FIELD_NAME, redirect_signin_function=signin_redirect, extra_context=None): """ Signin using email or username with password. Signs a user in by combinin...
python
def signin(request, auth_form=AuthenticationForm, template_name='accounts/signin_form.html', redirect_field_name=REDIRECT_FIELD_NAME, redirect_signin_function=signin_redirect, extra_context=None): """ Signin using email or username with password. Signs a user in by combinin...
[ "def", "signin", "(", "request", ",", "auth_form", "=", "AuthenticationForm", ",", "template_name", "=", "'accounts/signin_form.html'", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "redirect_signin_function", "=", "signin_redirect", ",", "extra_context", "...
Signin using email or username with password. Signs a user in by combining email/username with password. If the combination is correct and the user :func:`is_active` the :func:`redirect_signin_function` is called with the arguments ``REDIRECT_FIELD_NAME`` and an instance of the :class:`User` who is is ...
[ "Signin", "using", "email", "or", "username", "with", "password", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L191-L272
ff0000/scarlet
scarlet/accounts/views.py
signout
def signout(request, next_page=accounts_settings.ACCOUNTS_REDIRECT_ON_SIGNOUT, template_name='accounts/signout.html', *args, **kwargs): """ Signs out the user and adds a success message ``You have been signed out.`` If next_page is defined you will be redirected to the URI. If not the templa...
python
def signout(request, next_page=accounts_settings.ACCOUNTS_REDIRECT_ON_SIGNOUT, template_name='accounts/signout.html', *args, **kwargs): """ Signs out the user and adds a success message ``You have been signed out.`` If next_page is defined you will be redirected to the URI. If not the templa...
[ "def", "signout", "(", "request", ",", "next_page", "=", "accounts_settings", ".", "ACCOUNTS_REDIRECT_ON_SIGNOUT", ",", "template_name", "=", "'accounts/signout.html'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "user", ".", "is...
Signs out the user and adds a success message ``You have been signed out.`` If next_page is defined you will be redirected to the URI. If not the template in template_name is used. :param next_page: A string which specifies the URI to redirect to. :param template_name: String defining ...
[ "Signs", "out", "the", "user", "and", "adds", "a", "success", "message", "You", "have", "been", "signed", "out", ".", "If", "next_page", "is", "defined", "you", "will", "be", "redirected", "to", "the", "URI", ".", "If", "not", "the", "template", "in", ...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L276-L295
ff0000/scarlet
scarlet/accounts/views.py
email_change
def email_change(request, username, email_form=ChangeEmailForm, template_name='accounts/email_form.html', success_url=None, extra_context=None): """ Change email address :param username: String of the username which specifies the current account. :param email_...
python
def email_change(request, username, email_form=ChangeEmailForm, template_name='accounts/email_form.html', success_url=None, extra_context=None): """ Change email address :param username: String of the username which specifies the current account. :param email_...
[ "def", "email_change", "(", "request", ",", "username", ",", "email_form", "=", "ChangeEmailForm", ",", "template_name", "=", "'accounts/email_form.html'", ",", "success_url", "=", "None", ",", "extra_context", "=", "None", ")", ":", "user", "=", "get_object_or_40...
Change email address :param username: String of the username which specifies the current account. :param email_form: Form that will be used to change the email address. Defaults to :class:`ChangeEmailForm` supplied by accounts. :param template_name: String containing the t...
[ "Change", "email", "address" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L299-L365
ff0000/scarlet
scarlet/accounts/views.py
password_change
def password_change(request, username, template_name='accounts/password_form.html', pass_form=PasswordChangeForm, success_url=None, extra_context=None): """ Change password of user. This view is almost a mirror of the view supplied in :func:`contr...
python
def password_change(request, username, template_name='accounts/password_form.html', pass_form=PasswordChangeForm, success_url=None, extra_context=None): """ Change password of user. This view is almost a mirror of the view supplied in :func:`contr...
[ "def", "password_change", "(", "request", ",", "username", ",", "template_name", "=", "'accounts/password_form.html'", ",", "pass_form", "=", "PasswordChangeForm", ",", "success_url", "=", "None", ",", "extra_context", "=", "None", ")", ":", "user", "=", "get_obje...
Change password of user. This view is almost a mirror of the view supplied in :func:`contrib.auth.views.password_change`, with the minor change that in this view we also use the username to change the password. This was needed to keep our URLs logical (and REST) across the entire application. And t...
[ "Change", "password", "of", "user", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L369-L435
ff0000/scarlet
scarlet/accounts/views.py
profile_edit
def profile_edit(request, username, edit_profile_form=EditProfileForm, template_name='accounts/profile_form.html', success_url=None, extra_context=None, **kwargs): """ Edit profile. Edits a profile selected by the supplied username. First checks permissions if the user...
python
def profile_edit(request, username, edit_profile_form=EditProfileForm, template_name='accounts/profile_form.html', success_url=None, extra_context=None, **kwargs): """ Edit profile. Edits a profile selected by the supplied username. First checks permissions if the user...
[ "def", "profile_edit", "(", "request", ",", "username", ",", "edit_profile_form", "=", "EditProfileForm", ",", "template_name", "=", "'accounts/profile_form.html'", ",", "success_url", "=", "None", ",", "extra_context", "=", "None", ",", "*", "*", "kwargs", ")", ...
Edit profile. Edits a profile selected by the supplied username. First checks permissions if the user is allowed to edit this profile, if denied will show a 404. When the profile is successfully edited will redirect to ``success_url``. :param username: Username of the user which profile sh...
[ "Edit", "profile", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L439-L517
ff0000/scarlet
scarlet/accounts/views.py
profile_detail
def profile_detail( request, username, template_name=accounts_settings.ACCOUNTS_PROFILE_DETAIL_TEMPLATE, extra_context=None, **kwargs): """ Detailed view of an user. :param username: String of the username of which the profile should be viewed. :param template_name: String ...
python
def profile_detail( request, username, template_name=accounts_settings.ACCOUNTS_PROFILE_DETAIL_TEMPLATE, extra_context=None, **kwargs): """ Detailed view of an user. :param username: String of the username of which the profile should be viewed. :param template_name: String ...
[ "def", "profile_detail", "(", "request", ",", "username", ",", "template_name", "=", "accounts_settings", ".", "ACCOUNTS_PROFILE_DETAIL_TEMPLATE", ",", "extra_context", "=", "None", ",", "*", "*", "kwargs", ")", ":", "user", "=", "get_object_or_404", "(", "get_use...
Detailed view of an user. :param username: String of the username of which the profile should be viewed. :param template_name: String representing the template name that should be used to display the profile. :param extra_context: Dictionary of variables which should be su...
[ "Detailed", "view", "of", "an", "user", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L520-L558
ff0000/scarlet
scarlet/accounts/views.py
account_delete
def account_delete(request, username, template_name=accounts_settings.ACCOUNTS_PROFILE_DETAIL_TEMPLATE, extra_context=None, **kwargs): """ Delete an account. """ user = get_object_or_404(get_user_model(), username__iexact=username) user.is_active = False ...
python
def account_delete(request, username, template_name=accounts_settings.ACCOUNTS_PROFILE_DETAIL_TEMPLATE, extra_context=None, **kwargs): """ Delete an account. """ user = get_object_or_404(get_user_model(), username__iexact=username) user.is_active = False ...
[ "def", "account_delete", "(", "request", ",", "username", ",", "template_name", "=", "accounts_settings", ".", "ACCOUNTS_PROFILE_DETAIL_TEMPLATE", ",", "extra_context", "=", "None", ",", "*", "*", "kwargs", ")", ":", "user", "=", "get_object_or_404", "(", "get_use...
Delete an account.
[ "Delete", "an", "account", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/accounts/views.py#L561-L572
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
parse_properties
def parse_properties(parent_index_name, parent_name, nested_path, esProperties): """ RETURN THE COLUMN DEFINITIONS IN THE GIVEN esProperties OBJECT """ columns = FlatList() for name, property in esProperties.items(): index_name = parent_index_name column_name = concat_field(parent_na...
python
def parse_properties(parent_index_name, parent_name, nested_path, esProperties): """ RETURN THE COLUMN DEFINITIONS IN THE GIVEN esProperties OBJECT """ columns = FlatList() for name, property in esProperties.items(): index_name = parent_index_name column_name = concat_field(parent_na...
[ "def", "parse_properties", "(", "parent_index_name", ",", "parent_name", ",", "nested_path", ",", "esProperties", ")", ":", "columns", "=", "FlatList", "(", ")", "for", "name", ",", "property", "in", "esProperties", ".", "items", "(", ")", ":", "index_name", ...
RETURN THE COLUMN DEFINITIONS IN THE GIVEN esProperties OBJECT
[ "RETURN", "THE", "COLUMN", "DEFINITIONS", "IN", "THE", "GIVEN", "esProperties", "OBJECT" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L1253-L1343
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
_get_best_type_from_mapping
def _get_best_type_from_mapping(mapping): """ THERE ARE MULTIPLE TYPES IN AN INDEX, PICK THE BEST :param mapping: THE ES MAPPING DOCUMENT :return: (type_name, mapping) PAIR (mapping.properties WILL HAVE PROPERTIES """ best_type_name = None best_mapping = None for k, m in mapping.items():...
python
def _get_best_type_from_mapping(mapping): """ THERE ARE MULTIPLE TYPES IN AN INDEX, PICK THE BEST :param mapping: THE ES MAPPING DOCUMENT :return: (type_name, mapping) PAIR (mapping.properties WILL HAVE PROPERTIES """ best_type_name = None best_mapping = None for k, m in mapping.items():...
[ "def", "_get_best_type_from_mapping", "(", "mapping", ")", ":", "best_type_name", "=", "None", "best_mapping", "=", "None", "for", "k", ",", "m", "in", "mapping", ".", "items", "(", ")", ":", "if", "k", "==", "\"_default_\"", ":", "continue", "if", "best_t...
THERE ARE MULTIPLE TYPES IN AN INDEX, PICK THE BEST :param mapping: THE ES MAPPING DOCUMENT :return: (type_name, mapping) PAIR (mapping.properties WILL HAVE PROPERTIES
[ "THERE", "ARE", "MULTIPLE", "TYPES", "IN", "AN", "INDEX", "PICK", "THE", "BEST", ":", "param", "mapping", ":", "THE", "ES", "MAPPING", "DOCUMENT", ":", "return", ":", "(", "type_name", "mapping", ")", "PAIR", "(", "mapping", ".", "properties", "WILL", "H...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L1346-L1362
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
_merge_mapping
def _merge_mapping(a, b): """ MERGE TWO MAPPINGS, a TAKES PRECEDENCE """ for name, b_details in b.items(): a_details = a[literal_field(name)] if a_details.properties and not a_details.type: a_details.type = "object" if b_details.properties and not b_details.type: ...
python
def _merge_mapping(a, b): """ MERGE TWO MAPPINGS, a TAKES PRECEDENCE """ for name, b_details in b.items(): a_details = a[literal_field(name)] if a_details.properties and not a_details.type: a_details.type = "object" if b_details.properties and not b_details.type: ...
[ "def", "_merge_mapping", "(", "a", ",", "b", ")", ":", "for", "name", ",", "b_details", "in", "b", ".", "items", "(", ")", ":", "a_details", "=", "a", "[", "literal_field", "(", "name", ")", "]", "if", "a_details", ".", "properties", "and", "not", ...
MERGE TWO MAPPINGS, a TAKES PRECEDENCE
[ "MERGE", "TWO", "MAPPINGS", "a", "TAKES", "PRECEDENCE" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L1403-L1422
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
retro_schema
def retro_schema(schema): """ CONVERT SCHEMA FROM 5.x to 1.x :param schema: :return: """ output = wrap({ "mappings":{ typename: { "dynamic_templates": [ retro_dynamic_template(*(t.items()[0])) for t in details.dynamic_te...
python
def retro_schema(schema): """ CONVERT SCHEMA FROM 5.x to 1.x :param schema: :return: """ output = wrap({ "mappings":{ typename: { "dynamic_templates": [ retro_dynamic_template(*(t.items()[0])) for t in details.dynamic_te...
[ "def", "retro_schema", "(", "schema", ")", ":", "output", "=", "wrap", "(", "{", "\"mappings\"", ":", "{", "typename", ":", "{", "\"dynamic_templates\"", ":", "[", "retro_dynamic_template", "(", "*", "(", "t", ".", "items", "(", ")", "[", "0", "]", ")"...
CONVERT SCHEMA FROM 5.x to 1.x :param schema: :return:
[ "CONVERT", "SCHEMA", "FROM", "5", ".", "x", "to", "1", ".", "x", ":", "param", "schema", ":", ":", "return", ":" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L1425-L1444
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
diff_schema
def diff_schema(A, B): """ RETURN PROPERTIES IN A, BUT NOT IN B :param A: elasticsearch properties :param B: elasticsearch properties :return: (name, properties) PAIRS WHERE name IS DOT-DELIMITED PATH """ output =[] def _diff_schema(path, A, B): for k, av in A.items(): ...
python
def diff_schema(A, B): """ RETURN PROPERTIES IN A, BUT NOT IN B :param A: elasticsearch properties :param B: elasticsearch properties :return: (name, properties) PAIRS WHERE name IS DOT-DELIMITED PATH """ output =[] def _diff_schema(path, A, B): for k, av in A.items(): ...
[ "def", "diff_schema", "(", "A", ",", "B", ")", ":", "output", "=", "[", "]", "def", "_diff_schema", "(", "path", ",", "A", ",", "B", ")", ":", "for", "k", ",", "av", "in", "A", ".", "items", "(", ")", ":", "if", "k", "==", "\"_id\"", "and", ...
RETURN PROPERTIES IN A, BUT NOT IN B :param A: elasticsearch properties :param B: elasticsearch properties :return: (name, properties) PAIRS WHERE name IS DOT-DELIMITED PATH
[ "RETURN", "PROPERTIES", "IN", "A", "BUT", "NOT", "IN", "B", ":", "param", "A", ":", "elasticsearch", "properties", ":", "param", "B", ":", "elasticsearch", "properties", ":", "return", ":", "(", "name", "properties", ")", "PAIRS", "WHERE", "name", "IS", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L1518-L1543
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Index.delete_all_but_self
def delete_all_but_self(self): """ DELETE ALL INDEXES WITH GIVEN PREFIX, EXCEPT name """ prefix = self.settings.alias name = self.settings.index if prefix == name: Log.note("{{index_name}} will not be deleted", index_name= prefix) for a in self.clust...
python
def delete_all_but_self(self): """ DELETE ALL INDEXES WITH GIVEN PREFIX, EXCEPT name """ prefix = self.settings.alias name = self.settings.index if prefix == name: Log.note("{{index_name}} will not be deleted", index_name= prefix) for a in self.clust...
[ "def", "delete_all_but_self", "(", "self", ")", ":", "prefix", "=", "self", ".", "settings", ".", "alias", "name", "=", "self", ".", "settings", ".", "index", "if", "prefix", "==", "name", ":", "Log", ".", "note", "(", "\"{{index_name}} will not be deleted\"...
DELETE ALL INDEXES WITH GIVEN PREFIX, EXCEPT name
[ "DELETE", "ALL", "INDEXES", "WITH", "GIVEN", "PREFIX", "EXCEPT", "name" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L175-L187
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Index.is_proto
def is_proto(self, index): """ RETURN True IF THIS INDEX HAS NOT BEEN ASSIGNED ITS ALIAS """ for a in self.cluster.get_aliases(): if a.index == index and a.alias: return False return True
python
def is_proto(self, index): """ RETURN True IF THIS INDEX HAS NOT BEEN ASSIGNED ITS ALIAS """ for a in self.cluster.get_aliases(): if a.index == index and a.alias: return False return True
[ "def", "is_proto", "(", "self", ",", "index", ")", ":", "for", "a", "in", "self", ".", "cluster", ".", "get_aliases", "(", ")", ":", "if", "a", ".", "index", "==", "index", "and", "a", ".", "alias", ":", "return", "False", "return", "True" ]
RETURN True IF THIS INDEX HAS NOT BEEN ASSIGNED ITS ALIAS
[ "RETURN", "True", "IF", "THIS", "INDEX", "HAS", "NOT", "BEEN", "ASSIGNED", "ITS", "ALIAS" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L212-L219
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Index.extend
def extend(self, records): """ records - MUST HAVE FORM OF [{"value":value}, ... {"value":value}] OR [{"json":json}, ... {"json":json}] OPTIONAL "id" PROPERTY IS ALSO ACCEPTED """ if self.settings.read_only: Log.error("Index opened in read ...
python
def extend(self, records): """ records - MUST HAVE FORM OF [{"value":value}, ... {"value":value}] OR [{"json":json}, ... {"json":json}] OPTIONAL "id" PROPERTY IS ALSO ACCEPTED """ if self.settings.read_only: Log.error("Index opened in read ...
[ "def", "extend", "(", "self", ",", "records", ")", ":", "if", "self", ".", "settings", ".", "read_only", ":", "Log", ".", "error", "(", "\"Index opened in read only mode, no changes allowed\"", ")", "lines", "=", "[", "]", "try", ":", "for", "r", "in", "re...
records - MUST HAVE FORM OF [{"value":value}, ... {"value":value}] OR [{"json":json}, ... {"json":json}] OPTIONAL "id" PROPERTY IS ALSO ACCEPTED
[ "records", "-", "MUST", "HAVE", "FORM", "OF", "[", "{", "value", ":", "value", "}", "...", "{", "value", ":", "value", "}", "]", "OR", "[", "{", "json", ":", "json", "}", "...", "{", "json", ":", "json", "}", "]", "OPTIONAL", "id", "PROPERTY", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L297-L399
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Index.set_refresh_interval
def set_refresh_interval(self, seconds, **kwargs): """ :param seconds: -1 FOR NO REFRESH :param kwargs: ANY OTHER REQUEST PARAMETERS :return: None """ if seconds <= 0: interval = -1 else: interval = text_type(seconds) + "s" if sel...
python
def set_refresh_interval(self, seconds, **kwargs): """ :param seconds: -1 FOR NO REFRESH :param kwargs: ANY OTHER REQUEST PARAMETERS :return: None """ if seconds <= 0: interval = -1 else: interval = text_type(seconds) + "s" if sel...
[ "def", "set_refresh_interval", "(", "self", ",", "seconds", ",", "*", "*", "kwargs", ")", ":", "if", "seconds", "<=", "0", ":", "interval", "=", "-", "1", "else", ":", "interval", "=", "text_type", "(", "seconds", ")", "+", "\"s\"", "if", "self", "."...
:param seconds: -1 FOR NO REFRESH :param kwargs: ANY OTHER REQUEST PARAMETERS :return: None
[ ":", "param", "seconds", ":", "-", "1", "FOR", "NO", "REFRESH", ":", "param", "kwargs", ":", "ANY", "OTHER", "REQUEST", "PARAMETERS", ":", "return", ":", "None" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L428-L463
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Cluster.get_index
def get_index(self, index, type, alias=None, typed=None, read_only=True, kwargs=None): """ TESTS THAT THE INDEX EXISTS BEFORE RETURNING A HANDLE """ if kwargs.tjson != None: Log.error("used `typed` parameter, not `tjson`") if read_only: # GET EXACT MATCH, ...
python
def get_index(self, index, type, alias=None, typed=None, read_only=True, kwargs=None): """ TESTS THAT THE INDEX EXISTS BEFORE RETURNING A HANDLE """ if kwargs.tjson != None: Log.error("used `typed` parameter, not `tjson`") if read_only: # GET EXACT MATCH, ...
[ "def", "get_index", "(", "self", ",", "index", ",", "type", ",", "alias", "=", "None", ",", "typed", "=", "None", ",", "read_only", "=", "True", ",", "kwargs", "=", "None", ")", ":", "if", "kwargs", ".", "tjson", "!=", "None", ":", "Log", ".", "e...
TESTS THAT THE INDEX EXISTS BEFORE RETURNING A HANDLE
[ "TESTS", "THAT", "THE", "INDEX", "EXISTS", "BEFORE", "RETURNING", "A", "HANDLE" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L616-L647
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Cluster.get_alias
def get_alias(self, alias): """ RETURN REFERENCE TO ALIAS (MANY INDEXES) USER MUST BE SURE NOT TO SEND UPDATES """ aliases = self.get_aliases() if alias in aliases.alias: settings = self.settings.copy() settings.alias = alias settings.i...
python
def get_alias(self, alias): """ RETURN REFERENCE TO ALIAS (MANY INDEXES) USER MUST BE SURE NOT TO SEND UPDATES """ aliases = self.get_aliases() if alias in aliases.alias: settings = self.settings.copy() settings.alias = alias settings.i...
[ "def", "get_alias", "(", "self", ",", "alias", ")", ":", "aliases", "=", "self", ".", "get_aliases", "(", ")", "if", "alias", "in", "aliases", ".", "alias", ":", "settings", "=", "self", ".", "settings", ".", "copy", "(", ")", "settings", ".", "alias...
RETURN REFERENCE TO ALIAS (MANY INDEXES) USER MUST BE SURE NOT TO SEND UPDATES
[ "RETURN", "REFERENCE", "TO", "ALIAS", "(", "MANY", "INDEXES", ")", "USER", "MUST", "BE", "SURE", "NOT", "TO", "SEND", "UPDATES" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L649-L660
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Cluster.get_canonical_index
def get_canonical_index(self, alias): """ RETURN THE INDEX USED BY THIS alias THIS IS ACCORDING TO THE STRICT LIFECYCLE RULES: THERE IS ONLY ONE INDEX WITH AN ALIAS """ output = jx.sort(set( i for ai in self.get_aliases() for a, i in [(...
python
def get_canonical_index(self, alias): """ RETURN THE INDEX USED BY THIS alias THIS IS ACCORDING TO THE STRICT LIFECYCLE RULES: THERE IS ONLY ONE INDEX WITH AN ALIAS """ output = jx.sort(set( i for ai in self.get_aliases() for a, i in [(...
[ "def", "get_canonical_index", "(", "self", ",", "alias", ")", ":", "output", "=", "jx", ".", "sort", "(", "set", "(", "i", "for", "ai", "in", "self", ".", "get_aliases", "(", ")", "for", "a", ",", "i", "in", "[", "(", "ai", ".", "alias", ",", "...
RETURN THE INDEX USED BY THIS alias THIS IS ACCORDING TO THE STRICT LIFECYCLE RULES: THERE IS ONLY ONE INDEX WITH AN ALIAS
[ "RETURN", "THE", "INDEX", "USED", "BY", "THIS", "alias", "THIS", "IS", "ACCORDING", "TO", "THE", "STRICT", "LIFECYCLE", "RULES", ":", "THERE", "IS", "ONLY", "ONE", "INDEX", "WITH", "AN", "ALIAS" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L662-L681
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Cluster.get_prototype
def get_prototype(self, alias): """ RETURN ALL INDEXES THAT ARE INTENDED TO BE GIVEN alias, BUT HAVE NO ALIAS YET BECAUSE INCOMPLETE """ output = sort([ a.index for a in self.get_aliases() if re.match(re.escape(alias) + "\\d{8}_\\d{6}", a.index...
python
def get_prototype(self, alias): """ RETURN ALL INDEXES THAT ARE INTENDED TO BE GIVEN alias, BUT HAVE NO ALIAS YET BECAUSE INCOMPLETE """ output = sort([ a.index for a in self.get_aliases() if re.match(re.escape(alias) + "\\d{8}_\\d{6}", a.index...
[ "def", "get_prototype", "(", "self", ",", "alias", ")", ":", "output", "=", "sort", "(", "[", "a", ".", "index", "for", "a", "in", "self", ".", "get_aliases", "(", ")", "if", "re", ".", "match", "(", "re", ".", "escape", "(", "alias", ")", "+", ...
RETURN ALL INDEXES THAT ARE INTENDED TO BE GIVEN alias, BUT HAVE NO ALIAS YET BECAUSE INCOMPLETE
[ "RETURN", "ALL", "INDEXES", "THAT", "ARE", "INTENDED", "TO", "BE", "GIVEN", "alias", "BUT", "HAVE", "NO", "ALIAS", "YET", "BECAUSE", "INCOMPLETE" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L698-L708
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Cluster.delete_all_but
def delete_all_but(self, prefix, name): """ :param prefix: INDEX MUST HAVE THIS AS A PREFIX AND THE REMAINDER MUST BE DATE_TIME :param name: INDEX WITH THIS NAME IS NOT DELETED :return: """ if prefix == name: Log.note("{{index_name}} will not be deleted", {"in...
python
def delete_all_but(self, prefix, name): """ :param prefix: INDEX MUST HAVE THIS AS A PREFIX AND THE REMAINDER MUST BE DATE_TIME :param name: INDEX WITH THIS NAME IS NOT DELETED :return: """ if prefix == name: Log.note("{{index_name}} will not be deleted", {"in...
[ "def", "delete_all_but", "(", "self", ",", "prefix", ",", "name", ")", ":", "if", "prefix", "==", "name", ":", "Log", ".", "note", "(", "\"{{index_name}} will not be deleted\"", ",", "{", "\"index_name\"", ":", "prefix", "}", ")", "for", "a", "in", "self",...
:param prefix: INDEX MUST HAVE THIS AS A PREFIX AND THE REMAINDER MUST BE DATE_TIME :param name: INDEX WITH THIS NAME IS NOT DELETED :return:
[ ":", "param", "prefix", ":", "INDEX", "MUST", "HAVE", "THIS", "AS", "A", "PREFIX", "AND", "THE", "REMAINDER", "MUST", "BE", "DATE_TIME", ":", "param", "name", ":", "INDEX", "WITH", "THIS", "NAME", "IS", "NOT", "DELETED", ":", "return", ":" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L710-L721
klahnakoski/pyLibrary
pyLibrary/env/elasticsearch.py
Cluster.get_aliases
def get_aliases(self): """ RETURN LIST OF {"alias":a, "index":i} PAIRS ALL INDEXES INCLUDED, EVEN IF NO ALIAS {"alias":Null} """ for index, desc in self.get_metadata().indices.items(): if not desc["aliases"]: yield wrap({"index": index}) el...
python
def get_aliases(self): """ RETURN LIST OF {"alias":a, "index":i} PAIRS ALL INDEXES INCLUDED, EVEN IF NO ALIAS {"alias":Null} """ for index, desc in self.get_metadata().indices.items(): if not desc["aliases"]: yield wrap({"index": index}) el...
[ "def", "get_aliases", "(", "self", ")", ":", "for", "index", ",", "desc", "in", "self", ".", "get_metadata", "(", ")", ".", "indices", ".", "items", "(", ")", ":", "if", "not", "desc", "[", "\"aliases\"", "]", ":", "yield", "wrap", "(", "{", "\"ind...
RETURN LIST OF {"alias":a, "index":i} PAIRS ALL INDEXES INCLUDED, EVEN IF NO ALIAS {"alias":Null}
[ "RETURN", "LIST", "OF", "{", "alias", ":", "a", "index", ":", "i", "}", "PAIRS", "ALL", "INDEXES", "INCLUDED", "EVEN", "IF", "NO", "ALIAS", "{", "alias", ":", "Null", "}" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/elasticsearch.py#L839-L851
openfisca/openfisca-france-indirect-taxation
openfisca_france_indirect_taxation/build_survey_data/step_3_homogeneisation_caracteristiques_menages.py
build_homogeneisation_caracteristiques_sociales
def build_homogeneisation_caracteristiques_sociales(temporary_store = None, year = None): u"""Homogénéisation des caractéristiques sociales des ménages """ assert temporary_store is not None assert year is not None # Load data bdf_survey_collection = SurveyCollection.load( collection = 'bud...
python
def build_homogeneisation_caracteristiques_sociales(temporary_store = None, year = None): u"""Homogénéisation des caractéristiques sociales des ménages """ assert temporary_store is not None assert year is not None # Load data bdf_survey_collection = SurveyCollection.load( collection = 'bud...
[ "def", "build_homogeneisation_caracteristiques_sociales", "(", "temporary_store", "=", "None", ",", "year", "=", "None", ")", ":", "assert", "temporary_store", "is", "not", "None", "assert", "year", "is", "not", "None", "# Load data", "bdf_survey_collection", "=", "...
u"""Homogénéisation des caractéristiques sociales des ménages
[ "u", "Homogénéisation", "des", "caractéristiques", "sociales", "des", "ménages" ]
train
https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/build_survey_data/step_3_homogeneisation_caracteristiques_menages.py#L44-L666
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
search_obsgroups_sql_builder
def search_obsgroups_sql_builder(search): """ Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.ObservationGroupSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.ObservationGroup` instanc...
python
def search_obsgroups_sql_builder(search): """ Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.ObservationGroupSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.ObservationGroup` instanc...
[ "def", "search_obsgroups_sql_builder", "(", "search", ")", ":", "b", "=", "SQLBuilder", "(", "tables", "=", "\"\"\"archive_obs_groups g\nINNER JOIN archive_semanticTypes s ON g.semanticType=s.uid\"\"\"", ",", "where_clauses", "=", "[", "]", ")", "b", ".", "add_sql", "(", ...
Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.ObservationGroupSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.ObservationGroup` instances etc. :param ObservationGroupSearch search: ...
[ "Create", "and", "populate", "an", "instance", "of", ":", "class", ":", "meteorpi_db", ".", "SQLBuilder", "for", "a", "given", ":", "class", ":", "meteorpi_model", ".", "ObservationGroupSearch", ".", "This", "can", "then", "be", "used", "to", "retrieve", "th...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L63-L90
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
search_files_sql_builder
def search_files_sql_builder(search): """ Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.FileRecordSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.FileRecord` instances etc. :pa...
python
def search_files_sql_builder(search): """ Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.FileRecordSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.FileRecord` instances etc. :pa...
[ "def", "search_files_sql_builder", "(", "search", ")", ":", "b", "=", "SQLBuilder", "(", "tables", "=", "\"\"\"archive_files f\nINNER JOIN archive_semanticTypes s2 ON f.semanticType=s2.uid\nINNER JOIN archive_observations o ON f.observationId=o.uid\nINNER JOIN archive_semanticTypes s ON o.ob...
Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.FileRecordSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.FileRecord` instances etc. :param FileRecordSearch search: The search to...
[ "Create", "and", "populate", "an", "instance", "of", ":", "class", ":", "meteorpi_db", ".", "SQLBuilder", "for", "a", "given", ":", "class", ":", "meteorpi_model", ".", "FileRecordSearch", ".", "This", "can", "then", "be", "used", "to", "retrieve", "the", ...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L93-L134
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
search_metadata_sql_builder
def search_metadata_sql_builder(search): """ Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.ObservatoryMetadataSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.ObservatoryMetadata` in...
python
def search_metadata_sql_builder(search): """ Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.ObservatoryMetadataSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.ObservatoryMetadata` in...
[ "def", "search_metadata_sql_builder", "(", "search", ")", ":", "b", "=", "SQLBuilder", "(", "tables", "=", "\"\"\"archive_metadata m\nINNER JOIN archive_metadataFields f ON m.fieldId=f.uid\nINNER JOIN archive_observatories l ON m.observatory=l.uid\"\"\"", ",", "where_clauses", "=", "...
Create and populate an instance of :class:`meteorpi_db.SQLBuilder` for a given :class:`meteorpi_model.ObservatoryMetadataSearch`. This can then be used to retrieve the results of the search, materialise them into :class:`meteorpi_model.ObservatoryMetadata` instances etc. :param ObservatoryMetadataSearch se...
[ "Create", "and", "populate", "an", "instance", "of", ":", "class", ":", "meteorpi_db", ".", "SQLBuilder", "for", "a", "given", ":", "class", ":", "meteorpi_model", ".", "ObservatoryMetadataSearch", ".", "This", "can", "then", "be", "used", "to", "retrieve", ...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L137-L172
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
SQLBuilder.add_sql
def add_sql(self, value, clause): """ Add a WHERE clause to the state. :param value: The unknown to bind into the state. Uses SQLBuilder._map_value() to map this into an appropriate database compatible type. :param clause: A SQL fragment defining the ...
python
def add_sql(self, value, clause): """ Add a WHERE clause to the state. :param value: The unknown to bind into the state. Uses SQLBuilder._map_value() to map this into an appropriate database compatible type. :param clause: A SQL fragment defining the ...
[ "def", "add_sql", "(", "self", ",", "value", ",", "clause", ")", ":", "if", "value", "is", "not", "None", ":", "self", ".", "sql_args", ".", "append", "(", "SQLBuilder", ".", "map_value", "(", "value", ")", ")", "self", ".", "where_clauses", ".", "ap...
Add a WHERE clause to the state. :param value: The unknown to bind into the state. Uses SQLBuilder._map_value() to map this into an appropriate database compatible type. :param clause: A SQL fragment defining the restriction on the unknown value
[ "Add", "a", "WHERE", "clause", "to", "the", "state", "." ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L220-L232
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
SQLBuilder.add_set_membership
def add_set_membership(self, values, column_name): """ Append a set membership test, creating a query of the form 'WHERE name IN (?,?...?)'. :param values: A list of values, or a subclass of basestring. If this is non-None and non-empty this will add a set membership tes...
python
def add_set_membership(self, values, column_name): """ Append a set membership test, creating a query of the form 'WHERE name IN (?,?...?)'. :param values: A list of values, or a subclass of basestring. If this is non-None and non-empty this will add a set membership tes...
[ "def", "add_set_membership", "(", "self", ",", "values", ",", "column_name", ")", ":", "if", "values", "is", "not", "None", "and", "len", "(", "values", ")", ">", "0", ":", "if", "isinstance", "(", "values", ",", "basestring", ")", ":", "values", "=", ...
Append a set membership test, creating a query of the form 'WHERE name IN (?,?...?)'. :param values: A list of values, or a subclass of basestring. If this is non-None and non-empty this will add a set membership test to the state. If the supplied value is a basestring it will be wrappe...
[ "Append", "a", "set", "membership", "test", "creating", "a", "query", "of", "the", "form", "WHERE", "name", "IN", "(", "?", "?", "...", "?", ")", "." ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L234-L252
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
SQLBuilder.add_metadata_query_properties
def add_metadata_query_properties(self, meta_constraints, id_table, id_column): """ Construct WHERE clauses from a list of MetaConstraint objects, adding them to the query state. :param meta_constraints: A list of MetaConstraint objects, each of which defines a condition over metada...
python
def add_metadata_query_properties(self, meta_constraints, id_table, id_column): """ Construct WHERE clauses from a list of MetaConstraint objects, adding them to the query state. :param meta_constraints: A list of MetaConstraint objects, each of which defines a condition over metada...
[ "def", "add_metadata_query_properties", "(", "self", ",", "meta_constraints", ",", "id_table", ",", "id_column", ")", ":", "for", "mc", "in", "meta_constraints", ":", "meta_key", "=", "str", "(", "mc", ".", "key", ")", "ct", "=", "mc", ".", "constraint_type"...
Construct WHERE clauses from a list of MetaConstraint objects, adding them to the query state. :param meta_constraints: A list of MetaConstraint objects, each of which defines a condition over metadata which must be satisfied for results to be included in the overall query. :rai...
[ "Construct", "WHERE", "clauses", "from", "a", "list", "of", "MetaConstraint", "objects", "adding", "them", "to", "the", "query", "state", "." ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L254-L287
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
SQLBuilder.get_select_sql
def get_select_sql(self, columns, order=None, limit=0, skip=0): """ Build a SELECT query based on the current state of the builder. :param columns: SQL fragment describing which columns to select i.e. 'e.obstoryID, s.statusID' :param order: Optional ordering cons...
python
def get_select_sql(self, columns, order=None, limit=0, skip=0): """ Build a SELECT query based on the current state of the builder. :param columns: SQL fragment describing which columns to select i.e. 'e.obstoryID, s.statusID' :param order: Optional ordering cons...
[ "def", "get_select_sql", "(", "self", ",", "columns", ",", "order", "=", "None", ",", "limit", "=", "0", ",", "skip", "=", "0", ")", ":", "sql", "=", "'SELECT '", "sql", "+=", "'{0} FROM {1} '", ".", "format", "(", "columns", ",", "self", ".", "table...
Build a SELECT query based on the current state of the builder. :param columns: SQL fragment describing which columns to select i.e. 'e.obstoryID, s.statusID' :param order: Optional ordering constraint, i.e. 'e.eventTime DESC' :param limit: Optional, used to ...
[ "Build", "a", "SELECT", "query", "based", "on", "the", "current", "state", "of", "the", "builder", "." ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L289-L319
camsci/meteor-pi
src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py
SQLBuilder.get_count_sql
def get_count_sql(self): """ Build a SELECT query which returns the count of items for an unlimited SELECT :return: A SQL SELECT query which returns the count of items for an unlimited query based on this SQLBuilder """ sql = 'SELECT COUNT(*) FROM ' + self.tables ...
python
def get_count_sql(self): """ Build a SELECT query which returns the count of items for an unlimited SELECT :return: A SQL SELECT query which returns the count of items for an unlimited query based on this SQLBuilder """ sql = 'SELECT COUNT(*) FROM ' + self.tables ...
[ "def", "get_count_sql", "(", "self", ")", ":", "sql", "=", "'SELECT COUNT(*) FROM '", "+", "self", ".", "tables", "if", "len", "(", "self", ".", "where_clauses", ")", ">", "0", ":", "sql", "+=", "' WHERE '", "sql", "+=", "' AND '", ".", "join", "(", "s...
Build a SELECT query which returns the count of items for an unlimited SELECT :return: A SQL SELECT query which returns the count of items for an unlimited query based on this SQLBuilder
[ "Build", "a", "SELECT", "query", "which", "returns", "the", "count", "of", "items", "for", "an", "unlimited", "SELECT" ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/sql_builder.py#L321-L332
delfick/nose-of-yeti
noseOfYeti/tokeniser/tokens.py
Tokens.wrap_setup
def wrap_setup(self, class_name, typ, with_async=False): """Described.typ = noy_wrap_typ(Described, Described.typ)""" equivalence = self.equivalence[typ] return [ (NEWLINE, '\n') , (NAME, class_name) , (OP, '.') , (NAME, equivalence) ...
python
def wrap_setup(self, class_name, typ, with_async=False): """Described.typ = noy_wrap_typ(Described, Described.typ)""" equivalence = self.equivalence[typ] return [ (NEWLINE, '\n') , (NAME, class_name) , (OP, '.') , (NAME, equivalence) ...
[ "def", "wrap_setup", "(", "self", ",", "class_name", ",", "typ", ",", "with_async", "=", "False", ")", ":", "equivalence", "=", "self", ".", "equivalence", "[", "typ", "]", "return", "[", "(", "NEWLINE", ",", "'\\n'", ")", ",", "(", "NAME", ",", "cla...
Described.typ = noy_wrap_typ(Described, Described.typ)
[ "Described", ".", "typ", "=", "noy_wrap_typ", "(", "Described", "Described", ".", "typ", ")" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/tokens.py#L173-L190
note35/sinon
sinon/lib/base.py
init
def init(scope): """ Copy all values of scope into the class SinonGlobals Args: scope (eg. locals() or globals()) Return: SinonGlobals instance """ class SinonGlobals(object): #pylint: disable=too-few-public-methods """ A fully empty class External can pus...
python
def init(scope): """ Copy all values of scope into the class SinonGlobals Args: scope (eg. locals() or globals()) Return: SinonGlobals instance """ class SinonGlobals(object): #pylint: disable=too-few-public-methods """ A fully empty class External can pus...
[ "def", "init", "(", "scope", ")", ":", "class", "SinonGlobals", "(", "object", ")", ":", "#pylint: disable=too-few-public-methods", "\"\"\"\n A fully empty class\n External can push the whole `scope` into this class through global function init()\n \"\"\"", "pass", ...
Copy all values of scope into the class SinonGlobals Args: scope (eg. locals() or globals()) Return: SinonGlobals instance
[ "Copy", "all", "values", "of", "scope", "into", "the", "class", "SinonGlobals", "Args", ":", "scope", "(", "eg", ".", "locals", "()", "or", "globals", "()", ")", "Return", ":", "SinonGlobals", "instance" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L17-L37
note35/sinon
sinon/lib/base.py
SinonBase._get_wrapper
def _get_wrapper(self): """ Return: Wrapper object Raise: Exception if wrapper object cannot be found """ if self.args_type == "MODULE_FUNCTION": return getattr(self.obj, self.prop) elif self.args_type == "FUNCTION": return ...
python
def _get_wrapper(self): """ Return: Wrapper object Raise: Exception if wrapper object cannot be found """ if self.args_type == "MODULE_FUNCTION": return getattr(self.obj, self.prop) elif self.args_type == "FUNCTION": return ...
[ "def", "_get_wrapper", "(", "self", ")", ":", "if", "self", ".", "args_type", "==", "\"MODULE_FUNCTION\"", ":", "return", "getattr", "(", "self", ".", "obj", ",", "self", ".", "prop", ")", "elif", "self", ".", "args_type", "==", "\"FUNCTION\"", ":", "ret...
Return: Wrapper object Raise: Exception if wrapper object cannot be found
[ "Return", ":", "Wrapper", "object", "Raise", ":", "Exception", "if", "wrapper", "object", "cannot", "be", "found" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L78-L92
note35/sinon
sinon/lib/base.py
SinonBase.__set_type
def __set_type(self, obj, prop): """ Triage type based on arguments Here are four types of base: PURE, MODULE, MODULE_FUNCTION, FUNCTION Args: obj: None, FunctionType, ModuleType, Class, Instance prop: None, string """ if TypeHandler.is_pure(obj, p...
python
def __set_type(self, obj, prop): """ Triage type based on arguments Here are four types of base: PURE, MODULE, MODULE_FUNCTION, FUNCTION Args: obj: None, FunctionType, ModuleType, Class, Instance prop: None, string """ if TypeHandler.is_pure(obj, p...
[ "def", "__set_type", "(", "self", ",", "obj", ",", "prop", ")", ":", "if", "TypeHandler", ".", "is_pure", "(", "obj", ",", "prop", ")", ":", "self", ".", "args_type", "=", "\"PURE\"", "self", ".", "pure", "=", "SinonBase", ".", "Pure", "(", ")", "s...
Triage type based on arguments Here are four types of base: PURE, MODULE, MODULE_FUNCTION, FUNCTION Args: obj: None, FunctionType, ModuleType, Class, Instance prop: None, string
[ "Triage", "type", "based", "on", "arguments", "Here", "are", "four", "types", "of", "base", ":", "PURE", "MODULE", "MODULE_FUNCTION", "FUNCTION", "Args", ":", "obj", ":", "None", "FunctionType", "ModuleType", "Class", "Instance", "prop", ":", "None", "string" ...
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L133-L156
note35/sinon
sinon/lib/base.py
SinonBase.__check_lock
def __check_lock(self): """ Cheking whether the inspector is wrapped or not (1) MODULE_FUNCTION: Check whether both obj/prop has __SINONLOCK__/LOCK or not (2) MODULE: Check whether obj has __SINONLOCK__ or not (3) FUNCTION: Check whether function(mock as a class) ...
python
def __check_lock(self): """ Cheking whether the inspector is wrapped or not (1) MODULE_FUNCTION: Check whether both obj/prop has __SINONLOCK__/LOCK or not (2) MODULE: Check whether obj has __SINONLOCK__ or not (3) FUNCTION: Check whether function(mock as a class) ...
[ "def", "__check_lock", "(", "self", ")", ":", "if", "self", ".", "args_type", "==", "\"MODULE_FUNCTION\"", ":", "if", "hasattr", "(", "getattr", "(", "self", ".", "obj", ",", "self", ".", "prop", ")", ",", "\"LOCK\"", ")", ":", "ErrorHandler", ".", "lo...
Cheking whether the inspector is wrapped or not (1) MODULE_FUNCTION: Check whether both obj/prop has __SINONLOCK__/LOCK or not (2) MODULE: Check whether obj has __SINONLOCK__ or not (3) FUNCTION: Check whether function(mock as a class) has LOCK or not Raise: l...
[ "Cheking", "whether", "the", "inspector", "is", "wrapped", "or", "not", "(", "1", ")", "MODULE_FUNCTION", ":", "Check", "whether", "both", "obj", "/", "prop", "has", "__SINONLOCK__", "/", "LOCK", "or", "not", "(", "2", ")", "MODULE", ":", "Check", "wheth...
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L158-L175
note35/sinon
sinon/lib/base.py
SinonBase.wrap2spy
def wrap2spy(self): """ Wrapping the inspector as a spy based on the type """ if self.args_type == "MODULE_FUNCTION": self.orig_func = deepcopy(getattr(self.obj, self.prop)) setattr(self.obj, self.prop, Wrapper.wrap_spy(getattr(self.obj, self.prop))) elif ...
python
def wrap2spy(self): """ Wrapping the inspector as a spy based on the type """ if self.args_type == "MODULE_FUNCTION": self.orig_func = deepcopy(getattr(self.obj, self.prop)) setattr(self.obj, self.prop, Wrapper.wrap_spy(getattr(self.obj, self.prop))) elif ...
[ "def", "wrap2spy", "(", "self", ")", ":", "if", "self", ".", "args_type", "==", "\"MODULE_FUNCTION\"", ":", "self", ".", "orig_func", "=", "deepcopy", "(", "getattr", "(", "self", ".", "obj", ",", "self", ".", "prop", ")", ")", "setattr", "(", "self", ...
Wrapping the inspector as a spy based on the type
[ "Wrapping", "the", "inspector", "as", "a", "spy", "based", "on", "the", "type" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L177-L192
note35/sinon
sinon/lib/base.py
SinonBase.unwrap
def unwrap(self): """ Unwrapping the inspector based on the type """ if self.args_type == "MODULE_FUNCTION": setattr(self.obj, self.prop, self.orig_func) elif self.args_type == "MODULE": delattr(self.obj, "__SINONLOCK__") elif self.args_type == "FU...
python
def unwrap(self): """ Unwrapping the inspector based on the type """ if self.args_type == "MODULE_FUNCTION": setattr(self.obj, self.prop, self.orig_func) elif self.args_type == "MODULE": delattr(self.obj, "__SINONLOCK__") elif self.args_type == "FU...
[ "def", "unwrap", "(", "self", ")", ":", "if", "self", ".", "args_type", "==", "\"MODULE_FUNCTION\"", ":", "setattr", "(", "self", ".", "obj", ",", "self", ".", "prop", ",", "self", ".", "orig_func", ")", "elif", "self", ".", "args_type", "==", "\"MODUL...
Unwrapping the inspector based on the type
[ "Unwrapping", "the", "inspector", "based", "on", "the", "type" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L194-L205
note35/sinon
sinon/lib/base.py
SinonBase.wrap2stub
def wrap2stub(self, customfunc): """ Wrapping the inspector as a stub based on the type Args: customfunc: function that replaces the original Returns: function, the spy wrapper around the customfunc """ if self.args_type == "MODULE_FUNCTION": ...
python
def wrap2stub(self, customfunc): """ Wrapping the inspector as a stub based on the type Args: customfunc: function that replaces the original Returns: function, the spy wrapper around the customfunc """ if self.args_type == "MODULE_FUNCTION": ...
[ "def", "wrap2stub", "(", "self", ",", "customfunc", ")", ":", "if", "self", ".", "args_type", "==", "\"MODULE_FUNCTION\"", ":", "wrapper", "=", "Wrapper", ".", "wrap_spy", "(", "customfunc", ",", "self", ".", "obj", ")", "setattr", "(", "self", ".", "obj...
Wrapping the inspector as a stub based on the type Args: customfunc: function that replaces the original Returns: function, the spy wrapper around the customfunc
[ "Wrapping", "the", "inspector", "as", "a", "stub", "based", "on", "the", "type", "Args", ":", "customfunc", ":", "function", "that", "replaces", "the", "original", "Returns", ":", "function", "the", "spy", "wrapper", "around", "the", "customfunc" ]
train
https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/base.py#L207-L227
klahnakoski/pyLibrary
jx_base/language.py
is_op
def is_op(call, op): """ :param call: The specific operator instance (a method call) :param op: The the operator we are testing against :return: isinstance(call, op), but faster """ try: return call.id == op.id except Exception as e: return False
python
def is_op(call, op): """ :param call: The specific operator instance (a method call) :param op: The the operator we are testing against :return: isinstance(call, op), but faster """ try: return call.id == op.id except Exception as e: return False
[ "def", "is_op", "(", "call", ",", "op", ")", ":", "try", ":", "return", "call", ".", "id", "==", "op", ".", "id", "except", "Exception", "as", "e", ":", "return", "False" ]
:param call: The specific operator instance (a method call) :param op: The the operator we are testing against :return: isinstance(call, op), but faster
[ ":", "param", "call", ":", "The", "specific", "operator", "instance", "(", "a", "method", "call", ")", ":", "param", "op", ":", "The", "the", "operator", "we", "are", "testing", "against", ":", "return", ":", "isinstance", "(", "call", "op", ")", "but"...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/language.py#L125-L134
klahnakoski/pyLibrary
jx_base/language.py
value_compare
def value_compare(left, right, ordering=1): """ SORT VALUES, NULL IS THE LEAST VALUE :param left: LHS :param right: RHS :param ordering: (-1, 0, 1) TO AFFECT SORT ORDER :return: The return value is negative if x < y, zero if x == y and strictly positive if x > y. """ try: ltype ...
python
def value_compare(left, right, ordering=1): """ SORT VALUES, NULL IS THE LEAST VALUE :param left: LHS :param right: RHS :param ordering: (-1, 0, 1) TO AFFECT SORT ORDER :return: The return value is negative if x < y, zero if x == y and strictly positive if x > y. """ try: ltype ...
[ "def", "value_compare", "(", "left", ",", "right", ",", "ordering", "=", "1", ")", ":", "try", ":", "ltype", "=", "left", ".", "__class__", "rtype", "=", "right", ".", "__class__", "if", "ltype", "in", "list_types", "or", "rtype", "in", "list_types", "...
SORT VALUES, NULL IS THE LEAST VALUE :param left: LHS :param right: RHS :param ordering: (-1, 0, 1) TO AFFECT SORT ORDER :return: The return value is negative if x < y, zero if x == y and strictly positive if x > y.
[ "SORT", "VALUES", "NULL", "IS", "THE", "LEAST", "VALUE", ":", "param", "left", ":", "LHS", ":", "param", "right", ":", "RHS", ":", "param", "ordering", ":", "(", "-", "1", "0", "1", ")", "TO", "AFFECT", "SORT", "ORDER", ":", "return", ":", "The", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/language.py#L147-L216
klahnakoski/pyLibrary
jx_elasticsearch/meta.py
jx_type
def jx_type(column): """ return the jx_type for given column """ if column.es_column.endswith(EXISTS_TYPE): return EXISTS return es_type_to_json_type[column.es_type]
python
def jx_type(column): """ return the jx_type for given column """ if column.es_column.endswith(EXISTS_TYPE): return EXISTS return es_type_to_json_type[column.es_type]
[ "def", "jx_type", "(", "column", ")", ":", "if", "column", ".", "es_column", ".", "endswith", "(", "EXISTS_TYPE", ")", ":", "return", "EXISTS", "return", "es_type_to_json_type", "[", "column", ".", "es_type", "]" ]
return the jx_type for given column
[ "return", "the", "jx_type", "for", "given", "column" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L890-L896
klahnakoski/pyLibrary
jx_elasticsearch/meta.py
ElasticsearchMetadata._reload_columns
def _reload_columns(self, table_desc): """ :param alias: A REAL ALIAS (OR NAME OF INDEX THAT HAS NO ALIAS) :return: """ # FIND ALL INDEXES OF ALIAS es_last_updated = self.es_cluster.metatdata_last_updated alias = table_desc.name canonical_index = self.es_...
python
def _reload_columns(self, table_desc): """ :param alias: A REAL ALIAS (OR NAME OF INDEX THAT HAS NO ALIAS) :return: """ # FIND ALL INDEXES OF ALIAS es_last_updated = self.es_cluster.metatdata_last_updated alias = table_desc.name canonical_index = self.es_...
[ "def", "_reload_columns", "(", "self", ",", "table_desc", ")", ":", "# FIND ALL INDEXES OF ALIAS", "es_last_updated", "=", "self", ".", "es_cluster", ".", "metatdata_last_updated", "alias", "=", "table_desc", ".", "name", "canonical_index", "=", "self", ".", "es_clu...
:param alias: A REAL ALIAS (OR NAME OF INDEX THAT HAS NO ALIAS) :return:
[ ":", "param", "alias", ":", "A", "REAL", "ALIAS", "(", "OR", "NAME", "OF", "INDEX", "THAT", "HAS", "NO", "ALIAS", ")", ":", "return", ":" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L117-L153
klahnakoski/pyLibrary
jx_elasticsearch/meta.py
ElasticsearchMetadata.get_columns
def get_columns(self, table_name, column_name=None, after=None, timeout=None): """ RETURN METADATA COLUMNS :param table_name: TABLE WE WANT COLUMNS FOR :param column_name: OPTIONAL NAME, IF INTERESTED IN ONLY ONE COLUMN :param after: FORCE LOAD, WAITING FOR last_updated TO BE A...
python
def get_columns(self, table_name, column_name=None, after=None, timeout=None): """ RETURN METADATA COLUMNS :param table_name: TABLE WE WANT COLUMNS FOR :param column_name: OPTIONAL NAME, IF INTERESTED IN ONLY ONE COLUMN :param after: FORCE LOAD, WAITING FOR last_updated TO BE A...
[ "def", "get_columns", "(", "self", ",", "table_name", ",", "column_name", "=", "None", ",", "after", "=", "None", ",", "timeout", "=", "None", ")", ":", "DEBUG", "and", "after", "and", "Log", ".", "note", "(", "\"getting columns for after {{time}}\"", ",", ...
RETURN METADATA COLUMNS :param table_name: TABLE WE WANT COLUMNS FOR :param column_name: OPTIONAL NAME, IF INTERESTED IN ONLY ONE COLUMN :param after: FORCE LOAD, WAITING FOR last_updated TO BE AFTER THIS TIME :param timeout: Signal; True when should give up :return:
[ "RETURN", "METADATA", "COLUMNS" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L239-L305
klahnakoski/pyLibrary
jx_elasticsearch/meta.py
ElasticsearchMetadata._update_cardinality
def _update_cardinality(self, column): """ QUERY ES TO FIND CARDINALITY AND PARTITIONS FOR A SIMPLE COLUMN """ now = Date.now() if column.es_index in self.index_does_not_exist: return if column.jx_type in STRUCT: Log.error("not supported") ...
python
def _update_cardinality(self, column): """ QUERY ES TO FIND CARDINALITY AND PARTITIONS FOR A SIMPLE COLUMN """ now = Date.now() if column.es_index in self.index_does_not_exist: return if column.jx_type in STRUCT: Log.error("not supported") ...
[ "def", "_update_cardinality", "(", "self", ",", "column", ")", ":", "now", "=", "Date", ".", "now", "(", ")", "if", "column", ".", "es_index", "in", "self", ".", "index_does_not_exist", ":", "return", "if", "column", ".", "jx_type", "in", "STRUCT", ":", ...
QUERY ES TO FIND CARDINALITY AND PARTITIONS FOR A SIMPLE COLUMN
[ "QUERY", "ES", "TO", "FIND", "CARDINALITY", "AND", "PARTITIONS", "FOR", "A", "SIMPLE", "COLUMN" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L307-L515
klahnakoski/pyLibrary
jx_elasticsearch/meta.py
Snowflake.query_paths
def query_paths(self): """ RETURN A LIST OF ALL NESTED COLUMNS """ output = self.namespace.alias_to_query_paths.get(self.name) if output: return output Log.error("Can not find index {{index|quote}}", index=self.name)
python
def query_paths(self): """ RETURN A LIST OF ALL NESTED COLUMNS """ output = self.namespace.alias_to_query_paths.get(self.name) if output: return output Log.error("Can not find index {{index|quote}}", index=self.name)
[ "def", "query_paths", "(", "self", ")", ":", "output", "=", "self", ".", "namespace", ".", "alias_to_query_paths", ".", "get", "(", "self", ".", "name", ")", "if", "output", ":", "return", "output", "Log", ".", "error", "(", "\"Can not find index {{index|quo...
RETURN A LIST OF ALL NESTED COLUMNS
[ "RETURN", "A", "LIST", "OF", "ALL", "NESTED", "COLUMNS" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L631-L638