repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
kshlm/gant
gant/utils/gant_docker.py
GantDocker.build_base_image_cmd
def build_base_image_cmd(self, force): """ Build the glusterbase image """ check_permissions() basetag = self.conf.basetag basedir = self.conf.basedir verbose = self.conf.verbose if self.image_exists(tag=basetag): if not force: ...
python
def build_base_image_cmd(self, force): """ Build the glusterbase image """ check_permissions() basetag = self.conf.basetag basedir = self.conf.basedir verbose = self.conf.verbose if self.image_exists(tag=basetag): if not force: ...
[ "def", "build_base_image_cmd", "(", "self", ",", "force", ")", ":", "check_permissions", "(", ")", "basetag", "=", "self", ".", "conf", ".", "basetag", "basedir", "=", "self", ".", "conf", ".", "basedir", "verbose", "=", "self", ".", "conf", ".", "verbos...
Build the glusterbase image
[ "Build", "the", "glusterbase", "image" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/gant_docker.py#L50-L76
kshlm/gant
gant/utils/gant_docker.py
GantDocker.build_main_image_cmd
def build_main_image_cmd(self, srcdir, force): """ Build the main image to be used for launching containers """ check_permissions() basetag = self.conf.basetag basedir = self.conf.basedir maintag = self.conf.maintag if not self.image_exists(tag=basetag):...
python
def build_main_image_cmd(self, srcdir, force): """ Build the main image to be used for launching containers """ check_permissions() basetag = self.conf.basetag basedir = self.conf.basedir maintag = self.conf.maintag if not self.image_exists(tag=basetag):...
[ "def", "build_main_image_cmd", "(", "self", ",", "srcdir", ",", "force", ")", ":", "check_permissions", "(", ")", "basetag", "=", "self", ".", "conf", ".", "basetag", "basedir", "=", "self", ".", "conf", ".", "basedir", "maintag", "=", "self", ".", "conf...
Build the main image to be used for launching containers
[ "Build", "the", "main", "image", "to", "be", "used", "for", "launching", "containers" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/gant_docker.py#L78-L118
kshlm/gant
gant/utils/gant_docker.py
GantDocker.launch_cmd
def launch_cmd(self, n, force): """ Launch the specified docker containers using the main image """ check_permissions() prefix = self.conf.prefix maintag = self.conf.maintag commandStr = "supervisord -c /etc/supervisor/conf.d/supervisord.conf" for i in ...
python
def launch_cmd(self, n, force): """ Launch the specified docker containers using the main image """ check_permissions() prefix = self.conf.prefix maintag = self.conf.maintag commandStr = "supervisord -c /etc/supervisor/conf.d/supervisord.conf" for i in ...
[ "def", "launch_cmd", "(", "self", ",", "n", ",", "force", ")", ":", "check_permissions", "(", ")", "prefix", "=", "self", ".", "conf", ".", "prefix", "maintag", "=", "self", ".", "conf", ".", "maintag", "commandStr", "=", "\"supervisord -c /etc/supervisor/co...
Launch the specified docker containers using the main image
[ "Launch", "the", "specified", "docker", "containers", "using", "the", "main", "image" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/gant_docker.py#L120-L150
kshlm/gant
gant/utils/gant_docker.py
GantDocker.stop_cmd
def stop_cmd(self, name, force): """ Stop the specified or all docker containers launched by us """ check_permissions() if name: echo("Would stop container {0}".format(name)) else: echo("Would stop all containers") echo("For now use 'docke...
python
def stop_cmd(self, name, force): """ Stop the specified or all docker containers launched by us """ check_permissions() if name: echo("Would stop container {0}".format(name)) else: echo("Would stop all containers") echo("For now use 'docke...
[ "def", "stop_cmd", "(", "self", ",", "name", ",", "force", ")", ":", "check_permissions", "(", ")", "if", "name", ":", "echo", "(", "\"Would stop container {0}\"", ".", "format", "(", "name", ")", ")", "else", ":", "echo", "(", "\"Would stop all containers\"...
Stop the specified or all docker containers launched by us
[ "Stop", "the", "specified", "or", "all", "docker", "containers", "launched", "by", "us" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/gant_docker.py#L152-L162
kshlm/gant
gant/utils/gant_docker.py
GantDocker.ssh_cmd
def ssh_cmd(self, name, ssh_command): """ SSH into given container and executre command if given """ if not self.container_exists(name=name): exit("Unknown container {0}".format(name)) if not self.container_running(name=name): exit("Container {0} is not r...
python
def ssh_cmd(self, name, ssh_command): """ SSH into given container and executre command if given """ if not self.container_exists(name=name): exit("Unknown container {0}".format(name)) if not self.container_running(name=name): exit("Container {0} is not r...
[ "def", "ssh_cmd", "(", "self", ",", "name", ",", "ssh_command", ")", ":", "if", "not", "self", ".", "container_exists", "(", "name", "=", "name", ")", ":", "exit", "(", "\"Unknown container {0}\"", ".", "format", "(", "name", ")", ")", "if", "not", "se...
SSH into given container and executre command if given
[ "SSH", "into", "given", "container", "and", "executre", "command", "if", "given" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/gant_docker.py#L170-L187
kshlm/gant
gant/utils/gant_docker.py
GantDocker.ip_cmd
def ip_cmd(self, name): """ Print ip of given container """ if not self.container_exists(name=name): exit('Unknown container {0}'.format(name)) ip = self.get_container_ip(name) if not ip: exit("Failed to get network address for" "...
python
def ip_cmd(self, name): """ Print ip of given container """ if not self.container_exists(name=name): exit('Unknown container {0}'.format(name)) ip = self.get_container_ip(name) if not ip: exit("Failed to get network address for" "...
[ "def", "ip_cmd", "(", "self", ",", "name", ")", ":", "if", "not", "self", ".", "container_exists", "(", "name", "=", "name", ")", ":", "exit", "(", "'Unknown container {0}'", ".", "format", "(", "name", ")", ")", "ip", "=", "self", ".", "get_container_...
Print ip of given container
[ "Print", "ip", "of", "given", "container" ]
train
https://github.com/kshlm/gant/blob/eabaa17ebfd31b1654ee1f27e7026f6d7b370609/gant/utils/gant_docker.py#L189-L201
florianpaquet/mease
mease/backends/base.py
BasePublisher.pack
def pack(self, message_type, client_id, client_storage, args, kwargs): """ Packs a message """ return pickle.dumps( (message_type, client_id, client_storage, args, kwargs), protocol=2)
python
def pack(self, message_type, client_id, client_storage, args, kwargs): """ Packs a message """ return pickle.dumps( (message_type, client_id, client_storage, args, kwargs), protocol=2)
[ "def", "pack", "(", "self", ",", "message_type", ",", "client_id", ",", "client_storage", ",", "args", ",", "kwargs", ")", ":", "return", "pickle", ".", "dumps", "(", "(", "message_type", ",", "client_id", ",", "client_storage", ",", "args", ",", "kwargs",...
Packs a message
[ "Packs", "a", "message" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/base.py#L37-L42
florianpaquet/mease
mease/backends/base.py
BaseSubscriber.dispatch_message
def dispatch_message(self, message_type, client_id, client_storage, args, kwargs): """ Calls callback functions """ logger.debug("Backend message ({message_type}) : {args} {kwargs}".format( message_type=dict(MESSAGES_TYPES)[message_type], args=args, kwargs=kwargs)) i...
python
def dispatch_message(self, message_type, client_id, client_storage, args, kwargs): """ Calls callback functions """ logger.debug("Backend message ({message_type}) : {args} {kwargs}".format( message_type=dict(MESSAGES_TYPES)[message_type], args=args, kwargs=kwargs)) i...
[ "def", "dispatch_message", "(", "self", ",", "message_type", ",", "client_id", ",", "client_storage", ",", "args", ",", "kwargs", ")", ":", "logger", ".", "debug", "(", "\"Backend message ({message_type}) : {args} {kwargs}\"", ".", "format", "(", "message_type", "="...
Calls callback functions
[ "Calls", "callback", "functions" ]
train
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/backends/base.py#L71-L110
Zaeb0s/loop-function
loopfunction/loopfunction.py
Loop._loop
def _loop(self, *args, **kwargs): """Loops the target function :param args: The args specified on initiation :param kwargs: The kwargs specified on initiation """ self.on_start(*self.on_start_args, **self.on_start_kwargs) try: while not self._stop_signal: ...
python
def _loop(self, *args, **kwargs): """Loops the target function :param args: The args specified on initiation :param kwargs: The kwargs specified on initiation """ self.on_start(*self.on_start_args, **self.on_start_kwargs) try: while not self._stop_signal: ...
[ "def", "_loop", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "on_start", "(", "*", "self", ".", "on_start_args", ",", "*", "*", "self", ".", "on_start_kwargs", ")", "try", ":", "while", "not", "self", ".", "_stop_s...
Loops the target function :param args: The args specified on initiation :param kwargs: The kwargs specified on initiation
[ "Loops", "the", "target", "function" ]
train
https://github.com/Zaeb0s/loop-function/blob/5999132aca5cf79b34e4ad5c05f9185712f1b583/loopfunction/loopfunction.py#L48-L61
Zaeb0s/loop-function
loopfunction/loopfunction.py
Loop.start
def start(self, subthread=True): """Starts the loop Tries to start the loop. Raises RuntimeError if the loop is currently running. :param subthread: True/False value that specifies whether or not to start the loop within a subthread. If True the threading.Thread object is found in Loop...
python
def start(self, subthread=True): """Starts the loop Tries to start the loop. Raises RuntimeError if the loop is currently running. :param subthread: True/False value that specifies whether or not to start the loop within a subthread. If True the threading.Thread object is found in Loop...
[ "def", "start", "(", "self", ",", "subthread", "=", "True", ")", ":", "if", "self", ".", "is_running", "(", ")", ":", "raise", "RuntimeError", "(", "'Loop is currently running'", ")", "else", ":", "self", ".", "_lock", ".", "clear", "(", ")", "self", "...
Starts the loop Tries to start the loop. Raises RuntimeError if the loop is currently running. :param subthread: True/False value that specifies whether or not to start the loop within a subthread. If True the threading.Thread object is found in Loop._loop_thread.
[ "Starts", "the", "loop" ]
train
https://github.com/Zaeb0s/loop-function/blob/5999132aca5cf79b34e4ad5c05f9185712f1b583/loopfunction/loopfunction.py#L63-L83
Zaeb0s/loop-function
loopfunction/loopfunction.py
Loop.stop
def stop(self, silent=False): """Sends a stop signal to the loop thread and waits until it stops A stop signal is sent using Loop.send_stop_signal(silent) (see docs for Loop.send_stop_signal) :param silent: True/False same parameter as in Loop.send_stop_signal(silent) """ self....
python
def stop(self, silent=False): """Sends a stop signal to the loop thread and waits until it stops A stop signal is sent using Loop.send_stop_signal(silent) (see docs for Loop.send_stop_signal) :param silent: True/False same parameter as in Loop.send_stop_signal(silent) """ self....
[ "def", "stop", "(", "self", ",", "silent", "=", "False", ")", ":", "self", ".", "send_stop_signal", "(", "silent", ")", "self", ".", "_lock", ".", "wait", "(", ")" ]
Sends a stop signal to the loop thread and waits until it stops A stop signal is sent using Loop.send_stop_signal(silent) (see docs for Loop.send_stop_signal) :param silent: True/False same parameter as in Loop.send_stop_signal(silent)
[ "Sends", "a", "stop", "signal", "to", "the", "loop", "thread", "and", "waits", "until", "it", "stops" ]
train
https://github.com/Zaeb0s/loop-function/blob/5999132aca5cf79b34e4ad5c05f9185712f1b583/loopfunction/loopfunction.py#L85-L93
Zaeb0s/loop-function
loopfunction/loopfunction.py
Loop.send_stop_signal
def send_stop_signal(self, silent=False): """Sends a stop signal to the loop thread :param silent: True/False value that specifies whether or not to raise RuntimeError if the loop is currently not running :return: """ if self.is_running(): self._stop_signal =...
python
def send_stop_signal(self, silent=False): """Sends a stop signal to the loop thread :param silent: True/False value that specifies whether or not to raise RuntimeError if the loop is currently not running :return: """ if self.is_running(): self._stop_signal =...
[ "def", "send_stop_signal", "(", "self", ",", "silent", "=", "False", ")", ":", "if", "self", ".", "is_running", "(", ")", ":", "self", ".", "_stop_signal", "=", "True", "elif", "not", "silent", ":", "raise", "RuntimeError", "(", "'Loop is currently not runni...
Sends a stop signal to the loop thread :param silent: True/False value that specifies whether or not to raise RuntimeError if the loop is currently not running :return:
[ "Sends", "a", "stop", "signal", "to", "the", "loop", "thread" ]
train
https://github.com/Zaeb0s/loop-function/blob/5999132aca5cf79b34e4ad5c05f9185712f1b583/loopfunction/loopfunction.py#L95-L105
Zaeb0s/loop-function
loopfunction/loopfunction.py
Loop.restart
def restart(self, subthread=None): """Restarts the loop function Tries to restart the loop thread using the current thread. Raises RuntimeError if a previous call to Loop.start was not made. :param subthread: True/False value used when calling Loop.start(subthread=subthread). If set to...
python
def restart(self, subthread=None): """Restarts the loop function Tries to restart the loop thread using the current thread. Raises RuntimeError if a previous call to Loop.start was not made. :param subthread: True/False value used when calling Loop.start(subthread=subthread). If set to...
[ "def", "restart", "(", "self", ",", "subthread", "=", "None", ")", ":", "if", "self", ".", "_in_subthread", "is", "None", ":", "raise", "RuntimeError", "(", "'A call to start must first be placed before restart'", ")", "self", ".", "stop", "(", "silent", "=", ...
Restarts the loop function Tries to restart the loop thread using the current thread. Raises RuntimeError if a previous call to Loop.start was not made. :param subthread: True/False value used when calling Loop.start(subthread=subthread). If set to None it uses the same value as the la...
[ "Restarts", "the", "loop", "function" ]
train
https://github.com/Zaeb0s/loop-function/blob/5999132aca5cf79b34e4ad5c05f9185712f1b583/loopfunction/loopfunction.py#L107-L122
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
make_property
def make_property(prop_defs, prop_name, cls_names=[], hierarchy=[]): """ Generates a property class from the defintion dictionary args: prop_defs: the dictionary defining the property prop_name: the base name of the property cls_name: the name of the rdf_class with which the property is...
python
def make_property(prop_defs, prop_name, cls_names=[], hierarchy=[]): """ Generates a property class from the defintion dictionary args: prop_defs: the dictionary defining the property prop_name: the base name of the property cls_name: the name of the rdf_class with which the property is...
[ "def", "make_property", "(", "prop_defs", ",", "prop_name", ",", "cls_names", "=", "[", "]", ",", "hierarchy", "=", "[", "]", ")", ":", "register", "=", "False", "try", ":", "cls_names", ".", "remove", "(", "'RdfClassBase'", ")", "except", "ValueError", ...
Generates a property class from the defintion dictionary args: prop_defs: the dictionary defining the property prop_name: the base name of the property cls_name: the name of the rdf_class with which the property is associated
[ "Generates", "a", "property", "class", "from", "the", "defintion", "dictionary" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L313-L358
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
link_property
def link_property(prop, cls_object): """ Generates a property class linked to the rdfclass args: prop: unlinked property class cls_name: the name of the rdf_class with which the property is associated cls_object: the rdf_class """ register = False cls_name ...
python
def link_property(prop, cls_object): """ Generates a property class linked to the rdfclass args: prop: unlinked property class cls_name: the name of the rdf_class with which the property is associated cls_object: the rdf_class """ register = False cls_name ...
[ "def", "link_property", "(", "prop", ",", "cls_object", ")", ":", "register", "=", "False", "cls_name", "=", "cls_object", ".", "__name__", "if", "cls_name", "and", "cls_name", "!=", "'RdfBaseClass'", ":", "new_name", "=", "\"%s_%s\"", "%", "(", "prop", ".",...
Generates a property class linked to the rdfclass args: prop: unlinked property class cls_name: the name of the rdf_class with which the property is associated cls_object: the rdf_class
[ "Generates", "a", "property", "class", "linked", "to", "the", "rdfclass" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L361-L383
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
get_properties
def get_properties(cls_def): """ cycles through the class definiton and returns all properties """ # pdb.set_trace() prop_list = {prop: value for prop, value in cls_def.items() \ if 'rdf_Property' in value.get('rdf_type', "") or \ value.get('rdfs_domain')} return prop_...
python
def get_properties(cls_def): """ cycles through the class definiton and returns all properties """ # pdb.set_trace() prop_list = {prop: value for prop, value in cls_def.items() \ if 'rdf_Property' in value.get('rdf_type', "") or \ value.get('rdfs_domain')} return prop_...
[ "def", "get_properties", "(", "cls_def", ")", ":", "# pdb.set_trace()", "prop_list", "=", "{", "prop", ":", "value", "for", "prop", ",", "value", "in", "cls_def", ".", "items", "(", ")", "if", "'rdf_Property'", "in", "value", ".", "get", "(", "'rdf_type'",...
cycles through the class definiton and returns all properties
[ "cycles", "through", "the", "class", "definiton", "and", "returns", "all", "properties" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L385-L392
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
filter_prop_defs
def filter_prop_defs(prop_defs, hierarchy, cls_names): """ Reads through the prop_defs and returns a dictionary filtered by the current class args: prop_defs: the defintions from the rdf vocabulary defintion cls_object: the class object to tie the property cls_names: the name of...
python
def filter_prop_defs(prop_defs, hierarchy, cls_names): """ Reads through the prop_defs and returns a dictionary filtered by the current class args: prop_defs: the defintions from the rdf vocabulary defintion cls_object: the class object to tie the property cls_names: the name of...
[ "def", "filter_prop_defs", "(", "prop_defs", ",", "hierarchy", ",", "cls_names", ")", ":", "def", "_is_valid", "(", "test_list", ",", "valid_list", ")", ":", "\"\"\" reads the list of classes in appliesToClass and returns whether\n the test_list matches\n\n args...
Reads through the prop_defs and returns a dictionary filtered by the current class args: prop_defs: the defintions from the rdf vocabulary defintion cls_object: the class object to tie the property cls_names: the name of the classes
[ "Reads", "through", "the", "prop_defs", "and", "returns", "a", "dictionary", "filtered", "by", "the", "current", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L423-L463
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
prepare_prop_defs
def prepare_prop_defs(prop_defs, prop_name, cls_names): """ Examines and adds any missing defs to the prop_defs dictionary for use with the RdfPropertyMeta.__prepare__ method Args: ----- prop_defs: the defintions from the rdf vocabulary defintion prop_name: the property name ...
python
def prepare_prop_defs(prop_defs, prop_name, cls_names): """ Examines and adds any missing defs to the prop_defs dictionary for use with the RdfPropertyMeta.__prepare__ method Args: ----- prop_defs: the defintions from the rdf vocabulary defintion prop_name: the property name ...
[ "def", "prepare_prop_defs", "(", "prop_defs", ",", "prop_name", ",", "cls_names", ")", ":", "def", "get_def", "(", "prop_defs", ",", "def_fields", ",", "default_val", "=", "None", ")", ":", "\"\"\" returns the cross corelated fields for delealing with mutiple\n ...
Examines and adds any missing defs to the prop_defs dictionary for use with the RdfPropertyMeta.__prepare__ method Args: ----- prop_defs: the defintions from the rdf vocabulary defintion prop_name: the property name cls_names: the name of the associated classes Returns: ---...
[ "Examines", "and", "adds", "any", "missing", "defs", "to", "the", "prop_defs", "dictionary", "for", "use", "with", "the", "RdfPropertyMeta", ".", "__prepare__", "method" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L465-L551
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
tie_prop_to_class
def tie_prop_to_class(prop, cls_name): """ reads through the prop attributes and filters them for the associated class and returns a dictionary for meta_class __prepare__ args: prop: class object to read cls_name: the name of the class to tie the porperty to """ attr_list = [attr fo...
python
def tie_prop_to_class(prop, cls_name): """ reads through the prop attributes and filters them for the associated class and returns a dictionary for meta_class __prepare__ args: prop: class object to read cls_name: the name of the class to tie the porperty to """ attr_list = [attr fo...
[ "def", "tie_prop_to_class", "(", "prop", ",", "cls_name", ")", ":", "attr_list", "=", "[", "attr", "for", "attr", "in", "dir", "(", "prop", ")", "if", "type", "(", "attr", ",", "Uri", ")", "]", "prop_defs", "=", "kwargs", ".", "pop", "(", "'prop_defs...
reads through the prop attributes and filters them for the associated class and returns a dictionary for meta_class __prepare__ args: prop: class object to read cls_name: the name of the class to tie the porperty to
[ "reads", "through", "the", "prop", "attributes", "and", "filters", "them", "for", "the", "associated", "class", "and", "returns", "a", "dictionary", "for", "meta_class", "__prepare__" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L553-L585
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
unique_append
def unique_append(self, value): """ function for only appending unique items to a list. #! consider the possibility of item using this to a set """ if value not in self: try: super(self.__class__, self).append(Uri(value)) except AttributeError as err: if isinstanc...
python
def unique_append(self, value): """ function for only appending unique items to a list. #! consider the possibility of item using this to a set """ if value not in self: try: super(self.__class__, self).append(Uri(value)) except AttributeError as err: if isinstanc...
[ "def", "unique_append", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "self", ":", "try", ":", "super", "(", "self", ".", "__class__", ",", "self", ")", ".", "append", "(", "Uri", "(", "value", ")", ")", "except", "AttributeError",...
function for only appending unique items to a list. #! consider the possibility of item using this to a set
[ "function", "for", "only", "appending", "unique", "items", "to", "a", "list", ".", "#!", "consider", "the", "possibility", "of", "item", "using", "this", "to", "a", "set" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L588-L599
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
get_processors
def get_processors(processor_cat, prop_defs, data_attr=None): """ reads the prop defs and adds applicable processors for the property Args: processor_cat(str): The category of processors to retreive prop_defs: property defintions as defined by the rdf defintions data_attr: the attr to m...
python
def get_processors(processor_cat, prop_defs, data_attr=None): """ reads the prop defs and adds applicable processors for the property Args: processor_cat(str): The category of processors to retreive prop_defs: property defintions as defined by the rdf defintions data_attr: the attr to m...
[ "def", "get_processors", "(", "processor_cat", ",", "prop_defs", ",", "data_attr", "=", "None", ")", ":", "processor_defs", "=", "prop_defs", ".", "get", "(", "processor_cat", ",", "[", "]", ")", "processor_list", "=", "[", "]", "for", "processor", "in", "...
reads the prop defs and adds applicable processors for the property Args: processor_cat(str): The category of processors to retreive prop_defs: property defintions as defined by the rdf defintions data_attr: the attr to manipulate during processing. Returns: list: a list of pro...
[ "reads", "the", "prop", "defs", "and", "adds", "applicable", "processors", "for", "the", "property" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L601-L618
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
merge_rdf_list
def merge_rdf_list(rdf_list): """ takes an rdf list and merges it into a python list args: rdf_list: the RdfDataset object with the list values returns: list of values """ # pdb.set_trace() if isinstance(rdf_list, list): rdf_list = rdf_list[0] rtn_list = [] # fo...
python
def merge_rdf_list(rdf_list): """ takes an rdf list and merges it into a python list args: rdf_list: the RdfDataset object with the list values returns: list of values """ # pdb.set_trace() if isinstance(rdf_list, list): rdf_list = rdf_list[0] rtn_list = [] # fo...
[ "def", "merge_rdf_list", "(", "rdf_list", ")", ":", "# pdb.set_trace()", "if", "isinstance", "(", "rdf_list", ",", "list", ")", ":", "rdf_list", "=", "rdf_list", "[", "0", "]", "rtn_list", "=", "[", "]", "# for item in rdf_list:", "item", "=", "rdf_list", "i...
takes an rdf list and merges it into a python list args: rdf_list: the RdfDataset object with the list values returns: list of values
[ "takes", "an", "rdf", "list", "and", "merges", "it", "into", "a", "python", "list" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L621-L641
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
RdfPropertyBase.es_mapping
def es_mapping(cls, base_class, **kwargs): """ Returns the es mapping for the property """ es_map = {} ranges = cls.rdfs_range # pylint: disable=no-member rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef) rng_def = get_prop_range_def(rng_defs) if ...
python
def es_mapping(cls, base_class, **kwargs): """ Returns the es mapping for the property """ es_map = {} ranges = cls.rdfs_range # pylint: disable=no-member rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef) rng_def = get_prop_range_def(rng_defs) if ...
[ "def", "es_mapping", "(", "cls", ",", "base_class", ",", "*", "*", "kwargs", ")", ":", "es_map", "=", "{", "}", "ranges", "=", "cls", ".", "rdfs_range", "# pylint: disable=no-member", "rng_defs", "=", "get_prop_range_defs", "(", "cls", ".", "class_names", ",...
Returns the es mapping for the property
[ "Returns", "the", "es", "mapping", "for", "the", "property" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L158-L216
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
RdfPropertyBase.es_indexers
def es_indexers(cls, base_class, **kwargs): """ Returns the es mapping for the property """ indexer_list = [] ranges = cls.rdfs_range # pylint: disable=no-member rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef) rng_def = get_prop_range_def(rng_defs) ...
python
def es_indexers(cls, base_class, **kwargs): """ Returns the es mapping for the property """ indexer_list = [] ranges = cls.rdfs_range # pylint: disable=no-member rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef) rng_def = get_prop_range_def(rng_defs) ...
[ "def", "es_indexers", "(", "cls", ",", "base_class", ",", "*", "*", "kwargs", ")", ":", "indexer_list", "=", "[", "]", "ranges", "=", "cls", ".", "rdfs_range", "# pylint: disable=no-member", "rng_defs", "=", "get_prop_range_defs", "(", "cls", ".", "class_names...
Returns the es mapping for the property
[ "Returns", "the", "es", "mapping", "for", "the", "property" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L219-L240
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfproperty.py
RdfPropertyBase.es_json
def es_json(self, **kwargs): """ Returns a JSON object of the property for insertion into es """ rtn_list = [] rng_defs = get_prop_range_defs(self.class_names, self.kds_rangeDef) # if self.__class__._prop_name == 'bf_partOf': # pdb.set_trace() rng_def = get_pr...
python
def es_json(self, **kwargs): """ Returns a JSON object of the property for insertion into es """ rtn_list = [] rng_defs = get_prop_range_defs(self.class_names, self.kds_rangeDef) # if self.__class__._prop_name == 'bf_partOf': # pdb.set_trace() rng_def = get_pr...
[ "def", "es_json", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rtn_list", "=", "[", "]", "rng_defs", "=", "get_prop_range_defs", "(", "self", ".", "class_names", ",", "self", ".", "kds_rangeDef", ")", "# if self.__class__._prop_name == 'bf_partOf':", "# ...
Returns a JSON object of the property for insertion into es
[ "Returns", "a", "JSON", "object", "of", "the", "property", "for", "insertion", "into", "es" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfproperty.py#L242-L310
laysakura/relshell
relshell/batch_command.py
BatchCommand._parse
def _parse(batch_cmd): """ :rtype: (sh_cmd, batch_to_file_s, batch_from_file) :returns: parsed result like below: .. code-block:: python # when parsing 'diff IN_BATCH0 IN_BATCH1 > OUT_BATCH' ( 'diff /tmp/relshell-AbCDeF /tmp/relshell-uVwXyz', ...
python
def _parse(batch_cmd): """ :rtype: (sh_cmd, batch_to_file_s, batch_from_file) :returns: parsed result like below: .. code-block:: python # when parsing 'diff IN_BATCH0 IN_BATCH1 > OUT_BATCH' ( 'diff /tmp/relshell-AbCDeF /tmp/relshell-uVwXyz', ...
[ "def", "_parse", "(", "batch_cmd", ")", ":", "cmd_array", "=", "shlex", ".", "split", "(", "batch_cmd", ")", "(", "cmd_array", ",", "batch_to_file_s", ")", "=", "BatchCommand", ".", "_parse_in_batches", "(", "cmd_array", ")", "(", "cmd_array", ",", "batch_fr...
:rtype: (sh_cmd, batch_to_file_s, batch_from_file) :returns: parsed result like below: .. code-block:: python # when parsing 'diff IN_BATCH0 IN_BATCH1 > OUT_BATCH' ( 'diff /tmp/relshell-AbCDeF /tmp/relshell-uVwXyz', ( <instance of BatchToFile>,...
[ ":", "rtype", ":", "(", "sh_cmd", "batch_to_file_s", "batch_from_file", ")", ":", "returns", ":", "parsed", "result", "like", "below", ":" ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/batch_command.py#L40-L57
laysakura/relshell
relshell/batch_command.py
BatchCommand._parse_in_batches
def _parse_in_batches(cmd_array): """Find patterns that match to `in_batches_pat` and replace them into `STDIN` or `TMPFILE`. :param cmd_array: `shlex.split`-ed command :rtype: ([cmd_array], ( batch_to_file, batch_to_file, ... ) ) :returns: Modified `cmd_array` and tuple to show how e...
python
def _parse_in_batches(cmd_array): """Find patterns that match to `in_batches_pat` and replace them into `STDIN` or `TMPFILE`. :param cmd_array: `shlex.split`-ed command :rtype: ([cmd_array], ( batch_to_file, batch_to_file, ... ) ) :returns: Modified `cmd_array` and tuple to show how e...
[ "def", "_parse_in_batches", "(", "cmd_array", ")", ":", "res_cmd_array", "=", "cmd_array", "[", ":", "]", "res_batch_to_file_s", "=", "[", "]", "in_batches_cmdidx", "=", "BatchCommand", ".", "_in_batches_cmdidx", "(", "cmd_array", ")", "for", "batch_id", ",", "c...
Find patterns that match to `in_batches_pat` and replace them into `STDIN` or `TMPFILE`. :param cmd_array: `shlex.split`-ed command :rtype: ([cmd_array], ( batch_to_file, batch_to_file, ... ) ) :returns: Modified `cmd_array` and tuple to show how each IN_BATCH is instantiated (TMPFILE or STDI...
[ "Find", "patterns", "that", "match", "to", "in_batches_pat", "and", "replace", "them", "into", "STDIN", "or", "TMPFILE", "." ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/batch_command.py#L60-L83
laysakura/relshell
relshell/batch_command.py
BatchCommand._parse_out_batch
def _parse_out_batch(cmd_array): """Find patterns that match to `out_batch_pat` and replace them into `STDOUT` or `TMPFILE`. :param cmd_array: `shlex.split`-ed command :rtype: ([cmd_array], batch_from_file) :returns: Modified `cmd_array` and tuple to show how OUT_BATCH is instantiated...
python
def _parse_out_batch(cmd_array): """Find patterns that match to `out_batch_pat` and replace them into `STDOUT` or `TMPFILE`. :param cmd_array: `shlex.split`-ed command :rtype: ([cmd_array], batch_from_file) :returns: Modified `cmd_array` and tuple to show how OUT_BATCH is instantiated...
[ "def", "_parse_out_batch", "(", "cmd_array", ")", ":", "res_cmd_array", "=", "cmd_array", "[", ":", "]", "res_batch_from_file", "=", "None", "out_batch_cmdidx", "=", "BatchCommand", ".", "_out_batch_cmdidx", "(", "cmd_array", ")", "if", "out_batch_cmdidx", "is", "...
Find patterns that match to `out_batch_pat` and replace them into `STDOUT` or `TMPFILE`. :param cmd_array: `shlex.split`-ed command :rtype: ([cmd_array], batch_from_file) :returns: Modified `cmd_array` and tuple to show how OUT_BATCH is instantiated (TMPFILE or STDOUT). Returned `...
[ "Find", "patterns", "that", "match", "to", "out_batch_pat", "and", "replace", "them", "into", "STDOUT", "or", "TMPFILE", "." ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/batch_command.py#L86-L110
laysakura/relshell
relshell/batch_command.py
BatchCommand._in_batches_cmdidx
def _in_batches_cmdidx(cmd_array): """Raise `IndexError` if IN_BATCH0 - IN_BATCHx is not used sequentially in `cmd_array` :returns: (IN_BATCH0's cmdidx, IN_BATCH1's cmdidx, ...) $ cat a.txt IN_BATCH1 IN_BATCH0 b.txt c.txt IN_BATCH2 => (3, 2, 5) """ in_batches_cmdidx_dict = {...
python
def _in_batches_cmdidx(cmd_array): """Raise `IndexError` if IN_BATCH0 - IN_BATCHx is not used sequentially in `cmd_array` :returns: (IN_BATCH0's cmdidx, IN_BATCH1's cmdidx, ...) $ cat a.txt IN_BATCH1 IN_BATCH0 b.txt c.txt IN_BATCH2 => (3, 2, 5) """ in_batches_cmdidx_dict = {...
[ "def", "_in_batches_cmdidx", "(", "cmd_array", ")", ":", "in_batches_cmdidx_dict", "=", "{", "}", "for", "cmdidx", ",", "tok", "in", "enumerate", "(", "cmd_array", ")", ":", "mat", "=", "BatchCommand", ".", "in_batches_pat", ".", "match", "(", "tok", ")", ...
Raise `IndexError` if IN_BATCH0 - IN_BATCHx is not used sequentially in `cmd_array` :returns: (IN_BATCH0's cmdidx, IN_BATCH1's cmdidx, ...) $ cat a.txt IN_BATCH1 IN_BATCH0 b.txt c.txt IN_BATCH2 => (3, 2, 5)
[ "Raise", "IndexError", "if", "IN_BATCH0", "-", "IN_BATCHx", "is", "not", "used", "sequentially", "in", "cmd_array" ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/batch_command.py#L113-L139
laysakura/relshell
relshell/batch_command.py
BatchCommand._out_batch_cmdidx
def _out_batch_cmdidx(cmd_array): """Raise `IndexError` if OUT_BATCH is used multiple time :returns: OUT_BATCH cmdidx (None if OUT_BATCH is not in `cmd_array`) $ cat a.txt > OUT_BATCH => 3 """ out_batch_cmdidx = None for cmdidx, tok in enumerate(cmd_array): ...
python
def _out_batch_cmdidx(cmd_array): """Raise `IndexError` if OUT_BATCH is used multiple time :returns: OUT_BATCH cmdidx (None if OUT_BATCH is not in `cmd_array`) $ cat a.txt > OUT_BATCH => 3 """ out_batch_cmdidx = None for cmdidx, tok in enumerate(cmd_array): ...
[ "def", "_out_batch_cmdidx", "(", "cmd_array", ")", ":", "out_batch_cmdidx", "=", "None", "for", "cmdidx", ",", "tok", "in", "enumerate", "(", "cmd_array", ")", ":", "mat", "=", "BatchCommand", ".", "out_batch_pat", ".", "match", "(", "tok", ")", "if", "mat...
Raise `IndexError` if OUT_BATCH is used multiple time :returns: OUT_BATCH cmdidx (None if OUT_BATCH is not in `cmd_array`) $ cat a.txt > OUT_BATCH => 3
[ "Raise", "IndexError", "if", "OUT_BATCH", "is", "used", "multiple", "time" ]
train
https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/batch_command.py#L142-L157
mouse-reeve/nomina-flora
nominaflora/NominaFlora.py
NominaFlora.get_builder
def get_builder(self, corpus): ''' creates a builder object for a wordlist ''' builder = WordBuilder(chunk_size=self.chunk_size) builder.ingest(corpus) return builder
python
def get_builder(self, corpus): ''' creates a builder object for a wordlist ''' builder = WordBuilder(chunk_size=self.chunk_size) builder.ingest(corpus) return builder
[ "def", "get_builder", "(", "self", ",", "corpus", ")", ":", "builder", "=", "WordBuilder", "(", "chunk_size", "=", "self", ".", "chunk_size", ")", "builder", ".", "ingest", "(", "corpus", ")", "return", "builder" ]
creates a builder object for a wordlist
[ "creates", "a", "builder", "object", "for", "a", "wordlist" ]
train
https://github.com/mouse-reeve/nomina-flora/blob/d99723b95d169dc38021a38c1f9d1f9f2b04c46b/nominaflora/NominaFlora.py#L19-L23
mouse-reeve/nomina-flora
nominaflora/NominaFlora.py
NominaFlora.get_common
def get_common(self, filename): ''' Process lists of common name words ''' word_list = [] words = open(filename) for word in words.readlines(): word_list.append(word.strip()) return word_list
python
def get_common(self, filename): ''' Process lists of common name words ''' word_list = [] words = open(filename) for word in words.readlines(): word_list.append(word.strip()) return word_list
[ "def", "get_common", "(", "self", ",", "filename", ")", ":", "word_list", "=", "[", "]", "words", "=", "open", "(", "filename", ")", "for", "word", "in", "words", ".", "readlines", "(", ")", ":", "word_list", ".", "append", "(", "word", ".", "strip",...
Process lists of common name words
[ "Process", "lists", "of", "common", "name", "words" ]
train
https://github.com/mouse-reeve/nomina-flora/blob/d99723b95d169dc38021a38c1f9d1f9f2b04c46b/nominaflora/NominaFlora.py#L26-L32
mouse-reeve/nomina-flora
nominaflora/NominaFlora.py
NominaFlora.get_scientific_name
def get_scientific_name(self): ''' Get a new flower name ''' genus = self.genus_builder.get_word() species = self.species_builder.get_word() return '%s %s' % (genus, species)
python
def get_scientific_name(self): ''' Get a new flower name ''' genus = self.genus_builder.get_word() species = self.species_builder.get_word() return '%s %s' % (genus, species)
[ "def", "get_scientific_name", "(", "self", ")", ":", "genus", "=", "self", ".", "genus_builder", ".", "get_word", "(", ")", "species", "=", "self", ".", "species_builder", ".", "get_word", "(", ")", "return", "'%s %s'", "%", "(", "genus", ",", "species", ...
Get a new flower name
[ "Get", "a", "new", "flower", "name" ]
train
https://github.com/mouse-reeve/nomina-flora/blob/d99723b95d169dc38021a38c1f9d1f9f2b04c46b/nominaflora/NominaFlora.py#L35-L39
mouse-reeve/nomina-flora
nominaflora/NominaFlora.py
NominaFlora.get_common_name
def get_common_name(self): ''' Get a flower's common name ''' name = random.choice(self.common_first) if random.randint(0, 1) == 1: name += ' ' + random.choice(self.common_first).lower() name += ' ' + random.choice(self.common_second).lower() return name
python
def get_common_name(self): ''' Get a flower's common name ''' name = random.choice(self.common_first) if random.randint(0, 1) == 1: name += ' ' + random.choice(self.common_first).lower() name += ' ' + random.choice(self.common_second).lower() return name
[ "def", "get_common_name", "(", "self", ")", ":", "name", "=", "random", ".", "choice", "(", "self", ".", "common_first", ")", "if", "random", ".", "randint", "(", "0", ",", "1", ")", "==", "1", ":", "name", "+=", "' '", "+", "random", ".", "choice"...
Get a flower's common name
[ "Get", "a", "flower", "s", "common", "name" ]
train
https://github.com/mouse-reeve/nomina-flora/blob/d99723b95d169dc38021a38c1f9d1f9f2b04c46b/nominaflora/NominaFlora.py#L42-L48
adamkerz/django-presentation
django_presentation/forms/FormPresentationItem.py
FormPresentationItem.getLabel
def getLabel(self,form): """A label can be a string, dict (lookup by name) or a callable (passed the form).""" return specialInterpretValue(self.label,self.name,form=form)
python
def getLabel(self,form): """A label can be a string, dict (lookup by name) or a callable (passed the form).""" return specialInterpretValue(self.label,self.name,form=form)
[ "def", "getLabel", "(", "self", ",", "form", ")", ":", "return", "specialInterpretValue", "(", "self", ".", "label", ",", "self", ".", "name", ",", "form", "=", "form", ")" ]
A label can be a string, dict (lookup by name) or a callable (passed the form).
[ "A", "label", "can", "be", "a", "string", "dict", "(", "lookup", "by", "name", ")", "or", "a", "callable", "(", "passed", "the", "form", ")", "." ]
train
https://github.com/adamkerz/django-presentation/blob/1e812faa5f682e021fa6580509d8d324cfcc119c/django_presentation/forms/FormPresentationItem.py#L25-L27
sys-git/certifiable
certifiable/complex.py
certify_dict_schema
def certify_dict_schema( value, schema=None, key_certifier=None, value_certifier=None, required=None, allow_extra=None, ): """ Certify the dictionary schema. :param dict|Mapping|MutableMapping value: The mapping value to certify against the schema. :param object schema: The schema t...
python
def certify_dict_schema( value, schema=None, key_certifier=None, value_certifier=None, required=None, allow_extra=None, ): """ Certify the dictionary schema. :param dict|Mapping|MutableMapping value: The mapping value to certify against the schema. :param object schema: The schema t...
[ "def", "certify_dict_schema", "(", "value", ",", "schema", "=", "None", ",", "key_certifier", "=", "None", ",", "value_certifier", "=", "None", ",", "required", "=", "None", ",", "allow_extra", "=", "None", ",", ")", ":", "if", "key_certifier", "is", "not"...
Certify the dictionary schema. :param dict|Mapping|MutableMapping value: The mapping value to certify against the schema. :param object schema: The schema to validate with. :param callable key_certifier: A certifier to use on the dictionary's keys. :param callable value_certifie...
[ "Certify", "the", "dictionary", "schema", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L26-L80
sys-git/certifiable
certifiable/complex.py
certify_dict
def certify_dict( value, schema=None, allow_extra=False, required=True, key_certifier=None, value_certifier=None, include_collections=False, ): """ Certifies a dictionary, checking it against an optional schema. The schema should be a dictionary, with keys corresponding to the expected keys in `val...
python
def certify_dict( value, schema=None, allow_extra=False, required=True, key_certifier=None, value_certifier=None, include_collections=False, ): """ Certifies a dictionary, checking it against an optional schema. The schema should be a dictionary, with keys corresponding to the expected keys in `val...
[ "def", "certify_dict", "(", "value", ",", "schema", "=", "None", ",", "allow_extra", "=", "False", ",", "required", "=", "True", ",", "key_certifier", "=", "None", ",", "value_certifier", "=", "None", ",", "include_collections", "=", "False", ",", ")", ":"...
Certifies a dictionary, checking it against an optional schema. The schema should be a dictionary, with keys corresponding to the expected keys in `value`, but with the values replaced by functions which will be called to with the corresponding value in the input. A simple example: >>> certif...
[ "Certifies", "a", "dictionary", "checking", "it", "against", "an", "optional", "schema", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L84-L160
sys-git/certifiable
certifiable/complex.py
certify_iterable_schema
def certify_iterable_schema(value, schema=None, required=True): """ Certify an iterable against a schema. :param iterable value: The iterable to certify against the schema. :param iterable schema: The schema to use :param bool required: Whether the value can't be `None`. Def...
python
def certify_iterable_schema(value, schema=None, required=True): """ Certify an iterable against a schema. :param iterable value: The iterable to certify against the schema. :param iterable schema: The schema to use :param bool required: Whether the value can't be `None`. Def...
[ "def", "certify_iterable_schema", "(", "value", ",", "schema", "=", "None", ",", "required", "=", "True", ")", ":", "if", "schema", "is", "not", "None", ":", "if", "len", "(", "schema", ")", "!=", "len", "(", "value", ")", ":", "raise", "CertifierValue...
Certify an iterable against a schema. :param iterable value: The iterable to certify against the schema. :param iterable schema: The schema to use :param bool required: Whether the value can't be `None`. Defaults to True. :return: The validated iterable. :rtype: ...
[ "Certify", "an", "iterable", "against", "a", "schema", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L164-L200
sys-git/certifiable
certifiable/complex.py
certify_iterable
def certify_iterable( value, types, certifier=None, min_len=None, max_len=None, schema=None, required=True ): """ Validates an iterable sequence, checking it against an optional schema. The schema should be a list of expected values replaced by functions which will be called to with the corresp...
python
def certify_iterable( value, types, certifier=None, min_len=None, max_len=None, schema=None, required=True ): """ Validates an iterable sequence, checking it against an optional schema. The schema should be a list of expected values replaced by functions which will be called to with the corresp...
[ "def", "certify_iterable", "(", "value", ",", "types", ",", "certifier", "=", "None", ",", "min_len", "=", "None", ",", "max_len", "=", "None", ",", "schema", "=", "None", ",", "required", "=", "True", ")", ":", "certify_required", "(", "value", "=", "...
Validates an iterable sequence, checking it against an optional schema. The schema should be a list of expected values replaced by functions which will be called to with the corresponding value in the input. :param iterable value: The value to be certified. :param tuple(object) types: ...
[ "Validates", "an", "iterable", "sequence", "checking", "it", "against", "an", "optional", "schema", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L203-L281
sys-git/certifiable
certifiable/complex.py
certify_set
def certify_set( value, certifier=None, min_len=None, max_len=None, include_collections=False, required=True, ): """ Certifier for a set. :param set value: The set to be certified. :param func certifier: A function to be called on each value in the list to check that it is valid...
python
def certify_set( value, certifier=None, min_len=None, max_len=None, include_collections=False, required=True, ): """ Certifier for a set. :param set value: The set to be certified. :param func certifier: A function to be called on each value in the list to check that it is valid...
[ "def", "certify_set", "(", "value", ",", "certifier", "=", "None", ",", "min_len", "=", "None", ",", "max_len", "=", "None", ",", "include_collections", "=", "False", ",", "required", "=", "True", ",", ")", ":", "certify_bool", "(", "include_collections", ...
Certifier for a set. :param set value: The set to be certified. :param func certifier: A function to be called on each value in the list to check that it is valid. :param int min_len: The minimum acceptable length for the list. If None, the minimum length is not checked. :param ...
[ "Certifier", "for", "a", "set", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L285-L322
sys-git/certifiable
certifiable/complex.py
certify_tuple
def certify_tuple(value, certifier=None, min_len=None, max_len=None, required=True, schema=None): """ Validates a tuple, checking it against an optional schema. The schema should be a list of expected values replaced by functions which will be called to with the corresponding value in the input. A...
python
def certify_tuple(value, certifier=None, min_len=None, max_len=None, required=True, schema=None): """ Validates a tuple, checking it against an optional schema. The schema should be a list of expected values replaced by functions which will be called to with the corresponding value in the input. A...
[ "def", "certify_tuple", "(", "value", ",", "certifier", "=", "None", ",", "min_len", "=", "None", ",", "max_len", "=", "None", ",", "required", "=", "True", ",", "schema", "=", "None", ")", ":", "certify_iterable", "(", "value", "=", "value", ",", "typ...
Validates a tuple, checking it against an optional schema. The schema should be a list of expected values replaced by functions which will be called to with the corresponding value in the input. A simple example: >>> certifier = certify_tuple(schema=( ... certify_key(kind='Model'), ...
[ "Validates", "a", "tuple", "checking", "it", "against", "an", "optional", "schema", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L326-L372
sys-git/certifiable
certifiable/complex.py
certify_list
def certify_list( value, certifier=None, min_len=None, max_len=None, required=True, schema=None, include_collections=False, ): """ Certifier for a list. :param list value: The array to be certified. :param func certifier: A function to be called on each value in the iterable to ...
python
def certify_list( value, certifier=None, min_len=None, max_len=None, required=True, schema=None, include_collections=False, ): """ Certifier for a list. :param list value: The array to be certified. :param func certifier: A function to be called on each value in the iterable to ...
[ "def", "certify_list", "(", "value", ",", "certifier", "=", "None", ",", "min_len", "=", "None", ",", "max_len", "=", "None", ",", "required", "=", "True", ",", "schema", "=", "None", ",", "include_collections", "=", "False", ",", ")", ":", "certify_bool...
Certifier for a list. :param list value: The array to be certified. :param func certifier: A function to be called on each value in the iterable to check that it is valid. :param int min_len: The minimum acceptable length for the iterable. If None, the minimum length is not checked...
[ "Certifier", "for", "a", "list", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L376-L417
sys-git/certifiable
certifiable/complex.py
certify_email
def certify_email(value, required=True): """ Certifier which verifies that email addresses are well-formed. Does not check that the address exists. :param six.string_types value: The email address to certify. **Should be normalized!** :param bool required: Whether the value can be ...
python
def certify_email(value, required=True): """ Certifier which verifies that email addresses are well-formed. Does not check that the address exists. :param six.string_types value: The email address to certify. **Should be normalized!** :param bool required: Whether the value can be ...
[ "def", "certify_email", "(", "value", ",", "required", "=", "True", ")", ":", "certify_required", "(", "value", "=", "value", ",", "required", "=", "required", ",", ")", "certify_string", "(", "value", ",", "min_length", "=", "3", ",", "max_length", "=", ...
Certifier which verifies that email addresses are well-formed. Does not check that the address exists. :param six.string_types value: The email address to certify. **Should be normalized!** :param bool required: Whether the value can be `None`. Defaults to True. :return: The ce...
[ "Certifier", "which", "verifies", "that", "email", "addresses", "are", "well", "-", "formed", "." ]
train
https://github.com/sys-git/certifiable/blob/a3c33c0d4f3ac2c53be9eded3fae633fa5f697f8/certifiable/complex.py#L421-L471
a1ezzz/wasp-launcher
wasp_launcher/core_broker.py
WResponsiveBrokerCommand.create_task
def create_task(self, *command_tokens, **command_env): """ :return: WLauncherScheduleTask """ return self.__scheduled_task_cls(self.basic_command(), *command_tokens, **command_env)
python
def create_task(self, *command_tokens, **command_env): """ :return: WLauncherScheduleTask """ return self.__scheduled_task_cls(self.basic_command(), *command_tokens, **command_env)
[ "def", "create_task", "(", "self", ",", "*", "command_tokens", ",", "*", "*", "command_env", ")", ":", "return", "self", ".", "__scheduled_task_cls", "(", "self", ".", "basic_command", "(", ")", ",", "*", "command_tokens", ",", "*", "*", "command_env", ")"...
:return: WLauncherScheduleTask
[ ":", "return", ":", "WLauncherScheduleTask" ]
train
https://github.com/a1ezzz/wasp-launcher/blob/38b476286fb422830207031935d3af1fe8da316d/wasp_launcher/core_broker.py#L213-L217
treycucco/bidon
bidon/db/model/validation.py
Validation.is_valid
def is_valid(self, model, validator=None): """Returns true if the model passes the validation, and false if not. Validator must be present_optional if validation is not 'simple'. """ if self.property_name and self.is_property_specific: arg0 = getattr(model, self.property_name) else: arg0...
python
def is_valid(self, model, validator=None): """Returns true if the model passes the validation, and false if not. Validator must be present_optional if validation is not 'simple'. """ if self.property_name and self.is_property_specific: arg0 = getattr(model, self.property_name) else: arg0...
[ "def", "is_valid", "(", "self", ",", "model", ",", "validator", "=", "None", ")", ":", "if", "self", ".", "property_name", "and", "self", ".", "is_property_specific", ":", "arg0", "=", "getattr", "(", "model", ",", "self", ".", "property_name", ")", "els...
Returns true if the model passes the validation, and false if not. Validator must be present_optional if validation is not 'simple'.
[ "Returns", "true", "if", "the", "model", "passes", "the", "validation", "and", "false", "if", "not", ".", "Validator", "must", "be", "present_optional", "if", "validation", "is", "not", "simple", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L41-L55
treycucco/bidon
bidon/db/model/validation.py
Validation.validate
def validate(self, model, validator=None): """Checks the model against all filters, and if it shoud be validated, runs the validation. if the model is invalid, an error is added to the model. Then the validity value is returned. """ for filter_ in self.filters: if not filter_(model): retur...
python
def validate(self, model, validator=None): """Checks the model against all filters, and if it shoud be validated, runs the validation. if the model is invalid, an error is added to the model. Then the validity value is returned. """ for filter_ in self.filters: if not filter_(model): retur...
[ "def", "validate", "(", "self", ",", "model", ",", "validator", "=", "None", ")", ":", "for", "filter_", "in", "self", ".", "filters", ":", "if", "not", "filter_", "(", "model", ")", ":", "return", "True", "is_valid", ",", "message", "=", "self", "."...
Checks the model against all filters, and if it shoud be validated, runs the validation. if the model is invalid, an error is added to the model. Then the validity value is returned.
[ "Checks", "the", "model", "against", "all", "filters", "and", "if", "it", "shoud", "be", "validated", "runs", "the", "validation", ".", "if", "the", "model", "is", "invalid", "an", "error", "is", "added", "to", "the", "model", ".", "Then", "the", "validi...
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L57-L68
treycucco/bidon
bidon/db/model/validation.py
Validation._is_present
def _is_present(val): """Returns True if the value is not None, and if it is either not a string, or a string with length > 0. """ if val is None: return False if isinstance(val, str): return len(val) > 0 return True
python
def _is_present(val): """Returns True if the value is not None, and if it is either not a string, or a string with length > 0. """ if val is None: return False if isinstance(val, str): return len(val) > 0 return True
[ "def", "_is_present", "(", "val", ")", ":", "if", "val", "is", "None", ":", "return", "False", "if", "isinstance", "(", "val", ",", "str", ")", ":", "return", "len", "(", "val", ")", ">", "0", "return", "True" ]
Returns True if the value is not None, and if it is either not a string, or a string with length > 0.
[ "Returns", "True", "if", "the", "value", "is", "not", "None", "and", "if", "it", "is", "either", "not", "a", "string", "or", "a", "string", "with", "length", ">", "0", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L71-L79
treycucco/bidon
bidon/db/model/validation.py
Validation.is_length
def is_length(property_name, *, min_length=1, max_length=None, present_optional=False): """Returns a Validation that checks the length of a string.""" def check(val): """Checks that a value matches a scope-enclosed set of length parameters.""" if not val: return present_optional else: ...
python
def is_length(property_name, *, min_length=1, max_length=None, present_optional=False): """Returns a Validation that checks the length of a string.""" def check(val): """Checks that a value matches a scope-enclosed set of length parameters.""" if not val: return present_optional else: ...
[ "def", "is_length", "(", "property_name", ",", "*", ",", "min_length", "=", "1", ",", "max_length", "=", "None", ",", "present_optional", "=", "False", ")", ":", "def", "check", "(", "val", ")", ":", "\"\"\"Checks that a value matches a scope-enclosed set of lengt...
Returns a Validation that checks the length of a string.
[ "Returns", "a", "Validation", "that", "checks", "the", "length", "of", "a", "string", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L87-L107
treycucco/bidon
bidon/db/model/validation.py
Validation.matches
def matches(property_name, regex, *, present_optional=False, message=None): """Returns a Validation that checks a property against a regex.""" def check(val): """Checks that a value matches a scope-enclosed regex.""" if not val: return present_optional else: return True if rege...
python
def matches(property_name, regex, *, present_optional=False, message=None): """Returns a Validation that checks a property against a regex.""" def check(val): """Checks that a value matches a scope-enclosed regex.""" if not val: return present_optional else: return True if rege...
[ "def", "matches", "(", "property_name", ",", "regex", ",", "*", ",", "present_optional", "=", "False", ",", "message", "=", "None", ")", ":", "def", "check", "(", "val", ")", ":", "\"\"\"Checks that a value matches a scope-enclosed regex.\"\"\"", "if", "not", "v...
Returns a Validation that checks a property against a regex.
[ "Returns", "a", "Validation", "that", "checks", "a", "property", "against", "a", "regex", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L110-L119
treycucco/bidon
bidon/db/model/validation.py
Validation.is_numeric
def is_numeric(property_name, *, numtype="float", min=None, max=None, present_optional=False, message=None): """Returns a Validation that checks a property as a number, with optional range constraints.""" if numtype == "int": cast = util.try_parse_int elif numtype == "decimal": ...
python
def is_numeric(property_name, *, numtype="float", min=None, max=None, present_optional=False, message=None): """Returns a Validation that checks a property as a number, with optional range constraints.""" if numtype == "int": cast = util.try_parse_int elif numtype == "decimal": ...
[ "def", "is_numeric", "(", "property_name", ",", "*", ",", "numtype", "=", "\"float\"", ",", "min", "=", "None", ",", "max", "=", "None", ",", "present_optional", "=", "False", ",", "message", "=", "None", ")", ":", "if", "numtype", "==", "\"int\"", ":"...
Returns a Validation that checks a property as a number, with optional range constraints.
[ "Returns", "a", "Validation", "that", "checks", "a", "property", "as", "a", "number", "with", "optional", "range", "constraints", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L122-L163
treycucco/bidon
bidon/db/model/validation.py
Validation.is_date
def is_date(property_name, *, format=None, present_optional=False, message=None): """Returns a Validation that checks a value as a date.""" # NOTE: Not currently using format param def check(val): """Checks that a value can be parsed as a date.""" if val is None: return present_optional ...
python
def is_date(property_name, *, format=None, present_optional=False, message=None): """Returns a Validation that checks a value as a date.""" # NOTE: Not currently using format param def check(val): """Checks that a value can be parsed as a date.""" if val is None: return present_optional ...
[ "def", "is_date", "(", "property_name", ",", "*", ",", "format", "=", "None", ",", "present_optional", "=", "False", ",", "message", "=", "None", ")", ":", "# NOTE: Not currently using format param", "def", "check", "(", "val", ")", ":", "\"\"\"Checks that a val...
Returns a Validation that checks a value as a date.
[ "Returns", "a", "Validation", "that", "checks", "a", "value", "as", "a", "date", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L166-L177
treycucco/bidon
bidon/db/model/validation.py
Validation.is_datetime
def is_datetime(property_name, *, format=None, present_optional=False, message=None): """Returns a Validation that checks a value as a datetime.""" # NOTE: Not currently using format param def check(val): """Checks that a value can be parsed as a datetime.""" if val is None: return prese...
python
def is_datetime(property_name, *, format=None, present_optional=False, message=None): """Returns a Validation that checks a value as a datetime.""" # NOTE: Not currently using format param def check(val): """Checks that a value can be parsed as a datetime.""" if val is None: return prese...
[ "def", "is_datetime", "(", "property_name", ",", "*", ",", "format", "=", "None", ",", "present_optional", "=", "False", ",", "message", "=", "None", ")", ":", "# NOTE: Not currently using format param", "def", "check", "(", "val", ")", ":", "\"\"\"Checks that a...
Returns a Validation that checks a value as a datetime.
[ "Returns", "a", "Validation", "that", "checks", "a", "value", "as", "a", "datetime", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L180-L191
treycucco/bidon
bidon/db/model/validation.py
Validation.is_in
def is_in(property_name, set_values, *, present_optional=False, message=None): """Returns a Validation that checks that a value is contained within a given set.""" def check(val): """Checks that a value is contained within a scope-enclosed set.""" if val is None: return present_optional ...
python
def is_in(property_name, set_values, *, present_optional=False, message=None): """Returns a Validation that checks that a value is contained within a given set.""" def check(val): """Checks that a value is contained within a scope-enclosed set.""" if val is None: return present_optional ...
[ "def", "is_in", "(", "property_name", ",", "set_values", ",", "*", ",", "present_optional", "=", "False", ",", "message", "=", "None", ")", ":", "def", "check", "(", "val", ")", ":", "\"\"\"Checks that a value is contained within a scope-enclosed set.\"\"\"", "if", ...
Returns a Validation that checks that a value is contained within a given set.
[ "Returns", "a", "Validation", "that", "checks", "that", "a", "value", "is", "contained", "within", "a", "given", "set", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L194-L203
treycucco/bidon
bidon/db/model/validation.py
Validation.is_unique
def is_unique(keys, *, scope=None, comparison_operators=None, present_optional=False, message=None): """Returns a Validation that makes sure the given value is unique for a table and optionally a scope. """ def check(pname, validator): """Checks that a value is unique in its column...
python
def is_unique(keys, *, scope=None, comparison_operators=None, present_optional=False, message=None): """Returns a Validation that makes sure the given value is unique for a table and optionally a scope. """ def check(pname, validator): """Checks that a value is unique in its column...
[ "def", "is_unique", "(", "keys", ",", "*", ",", "scope", "=", "None", ",", "comparison_operators", "=", "None", ",", "present_optional", "=", "False", ",", "message", "=", "None", ")", ":", "def", "check", "(", "pname", ",", "validator", ")", ":", "\"\...
Returns a Validation that makes sure the given value is unique for a table and optionally a scope.
[ "Returns", "a", "Validation", "that", "makes", "sure", "the", "given", "value", "is", "unique", "for", "a", "table", "and", "optionally", "a", "scope", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L206-L259
treycucco/bidon
bidon/db/model/validation.py
Validator.validate
def validate(self, model, data_access=None, *, fail_fast=None): """Validates a model against the collection of Validations. Returns True if all Validations pass, or False if one or more do not. """ if fail_fast is None: fail_fast = self.fail_fast self.model = model self.data_access = dat...
python
def validate(self, model, data_access=None, *, fail_fast=None): """Validates a model against the collection of Validations. Returns True if all Validations pass, or False if one or more do not. """ if fail_fast is None: fail_fast = self.fail_fast self.model = model self.data_access = dat...
[ "def", "validate", "(", "self", ",", "model", ",", "data_access", "=", "None", ",", "*", ",", "fail_fast", "=", "None", ")", ":", "if", "fail_fast", "is", "None", ":", "fail_fast", "=", "self", ".", "fail_fast", "self", ".", "model", "=", "model", "s...
Validates a model against the collection of Validations. Returns True if all Validations pass, or False if one or more do not.
[ "Validates", "a", "model", "against", "the", "collection", "of", "Validations", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/validation.py#L275-L291
techdragon/python-git-repo-info
src/git_repo_info/git_repo_info.py
GitRepo._check_output
def _check_output(self, command): """Wrap the call to subprocess.check_output() to raise customized exceptions and always return strings.""" try: if sys.version_info[0] > 2: return check_output(self.base_command + command, stderr=STDOUT).decode('utf8') else: ...
python
def _check_output(self, command): """Wrap the call to subprocess.check_output() to raise customized exceptions and always return strings.""" try: if sys.version_info[0] > 2: return check_output(self.base_command + command, stderr=STDOUT).decode('utf8') else: ...
[ "def", "_check_output", "(", "self", ",", "command", ")", ":", "try", ":", "if", "sys", ".", "version_info", "[", "0", "]", ">", "2", ":", "return", "check_output", "(", "self", ".", "base_command", "+", "command", ",", "stderr", "=", "STDOUT", ")", ...
Wrap the call to subprocess.check_output() to raise customized exceptions and always return strings.
[ "Wrap", "the", "call", "to", "subprocess", ".", "check_output", "()", "to", "raise", "customized", "exceptions", "and", "always", "return", "strings", "." ]
train
https://github.com/techdragon/python-git-repo-info/blob/f840ad83fe349abac96002e55c153f55d77b1cc9/src/git_repo_info/git_repo_info.py#L40-L48
techdragon/python-git-repo-info
src/git_repo_info/git_repo_info.py
GitRepo.configured_options
def configured_options(self): """What are the configured options in the git repo.""" stdout_lines = self._check_output(['config', '--list']).splitlines() return {key: value for key, value in [line.split('=') for line in stdout_lines]}
python
def configured_options(self): """What are the configured options in the git repo.""" stdout_lines = self._check_output(['config', '--list']).splitlines() return {key: value for key, value in [line.split('=') for line in stdout_lines]}
[ "def", "configured_options", "(", "self", ")", ":", "stdout_lines", "=", "self", ".", "_check_output", "(", "[", "'config'", ",", "'--list'", "]", ")", ".", "splitlines", "(", ")", "return", "{", "key", ":", "value", "for", "key", ",", "value", "in", "...
What are the configured options in the git repo.
[ "What", "are", "the", "configured", "options", "in", "the", "git", "repo", "." ]
train
https://github.com/techdragon/python-git-repo-info/blob/f840ad83fe349abac96002e55c153f55d77b1cc9/src/git_repo_info/git_repo_info.py#L67-L70
KnowledgeLinks/rdfframework
rdfframework/search/esutilities.py
get_es_action_item
def get_es_action_item(data_item, action_settings, es_type, id_field=None): ''' This method will return an item formated and ready to append to the action list ''' action_item = dict.copy(action_settings) if id_field is not None: id_val = first(list(get_dict_key(data_item, id_field))) ...
python
def get_es_action_item(data_item, action_settings, es_type, id_field=None): ''' This method will return an item formated and ready to append to the action list ''' action_item = dict.copy(action_settings) if id_field is not None: id_val = first(list(get_dict_key(data_item, id_field))) ...
[ "def", "get_es_action_item", "(", "data_item", ",", "action_settings", ",", "es_type", ",", "id_field", "=", "None", ")", ":", "action_item", "=", "dict", ".", "copy", "(", "action_settings", ")", "if", "id_field", "is", "not", "None", ":", "id_val", "=", ...
This method will return an item formated and ready to append to the action list
[ "This", "method", "will", "return", "an", "item", "formated", "and", "ready", "to", "append", "to", "the", "action", "list" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esutilities.py#L1-L20
KnowledgeLinks/rdfframework
rdfframework/search/esutilities.py
es_field_sort
def es_field_sort(fld_name): """ Used with lambda to sort fields """ parts = fld_name.split(".") if "_" not in parts[-1]: parts[-1] = "_" + parts[-1] return ".".join(parts)
python
def es_field_sort(fld_name): """ Used with lambda to sort fields """ parts = fld_name.split(".") if "_" not in parts[-1]: parts[-1] = "_" + parts[-1] return ".".join(parts)
[ "def", "es_field_sort", "(", "fld_name", ")", ":", "parts", "=", "fld_name", ".", "split", "(", "\".\"", ")", "if", "\"_\"", "not", "in", "parts", "[", "-", "1", "]", ":", "parts", "[", "-", "1", "]", "=", "\"_\"", "+", "parts", "[", "-", "1", ...
Used with lambda to sort fields
[ "Used", "with", "lambda", "to", "sort", "fields" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esutilities.py#L111-L116
lizardsystem/tags2sdists
tags2sdists/script.py
main
def main(): """bin/tags2sdists: create an sdist for a directory of checkouts.""" usage = ("Usage: %prog CHECKOUTDIR SDISTDIR\n" " CHECKOUTDIR: directory with checkouts\n" " SDISTDIR: directory with sdist package directories") parser = optparse.OptionParser(usage=usage) pa...
python
def main(): """bin/tags2sdists: create an sdist for a directory of checkouts.""" usage = ("Usage: %prog CHECKOUTDIR SDISTDIR\n" " CHECKOUTDIR: directory with checkouts\n" " SDISTDIR: directory with sdist package directories") parser = optparse.OptionParser(usage=usage) pa...
[ "def", "main", "(", ")", ":", "usage", "=", "(", "\"Usage: %prog CHECKOUTDIR SDISTDIR\\n\"", "\" CHECKOUTDIR: directory with checkouts\\n\"", "\" SDISTDIR: directory with sdist package directories\"", ")", "parser", "=", "optparse", ".", "OptionParser", "(", "usage", "=",...
bin/tags2sdists: create an sdist for a directory of checkouts.
[ "bin", "/", "tags2sdists", ":", "create", "an", "sdist", "for", "a", "directory", "of", "checkouts", "." ]
train
https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/script.py#L13-L60
kodexlab/reliure
reliure/web.py
app_routes
def app_routes(app): """ list of route of an app """ _routes = [] for rule in app.url_map.iter_rules(): _routes.append({ 'path': rule.rule, 'name': rule.endpoint, 'methods': list(rule.methods) }) return jsonify({'routes': _routes})
python
def app_routes(app): """ list of route of an app """ _routes = [] for rule in app.url_map.iter_rules(): _routes.append({ 'path': rule.rule, 'name': rule.endpoint, 'methods': list(rule.methods) }) return jsonify({'routes': _routes})
[ "def", "app_routes", "(", "app", ")", ":", "_routes", "=", "[", "]", "for", "rule", "in", "app", ".", "url_map", ".", "iter_rules", "(", ")", ":", "_routes", ".", "append", "(", "{", "'path'", ":", "rule", ".", "rule", ",", "'name'", ":", "rule", ...
list of route of an app
[ "list", "of", "route", "of", "an", "app" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L28-L38
kodexlab/reliure
reliure/web.py
EngineView.set_input_type
def set_input_type(self, type_or_parse): """ Set an unique input type. If you use this then you have only one input for the play. """ self._inputs = OrderedDict() default_inputs = self.engine.in_name if len(default_inputs) > 1: raise ValueError("Need more tha...
python
def set_input_type(self, type_or_parse): """ Set an unique input type. If you use this then you have only one input for the play. """ self._inputs = OrderedDict() default_inputs = self.engine.in_name if len(default_inputs) > 1: raise ValueError("Need more tha...
[ "def", "set_input_type", "(", "self", ",", "type_or_parse", ")", ":", "self", ".", "_inputs", "=", "OrderedDict", "(", ")", "default_inputs", "=", "self", ".", "engine", ".", "in_name", "if", "len", "(", "default_inputs", ")", ">", "1", ":", "raise", "Va...
Set an unique input type. If you use this then you have only one input for the play.
[ "Set", "an", "unique", "input", "type", "." ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L74-L83
kodexlab/reliure
reliure/web.py
EngineView.add_input
def add_input(self, in_name, type_or_parse=None): """ Declare a possible input """ if type_or_parse is None: type_or_parse = GenericType() elif not isinstance(type_or_parse, GenericType) and callable(type_or_parse): type_or_parse = GenericType(parse=type_or_parse)...
python
def add_input(self, in_name, type_or_parse=None): """ Declare a possible input """ if type_or_parse is None: type_or_parse = GenericType() elif not isinstance(type_or_parse, GenericType) and callable(type_or_parse): type_or_parse = GenericType(parse=type_or_parse)...
[ "def", "add_input", "(", "self", ",", "in_name", ",", "type_or_parse", "=", "None", ")", ":", "if", "type_or_parse", "is", "None", ":", "type_or_parse", "=", "GenericType", "(", ")", "elif", "not", "isinstance", "(", "type_or_parse", ",", "GenericType", ")",...
Declare a possible input
[ "Declare", "a", "possible", "input" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L85-L94
kodexlab/reliure
reliure/web.py
EngineView.set_outputs
def set_outputs(self, *outputs): """ Set the outputs of the view """ self._outputs = OrderedDict() for output in outputs: out_name = None type_or_serialize = None if isinstance((list, tuple), output): if len(output) == 1: ...
python
def set_outputs(self, *outputs): """ Set the outputs of the view """ self._outputs = OrderedDict() for output in outputs: out_name = None type_or_serialize = None if isinstance((list, tuple), output): if len(output) == 1: ...
[ "def", "set_outputs", "(", "self", ",", "*", "outputs", ")", ":", "self", ".", "_outputs", "=", "OrderedDict", "(", ")", "for", "output", "in", "outputs", ":", "out_name", "=", "None", "type_or_serialize", "=", "None", "if", "isinstance", "(", "(", "list...
Set the outputs of the view
[ "Set", "the", "outputs", "of", "the", "view" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L96-L113
kodexlab/reliure
reliure/web.py
EngineView.add_output
def add_output(self, out_name, type_or_serialize=None, **kwargs): """ Declare an output """ if out_name not in self.engine.all_outputs(): raise ValueError("'%s' is not generated by the engine %s" % (out_name, self.engine.all_outputs())) if type_or_serialize is None: ...
python
def add_output(self, out_name, type_or_serialize=None, **kwargs): """ Declare an output """ if out_name not in self.engine.all_outputs(): raise ValueError("'%s' is not generated by the engine %s" % (out_name, self.engine.all_outputs())) if type_or_serialize is None: ...
[ "def", "add_output", "(", "self", ",", "out_name", ",", "type_or_serialize", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "out_name", "not", "in", "self", ".", "engine", ".", "all_outputs", "(", ")", ":", "raise", "ValueError", "(", "\"'%s' is n...
Declare an output
[ "Declare", "an", "output" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L115-L130
kodexlab/reliure
reliure/web.py
EngineView.parse_request
def parse_request(self): """ Parse request for :func:`play` """ data = {} options = {} ### get data if request.headers['Content-Type'].startswith('application/json'): # data in JSON data = request.json assert data is not None #FIXME: be...
python
def parse_request(self): """ Parse request for :func:`play` """ data = {} options = {} ### get data if request.headers['Content-Type'].startswith('application/json'): # data in JSON data = request.json assert data is not None #FIXME: be...
[ "def", "parse_request", "(", "self", ")", ":", "data", "=", "{", "}", "options", "=", "{", "}", "### get data", "if", "request", ".", "headers", "[", "'Content-Type'", "]", ".", "startswith", "(", "'application/json'", ")", ":", "# data in JSON", "data", "...
Parse request for :func:`play`
[ "Parse", "request", "for", ":", "func", ":", "play" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L148-L171
kodexlab/reliure
reliure/web.py
EngineView.run
def run(self, inputs_data, options): """ Run the engine/block according to some inputs data and options It is called from :func:`play` :param inputs_data: dict of input data :param options: engine/block configuration dict """ ### configure the engine ...
python
def run(self, inputs_data, options): """ Run the engine/block according to some inputs data and options It is called from :func:`play` :param inputs_data: dict of input data :param options: engine/block configuration dict """ ### configure the engine ...
[ "def", "run", "(", "self", ",", "inputs_data", ",", "options", ")", ":", "### configure the engine", "try", ":", "self", ".", "engine", ".", "configure", "(", "options", ")", "except", "ValueError", "as", "err", ":", "raise", "abort", "(", "406", ",", "e...
Run the engine/block according to some inputs data and options It is called from :func:`play` :param inputs_data: dict of input data :param options: engine/block configuration dict
[ "Run", "the", "engine", "/", "block", "according", "to", "some", "inputs", "data", "and", "options", "It", "is", "called", "from", ":", "func", ":", "play", ":", "param", "inputs_data", ":", "dict", "of", "input", "data", ":", "param", "options", ":", ...
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L173-L246
kodexlab/reliure
reliure/web.py
EngineView.options
def options(self): """ Engine options discover HTTP entry point """ #configure engine with an empty dict to ensure default selection/options self.engine.configure({}) conf = self.engine.as_dict() conf["returns"] = [oname for oname in six.iterkeys(self._outputs)] #...
python
def options(self): """ Engine options discover HTTP entry point """ #configure engine with an empty dict to ensure default selection/options self.engine.configure({}) conf = self.engine.as_dict() conf["returns"] = [oname for oname in six.iterkeys(self._outputs)] #...
[ "def", "options", "(", "self", ")", ":", "#configure engine with an empty dict to ensure default selection/options", "self", ".", "engine", ".", "configure", "(", "{", "}", ")", "conf", "=", "self", ".", "engine", ".", "as_dict", "(", ")", "conf", "[", "\"return...
Engine options discover HTTP entry point
[ "Engine", "options", "discover", "HTTP", "entry", "point" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L248-L257
kodexlab/reliure
reliure/web.py
EngineView.play
def play(self): """ Main http entry point: run the engine """ data, options = self.parse_request() #warning: 'data' are the raw data from the client, not the de-serialised ones outputs = self.run(data, options) return jsonify(outputs)
python
def play(self): """ Main http entry point: run the engine """ data, options = self.parse_request() #warning: 'data' are the raw data from the client, not the de-serialised ones outputs = self.run(data, options) return jsonify(outputs)
[ "def", "play", "(", "self", ")", ":", "data", ",", "options", "=", "self", ".", "parse_request", "(", ")", "#warning: 'data' are the raw data from the client, not the de-serialised ones", "outputs", "=", "self", ".", "run", "(", "data", ",", "options", ")", "retur...
Main http entry point: run the engine
[ "Main", "http", "entry", "point", ":", "run", "the", "engine" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L259-L265
kodexlab/reliure
reliure/web.py
EngineView.short_play
def short_play(self, **kwargs): """ Main http entry point: run the engine """ # options in URL arguments config = self._config_from_url() outputs = self.run(kwargs, config) return jsonify(outputs)
python
def short_play(self, **kwargs): """ Main http entry point: run the engine """ # options in URL arguments config = self._config_from_url() outputs = self.run(kwargs, config) return jsonify(outputs)
[ "def", "short_play", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# options in URL arguments", "config", "=", "self", ".", "_config_from_url", "(", ")", "outputs", "=", "self", ".", "run", "(", "kwargs", ",", "config", ")", "return", "jsonify", "(", ...
Main http entry point: run the engine
[ "Main", "http", "entry", "point", ":", "run", "the", "engine" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L267-L273
kodexlab/reliure
reliure/web.py
ComponentView._config_from_url
def _config_from_url(self): """ Manage block configuration from requests.args (url params) """ config = { "name": self._blk.name, "options": {} } for key, value in six.iteritems(request.args): if isinstance(value, list) and len(value) == 1: ...
python
def _config_from_url(self): """ Manage block configuration from requests.args (url params) """ config = { "name": self._blk.name, "options": {} } for key, value in six.iteritems(request.args): if isinstance(value, list) and len(value) == 1: ...
[ "def", "_config_from_url", "(", "self", ")", ":", "config", "=", "{", "\"name\"", ":", "self", ".", "_blk", ".", "name", ",", "\"options\"", ":", "{", "}", "}", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "request", ".", "args", ...
Manage block configuration from requests.args (url params)
[ "Manage", "block", "configuration", "from", "requests", ".", "args", "(", "url", "params", ")" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L306-L318
kodexlab/reliure
reliure/web.py
ReliureAPI.register_view
def register_view(self, view, url_prefix=None): """ Associate a :class:`EngineView` to this api """ if url_prefix is None: if view.name is None: raise ValueError("EngineView has no name and path is not specified") url_prefix = view.name # bind entr...
python
def register_view(self, view, url_prefix=None): """ Associate a :class:`EngineView` to this api """ if url_prefix is None: if view.name is None: raise ValueError("EngineView has no name and path is not specified") url_prefix = view.name # bind entr...
[ "def", "register_view", "(", "self", ",", "view", ",", "url_prefix", "=", "None", ")", ":", "if", "url_prefix", "is", "None", ":", "if", "view", ".", "name", "is", "None", ":", "raise", "ValueError", "(", "\"EngineView has no name and path is not specified\"", ...
Associate a :class:`EngineView` to this api
[ "Associate", "a", ":", "class", ":", "EngineView", "to", "this", "api" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L395-L415
kodexlab/reliure
reliure/web.py
ReliureAPI._routes
def _routes(self, app): """ list of routes (you should have the app where this is register) """ _routes = [] prefix = self.url_prefix if self.url_prefix is not None else "" for rule in app.url_map.iter_rules(): if str(rule).startswith(prefix): _routes....
python
def _routes(self, app): """ list of routes (you should have the app where this is register) """ _routes = [] prefix = self.url_prefix if self.url_prefix is not None else "" for rule in app.url_map.iter_rules(): if str(rule).startswith(prefix): _routes....
[ "def", "_routes", "(", "self", ",", "app", ")", ":", "_routes", "=", "[", "]", "prefix", "=", "self", ".", "url_prefix", "if", "self", ".", "url_prefix", "is", "not", "None", "else", "\"\"", "for", "rule", "in", "app", ".", "url_map", ".", "iter_rule...
list of routes (you should have the app where this is register)
[ "list", "of", "routes", "(", "you", "should", "have", "the", "app", "where", "this", "is", "register", ")" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L417-L434
kodexlab/reliure
reliure/web.py
RemoteApi.forward
def forward(self, **kwargs): """ remote http call to api endpoint accept *ONLY* GET and POST """ # rewrite url path prefix = self.url_prefix path= "" if request.path == "/" else request.path path = path[len(prefix):] url = '%s%s'% ( self.url_root[:-1], ...
python
def forward(self, **kwargs): """ remote http call to api endpoint accept *ONLY* GET and POST """ # rewrite url path prefix = self.url_prefix path= "" if request.path == "/" else request.path path = path[len(prefix):] url = '%s%s'% ( self.url_root[:-1], ...
[ "def", "forward", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# rewrite url path ", "prefix", "=", "self", ".", "url_prefix", "path", "=", "\"\"", "if", "request", ".", "path", "==", "\"/\"", "else", "request", ".", "path", "path", "=", "path", "...
remote http call to api endpoint accept *ONLY* GET and POST
[ "remote", "http", "call", "to", "api", "endpoint", "accept", "*", "ONLY", "*", "GET", "and", "POST" ]
train
https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/web.py#L505-L531
anti1869/sunhead
src/sunhead/events/stream.py
init_stream_from_settings
async def init_stream_from_settings(cfg: dict) -> Stream: """ Shortcut to create Stream from configured settings. Will definitely fail if there is no meaningful configuration provided. Example of such is:: { "streams": { "rabbitmq": { "transport": "s...
python
async def init_stream_from_settings(cfg: dict) -> Stream: """ Shortcut to create Stream from configured settings. Will definitely fail if there is no meaningful configuration provided. Example of such is:: { "streams": { "rabbitmq": { "transport": "s...
[ "async", "def", "init_stream_from_settings", "(", "cfg", ":", "dict", ")", "->", "Stream", ":", "cfg_name", "=", "cfg", "[", "\"active_stream\"", "]", "stream_init_kwargs", "=", "cfg", "[", "\"streams\"", "]", "[", "cfg_name", "]", "stream", "=", "Stream", "...
Shortcut to create Stream from configured settings. Will definitely fail if there is no meaningful configuration provided. Example of such is:: { "streams": { "rabbitmq": { "transport": "sunhead.events.transports.amqp.AMQPClient", "connec...
[ "Shortcut", "to", "create", "Stream", "from", "configured", "settings", "." ]
train
https://github.com/anti1869/sunhead/blob/5117ec797a38eb82d955241d20547d125efe80f3/src/sunhead/events/stream.py#L124-L157
openbermuda/ripl
ripl/md2py.py
Mark2Py.interpret
def interpret(self, infile): """ Process a file of rest and return list of dicts """ data = [] for record in self.generate_records(infile): data.append(record) return data
python
def interpret(self, infile): """ Process a file of rest and return list of dicts """ data = [] for record in self.generate_records(infile): data.append(record) return data
[ "def", "interpret", "(", "self", ",", "infile", ")", ":", "data", "=", "[", "]", "for", "record", "in", "self", ".", "generate_records", "(", "infile", ")", ":", "data", ".", "append", "(", "record", ")", "return", "data" ]
Process a file of rest and return list of dicts
[ "Process", "a", "file", "of", "rest", "and", "return", "list", "of", "dicts" ]
train
https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/md2py.py#L17-L25
openbermuda/ripl
ripl/md2py.py
Mark2Py.generate_lines
def generate_lines(self, infile): """ Split file into lines return dict with line=input, depth=n """ pound = '#' for line in infile: heading = 0 if line.startswith(pound): heading = self.hash_count(line) yield dict(...
python
def generate_lines(self, infile): """ Split file into lines return dict with line=input, depth=n """ pound = '#' for line in infile: heading = 0 if line.startswith(pound): heading = self.hash_count(line) yield dict(...
[ "def", "generate_lines", "(", "self", ",", "infile", ")", ":", "pound", "=", "'#'", "for", "line", "in", "infile", ":", "heading", "=", "0", "if", "line", ".", "startswith", "(", "pound", ")", ":", "heading", "=", "self", ".", "hash_count", "(", "lin...
Split file into lines return dict with line=input, depth=n
[ "Split", "file", "into", "lines" ]
train
https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/md2py.py#L40-L54
openbermuda/ripl
ripl/md2py.py
Mark2Py.generate_records
def generate_records(self, infile): """ Process a file of rest and yield dictionaries """ state = 0 record = {} for item in self.generate_lines(infile): line = item['line'] heading = item['heading'] # any Markdown heading is just a capt...
python
def generate_records(self, infile): """ Process a file of rest and yield dictionaries """ state = 0 record = {} for item in self.generate_lines(infile): line = item['line'] heading = item['heading'] # any Markdown heading is just a capt...
[ "def", "generate_records", "(", "self", ",", "infile", ")", ":", "state", "=", "0", "record", "=", "{", "}", "for", "item", "in", "self", ".", "generate_lines", "(", "infile", ")", ":", "line", "=", "item", "[", "'line'", "]", "heading", "=", "item",...
Process a file of rest and yield dictionaries
[ "Process", "a", "file", "of", "rest", "and", "yield", "dictionaries" ]
train
https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/md2py.py#L57-L116
jtpaasch/simplygithub
simplygithub/authentication/profile.py
read_profile
def read_profile(name): """Get a named profile from the CONFIG_FILE. Args: name The name of the profile to load. Returns: A dictionary with the profile's ``repo`` and ``token`` values. """ config = configparser.ConfigParser() config.read(CONFIG_FILE) profile =...
python
def read_profile(name): """Get a named profile from the CONFIG_FILE. Args: name The name of the profile to load. Returns: A dictionary with the profile's ``repo`` and ``token`` values. """ config = configparser.ConfigParser() config.read(CONFIG_FILE) profile =...
[ "def", "read_profile", "(", "name", ")", ":", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "config", ".", "read", "(", "CONFIG_FILE", ")", "profile", "=", "config", "[", "name", "]", "repo", "=", "profile", "[", "\"repo\"", "]", "token",...
Get a named profile from the CONFIG_FILE. Args: name The name of the profile to load. Returns: A dictionary with the profile's ``repo`` and ``token`` values.
[ "Get", "a", "named", "profile", "from", "the", "CONFIG_FILE", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/authentication/profile.py#L60-L77
jtpaasch/simplygithub
simplygithub/authentication/profile.py
write_profile
def write_profile(name, repo, token): """Save a profile to the CONFIG_FILE. After you use this method to save a profile, you can load it anytime later with the ``read_profile()`` function defined above. Args: name The name of the profile to save. repo The Gith...
python
def write_profile(name, repo, token): """Save a profile to the CONFIG_FILE. After you use this method to save a profile, you can load it anytime later with the ``read_profile()`` function defined above. Args: name The name of the profile to save. repo The Gith...
[ "def", "write_profile", "(", "name", ",", "repo", ",", "token", ")", ":", "make_sure_folder_exists", "(", "CONFIG_FOLDER", ")", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "config", ".", "read", "(", "CONFIG_FILE", ")", "profile", "=", "{",...
Save a profile to the CONFIG_FILE. After you use this method to save a profile, you can load it anytime later with the ``read_profile()`` function defined above. Args: name The name of the profile to save. repo The Github repo you want to connect to. For instance,...
[ "Save", "a", "profile", "to", "the", "CONFIG_FILE", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/authentication/profile.py#L80-L110
praekelt/jmbo-sitemap
jmbo_sitemap/admin.py
HTMLSitemapAdmin.changelist_view
def changelist_view(self, request, extra_context=None): """ If we only have a single preference object redirect to it, otherwise display listing. """ model = self.model if model.objects.all().count() > 1: return super(HTMLSitemapAdmin, self).changelist_view(re...
python
def changelist_view(self, request, extra_context=None): """ If we only have a single preference object redirect to it, otherwise display listing. """ model = self.model if model.objects.all().count() > 1: return super(HTMLSitemapAdmin, self).changelist_view(re...
[ "def", "changelist_view", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "model", "=", "self", ".", "model", "if", "model", ".", "objects", ".", "all", "(", ")", ".", "count", "(", ")", ">", "1", ":", "return", "super", "...
If we only have a single preference object redirect to it, otherwise display listing.
[ "If", "we", "only", "have", "a", "single", "preference", "object", "redirect", "to", "it", "otherwise", "display", "listing", "." ]
train
https://github.com/praekelt/jmbo-sitemap/blob/32b41c17553462d112e1a394338d65aa27c82561/jmbo_sitemap/admin.py#L16-L27
GaretJax/irco
setup.py
Setup.requirements
def requirements(fname): """ Utility function to create a list of requirements from the output of the pip freeze command saved in a text file. """ packages = Setup.read(fname, fail_silently=True).split('\n') packages = (p.strip() for p in packages) packages = (p f...
python
def requirements(fname): """ Utility function to create a list of requirements from the output of the pip freeze command saved in a text file. """ packages = Setup.read(fname, fail_silently=True).split('\n') packages = (p.strip() for p in packages) packages = (p f...
[ "def", "requirements", "(", "fname", ")", ":", "packages", "=", "Setup", ".", "read", "(", "fname", ",", "fail_silently", "=", "True", ")", ".", "split", "(", "'\\n'", ")", "packages", "=", "(", "p", ".", "strip", "(", ")", "for", "p", "in", "packa...
Utility function to create a list of requirements from the output of the pip freeze command saved in a text file.
[ "Utility", "function", "to", "create", "a", "list", "of", "requirements", "from", "the", "output", "of", "the", "pip", "freeze", "command", "saved", "in", "a", "text", "file", "." ]
train
https://github.com/GaretJax/irco/blob/e5df3cf1a608dc813011a1ee7e920637e5bd155c/setup.py#L22-L30
elijahr/lk
lk.py
build_parser
def build_parser(): """ Returns an argparse.ArgumentParser instance to parse the command line arguments for lk """ import argparse description = "A programmer's search tool, parallel and fast" parser = argparse.ArgumentParser(description=description) parser.add_argument('pattern', metava...
python
def build_parser(): """ Returns an argparse.ArgumentParser instance to parse the command line arguments for lk """ import argparse description = "A programmer's search tool, parallel and fast" parser = argparse.ArgumentParser(description=description) parser.add_argument('pattern', metava...
[ "def", "build_parser", "(", ")", ":", "import", "argparse", "description", "=", "\"A programmer's search tool, parallel and fast\"", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "description", ")", "parser", ".", "add_argument", "(", "'pa...
Returns an argparse.ArgumentParser instance to parse the command line arguments for lk
[ "Returns", "an", "argparse", ".", "ArgumentParser", "instance", "to", "parse", "the", "command", "line", "arguments", "for", "lk" ]
train
https://github.com/elijahr/lk/blob/78f10909b1d8bb3ebe16223dd5438a1201b7db97/lk.py#L14-L66
elijahr/lk
lk.py
get_file_contents
def get_file_contents(path, binary=False): """ Return the contents of the text file at path. If it is a binary file,raise an IOError """ # if this isn't a text file, we should raise an IOError f = open(path, 'r') file_contents = f.read() f.close() if not binary and file_contents.find...
python
def get_file_contents(path, binary=False): """ Return the contents of the text file at path. If it is a binary file,raise an IOError """ # if this isn't a text file, we should raise an IOError f = open(path, 'r') file_contents = f.read() f.close() if not binary and file_contents.find...
[ "def", "get_file_contents", "(", "path", ",", "binary", "=", "False", ")", ":", "# if this isn't a text file, we should raise an IOError", "f", "=", "open", "(", "path", ",", "'r'", ")", "file_contents", "=", "f", ".", "read", "(", ")", "f", ".", "close", "(...
Return the contents of the text file at path. If it is a binary file,raise an IOError
[ "Return", "the", "contents", "of", "the", "text", "file", "at", "path", ".", "If", "it", "is", "a", "binary", "file", "raise", "an", "IOError" ]
train
https://github.com/elijahr/lk/blob/78f10909b1d8bb3ebe16223dd5438a1201b7db97/lk.py#L68-L79
elijahr/lk
lk.py
main
def main(): """ if lk.py is run as a script, this function will run """ parser = build_parser() args = parser.parse_args() flags = re.LOCALE if args.dot_all: flags |= re.DOTALL if args.ignorecase: flags |= re.IGNORECASE if args.unicode: flags |= re.UNICODE...
python
def main(): """ if lk.py is run as a script, this function will run """ parser = build_parser() args = parser.parse_args() flags = re.LOCALE if args.dot_all: flags |= re.DOTALL if args.ignorecase: flags |= re.IGNORECASE if args.unicode: flags |= re.UNICODE...
[ "def", "main", "(", ")", ":", "parser", "=", "build_parser", "(", ")", "args", "=", "parser", ".", "parse_args", "(", ")", "flags", "=", "re", ".", "LOCALE", "if", "args", ".", "dot_all", ":", "flags", "|=", "re", ".", "DOTALL", "if", "args", ".", ...
if lk.py is run as a script, this function will run
[ "if", "lk", ".", "py", "is", "run", "as", "a", "script", "this", "function", "will", "run" ]
train
https://github.com/elijahr/lk/blob/78f10909b1d8bb3ebe16223dd5438a1201b7db97/lk.py#L306-L349
elijahr/lk
lk.py
SearchManager.enqueue_directory
def enqueue_directory(self, directory): """ add a search of the directory to the queue """ exclude_path_regexes = self.exclude_path_regexes[:] if not self.search_hidden: exclude_path_regexes.append(self.hidden_file_regex) else: exclude_path_regex...
python
def enqueue_directory(self, directory): """ add a search of the directory to the queue """ exclude_path_regexes = self.exclude_path_regexes[:] if not self.search_hidden: exclude_path_regexes.append(self.hidden_file_regex) else: exclude_path_regex...
[ "def", "enqueue_directory", "(", "self", ",", "directory", ")", ":", "exclude_path_regexes", "=", "self", ".", "exclude_path_regexes", "[", ":", "]", "if", "not", "self", ".", "search_hidden", ":", "exclude_path_regexes", ".", "append", "(", "self", ".", "hidd...
add a search of the directory to the queue
[ "add", "a", "search", "of", "the", "directory", "to", "the", "queue" ]
train
https://github.com/elijahr/lk/blob/78f10909b1d8bb3ebe16223dd5438a1201b7db97/lk.py#L103-L158
elijahr/lk
lk.py
SearchManager.search_worker
def search_worker(self, regex, directory_path, names, binary=False, callback=None): """ build a DirectoryResult for the given regex, directory path, and file names """ try: result = DirectoryResult(directory_path) def find_matches(name): ...
python
def search_worker(self, regex, directory_path, names, binary=False, callback=None): """ build a DirectoryResult for the given regex, directory path, and file names """ try: result = DirectoryResult(directory_path) def find_matches(name): ...
[ "def", "search_worker", "(", "self", ",", "regex", ",", "directory_path", ",", "names", ",", "binary", "=", "False", ",", "callback", "=", "None", ")", ":", "try", ":", "result", "=", "DirectoryResult", "(", "directory_path", ")", "def", "find_matches", "(...
build a DirectoryResult for the given regex, directory path, and file names
[ "build", "a", "DirectoryResult", "for", "the", "given", "regex", "directory", "path", "and", "file", "names" ]
train
https://github.com/elijahr/lk/blob/78f10909b1d8bb3ebe16223dd5438a1201b7db97/lk.py#L160-L184
elijahr/lk
lk.py
ColorWriter.print_result
def print_result(self, directory_result): """ Print out the contents of the directory result, using ANSI color codes if supported """ for file_name, line_results_dict in directory_result.iter_line_results_items(): full_path = path.join(directory_result.directory_path,...
python
def print_result(self, directory_result): """ Print out the contents of the directory result, using ANSI color codes if supported """ for file_name, line_results_dict in directory_result.iter_line_results_items(): full_path = path.join(directory_result.directory_path,...
[ "def", "print_result", "(", "self", ",", "directory_result", ")", ":", "for", "file_name", ",", "line_results_dict", "in", "directory_result", ".", "iter_line_results_items", "(", ")", ":", "full_path", "=", "path", ".", "join", "(", "directory_result", ".", "di...
Print out the contents of the directory result, using ANSI color codes if supported
[ "Print", "out", "the", "contents", "of", "the", "directory", "result", "using", "ANSI", "color", "codes", "if", "supported" ]
train
https://github.com/elijahr/lk/blob/78f10909b1d8bb3ebe16223dd5438a1201b7db97/lk.py#L237-L256
ojake/django-tracked-model
tracked_model/models.py
RequestInfo.create_or_get_from_request
def create_or_get_from_request(request): """Returns `RequestInfo` instance. If object was already created during ``request`` it is returned. Otherwise new instance is created with details populated from ``request``. New instance is then cached for reuse on subsequential calls. ...
python
def create_or_get_from_request(request): """Returns `RequestInfo` instance. If object was already created during ``request`` it is returned. Otherwise new instance is created with details populated from ``request``. New instance is then cached for reuse on subsequential calls. ...
[ "def", "create_or_get_from_request", "(", "request", ")", ":", "saved", "=", "getattr", "(", "request", ",", "REQUEST_CACHE_FIELD", ",", "None", ")", "if", "isinstance", "(", "saved", ",", "RequestInfo", ")", ":", "return", "saved", "req", "=", "RequestInfo", ...
Returns `RequestInfo` instance. If object was already created during ``request`` it is returned. Otherwise new instance is created with details populated from ``request``. New instance is then cached for reuse on subsequential calls.
[ "Returns", "RequestInfo", "instance", "." ]
train
https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/models.py#L21-L42
ojake/django-tracked-model
tracked_model/models.py
History.materialize
def materialize(self): """Returns instance of ``TrackedModel`` created from current ``History`` snapshot. To rollback to current snapshot, simply call ``save`` on materialized object. """ if self.action_type == ActionType.DELETE: # On deletion current state is...
python
def materialize(self): """Returns instance of ``TrackedModel`` created from current ``History`` snapshot. To rollback to current snapshot, simply call ``save`` on materialized object. """ if self.action_type == ActionType.DELETE: # On deletion current state is...
[ "def", "materialize", "(", "self", ")", ":", "if", "self", ".", "action_type", "==", "ActionType", ".", "DELETE", ":", "# On deletion current state is dumped to change_log", "# so it's enough to just restore it to object", "data", "=", "serializer", ".", "from_json", "(",...
Returns instance of ``TrackedModel`` created from current ``History`` snapshot. To rollback to current snapshot, simply call ``save`` on materialized object.
[ "Returns", "instance", "of", "TrackedModel", "created", "from", "current", "History", "snapshot", ".", "To", "rollback", "to", "current", "snapshot", "simply", "call", "save", "on", "materialized", "object", "." ]
train
https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/models.py#L79-L108
xtrementl/focus
focus/plugin/registration.py
_is_plugin_disabled
def _is_plugin_disabled(plugin): """ Determines if provided plugin is disabled from running for the active task. """ item = _registered.get(plugin.name) if not item: return False _, props = item return bool(props.get('disabled'))
python
def _is_plugin_disabled(plugin): """ Determines if provided plugin is disabled from running for the active task. """ item = _registered.get(plugin.name) if not item: return False _, props = item return bool(props.get('disabled'))
[ "def", "_is_plugin_disabled", "(", "plugin", ")", ":", "item", "=", "_registered", ".", "get", "(", "plugin", ".", "name", ")", "if", "not", "item", ":", "return", "False", "_", ",", "props", "=", "item", "return", "bool", "(", "props", ".", "get", "...
Determines if provided plugin is disabled from running for the active task.
[ "Determines", "if", "provided", "plugin", "is", "disabled", "from", "running", "for", "the", "active", "task", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L25-L34
xtrementl/focus
focus/plugin/registration.py
_setup_events
def _setup_events(plugin): """ Handles setup or teardown of event hook registration for the provided plugin. `plugin` ``Plugin`` class. """ events = plugin.events if events and isinstance(events, (list, tuple)): for event in [e for e in events if e in _EVENT_VA...
python
def _setup_events(plugin): """ Handles setup or teardown of event hook registration for the provided plugin. `plugin` ``Plugin`` class. """ events = plugin.events if events and isinstance(events, (list, tuple)): for event in [e for e in events if e in _EVENT_VA...
[ "def", "_setup_events", "(", "plugin", ")", ":", "events", "=", "plugin", ".", "events", "if", "events", "and", "isinstance", "(", "events", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "event", "in", "[", "e", "for", "e", "in", "events", ...
Handles setup or teardown of event hook registration for the provided plugin. `plugin` ``Plugin`` class.
[ "Handles", "setup", "or", "teardown", "of", "event", "hook", "registration", "for", "the", "provided", "plugin", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L49-L61
xtrementl/focus
focus/plugin/registration.py
_setup_options
def _setup_options(plugin): """ Handles setup or teardown of option hook registration for the provided plugin. `plugin` ``Plugin`` class. """ options = plugin.options if options and isinstance(options, (list, tuple)): for props in options: if isinst...
python
def _setup_options(plugin): """ Handles setup or teardown of option hook registration for the provided plugin. `plugin` ``Plugin`` class. """ options = plugin.options if options and isinstance(options, (list, tuple)): for props in options: if isinst...
[ "def", "_setup_options", "(", "plugin", ")", ":", "options", "=", "plugin", ".", "options", "if", "options", "and", "isinstance", "(", "options", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "props", "in", "options", ":", "if", "isinstance", "...
Handles setup or teardown of option hook registration for the provided plugin. `plugin` ``Plugin`` class.
[ "Handles", "setup", "or", "teardown", "of", "option", "hook", "registration", "for", "the", "provided", "plugin", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L64-L94
xtrementl/focus
focus/plugin/registration.py
register
def register(hook_type, key, plugin_cls, properties=None): """ Handles registration of a plugin hook in the global registries. `hook_type` Type of hook to register ('event', 'command', or 'option') `key` Unique key associated with `hook_type` and `plugin`. Value ...
python
def register(hook_type, key, plugin_cls, properties=None): """ Handles registration of a plugin hook in the global registries. `hook_type` Type of hook to register ('event', 'command', or 'option') `key` Unique key associated with `hook_type` and `plugin`. Value ...
[ "def", "register", "(", "hook_type", ",", "key", ",", "plugin_cls", ",", "properties", "=", "None", ")", ":", "def", "fetch_plugin", "(", ")", ":", "\"\"\" This function is used as a lazy evaluation of fetching the\n specified plugin. This is required, because at the...
Handles registration of a plugin hook in the global registries. `hook_type` Type of hook to register ('event', 'command', or 'option') `key` Unique key associated with `hook_type` and `plugin`. Value depends on type:: 'command' - Name of the command ...
[ "Handles", "registration", "of", "a", "plugin", "hook", "in", "the", "global", "registries", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L106-L167
xtrementl/focus
focus/plugin/registration.py
setup_sudo_access
def setup_sudo_access(plugin): """ Injects a `run_root` method into the provided plugin instance that forks a shell command using sudo. Used for command plugin needs. `plugin` ``Plugin`` instance. """ def run_root(self, command): """ Executes a shell command as root...
python
def setup_sudo_access(plugin): """ Injects a `run_root` method into the provided plugin instance that forks a shell command using sudo. Used for command plugin needs. `plugin` ``Plugin`` instance. """ def run_root(self, command): """ Executes a shell command as root...
[ "def", "setup_sudo_access", "(", "plugin", ")", ":", "def", "run_root", "(", "self", ",", "command", ")", ":", "\"\"\" Executes a shell command as root.\n\n `command`\n Shell command string.\n\n Returns boolean.\n \"\"\"", "try", ":", ...
Injects a `run_root` method into the provided plugin instance that forks a shell command using sudo. Used for command plugin needs. `plugin` ``Plugin`` instance.
[ "Injects", "a", "run_root", "method", "into", "the", "provided", "plugin", "instance", "that", "forks", "a", "shell", "command", "using", "sudo", ".", "Used", "for", "command", "plugin", "needs", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L181-L203
xtrementl/focus
focus/plugin/registration.py
get_registered
def get_registered(option_hooks=None, event_hooks=None, command_hooks=None, root_access=None, task_active=True): """ Returns a generator of registered plugins matching filters. `option_hooks` Boolean to include or exclude plugins using option hooks. ...
python
def get_registered(option_hooks=None, event_hooks=None, command_hooks=None, root_access=None, task_active=True): """ Returns a generator of registered plugins matching filters. `option_hooks` Boolean to include or exclude plugins using option hooks. ...
[ "def", "get_registered", "(", "option_hooks", "=", "None", ",", "event_hooks", "=", "None", ",", "command_hooks", "=", "None", ",", "root_access", "=", "None", ",", "task_active", "=", "True", ")", ":", "plugins", "=", "[", "]", "for", "_", ",", "item", ...
Returns a generator of registered plugins matching filters. `option_hooks` Boolean to include or exclude plugins using option hooks. `event_hooks` Boolean to include or exclude task event plugins. `command_hooks` Boolean to include or exclude command plugins....
[ "Returns", "a", "generator", "of", "registered", "plugins", "matching", "filters", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L206-L256
xtrementl/focus
focus/plugin/registration.py
get_command_hook
def get_command_hook(command, task_active=True): """ Gets registered command ``Plugin`` instance for the provided command. `command` Command string registered to a plugin. `task_active` Set to ``False`` to indicate no active tasks. Returns ``Plugin`` instanc...
python
def get_command_hook(command, task_active=True): """ Gets registered command ``Plugin`` instance for the provided command. `command` Command string registered to a plugin. `task_active` Set to ``False`` to indicate no active tasks. Returns ``Plugin`` instanc...
[ "def", "get_command_hook", "(", "command", ",", "task_active", "=", "True", ")", ":", "plugin_obj", "=", "_command_hooks", ".", "get", "(", "command", ")", "if", "plugin_obj", ":", "if", "task_active", "or", "(", "not", "plugin_obj", ".", "options", "and", ...
Gets registered command ``Plugin`` instance for the provided command. `command` Command string registered to a plugin. `task_active` Set to ``False`` to indicate no active tasks. Returns ``Plugin`` instance or ``None``.
[ "Gets", "registered", "command", "Plugin", "instance", "for", "the", "provided", "command", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L259-L280
xtrementl/focus
focus/plugin/registration.py
run_event_hooks
def run_event_hooks(event, task): """ Executes registered task event plugins for the provided event and task. `event` Name of the event to trigger for the plugin: ('task_start', 'task_run', 'task_end') `task` ``Task`` instance. """ # get chain of...
python
def run_event_hooks(event, task): """ Executes registered task event plugins for the provided event and task. `event` Name of the event to trigger for the plugin: ('task_start', 'task_run', 'task_end') `task` ``Task`` instance. """ # get chain of...
[ "def", "run_event_hooks", "(", "event", ",", "task", ")", ":", "# get chain of classes registered for this event", "call_chain", "=", "_event_hooks", ".", "get", "(", "event", ")", "if", "call_chain", ":", "# lookup the associated class method for this event", "event_method...
Executes registered task event plugins for the provided event and task. `event` Name of the event to trigger for the plugin: ('task_start', 'task_run', 'task_end') `task` ``Task`` instance.
[ "Executes", "registered", "task", "event", "plugins", "for", "the", "provided", "event", "and", "task", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L283-L314
xtrementl/focus
focus/plugin/registration.py
run_option_hooks
def run_option_hooks(parser, disable_missing=True): """ Executes registered plugins using option hooks for the provided ``SettingParser`` instance. `parser` ``SettingParser`` instance. `disable_missing` Set to ``True`` to disable any plugins using option hooks whose ...
python
def run_option_hooks(parser, disable_missing=True): """ Executes registered plugins using option hooks for the provided ``SettingParser`` instance. `parser` ``SettingParser`` instance. `disable_missing` Set to ``True`` to disable any plugins using option hooks whose ...
[ "def", "run_option_hooks", "(", "parser", ",", "disable_missing", "=", "True", ")", ":", "plugins", "=", "[", "]", "state", "=", "{", "}", "# state information", "def", "_raise_error", "(", "msg", ",", "block", ")", ":", "\"\"\" Raises ``InvalidTaskConfig`` exce...
Executes registered plugins using option hooks for the provided ``SettingParser`` instance. `parser` ``SettingParser`` instance. `disable_missing` Set to ``True`` to disable any plugins using option hooks whose defined option hooks are not available in the da...
[ "Executes", "registered", "plugins", "using", "option", "hooks", "for", "the", "provided", "SettingParser", "instance", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/registration.py#L317-L395
shoppimon/figcan
figcan/figcan.py
_recursive_merge
def _recursive_merge(dct, merge_dct, raise_on_missing): # type: (Dict[str, Any], Dict[str, Any], bool) -> Dict[str, Any] """Recursive dict merge This modifies `dct` in place. Use `copy.deepcopy` if this behavior is not desired. """ for k, v in merge_dct.items(): if k in dct: if ...
python
def _recursive_merge(dct, merge_dct, raise_on_missing): # type: (Dict[str, Any], Dict[str, Any], bool) -> Dict[str, Any] """Recursive dict merge This modifies `dct` in place. Use `copy.deepcopy` if this behavior is not desired. """ for k, v in merge_dct.items(): if k in dct: if ...
[ "def", "_recursive_merge", "(", "dct", ",", "merge_dct", ",", "raise_on_missing", ")", ":", "# type: (Dict[str, Any], Dict[str, Any], bool) -> Dict[str, Any]", "for", "k", ",", "v", "in", "merge_dct", ".", "items", "(", ")", ":", "if", "k", "in", "dct", ":", "if...
Recursive dict merge This modifies `dct` in place. Use `copy.deepcopy` if this behavior is not desired.
[ "Recursive", "dict", "merge" ]
train
https://github.com/shoppimon/figcan/blob/bdfa59ceed33277c060fc009fbf44c41b9852681/figcan/figcan.py#L109-L130