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
zkbt/the-friendly-stars
thefriendlystars/talker.py
Talker.input
def input(self, string='', level=0, prompt='(please respond) '): '''If verbose=True and terse=False, this will print to terminal. Otherwise, it won't.''' self.report(string, level) return input("{0}".format(self._prefix + prompt))
python
def input(self, string='', level=0, prompt='(please respond) '): '''If verbose=True and terse=False, this will print to terminal. Otherwise, it won't.''' self.report(string, level) return input("{0}".format(self._prefix + prompt))
[ "def", "input", "(", "self", ",", "string", "=", "''", ",", "level", "=", "0", ",", "prompt", "=", "'(please respond) '", ")", ":", "self", ".", "report", "(", "string", ",", "level", ")", "return", "input", "(", "\"{0}\"", ".", "format", "(", "self"...
If verbose=True and terse=False, this will print to terminal. Otherwise, it won't.
[ "If", "verbose", "=", "True", "and", "terse", "=", "False", "this", "will", "print", "to", "terminal", ".", "Otherwise", "it", "won", "t", "." ]
train
https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/talker.py#L38-L41
zkbt/the-friendly-stars
thefriendlystars/talker.py
Talker.report
def report(self, string='', level=0, prelude='', progress=False, abbreviate=True): '''If verbose=True, this will print to terminal. Otherwise, it won't.''' if self._mute == False: self._prefix = prelude + '{spacing}[{name}] '.format(name = self.nametag, spacing = ' '*level) self....
python
def report(self, string='', level=0, prelude='', progress=False, abbreviate=True): '''If verbose=True, this will print to terminal. Otherwise, it won't.''' if self._mute == False: self._prefix = prelude + '{spacing}[{name}] '.format(name = self.nametag, spacing = ' '*level) self....
[ "def", "report", "(", "self", ",", "string", "=", "''", ",", "level", "=", "0", ",", "prelude", "=", "''", ",", "progress", "=", "False", ",", "abbreviate", "=", "True", ")", ":", "if", "self", ".", "_mute", "==", "False", ":", "self", ".", "_pre...
If verbose=True, this will print to terminal. Otherwise, it won't.
[ "If", "verbose", "=", "True", "this", "will", "print", "to", "terminal", ".", "Otherwise", "it", "won", "t", "." ]
train
https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/talker.py#L43-L58
zkbt/the-friendly-stars
thefriendlystars/talker.py
Talker.summarize
def summarize(self): '''Print a summary of the contents of this object.''' self.speak('Here is a brief summary of {}.'.format(self.nametag)) s = '\n'+pprint.pformat(self.__dict__) print(s.replace('\n', '\n'+' '*(len(self._prefix)+1)) + '\n')
python
def summarize(self): '''Print a summary of the contents of this object.''' self.speak('Here is a brief summary of {}.'.format(self.nametag)) s = '\n'+pprint.pformat(self.__dict__) print(s.replace('\n', '\n'+' '*(len(self._prefix)+1)) + '\n')
[ "def", "summarize", "(", "self", ")", ":", "self", ".", "speak", "(", "'Here is a brief summary of {}.'", ".", "format", "(", "self", ".", "nametag", ")", ")", "s", "=", "'\\n'", "+", "pprint", ".", "pformat", "(", "self", ".", "__dict__", ")", "print", ...
Print a summary of the contents of this object.
[ "Print", "a", "summary", "of", "the", "contents", "of", "this", "object", "." ]
train
https://github.com/zkbt/the-friendly-stars/blob/50d3f979e79e63c66629065c75595696dc79802e/thefriendlystars/talker.py#L62-L67
roboogle/gtkmvc3
gtkmvco/examples/converter/main1.py
setup_path
def setup_path(): """Sets up the python include paths to include src""" import os.path; import sys if sys.argv[0]: top_dir = os.path.dirname(os.path.abspath(sys.argv[0])) sys.path = [os.path.join(top_dir, "src")] + sys.path pass return
python
def setup_path(): """Sets up the python include paths to include src""" import os.path; import sys if sys.argv[0]: top_dir = os.path.dirname(os.path.abspath(sys.argv[0])) sys.path = [os.path.join(top_dir, "src")] + sys.path pass return
[ "def", "setup_path", "(", ")", ":", "import", "os", ".", "path", "import", "sys", "if", "sys", ".", "argv", "[", "0", "]", ":", "top_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "sys", ".", "argv", ...
Sets up the python include paths to include src
[ "Sets", "up", "the", "python", "include", "paths", "to", "include", "src" ]
train
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/examples/converter/main1.py#L26-L34
Brazelton-Lab/bio_utils
bio_utils/verifiers/verify_entries.py
entry_verifier
def entry_verifier(entries, regex, delimiter): """Checks each entry against regex for validity, If an entry does not match the regex, the entry and regex are broken down by the delimiter and each segment is analyzed to produce an accurate error message. Args: entries (list): List of entrie...
python
def entry_verifier(entries, regex, delimiter): """Checks each entry against regex for validity, If an entry does not match the regex, the entry and regex are broken down by the delimiter and each segment is analyzed to produce an accurate error message. Args: entries (list): List of entrie...
[ "def", "entry_verifier", "(", "entries", ",", "regex", ",", "delimiter", ")", ":", "cregex", "=", "re", ".", "compile", "(", "regex", ")", "# Compiling saves time if many entries given", "# Encode raw delimiter in order to split a bad entry", "python_version", "=", "int",...
Checks each entry against regex for validity, If an entry does not match the regex, the entry and regex are broken down by the delimiter and each segment is analyzed to produce an accurate error message. Args: entries (list): List of entries to check with regex regex (str): Regular ex...
[ "Checks", "each", "entry", "against", "regex", "for", "validity" ]
train
https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/verifiers/verify_entries.py#L78-L130
mapmyfitness/jtime
jtime/connection.py
jira_connection
def jira_connection(config): """ Gets a JIRA API connection. If a connection has already been created the existing connection will be returned. """ global _jira_connection if _jira_connection: return _jira_connection else: jira_options = {'server': config.get('jira').get('ur...
python
def jira_connection(config): """ Gets a JIRA API connection. If a connection has already been created the existing connection will be returned. """ global _jira_connection if _jira_connection: return _jira_connection else: jira_options = {'server': config.get('jira').get('ur...
[ "def", "jira_connection", "(", "config", ")", ":", "global", "_jira_connection", "if", "_jira_connection", ":", "return", "_jira_connection", "else", ":", "jira_options", "=", "{", "'server'", ":", "config", ".", "get", "(", "'jira'", ")", ".", "get", "(", "...
Gets a JIRA API connection. If a connection has already been created the existing connection will be returned.
[ "Gets", "a", "JIRA", "API", "connection", ".", "If", "a", "connection", "has", "already", "been", "created", "the", "existing", "connection", "will", "be", "returned", "." ]
train
https://github.com/mapmyfitness/jtime/blob/402fb6b40ac7a78c23fd02fac50c6dbe49e5ebfd/jtime/connection.py#L12-L47
rbarrois/django-batchform
batchform/views.py
BaseUploadView.form_upload_valid
def form_upload_valid(self, form): """Handle a valid upload form.""" self.current_step = self.STEP_LINES lines = form.cleaned_data['file'] initial_lines = [dict(zip(self.get_columns(), line)) for line in lines] inner_form = self.get_form(self.get_form_class(), data=N...
python
def form_upload_valid(self, form): """Handle a valid upload form.""" self.current_step = self.STEP_LINES lines = form.cleaned_data['file'] initial_lines = [dict(zip(self.get_columns(), line)) for line in lines] inner_form = self.get_form(self.get_form_class(), data=N...
[ "def", "form_upload_valid", "(", "self", ",", "form", ")", ":", "self", ".", "current_step", "=", "self", ".", "STEP_LINES", "lines", "=", "form", ".", "cleaned_data", "[", "'file'", "]", "initial_lines", "=", "[", "dict", "(", "zip", "(", "self", ".", ...
Handle a valid upload form.
[ "Handle", "a", "valid", "upload", "form", "." ]
train
https://github.com/rbarrois/django-batchform/blob/f6b659a6790750285af248ccd1d4d178ecbad129/batchform/views.py#L99-L110
rbarrois/django-batchform
batchform/views.py
BaseUploadView.form_lines_valid
def form_lines_valid(self, form): """Handle a valid LineFormSet.""" handled = 0 for inner_form in form: if not inner_form.cleaned_data.get(formsets.DELETION_FIELD_NAME): handled += 1 self.handle_inner_form(inner_form) self.log_and_notify_lines...
python
def form_lines_valid(self, form): """Handle a valid LineFormSet.""" handled = 0 for inner_form in form: if not inner_form.cleaned_data.get(formsets.DELETION_FIELD_NAME): handled += 1 self.handle_inner_form(inner_form) self.log_and_notify_lines...
[ "def", "form_lines_valid", "(", "self", ",", "form", ")", ":", "handled", "=", "0", "for", "inner_form", "in", "form", ":", "if", "not", "inner_form", ".", "cleaned_data", ".", "get", "(", "formsets", ".", "DELETION_FIELD_NAME", ")", ":", "handled", "+=", ...
Handle a valid LineFormSet.
[ "Handle", "a", "valid", "LineFormSet", "." ]
train
https://github.com/rbarrois/django-batchform/blob/f6b659a6790750285af248ccd1d4d178ecbad129/batchform/views.py#L119-L128
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
rank_environment_and_phenotypes
def rank_environment_and_phenotypes(environment, phenotypes, k=15): """ Clusters sets of resources/tasks using a weighted hamming distance such that you can have few enough values to give each group of similar things a different color. This function is designed for cases when you want to color both ...
python
def rank_environment_and_phenotypes(environment, phenotypes, k=15): """ Clusters sets of resources/tasks using a weighted hamming distance such that you can have few enough values to give each group of similar things a different color. This function is designed for cases when you want to color both ...
[ "def", "rank_environment_and_phenotypes", "(", "environment", ",", "phenotypes", ",", "k", "=", "15", ")", ":", "environment", "=", "convert_world_to_phenotype", "(", "environment", ")", "ranks", "=", "get_ranks_for_environment_and_phenotypes", "(", "environment", ",", ...
Clusters sets of resources/tasks using a weighted hamming distance such that you can have few enough values to give each group of similar things a different color. This function is designed for cases when you want to color both an environment and a set of phenotypes such that the colors corespond to eac...
[ "Clusters", "sets", "of", "resources", "/", "tasks", "using", "a", "weighted", "hamming", "distance", "such", "that", "you", "can", "have", "few", "enough", "values", "to", "give", "each", "group", "of", "similar", "things", "a", "different", "color", ".", ...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L6-L32
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
do_clustering
def do_clustering(types, max_clust): """ Helper method for clustering that takes a list of all of the things being clustered (which are assumed to be binary numbers represented as strings), and an int representing the maximum number of clusters that are allowed. Returns: A dictionary mapping cluste...
python
def do_clustering(types, max_clust): """ Helper method for clustering that takes a list of all of the things being clustered (which are assumed to be binary numbers represented as strings), and an int representing the maximum number of clusters that are allowed. Returns: A dictionary mapping cluste...
[ "def", "do_clustering", "(", "types", ",", "max_clust", ")", ":", "# Fill in leading zeros to make all numbers same length.", "ls", "=", "[", "list", "(", "t", "[", "t", ".", "find", "(", "\"b\"", ")", "+", "1", ":", "]", ")", "for", "t", "in", "types", ...
Helper method for clustering that takes a list of all of the things being clustered (which are assumed to be binary numbers represented as strings), and an int representing the maximum number of clusters that are allowed. Returns: A dictionary mapping cluster ids to lists of numbers that are part of th...
[ "Helper", "method", "for", "clustering", "that", "takes", "a", "list", "of", "all", "of", "the", "things", "being", "clustered", "(", "which", "are", "assumed", "to", "be", "binary", "numbers", "represented", "as", "strings", ")", "and", "an", "int", "repr...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L35-L58
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
rank_clusters
def rank_clusters(cluster_dict): """ Helper function for clustering that takes a dictionary mapping cluster ids to lists of the binary strings that are part of that cluster and returns a dictionary mapping cluster ids to integers representing their "rank". Ranks provide an ordering for the clusters ...
python
def rank_clusters(cluster_dict): """ Helper function for clustering that takes a dictionary mapping cluster ids to lists of the binary strings that are part of that cluster and returns a dictionary mapping cluster ids to integers representing their "rank". Ranks provide an ordering for the clusters ...
[ "def", "rank_clusters", "(", "cluster_dict", ")", ":", "# Figure out the relative rank of each cluster", "cluster_ranks", "=", "dict", ".", "fromkeys", "(", "cluster_dict", ".", "keys", "(", ")", ")", "for", "key", "in", "cluster_dict", ":", "cluster_ranks", "[", ...
Helper function for clustering that takes a dictionary mapping cluster ids to lists of the binary strings that are part of that cluster and returns a dictionary mapping cluster ids to integers representing their "rank". Ranks provide an ordering for the clusters such that each cluster has its own rank, ...
[ "Helper", "function", "for", "clustering", "that", "takes", "a", "dictionary", "mapping", "cluster", "ids", "to", "lists", "of", "the", "binary", "strings", "that", "are", "part", "of", "that", "cluster", "and", "returns", "a", "dictionary", "mapping", "cluste...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L61-L80
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
get_ranks_for_environment_and_phenotypes
def get_ranks_for_environment_and_phenotypes(environment, phenotypes, k=15): """ Takes an EnvironmentFile and a 2d array represemtimg phenotypes at each location. Optionally also takes an integer indicating the maximum number of clusters allowed to be created (default 15). Environment is expected t...
python
def get_ranks_for_environment_and_phenotypes(environment, phenotypes, k=15): """ Takes an EnvironmentFile and a 2d array represemtimg phenotypes at each location. Optionally also takes an integer indicating the maximum number of clusters allowed to be created (default 15). Environment is expected t...
[ "def", "get_ranks_for_environment_and_phenotypes", "(", "environment", ",", "phenotypes", ",", "k", "=", "15", ")", ":", "# Create list of all niches and all phenotypes, in phenotype format", "niches", "=", "flatten_array", "(", "environment", ")", "phenotypes", "=", "flatt...
Takes an EnvironmentFile and a 2d array represemtimg phenotypes at each location. Optionally also takes an integer indicating the maximum number of clusters allowed to be created (default 15). Environment is expected to already have been converted to binary numbers (generally because this is being call...
[ "Takes", "an", "EnvironmentFile", "and", "a", "2d", "array", "represemtimg", "phenotypes", "at", "each", "location", ".", "Optionally", "also", "takes", "an", "integer", "indicating", "the", "maximum", "number", "of", "clusters", "allowed", "to", "be", "created"...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L83-L111
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
assign_ranks_by_cluster
def assign_ranks_by_cluster(grid, n, ranks=None): """ Takes a 2D array representing phenotypes or resource sets across the world, and integer rpresenting the maximum number of clusters allowed, and optionally a dictionary indicating the rank of the cluster of each phenotype/resource set. If this dic...
python
def assign_ranks_by_cluster(grid, n, ranks=None): """ Takes a 2D array representing phenotypes or resource sets across the world, and integer rpresenting the maximum number of clusters allowed, and optionally a dictionary indicating the rank of the cluster of each phenotype/resource set. If this dic...
[ "def", "assign_ranks_by_cluster", "(", "grid", ",", "n", ",", "ranks", "=", "None", ")", ":", "if", "ranks", "is", "None", ":", "ranks", "=", "generate_ranks", "(", "grid", ",", "n", ")", "return", "assign_ranks_to_grid", "(", "grid", ",", "ranks", ")", ...
Takes a 2D array representing phenotypes or resource sets across the world, and integer rpresenting the maximum number of clusters allowed, and optionally a dictionary indicating the rank of the cluster of each phenotype/resource set. If this dictionary is not provided, one will be generated. Retur...
[ "Takes", "a", "2D", "array", "representing", "phenotypes", "or", "resource", "sets", "across", "the", "world", "and", "integer", "rpresenting", "the", "maximum", "number", "of", "clusters", "allowed", "and", "optionally", "a", "dictionary", "indicating", "the", ...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L114-L128
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
generate_ranks
def generate_ranks(grid, n): """ Takes a grid of phenotypes or resource sets representing as strings representing binary numbers, and an integer indicating the maximum number of clusters to generated. Clusters the data in grid into a maximum of n groups, ranks each group by the complexity and l...
python
def generate_ranks(grid, n): """ Takes a grid of phenotypes or resource sets representing as strings representing binary numbers, and an integer indicating the maximum number of clusters to generated. Clusters the data in grid into a maximum of n groups, ranks each group by the complexity and l...
[ "def", "generate_ranks", "(", "grid", ",", "n", ")", ":", "phenotypes", "=", "deepcopy", "(", "grid", ")", "if", "type", "(", "phenotypes", ")", "is", "list", "and", "type", "(", "phenotypes", "[", "0", "]", ")", "is", "list", ":", "phenotypes", "=",...
Takes a grid of phenotypes or resource sets representing as strings representing binary numbers, and an integer indicating the maximum number of clusters to generated. Clusters the data in grid into a maximum of n groups, ranks each group by the complexity and length of its "average" member, and return...
[ "Takes", "a", "grid", "of", "phenotypes", "or", "resource", "sets", "representing", "as", "strings", "representing", "binary", "numbers", "and", "an", "integer", "indicating", "the", "maximum", "number", "of", "clusters", "to", "generated", "." ]
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L131-L153
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
assign_ranks_to_grid
def assign_ranks_to_grid(grid, ranks): """ Takes a 2D array of binary numbers represented as strings and a dictionary mapping binary strings to integers representing the rank of the cluster they belong to, and returns a grid in which each binary number has been replaced with the rank of its cluster....
python
def assign_ranks_to_grid(grid, ranks): """ Takes a 2D array of binary numbers represented as strings and a dictionary mapping binary strings to integers representing the rank of the cluster they belong to, and returns a grid in which each binary number has been replaced with the rank of its cluster....
[ "def", "assign_ranks_to_grid", "(", "grid", ",", "ranks", ")", ":", "assignments", "=", "deepcopy", "(", "grid", ")", "ranks", "[", "\"0b0\"", "]", "=", "0", "ranks", "[", "\"-0b1\"", "]", "=", "-", "1", "for", "i", "in", "range", "(", "len", "(", ...
Takes a 2D array of binary numbers represented as strings and a dictionary mapping binary strings to integers representing the rank of the cluster they belong to, and returns a grid in which each binary number has been replaced with the rank of its cluster.
[ "Takes", "a", "2D", "array", "of", "binary", "numbers", "represented", "as", "strings", "and", "a", "dictionary", "mapping", "binary", "strings", "to", "integers", "representing", "the", "rank", "of", "the", "cluster", "they", "belong", "to", "and", "returns",...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L156-L175
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
cluster_types
def cluster_types(types, max_clust=12): """ Generates a dictionary mapping each binary number in types to an integer from 0 to max_clust. Hierarchical clustering is used to determine which which binary numbers should map to the same integer. """ if len(types) < max_clust: max_clust = le...
python
def cluster_types(types, max_clust=12): """ Generates a dictionary mapping each binary number in types to an integer from 0 to max_clust. Hierarchical clustering is used to determine which which binary numbers should map to the same integer. """ if len(types) < max_clust: max_clust = le...
[ "def", "cluster_types", "(", "types", ",", "max_clust", "=", "12", ")", ":", "if", "len", "(", "types", ")", "<", "max_clust", ":", "max_clust", "=", "len", "(", "types", ")", "# Do actual clustering", "cluster_dict", "=", "do_clustering", "(", "types", ",...
Generates a dictionary mapping each binary number in types to an integer from 0 to max_clust. Hierarchical clustering is used to determine which which binary numbers should map to the same integer.
[ "Generates", "a", "dictionary", "mapping", "each", "binary", "number", "in", "types", "to", "an", "integer", "from", "0", "to", "max_clust", ".", "Hierarchical", "clustering", "is", "used", "to", "determine", "which", "which", "binary", "numbers", "should", "m...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L178-L198
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
rank_types
def rank_types(types): """ Takes a list of binary numbers and returns a dictionary mapping each binary number to an integer indicating it's rank within the list. This is basically the better alternative to cluster_types, that works in that perfect world where we have few enough types to represent e...
python
def rank_types(types): """ Takes a list of binary numbers and returns a dictionary mapping each binary number to an integer indicating it's rank within the list. This is basically the better alternative to cluster_types, that works in that perfect world where we have few enough types to represent e...
[ "def", "rank_types", "(", "types", ")", ":", "include_null", "=", "'0b0'", "in", "types", "sorted_types", "=", "deepcopy", "(", "types", ")", "for", "i", "in", "range", "(", "len", "(", "sorted_types", ")", ")", ":", "sorted_types", "[", "i", "]", "=",...
Takes a list of binary numbers and returns a dictionary mapping each binary number to an integer indicating it's rank within the list. This is basically the better alternative to cluster_types, that works in that perfect world where we have few enough types to represent each as its own color.
[ "Takes", "a", "list", "of", "binary", "numbers", "and", "returns", "a", "dictionary", "mapping", "each", "binary", "number", "to", "an", "integer", "indicating", "it", "s", "rank", "within", "the", "list", "." ]
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L201-L220
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
make_count_grid
def make_count_grid(data): """ Takes a 2 or 3d grid of strings representing binary numbers. Returns a grid of the same dimensions in which each binary number has been replaced by an integer indicating the number of ones that were in that number. """ data = deepcopy(data) for i in range...
python
def make_count_grid(data): """ Takes a 2 or 3d grid of strings representing binary numbers. Returns a grid of the same dimensions in which each binary number has been replaced by an integer indicating the number of ones that were in that number. """ data = deepcopy(data) for i in range...
[ "def", "make_count_grid", "(", "data", ")", ":", "data", "=", "deepcopy", "(", "data", ")", "for", "i", "in", "range", "(", "len", "(", "data", ")", ")", ":", "for", "j", "in", "range", "(", "len", "(", "data", "[", "i", "]", ")", ")", ":", "...
Takes a 2 or 3d grid of strings representing binary numbers. Returns a grid of the same dimensions in which each binary number has been replaced by an integer indicating the number of ones that were in that number.
[ "Takes", "a", "2", "or", "3d", "grid", "of", "strings", "representing", "binary", "numbers", "." ]
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L223-L248
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
make_optimal_phenotype_grid
def make_optimal_phenotype_grid(environment, phenotypes): """ Takes an EnvironmentFile object and a 2d array of phenotypes and returns a 2d array in which each location contains an index representing the distance between the phenotype in that location and the optimal phenotype for that location. ...
python
def make_optimal_phenotype_grid(environment, phenotypes): """ Takes an EnvironmentFile object and a 2d array of phenotypes and returns a 2d array in which each location contains an index representing the distance between the phenotype in that location and the optimal phenotype for that location. ...
[ "def", "make_optimal_phenotype_grid", "(", "environment", ",", "phenotypes", ")", ":", "world_size", "=", "environment", ".", "size", "phenotypes", "=", "deepcopy", "(", "phenotypes", ")", "for", "i", "in", "range", "(", "world_size", "[", "1", "]", ")", ":"...
Takes an EnvironmentFile object and a 2d array of phenotypes and returns a 2d array in which each location contains an index representing the distance between the phenotype in that location and the optimal phenotype for that location. This is acheived by using the task list in the EnvironmentFile to co...
[ "Takes", "an", "EnvironmentFile", "object", "and", "a", "2d", "array", "of", "phenotypes", "and", "returns", "a", "2d", "array", "in", "which", "each", "location", "contains", "an", "index", "representing", "the", "distance", "between", "the", "phenotype", "in...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L251-L277
emilydolson/avida-spatial-tools
avidaspatial/transform_data.py
task_percentages
def task_percentages(data, n_tasks=9): """ Takes a 3D array of strings representing binary numbers and calculates the percentage of organisms in each cell (across multiple files) that were doing a given task. Returns an m x n x n_tasks array indicating the percentages of organisms at each locat...
python
def task_percentages(data, n_tasks=9): """ Takes a 3D array of strings representing binary numbers and calculates the percentage of organisms in each cell (across multiple files) that were doing a given task. Returns an m x n x n_tasks array indicating the percentages of organisms at each locat...
[ "def", "task_percentages", "(", "data", ",", "n_tasks", "=", "9", ")", ":", "pdata", "=", "deepcopy", "(", "data", ")", "for", "i", "in", "range", "(", "len", "(", "data", ")", ")", ":", "for", "j", "in", "range", "(", "len", "(", "data", "[", ...
Takes a 3D array of strings representing binary numbers and calculates the percentage of organisms in each cell (across multiple files) that were doing a given task. Returns an m x n x n_tasks array indicating the percentages of organisms at each location (across the 3rd dimension) that were doing each...
[ "Takes", "a", "3D", "array", "of", "strings", "representing", "binary", "numbers", "and", "calculates", "the", "percentage", "of", "organisms", "in", "each", "cell", "(", "across", "multiple", "files", ")", "that", "were", "doing", "a", "given", "task", "." ...
train
https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L280-L301
Adman/python-cpsk-api
cpsk/__init__.py
get_routes
def get_routes(departure, dest, vehicle='vlakbus', time='', date=''): """Return list of available routes from departure city to destination""" def _get_leaf_element(table, path): """Returns leaf element's text in given path""" res = table.xpath(path + '/*[not(*)]') if res: r...
python
def get_routes(departure, dest, vehicle='vlakbus', time='', date=''): """Return list of available routes from departure city to destination""" def _get_leaf_element(table, path): """Returns leaf element's text in given path""" res = table.xpath(path + '/*[not(*)]') if res: r...
[ "def", "get_routes", "(", "departure", ",", "dest", ",", "vehicle", "=", "'vlakbus'", ",", "time", "=", "''", ",", "date", "=", "''", ")", ":", "def", "_get_leaf_element", "(", "table", ",", "path", ")", ":", "\"\"\"Returns leaf element's text in given path\"\...
Return list of available routes from departure city to destination
[ "Return", "list", "of", "available", "routes", "from", "departure", "city", "to", "destination" ]
train
https://github.com/Adman/python-cpsk-api/blob/d717a315f619a2ab39a8d3e40c328e2b1452f4a9/cpsk/__init__.py#L53-L137
nrnb/target-interaction-finder
targetinteractionfinder/__init__.py
main
def main(): parser = argparse.ArgumentParser( description='''Extract subgraph(s) from XGMML network(s).''') parser.add_argument('ids', type=str, help='identifier or file path to identifier list') parser.add_argument('-c', '--column', ...
python
def main(): parser = argparse.ArgumentParser( description='''Extract subgraph(s) from XGMML network(s).''') parser.add_argument('ids', type=str, help='identifier or file path to identifier list') parser.add_argument('-c', '--column', ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'''Extract subgraph(s) from XGMML network(s).'''", ")", "parser", ".", "add_argument", "(", "'ids'", ",", "type", "=", "str", ",", "help", "=", "'identifier...
parser.add_argument('--cache', default=True, type=bool, help='''Cache source_xgmml graph(s) and use in subsequent runs to reduce parse time (default = True)''')
[ "parser", ".", "add_argument", "(", "--", "cache", "default", "=", "True", "type", "=", "bool", "help", "=", "Cache", "source_xgmml", "graph", "(", "s", ")", "and", "use", "in", "subsequent", "runs", "to", "reduce", "parse", "time", "(", "default", "=", ...
train
https://github.com/nrnb/target-interaction-finder/blob/51d58c5eced0eb0c0e0e1284a3c97745eefbbe57/targetinteractionfinder/__init__.py#L8-L62
Brazelton-Lab/bio_utils
bio_utils/iterators/fastq.py
fastq_iter
def fastq_iter(handle, header=None): """Iterate over FASTQ file and return FASTQ entries Args: handle (file): FASTQ file handle, can be any iterator so long as it it returns subsequent "lines" of a FASTQ entry header (str): Header line of next FASTQ entry, if 'handle' has been ...
python
def fastq_iter(handle, header=None): """Iterate over FASTQ file and return FASTQ entries Args: handle (file): FASTQ file handle, can be any iterator so long as it it returns subsequent "lines" of a FASTQ entry header (str): Header line of next FASTQ entry, if 'handle' has been ...
[ "def", "fastq_iter", "(", "handle", ",", "header", "=", "None", ")", ":", "# Speed tricks: reduces function calls", "append", "=", "list", ".", "append", "join", "=", "str", ".", "join", "strip", "=", "str", ".", "strip", "next_line", "=", "next", "if", "h...
Iterate over FASTQ file and return FASTQ entries Args: handle (file): FASTQ file handle, can be any iterator so long as it it returns subsequent "lines" of a FASTQ entry header (str): Header line of next FASTQ entry, if 'handle' has been partially read and you want to start...
[ "Iterate", "over", "FASTQ", "file", "and", "return", "FASTQ", "entries" ]
train
https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/iterators/fastq.py#L77-L181
Brazelton-Lab/bio_utils
bio_utils/iterators/fastq.py
FastqEntry.write
def write(self): """Return FASTQ formatted string Returns: str: FASTQ formatted string containing entire FASTQ entry """ if self.description: return '@{0} {1}{4}{2}{4}+{4}{3}{4}'.format(self.id, self.descri...
python
def write(self): """Return FASTQ formatted string Returns: str: FASTQ formatted string containing entire FASTQ entry """ if self.description: return '@{0} {1}{4}{2}{4}+{4}{3}{4}'.format(self.id, self.descri...
[ "def", "write", "(", "self", ")", ":", "if", "self", ".", "description", ":", "return", "'@{0} {1}{4}{2}{4}+{4}{3}{4}'", ".", "format", "(", "self", ".", "id", ",", "self", ".", "description", ",", "self", ".", "sequence", ",", "self", ".", "quality", ",...
Return FASTQ formatted string Returns: str: FASTQ formatted string containing entire FASTQ entry
[ "Return", "FASTQ", "formatted", "string" ]
train
https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/iterators/fastq.py#L57-L74
crypto101/arthur
arthur/run.py
buildWorkbenchWithLauncher
def buildWorkbenchWithLauncher(): """Builds a workbench. The workbench has a launcher with all of the default tools. The launcher will be displayed on the workbench. """ workbench = ui.Workbench() tools = [exercises.SearchTool()] launcher = ui.Launcher(workbench, tools) workbench.disp...
python
def buildWorkbenchWithLauncher(): """Builds a workbench. The workbench has a launcher with all of the default tools. The launcher will be displayed on the workbench. """ workbench = ui.Workbench() tools = [exercises.SearchTool()] launcher = ui.Launcher(workbench, tools) workbench.disp...
[ "def", "buildWorkbenchWithLauncher", "(", ")", ":", "workbench", "=", "ui", ".", "Workbench", "(", ")", "tools", "=", "[", "exercises", ".", "SearchTool", "(", ")", "]", "launcher", "=", "ui", ".", "Launcher", "(", "workbench", ",", "tools", ")", "workbe...
Builds a workbench. The workbench has a launcher with all of the default tools. The launcher will be displayed on the workbench.
[ "Builds", "a", "workbench", "." ]
train
https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/run.py#L7-L20
crypto101/arthur
arthur/run.py
buildMainLoop
def buildMainLoop(workbench, launcher, **kwargs): """Builds a main loop from the given workbench and launcher. The main loop will have the default pallette, as well as the default unused key handler. The key handler will have a reference to the workbench and launcher so that it can clear the screen. ...
python
def buildMainLoop(workbench, launcher, **kwargs): """Builds a main loop from the given workbench and launcher. The main loop will have the default pallette, as well as the default unused key handler. The key handler will have a reference to the workbench and launcher so that it can clear the screen. ...
[ "def", "buildMainLoop", "(", "workbench", ",", "launcher", ",", "*", "*", "kwargs", ")", ":", "unhandledInput", "=", "partial", "(", "ui", ".", "_unhandledInput", ",", "workbench", "=", "workbench", ",", "launcher", "=", "launcher", ")", "mainLoop", "=", "...
Builds a main loop from the given workbench and launcher. The main loop will have the default pallette, as well as the default unused key handler. The key handler will have a reference to the workbench and launcher so that it can clear the screen. The extra keyword arguments are passed to the main loo...
[ "Builds", "a", "main", "loop", "from", "the", "given", "workbench", "and", "launcher", "." ]
train
https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/run.py#L23-L40
cdumay/cdumay-rest-client
src/cdumay_rest_client/errors.py
from_status
def from_status(status, message=None, extra=None): """ Try to create an error from status code :param int status: HTTP status :param str message: Body content :param dict extra: Additional info :return: An error :rtype: cdumay_rest_client.errors.Error """ if status in HTTP_STATUS_CODES:...
python
def from_status(status, message=None, extra=None): """ Try to create an error from status code :param int status: HTTP status :param str message: Body content :param dict extra: Additional info :return: An error :rtype: cdumay_rest_client.errors.Error """ if status in HTTP_STATUS_CODES:...
[ "def", "from_status", "(", "status", ",", "message", "=", "None", ",", "extra", "=", "None", ")", ":", "if", "status", "in", "HTTP_STATUS_CODES", ":", "return", "HTTP_STATUS_CODES", "[", "status", "]", "(", "message", "=", "message", ",", "extra", "=", "...
Try to create an error from status code :param int status: HTTP status :param str message: Body content :param dict extra: Additional info :return: An error :rtype: cdumay_rest_client.errors.Error
[ "Try", "to", "create", "an", "error", "from", "status", "code" ]
train
https://github.com/cdumay/cdumay-rest-client/blob/bca34d45748cb8227a7492af5ccfead3d8ab435d/src/cdumay_rest_client/errors.py#L335-L350
cdumay/cdumay-rest-client
src/cdumay_rest_client/errors.py
from_response
def from_response(response, url): """ Try to create an error from a HTTP response :param request.Response response: HTTP response :param str url: URL attained :return: An error :rtype: cdumay_rest_client.errors.Error """ # noinspection PyBroadException try: data = response.json(...
python
def from_response(response, url): """ Try to create an error from a HTTP response :param request.Response response: HTTP response :param str url: URL attained :return: An error :rtype: cdumay_rest_client.errors.Error """ # noinspection PyBroadException try: data = response.json(...
[ "def", "from_response", "(", "response", ",", "url", ")", ":", "# noinspection PyBroadException", "try", ":", "data", "=", "response", ".", "json", "(", ")", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "from_status", "(", "resp...
Try to create an error from a HTTP response :param request.Response response: HTTP response :param str url: URL attained :return: An error :rtype: cdumay_rest_client.errors.Error
[ "Try", "to", "create", "an", "error", "from", "a", "HTTP", "response" ]
train
https://github.com/cdumay/cdumay-rest-client/blob/bca34d45748cb8227a7492af5ccfead3d8ab435d/src/cdumay_rest_client/errors.py#L353-L379
FujiMakoto/AgentML
agentml/__init__.py
AgentML.load_directory
def load_directory(self, dir_path): """ Load all AgentML files contained in a specified directory :param dir_path: Path to the directory :type dir_path: str """ self._log.info('Loading all AgentML files contained in: ' + dir_path) # Get a list of file paths ...
python
def load_directory(self, dir_path): """ Load all AgentML files contained in a specified directory :param dir_path: Path to the directory :type dir_path: str """ self._log.info('Loading all AgentML files contained in: ' + dir_path) # Get a list of file paths ...
[ "def", "load_directory", "(", "self", ",", "dir_path", ")", ":", "self", ".", "_log", ".", "info", "(", "'Loading all AgentML files contained in: '", "+", "dir_path", ")", "# Get a list of file paths", "aml_files", "=", "[", "]", "for", "root", ",", "dirs", ",",...
Load all AgentML files contained in a specified directory :param dir_path: Path to the directory :type dir_path: str
[ "Load", "all", "AgentML", "files", "contained", "in", "a", "specified", "directory", ":", "param", "dir_path", ":", "Path", "to", "the", "directory", ":", "type", "dir_path", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L73-L89
FujiMakoto/AgentML
agentml/__init__.py
AgentML.load_file
def load_file(self, file_path): """ Load a single AgentML file :param file_path: Path to the file :type file_path: str """ self._log.info('Loading file: ' + file_path) agentml = etree.parse(file_path) # Validate the file for proper AgentML syntax ...
python
def load_file(self, file_path): """ Load a single AgentML file :param file_path: Path to the file :type file_path: str """ self._log.info('Loading file: ' + file_path) agentml = etree.parse(file_path) # Validate the file for proper AgentML syntax ...
[ "def", "load_file", "(", "self", ",", "file_path", ")", ":", "self", ".", "_log", ".", "info", "(", "'Loading file: '", "+", "file_path", ")", "agentml", "=", "etree", ".", "parse", "(", "file_path", ")", "# Validate the file for proper AgentML syntax", "self", ...
Load a single AgentML file :param file_path: Path to the file :type file_path: str
[ "Load", "a", "single", "AgentML", "file", ":", "param", "file_path", ":", "Path", "to", "the", "file", ":", "type", "file_path", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L91-L145
FujiMakoto/AgentML
agentml/__init__.py
AgentML.sort
def sort(self): """ Sort triggers and their associated responses """ # Sort triggers by word and character length first for priority, triggers in self._triggers.items(): self._log.debug('Sorting priority {priority} triggers'.format(priority=priority)) # G...
python
def sort(self): """ Sort triggers and their associated responses """ # Sort triggers by word and character length first for priority, triggers in self._triggers.items(): self._log.debug('Sorting priority {priority} triggers'.format(priority=priority)) # G...
[ "def", "sort", "(", "self", ")", ":", "# Sort triggers by word and character length first", "for", "priority", ",", "triggers", "in", "self", ".", "_triggers", ".", "items", "(", ")", ":", "self", ".", "_log", ".", "debug", "(", "'Sorting priority {priority} trigg...
Sort triggers and their associated responses
[ "Sort", "triggers", "and", "their", "associated", "responses" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L147-L173
FujiMakoto/AgentML
agentml/__init__.py
AgentML.get_reply
def get_reply(self, user, message, groups=None): """ Attempt to retrieve a reply to the provided message :param user: The user / client. This can be a hostmask, IP address, database ID or any other unique identifier :type user: str :param message: The message to retrieve a repl...
python
def get_reply(self, user, message, groups=None): """ Attempt to retrieve a reply to the provided message :param user: The user / client. This can be a hostmask, IP address, database ID or any other unique identifier :type user: str :param message: The message to retrieve a repl...
[ "def", "get_reply", "(", "self", ",", "user", ",", "message", ",", "groups", "=", "None", ")", ":", "# Make sure triggers have been sorted since the most recent trigger was added", "if", "not", "self", ".", "sorted", ":", "self", ".", "sort", "(", ")", "user", "...
Attempt to retrieve a reply to the provided message :param user: The user / client. This can be a hostmask, IP address, database ID or any other unique identifier :type user: str :param message: The message to retrieve a reply to :type message: string_types :param groups: The...
[ "Attempt", "to", "retrieve", "a", "reply", "to", "the", "provided", "message", ":", "param", "user", ":", "The", "user", "/", "client", ".", "This", "can", "be", "a", "hostmask", "IP", "address", "database", "ID", "or", "any", "other", "unique", "identif...
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L175-L244
FujiMakoto/AgentML
agentml/__init__.py
AgentML.add_trigger
def add_trigger(self, trigger): """ Add a new trigger :param trigger: The Trigger object :type trigger: Trigger """ # Make sure triggers are re-sorted before a new reply can be requested self.sorted = False # If no trigger with this priority level has be...
python
def add_trigger(self, trigger): """ Add a new trigger :param trigger: The Trigger object :type trigger: Trigger """ # Make sure triggers are re-sorted before a new reply can be requested self.sorted = False # If no trigger with this priority level has be...
[ "def", "add_trigger", "(", "self", ",", "trigger", ")", ":", "# Make sure triggers are re-sorted before a new reply can be requested", "self", ".", "sorted", "=", "False", "# If no trigger with this priority level has been defined yet, create a new list", "if", "trigger", ".", "p...
Add a new trigger :param trigger: The Trigger object :type trigger: Trigger
[ "Add", "a", "new", "trigger", ":", "param", "trigger", ":", "The", "Trigger", "object", ":", "type", "trigger", ":", "Trigger" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L246-L261
FujiMakoto/AgentML
agentml/__init__.py
AgentML.set_substitution
def set_substitution(self, word, substitution): """ Add a word substitution :param word: The word to replace :type word: str :param substitution: The word's substitution :type substitution: str """ # Parse the word and its substitution raw_word ...
python
def set_substitution(self, word, substitution): """ Add a word substitution :param word: The word to replace :type word: str :param substitution: The word's substitution :type substitution: str """ # Parse the word and its substitution raw_word ...
[ "def", "set_substitution", "(", "self", ",", "word", ",", "substitution", ")", ":", "# Parse the word and its substitution", "raw_word", "=", "re", ".", "escape", "(", "word", ")", "raw_substitution", "=", "substitution", "case_word", "=", "re", ".", "escape", "...
Add a word substitution :param word: The word to replace :type word: str :param substitution: The word's substitution :type substitution: str
[ "Add", "a", "word", "substitution", ":", "param", "word", ":", "The", "word", "to", "replace", ":", "type", "word", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L263-L292
FujiMakoto/AgentML
agentml/__init__.py
AgentML.parse_substitutions
def parse_substitutions(self, messages): """ Parse substitutions in a supplied message :param messages: A tuple messages being parsed (normalized, case preserved, raw) :type messages: tuple of (str, str, str) :return: Substituted messages (normalized, case preserved, raw) ...
python
def parse_substitutions(self, messages): """ Parse substitutions in a supplied message :param messages: A tuple messages being parsed (normalized, case preserved, raw) :type messages: tuple of (str, str, str) :return: Substituted messages (normalized, case preserved, raw) ...
[ "def", "parse_substitutions", "(", "self", ",", "messages", ")", ":", "# If no substitutions have been defined, just normalize the message", "if", "not", "self", ".", "_substitutions", ":", "self", ".", "_log", ".", "info", "(", "'No substitutions to process'", ")", "re...
Parse substitutions in a supplied message :param messages: A tuple messages being parsed (normalized, case preserved, raw) :type messages: tuple of (str, str, str) :return: Substituted messages (normalized, case preserved, raw) :rtype : tuple of (str, str, str)
[ "Parse", "substitutions", "in", "a", "supplied", "message", ":", "param", "messages", ":", "A", "tuple", "messages", "being", "parsed", "(", "normalized", "case", "preserved", "raw", ")", ":", "type", "messages", ":", "tuple", "of", "(", "str", "str", "str...
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L295-L321
FujiMakoto/AgentML
agentml/__init__.py
AgentML.get_var
def get_var(self, name, user=None): """ Retrieve a global or user variable :param name: The name of the variable to retrieve :type name: str :param user: If retrieving a user variable, the user identifier :type user: str or None :rtype: str :raises Us...
python
def get_var(self, name, user=None): """ Retrieve a global or user variable :param name: The name of the variable to retrieve :type name: str :param user: If retrieving a user variable, the user identifier :type user: str or None :rtype: str :raises Us...
[ "def", "get_var", "(", "self", ",", "name", ",", "user", "=", "None", ")", ":", "# Retrieve a user variable", "if", "user", "is", "not", "None", ":", "if", "user", "not", "in", "self", ".", "_users", ":", "raise", "UserNotDefinedError", "return", "self", ...
Retrieve a global or user variable :param name: The name of the variable to retrieve :type name: str :param user: If retrieving a user variable, the user identifier :type user: str or None :rtype: str :raises UserNotDefinedError: The specified user does not exist ...
[ "Retrieve", "a", "global", "or", "user", "variable", ":", "param", "name", ":", "The", "name", "of", "the", "variable", "to", "retrieve", ":", "type", "name", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L323-L348
FujiMakoto/AgentML
agentml/__init__.py
AgentML.set_var
def set_var(self, name, value, user=None): """ Set a global or user variable :param name: The name of the variable to set :type name: str :param value: The value of the variable to set :type value: str :param user: If defining a user variable, the user identif...
python
def set_var(self, name, value, user=None): """ Set a global or user variable :param name: The name of the variable to set :type name: str :param value: The value of the variable to set :type value: str :param user: If defining a user variable, the user identif...
[ "def", "set_var", "(", "self", ",", "name", ",", "value", ",", "user", "=", "None", ")", ":", "# Set a user variable", "if", "user", "is", "not", "None", ":", "if", "user", "not", "in", "self", ".", "_users", ":", "raise", "UserNotDefinedError", "self", ...
Set a global or user variable :param name: The name of the variable to set :type name: str :param value: The value of the variable to set :type value: str :param user: If defining a user variable, the user identifier :type user: str :raises UserNotDefinedErr...
[ "Set", "a", "global", "or", "user", "variable", ":", "param", "name", ":", "The", "name", "of", "the", "variable", "to", "set", ":", "type", "name", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L350-L373
FujiMakoto/AgentML
agentml/__init__.py
AgentML.set_limit
def set_limit(self, identifier, expires_at, blocking=False): """ Set a new global trigger or response limit :param identifier: The Trigger or Response object :type identifier: parser.trigger.Trigger or parser.trigger.response.Response :param expires_at: The limit expiration as ...
python
def set_limit(self, identifier, expires_at, blocking=False): """ Set a new global trigger or response limit :param identifier: The Trigger or Response object :type identifier: parser.trigger.Trigger or parser.trigger.response.Response :param expires_at: The limit expiration as ...
[ "def", "set_limit", "(", "self", ",", "identifier", ",", "expires_at", ",", "blocking", "=", "False", ")", ":", "self", ".", "_limits", "[", "identifier", "]", "=", "(", "expires_at", ",", "blocking", ")" ]
Set a new global trigger or response limit :param identifier: The Trigger or Response object :type identifier: parser.trigger.Trigger or parser.trigger.response.Response :param expires_at: The limit expiration as a Unix timestamp :type expires_at: float :param blocking: When ...
[ "Set", "a", "new", "global", "trigger", "or", "response", "limit", ":", "param", "identifier", ":", "The", "Trigger", "or", "Response", "object", ":", "type", "identifier", ":", "parser", ".", "trigger", ".", "Trigger", "or", "parser", ".", "trigger", ".",...
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L375-L387
FujiMakoto/AgentML
agentml/__init__.py
AgentML.clear_limit
def clear_limit(self, identifier=None): """ Remove a single limit or all defined limits :param identifier: The identifier to clear limits for, or if no identifier is supplied, clears ALL limits :type identifier: int :return: True if a limit was successfully found and removed, F...
python
def clear_limit(self, identifier=None): """ Remove a single limit or all defined limits :param identifier: The identifier to clear limits for, or if no identifier is supplied, clears ALL limits :type identifier: int :return: True if a limit was successfully found and removed, F...
[ "def", "clear_limit", "(", "self", ",", "identifier", "=", "None", ")", ":", "# Remove a single limit", "if", "identifier", ":", "if", "identifier", "in", "self", ".", "_limits", ":", "del", "self", ".", "_limits", "[", "identifier", "]", "return", "True", ...
Remove a single limit or all defined limits :param identifier: The identifier to clear limits for, or if no identifier is supplied, clears ALL limits :type identifier: int :return: True if a limit was successfully found and removed, False if no limit could be matched for removal :rtype...
[ "Remove", "a", "single", "limit", "or", "all", "defined", "limits", ":", "param", "identifier", ":", "The", "identifier", "to", "clear", "limits", "for", "or", "if", "no", "identifier", "is", "supplied", "clears", "ALL", "limits", ":", "type", "identifier", ...
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L389-L411
FujiMakoto/AgentML
agentml/__init__.py
AgentML.is_limited
def is_limited(self, identifier): """ Test whether or not there is an active global limit for the specified Trigger or Response instance :param identifier: The Trigger or Response object :type identifier: parser.trigger.Trigger or parser.trigger.response.Response :return: True ...
python
def is_limited(self, identifier): """ Test whether or not there is an active global limit for the specified Trigger or Response instance :param identifier: The Trigger or Response object :type identifier: parser.trigger.Trigger or parser.trigger.response.Response :return: True ...
[ "def", "is_limited", "(", "self", ",", "identifier", ")", ":", "# If there is a limit for this Trigger assigned, make sure it hasn't expired", "if", "identifier", "in", "self", ".", "_limits", ":", "limit", ",", "blocking", "=", "self", ".", "_limits", "[", "identifie...
Test whether or not there is an active global limit for the specified Trigger or Response instance :param identifier: The Trigger or Response object :type identifier: parser.trigger.Trigger or parser.trigger.response.Response :return: True if there is a limit enforced, otherwise False ...
[ "Test", "whether", "or", "not", "there", "is", "an", "active", "global", "limit", "for", "the", "specified", "Trigger", "or", "Response", "instance", ":", "param", "identifier", ":", "The", "Trigger", "or", "Response", "object", ":", "type", "identifier", ":...
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L413-L438
FujiMakoto/AgentML
agentml/__init__.py
AgentML.add_condition
def add_condition(self, name, cond_class): """ Add a new custom condition type parser :param name: The name of the condition type :type name: str :param cond_class: The Class :return: """ # Has this condition type already been defined? if name in...
python
def add_condition(self, name, cond_class): """ Add a new custom condition type parser :param name: The name of the condition type :type name: str :param cond_class: The Class :return: """ # Has this condition type already been defined? if name in...
[ "def", "add_condition", "(", "self", ",", "name", ",", "cond_class", ")", ":", "# Has this condition type already been defined?", "if", "name", "in", "self", ".", "conditions", ":", "self", ".", "_log", ".", "warn", "(", "'Overwriting an existing Condition Type class:...
Add a new custom condition type parser :param name: The name of the condition type :type name: str :param cond_class: The Class :return:
[ "Add", "a", "new", "custom", "condition", "type", "parser", ":", "param", "name", ":", "The", "name", "of", "the", "condition", "type", ":", "type", "name", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L449-L468
FujiMakoto/AgentML
agentml/__init__.py
AgentML.set_tag
def set_tag(self, name, tag_class): """ Define a new tag parser method :param name: The name of the tag :type name: str :param tag_class: The Tag class, this must be a subclass of base parser.tags.Tag :type tag_class: Tag """ # Has this tag already been...
python
def set_tag(self, name, tag_class): """ Define a new tag parser method :param name: The name of the tag :type name: str :param tag_class: The Tag class, this must be a subclass of base parser.tags.Tag :type tag_class: Tag """ # Has this tag already been...
[ "def", "set_tag", "(", "self", ",", "name", ",", "tag_class", ")", ":", "# Has this tag already been defined?", "if", "name", "in", "self", ".", "_tags", ":", "self", ".", "_log", ".", "warn", "(", "'Overwriting an existing Tag class: {tag}'", ".", "format", "("...
Define a new tag parser method :param name: The name of the tag :type name: str :param tag_class: The Tag class, this must be a subclass of base parser.tags.Tag :type tag_class: Tag
[ "Define", "a", "new", "tag", "parser", "method", ":", "param", "name", ":", "The", "name", "of", "the", "tag", ":", "type", "name", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L470-L489
FujiMakoto/AgentML
agentml/__init__.py
AgentML.parse_tags
def parse_tags(self, element, trigger): """ Parse tags in an XML element :param element: The response [message] XML element :type element: etree._Element :return: A list of strings and Tag objects in the order they are parsed :rtype : list of (str or parser.tags.tag,Tag...
python
def parse_tags(self, element, trigger): """ Parse tags in an XML element :param element: The response [message] XML element :type element: etree._Element :return: A list of strings and Tag objects in the order they are parsed :rtype : list of (str or parser.tags.tag,Tag...
[ "def", "parse_tags", "(", "self", ",", "element", ",", "trigger", ")", ":", "response", "=", "[", "]", "# Add the starting text to the response list", "head", "=", "element", ".", "text", "if", "isinstance", "(", "element", ".", "text", ",", "string_types", ")...
Parse tags in an XML element :param element: The response [message] XML element :type element: etree._Element :return: A list of strings and Tag objects in the order they are parsed :rtype : list of (str or parser.tags.tag,Tag)
[ "Parse", "tags", "in", "an", "XML", "element", ":", "param", "element", ":", "The", "response", "[", "message", "]", "XML", "element", ":", "type", "element", ":", "etree", ".", "_Element" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L491-L544
FujiMakoto/AgentML
agentml/__init__.py
AgentML.interpreter
def interpreter(self): """ Launch an AML interpreter session for testing """ while True: message = input('[#] ') if message.lower().strip() == 'exit': break reply = self.get_reply('#interpreter#', message) if not reply: ...
python
def interpreter(self): """ Launch an AML interpreter session for testing """ while True: message = input('[#] ') if message.lower().strip() == 'exit': break reply = self.get_reply('#interpreter#', message) if not reply: ...
[ "def", "interpreter", "(", "self", ")", ":", "while", "True", ":", "message", "=", "input", "(", "'[#] '", ")", "if", "message", ".", "lower", "(", ")", ".", "strip", "(", ")", "==", "'exit'", ":", "break", "reply", "=", "self", ".", "get_reply", "...
Launch an AML interpreter session for testing
[ "Launch", "an", "AML", "interpreter", "session", "for", "testing" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L546-L561
FujiMakoto/AgentML
agentml/__init__.py
Message.format
def format(self, message_format): """ Set the message format :param message_format: The format to set :type message_format: str """ if message_format not in self.formats: self._log.error('Invalid Message format specified: {format}'.format(format=message_forma...
python
def format(self, message_format): """ Set the message format :param message_format: The format to set :type message_format: str """ if message_format not in self.formats: self._log.error('Invalid Message format specified: {format}'.format(format=message_forma...
[ "def", "format", "(", "self", ",", "message_format", ")", ":", "if", "message_format", "not", "in", "self", ".", "formats", ":", "self", ".", "_log", ".", "error", "(", "'Invalid Message format specified: {format}'", ".", "format", "(", "format", "=", "message...
Set the message format :param message_format: The format to set :type message_format: str
[ "Set", "the", "message", "format", ":", "param", "message_format", ":", "The", "format", "to", "set", ":", "type", "message_format", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L610-L621
FujiMakoto/AgentML
agentml/__init__.py
User.get_var
def get_var(self, name): """ Retrieve a variable assigned to this user :param name: The name of the variable to retrieve :type name: str :rtype: str :raises VarNotDefinedError: The requested variable has not been defined """ if name not in self._vars: ...
python
def get_var(self, name): """ Retrieve a variable assigned to this user :param name: The name of the variable to retrieve :type name: str :rtype: str :raises VarNotDefinedError: The requested variable has not been defined """ if name not in self._vars: ...
[ "def", "get_var", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_vars", ":", "raise", "VarNotDefinedError", "return", "self", ".", "_vars", "[", "name", "]" ]
Retrieve a variable assigned to this user :param name: The name of the variable to retrieve :type name: str :rtype: str :raises VarNotDefinedError: The requested variable has not been defined
[ "Retrieve", "a", "variable", "assigned", "to", "this", "user", ":", "param", "name", ":", "The", "name", "of", "the", "variable", "to", "retrieve", ":", "type", "name", ":", "str" ]
train
https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/__init__.py#L667-L680
TestInABox/stackInABox
stackinabox/util/responses/core.py
responses_callback
def responses_callback(request): """Responses Request Handler. Converts a call intercepted by Responses to the Stack-In-A-Box infrastructure :param request: request object :returns: tuple - (int, dict, string) containing: int - the HTTP response status code ...
python
def responses_callback(request): """Responses Request Handler. Converts a call intercepted by Responses to the Stack-In-A-Box infrastructure :param request: request object :returns: tuple - (int, dict, string) containing: int - the HTTP response status code ...
[ "def", "responses_callback", "(", "request", ")", ":", "method", "=", "request", ".", "method", "headers", "=", "CaseInsensitiveDict", "(", ")", "request_headers", "=", "CaseInsensitiveDict", "(", ")", "request_headers", ".", "update", "(", "request", ".", "head...
Responses Request Handler. Converts a call intercepted by Responses to the Stack-In-A-Box infrastructure :param request: request object :returns: tuple - (int, dict, string) containing: int - the HTTP response status code dict - the headers for the HTTP res...
[ "Responses", "Request", "Handler", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/util/responses/core.py#L19-L41
TestInABox/stackInABox
stackinabox/util/responses/core.py
registration
def registration(uri): """Responses handler registration. Registers a handler for a given URI with Responses so that it can be intercepted and handed to Stack-In-A-Box. :param uri: URI used for the base of the HTTP requests :returns: n/a """ # log the URI that is used to access the S...
python
def registration(uri): """Responses handler registration. Registers a handler for a given URI with Responses so that it can be intercepted and handed to Stack-In-A-Box. :param uri: URI used for the base of the HTTP requests :returns: n/a """ # log the URI that is used to access the S...
[ "def", "registration", "(", "uri", ")", ":", "# log the URI that is used to access the Stack-In-A-Box services", "logger", ".", "debug", "(", "'Registering Stack-In-A-Box at {0} under Python Responses'", ".", "format", "(", "uri", ")", ")", "# tell Stack-In-A-Box what URI to matc...
Responses handler registration. Registers a handler for a given URI with Responses so that it can be intercepted and handed to Stack-In-A-Box. :param uri: URI used for the base of the HTTP requests :returns: n/a
[ "Responses", "handler", "registration", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/util/responses/core.py#L44-L78
bwesterb/sarah
src/cacheDecorators.py
cacheOnSameArgs
def cacheOnSameArgs(timeout=None): """ Caches the return of the function until the the specified time has elapsed or the arguments change. If timeout is None it will not be considered. """ if isinstance(timeout, int): timeout = datetime.timedelta(0, timeout) def decorator(f): ...
python
def cacheOnSameArgs(timeout=None): """ Caches the return of the function until the the specified time has elapsed or the arguments change. If timeout is None it will not be considered. """ if isinstance(timeout, int): timeout = datetime.timedelta(0, timeout) def decorator(f): ...
[ "def", "cacheOnSameArgs", "(", "timeout", "=", "None", ")", ":", "if", "isinstance", "(", "timeout", ",", "int", ")", ":", "timeout", "=", "datetime", ".", "timedelta", "(", "0", ",", "timeout", ")", "def", "decorator", "(", "f", ")", ":", "_cache", ...
Caches the return of the function until the the specified time has elapsed or the arguments change. If timeout is None it will not be considered.
[ "Caches", "the", "return", "of", "the", "function", "until", "the", "the", "specified", "time", "has", "elapsed", "or", "the", "arguments", "change", ".", "If", "timeout", "is", "None", "it", "will", "not", "be", "considered", "." ]
train
https://github.com/bwesterb/sarah/blob/a9e46e875dfff1dc11255d714bb736e5eb697809/src/cacheDecorators.py#L5-L28
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
verify_file_exists
def verify_file_exists(file_name, file_location): """ Function to verify if a file exists Args: file_name: The name of file to check file_location: The location of the file, derive from the os module Returns: returns boolean True or False """ return __os.path.isfile(__os.path.j...
python
def verify_file_exists(file_name, file_location): """ Function to verify if a file exists Args: file_name: The name of file to check file_location: The location of the file, derive from the os module Returns: returns boolean True or False """ return __os.path.isfile(__os.path.j...
[ "def", "verify_file_exists", "(", "file_name", ",", "file_location", ")", ":", "return", "__os", ".", "path", ".", "isfile", "(", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", ")" ]
Function to verify if a file exists Args: file_name: The name of file to check file_location: The location of the file, derive from the os module Returns: returns boolean True or False
[ "Function", "to", "verify", "if", "a", "file", "exists", "Args", ":", "file_name", ":", "The", "name", "of", "file", "to", "check", "file_location", ":", "The", "location", "of", "the", "file", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L77-L87
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
file_name_increase
def file_name_increase(file_name, file_location): """ Function to increase a filename by a number 1 Args: file_name: The name of file to check file_location: The location of the file, derive from the os module Returns: returns a good filename. """ add_one = 1 file_name_temp...
python
def file_name_increase(file_name, file_location): """ Function to increase a filename by a number 1 Args: file_name: The name of file to check file_location: The location of the file, derive from the os module Returns: returns a good filename. """ add_one = 1 file_name_temp...
[ "def", "file_name_increase", "(", "file_name", ",", "file_location", ")", ":", "add_one", "=", "1", "file_name_temp", "=", "file_name", "while", "verify_file_exists", "(", "file_name_temp", ",", "file_location", ")", ":", "try", ":", "name", ",", "file_extension",...
Function to increase a filename by a number 1 Args: file_name: The name of file to check file_location: The location of the file, derive from the os module Returns: returns a good filename.
[ "Function", "to", "increase", "a", "filename", "by", "a", "number", "1", "Args", ":", "file_name", ":", "The", "name", "of", "file", "to", "check", "file_location", ":", "The", "location", "of", "the", "file", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L90-L112
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
verify_directory
def verify_directory(directory_name, directory_location, directory_create=False): """ Function to verify if a directory exists Args: directory_name: The name of directory to check directory_location: The location of the directory, derive from the os module directory_create: If you wa...
python
def verify_directory(directory_name, directory_location, directory_create=False): """ Function to verify if a directory exists Args: directory_name: The name of directory to check directory_location: The location of the directory, derive from the os module directory_create: If you wa...
[ "def", "verify_directory", "(", "directory_name", ",", "directory_location", ",", "directory_create", "=", "False", ")", ":", "if", "not", "directory_create", ":", "return", "__os", ".", "path", ".", "exists", "(", "__os", ".", "path", ".", "join", "(", "dir...
Function to verify if a directory exists Args: directory_name: The name of directory to check directory_location: The location of the directory, derive from the os module directory_create: If you want to create the directory Returns: returns boolean True or False, but if you set directo...
[ "Function", "to", "verify", "if", "a", "directory", "exists", "Args", ":", "directory_name", ":", "The", "name", "of", "directory", "to", "check", "directory_location", ":", "The", "location", "of", "the", "directory", "derive", "from", "the", "os", "module", ...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L115-L131
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
list_to_file
def list_to_file(orig_list, file_name, file_location): """ Function to export a list to a text file Args: orig_list: The list you want exported file_name: The name of the exported file file_location: The location of the file, derive from the os module Returns: returns the filena...
python
def list_to_file(orig_list, file_name, file_location): """ Function to export a list to a text file Args: orig_list: The list you want exported file_name: The name of the exported file file_location: The location of the file, derive from the os module Returns: returns the filena...
[ "def", "list_to_file", "(", "orig_list", ",", "file_name", ",", "file_location", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "def", "add_line_break", "(", "list_line", ")", ":", "\"\"\"\n Create ...
Function to export a list to a text file Args: orig_list: The list you want exported file_name: The name of the exported file file_location: The location of the file, derive from the os module Returns: returns the filename info
[ "Function", "to", "export", "a", "list", "to", "a", "text", "file", "Args", ":", "orig_list", ":", "The", "list", "you", "want", "exported", "file_name", ":", "The", "name", "of", "the", "exported", "file", "file_location", ":", "The", "location", "of", ...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L134-L162
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
file_to_list
def file_to_list(file_name, file_location): """ Function to import a text file to a list Args: file_name: The name of file to be import file_location: The location of the file, derive from the os module Returns: returns a list """ file = __os.path.join(file_location, file_name)...
python
def file_to_list(file_name, file_location): """ Function to import a text file to a list Args: file_name: The name of file to be import file_location: The location of the file, derive from the os module Returns: returns a list """ file = __os.path.join(file_location, file_name)...
[ "def", "file_to_list", "(", "file_name", ",", "file_location", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "read_file", "=", "open", "(", "file", ",", "\"r\"", ")", "temp_list", "=", "read_file", ...
Function to import a text file to a list Args: file_name: The name of file to be import file_location: The location of the file, derive from the os module Returns: returns a list
[ "Function", "to", "import", "a", "text", "file", "to", "a", "list", "Args", ":", "file_name", ":", "The", "name", "of", "file", "to", "be", "import", "file_location", ":", "The", "location", "of", "the", "file", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L165-L179
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
csv_to_dict
def csv_to_dict(file_name, file_location): """ Function to import a csv as a dictionary Args: file_name: The name of the csv file file_location: The location of the file, derive from the os module Returns: returns a dictionary """ file = __os.path.join(file_location, file_name)...
python
def csv_to_dict(file_name, file_location): """ Function to import a csv as a dictionary Args: file_name: The name of the csv file file_location: The location of the file, derive from the os module Returns: returns a dictionary """ file = __os.path.join(file_location, file_name)...
[ "def", "csv_to_dict", "(", "file_name", ",", "file_location", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "try", ":", "csv_read", "=", "open", "(", "file", ",", "\"r\"", ")", "except", "Exception"...
Function to import a csv as a dictionary Args: file_name: The name of the csv file file_location: The location of the file, derive from the os module Returns: returns a dictionary
[ "Function", "to", "import", "a", "csv", "as", "a", "dictionary", "Args", ":", "file_name", ":", "The", "name", "of", "the", "csv", "file", "file_location", ":", "The", "location", "of", "the", "file", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L182-L206
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
dict_to_csv
def dict_to_csv(orig_dict, file_name, field_names_tuple, file_location): """ Function to export a dictionary to a csv file Args: orig_dict: The dictionary you want exported file_name: The name of the exported file field_names_tuple: The fieldnames in a tuple file_location: Th...
python
def dict_to_csv(orig_dict, file_name, field_names_tuple, file_location): """ Function to export a dictionary to a csv file Args: orig_dict: The dictionary you want exported file_name: The name of the exported file field_names_tuple: The fieldnames in a tuple file_location: Th...
[ "def", "dict_to_csv", "(", "orig_dict", ",", "file_name", ",", "field_names_tuple", ",", "file_location", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "csv_write", "=", "open", "(", "file", ",", "'a'...
Function to export a dictionary to a csv file Args: orig_dict: The dictionary you want exported file_name: The name of the exported file field_names_tuple: The fieldnames in a tuple file_location: The location of the file, derive from the os module Returns: returns the filename ...
[ "Function", "to", "export", "a", "dictionary", "to", "a", "csv", "file", "Args", ":", "orig_dict", ":", "The", "dictionary", "you", "want", "exported", "file_name", ":", "The", "name", "of", "the", "exported", "file", "field_names_tuple", ":", "The", "fieldn...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L209-L229
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
store_object
def store_object(file_name, save_key, file_location, object_to_store=None): """ Function to store objects in a shelve Args: file_name: Shelve storage file name save_key: The name of the key to store the item to file_location: The location of the file, derive from the os module ...
python
def store_object(file_name, save_key, file_location, object_to_store=None): """ Function to store objects in a shelve Args: file_name: Shelve storage file name save_key: The name of the key to store the item to file_location: The location of the file, derive from the os module ...
[ "def", "store_object", "(", "file_name", ",", "save_key", ",", "file_location", ",", "object_to_store", "=", "None", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "try", ":", "shelve_store", "=", "__s...
Function to store objects in a shelve Args: file_name: Shelve storage file name save_key: The name of the key to store the item to file_location: The location of the file, derive from the os module object_to_store: The object you want to store Returns:
[ "Function", "to", "store", "objects", "in", "a", "shelve", "Args", ":", "file_name", ":", "Shelve", "storage", "file", "name", "save_key", ":", "The", "name", "of", "the", "key", "to", "store", "the", "item", "to", "file_location", ":", "The", "location", ...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L232-L253
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
retrieve_object_from_file
def retrieve_object_from_file(file_name, save_key, file_location): """ Function to retrieve objects from a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Retu...
python
def retrieve_object_from_file(file_name, save_key, file_location): """ Function to retrieve objects from a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Retu...
[ "def", "retrieve_object_from_file", "(", "file_name", ",", "save_key", ",", "file_location", ")", ":", "shelve_store", "=", "None", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "try", ":", "shelve_store", "=", "...
Function to retrieve objects from a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns: Returns the stored object
[ "Function", "to", "retrieve", "objects", "from", "a", "shelve", "Args", ":", "file_name", ":", "Shelve", "storage", "file", "name", "save_key", ":", "The", "name", "of", "the", "key", "the", "item", "is", "stored", "in", "file_location", ":", "The", "locat...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L256-L276
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
delete_object_from_file
def delete_object_from_file(file_name, save_key, file_location): """ Function to delete objects from a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns:...
python
def delete_object_from_file(file_name, save_key, file_location): """ Function to delete objects from a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns:...
[ "def", "delete_object_from_file", "(", "file_name", ",", "save_key", ",", "file_location", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "shelve_store", "=", "__shelve", ".", "open", "(", "file", ")", ...
Function to delete objects from a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns:
[ "Function", "to", "delete", "objects", "from", "a", "shelve", "Args", ":", "file_name", ":", "Shelve", "storage", "file", "name", "save_key", ":", "The", "name", "of", "the", "key", "the", "item", "is", "stored", "in", "file_location", ":", "The", "locatio...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L279-L293
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
verify_key_in_shelve
def verify_key_in_shelve(file_name, save_key, file_location): """ Function to check for a key in a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns: ret...
python
def verify_key_in_shelve(file_name, save_key, file_location): """ Function to check for a key in a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns: ret...
[ "def", "verify_key_in_shelve", "(", "file_name", ",", "save_key", ",", "file_location", ")", ":", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "shelve_store", "=", "__shelve", ".", "open", "(", "file", ")", "e...
Function to check for a key in a shelve Args: file_name: Shelve storage file name save_key: The name of the key the item is stored in file_location: The location of the file, derive from the os module Returns: returns true or false
[ "Function", "to", "check", "for", "a", "key", "in", "a", "shelve", "Args", ":", "file_name", ":", "Shelve", "storage", "file", "name", "save_key", ":", "The", "name", "of", "the", "key", "the", "item", "is", "stored", "in", "file_location", ":", "The", ...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L296-L315
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
get_keys_from_shelve
def get_keys_from_shelve(file_name, file_location): """ Function to retreive all keys in a shelve Args: file_name: Shelve storage file name file_location: The location of the file, derive from the os module Returns: a list of the keys """ temp_list = list() file = _...
python
def get_keys_from_shelve(file_name, file_location): """ Function to retreive all keys in a shelve Args: file_name: Shelve storage file name file_location: The location of the file, derive from the os module Returns: a list of the keys """ temp_list = list() file = _...
[ "def", "get_keys_from_shelve", "(", "file_name", ",", "file_location", ")", ":", "temp_list", "=", "list", "(", ")", "file", "=", "__os", ".", "path", ".", "join", "(", "file_location", ",", "file_name", ")", "shelve_store", "=", "__shelve", ".", "open", "...
Function to retreive all keys in a shelve Args: file_name: Shelve storage file name file_location: The location of the file, derive from the os module Returns: a list of the keys
[ "Function", "to", "retreive", "all", "keys", "in", "a", "shelve", "Args", ":", "file_name", ":", "Shelve", "storage", "file", "name", "file_location", ":", "The", "location", "of", "the", "file", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L318-L335
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
remove_symbol_add_symbol
def remove_symbol_add_symbol(string_item, remove_symbol, add_symbol): """ Remove a symbol from a string, and replace it with a different one Args: string_item: String that you want to replace symbols in remove_symbol: Symbol to remove add_symbol: Symbol to add Returns: returns a...
python
def remove_symbol_add_symbol(string_item, remove_symbol, add_symbol): """ Remove a symbol from a string, and replace it with a different one Args: string_item: String that you want to replace symbols in remove_symbol: Symbol to remove add_symbol: Symbol to add Returns: returns a...
[ "def", "remove_symbol_add_symbol", "(", "string_item", ",", "remove_symbol", ",", "add_symbol", ")", ":", "string_item", "=", "add_symbol", ".", "join", "(", "string_item", ".", "split", "(", "remove_symbol", ")", ")", "return", "string_item" ]
Remove a symbol from a string, and replace it with a different one Args: string_item: String that you want to replace symbols in remove_symbol: Symbol to remove add_symbol: Symbol to add Returns: returns a string with symbols swapped
[ "Remove", "a", "symbol", "from", "a", "string", "and", "replace", "it", "with", "a", "different", "one", "Args", ":", "string_item", ":", "String", "that", "you", "want", "to", "replace", "symbols", "in", "remove_symbol", ":", "Symbol", "to", "remove", "ad...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L377-L389
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
list_files_in_directory
def list_files_in_directory(full_directory_path): """ List the files in a specified directory Args: full_directory_path: The full directory path to check, derive from the os module Returns: returns a list of files """ files = list() for file_name in __os.listdir(full_directory_path...
python
def list_files_in_directory(full_directory_path): """ List the files in a specified directory Args: full_directory_path: The full directory path to check, derive from the os module Returns: returns a list of files """ files = list() for file_name in __os.listdir(full_directory_path...
[ "def", "list_files_in_directory", "(", "full_directory_path", ")", ":", "files", "=", "list", "(", ")", "for", "file_name", "in", "__os", ".", "listdir", "(", "full_directory_path", ")", ":", "if", "__os", ".", "path", ".", "isfile", "(", "__os", ".", "pat...
List the files in a specified directory Args: full_directory_path: The full directory path to check, derive from the os module Returns: returns a list of files
[ "List", "the", "files", "in", "a", "specified", "directory", "Args", ":", "full_directory_path", ":", "The", "full", "directory", "path", "to", "check", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L392-L405
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
list_directories_in_directory
def list_directories_in_directory(full_directory_path): """ List the directories in a specified directory Args: full_directory_path: The full directory path to check, derive from the os module Returns: returns a list of directories """ directories = list() for directory_name in __o...
python
def list_directories_in_directory(full_directory_path): """ List the directories in a specified directory Args: full_directory_path: The full directory path to check, derive from the os module Returns: returns a list of directories """ directories = list() for directory_name in __o...
[ "def", "list_directories_in_directory", "(", "full_directory_path", ")", ":", "directories", "=", "list", "(", ")", "for", "directory_name", "in", "__os", ".", "listdir", "(", "full_directory_path", ")", ":", "if", "__os", ".", "path", ".", "isdir", "(", "__os...
List the directories in a specified directory Args: full_directory_path: The full directory path to check, derive from the os module Returns: returns a list of directories
[ "List", "the", "directories", "in", "a", "specified", "directory", "Args", ":", "full_directory_path", ":", "The", "full", "directory", "path", "to", "check", "derive", "from", "the", "os", "module" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L408-L421
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
split_strings_in_list_retain_spaces
def split_strings_in_list_retain_spaces(orig_list): """ Function to split every line in a list, and retain spaces for a rejoin :param orig_list: Original list :return: A List with split lines """ temp_list = list() for line in orig_list: line_split = __re.split(r'(\s+)', lin...
python
def split_strings_in_list_retain_spaces(orig_list): """ Function to split every line in a list, and retain spaces for a rejoin :param orig_list: Original list :return: A List with split lines """ temp_list = list() for line in orig_list: line_split = __re.split(r'(\s+)', lin...
[ "def", "split_strings_in_list_retain_spaces", "(", "orig_list", ")", ":", "temp_list", "=", "list", "(", ")", "for", "line", "in", "orig_list", ":", "line_split", "=", "__re", ".", "split", "(", "r'(\\s+)'", ",", "line", ")", "temp_list", ".", "append", "(",...
Function to split every line in a list, and retain spaces for a rejoin :param orig_list: Original list :return: A List with split lines
[ "Function", "to", "split", "every", "line", "in", "a", "list", "and", "retain", "spaces", "for", "a", "rejoin", ":", "param", "orig_list", ":", "Original", "list", ":", "return", ":", "A", "List", "with", "split", "lines" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L446-L459
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
random_line_data
def random_line_data(chars_per_line=80): """ Function to create a line of a random string Args: chars_per_line: An integer that says how many characters to return Returns: A String """ return ''.join(__random.choice(__string.ascii_letters) for x in range(chars_per_line))
python
def random_line_data(chars_per_line=80): """ Function to create a line of a random string Args: chars_per_line: An integer that says how many characters to return Returns: A String """ return ''.join(__random.choice(__string.ascii_letters) for x in range(chars_per_line))
[ "def", "random_line_data", "(", "chars_per_line", "=", "80", ")", ":", "return", "''", ".", "join", "(", "__random", ".", "choice", "(", "__string", ".", "ascii_letters", ")", "for", "x", "in", "range", "(", "chars_per_line", ")", ")" ]
Function to create a line of a random string Args: chars_per_line: An integer that says how many characters to return Returns: A String
[ "Function", "to", "create", "a", "line", "of", "a", "random", "string", "Args", ":", "chars_per_line", ":", "An", "integer", "that", "says", "how", "many", "characters", "to", "return" ]
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L462-L472
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
random_data
def random_data(line_count=1, chars_per_line=80): """ Function to creates lines of random string data Args: line_count: An integer that says how many lines to return chars_per_line: An integer that says how many characters per line to return Returns: A String """ divide...
python
def random_data(line_count=1, chars_per_line=80): """ Function to creates lines of random string data Args: line_count: An integer that says how many lines to return chars_per_line: An integer that says how many characters per line to return Returns: A String """ divide...
[ "def", "random_data", "(", "line_count", "=", "1", ",", "chars_per_line", "=", "80", ")", ":", "divide_lines", "=", "chars_per_line", "*", "line_count", "return", "'\\n'", ".", "join", "(", "random_line_data", "(", "chars_per_line", ")", "for", "x", "in", "r...
Function to creates lines of random string data Args: line_count: An integer that says how many lines to return chars_per_line: An integer that says how many characters per line to return Returns: A String
[ "Function", "to", "creates", "lines", "of", "random", "string", "data", "Args", ":", "line_count", ":", "An", "integer", "that", "says", "how", "many", "lines", "to", "return", "chars_per_line", ":", "An", "integer", "that", "says", "how", "many", "character...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L475-L487
btr1975/persistentdatatools
persistentdatatools/persistentdatatools.py
collect_and_zip_files
def collect_and_zip_files(dir_list, output_dir, zip_file_name, file_extension_list=None, file_name_list=None): """ Function to collect files and make a zip file :param dir_list: A list of directories :param output_dir: The output directory :param zip_file_name: Zip file name :param file_extensio...
python
def collect_and_zip_files(dir_list, output_dir, zip_file_name, file_extension_list=None, file_name_list=None): """ Function to collect files and make a zip file :param dir_list: A list of directories :param output_dir: The output directory :param zip_file_name: Zip file name :param file_extensio...
[ "def", "collect_and_zip_files", "(", "dir_list", ",", "output_dir", ",", "zip_file_name", ",", "file_extension_list", "=", "None", ",", "file_name_list", "=", "None", ")", ":", "temp_list", "=", "list", "(", ")", "if", "isinstance", "(", "dir_list", ",", "list...
Function to collect files and make a zip file :param dir_list: A list of directories :param output_dir: The output directory :param zip_file_name: Zip file name :param file_extension_list: A list of extensions of files to find :param file_name_list: A list of file names to find :return: ...
[ "Function", "to", "collect", "files", "and", "make", "a", "zip", "file", ":", "param", "dir_list", ":", "A", "list", "of", "directories", ":", "param", "output_dir", ":", "The", "output", "directory", ":", "param", "zip_file_name", ":", "Zip", "file", "nam...
train
https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L490-L569
baguette-io/baguette-messaging
farine/discovery.py
import_module
def import_module(module): """ | Given a module `service`, try to import it. | It will autodiscovers all the entrypoints | and add them in `ENTRYPOINTS`. :param module: The module's name to import. :type module: str :rtype: None :raises ImportError: When the service/module to start is n...
python
def import_module(module): """ | Given a module `service`, try to import it. | It will autodiscovers all the entrypoints | and add them in `ENTRYPOINTS`. :param module: The module's name to import. :type module: str :rtype: None :raises ImportError: When the service/module to start is n...
[ "def", "import_module", "(", "module", ")", ":", "try", ":", "__import__", "(", "'{0}.service'", ".", "format", "(", "module", ")", ")", "except", "ImportError", ":", "LOGGER", ".", "error", "(", "'No module/service found. Quit.'", ")", "sys", ".", "exit", "...
| Given a module `service`, try to import it. | It will autodiscovers all the entrypoints | and add them in `ENTRYPOINTS`. :param module: The module's name to import. :type module: str :rtype: None :raises ImportError: When the service/module to start is not found.
[ "|", "Given", "a", "module", "service", "try", "to", "import", "it", ".", "|", "It", "will", "autodiscovers", "all", "the", "entrypoints", "|", "and", "add", "them", "in", "ENTRYPOINTS", "." ]
train
https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/discovery.py#L19-L34
baguette-io/baguette-messaging
farine/discovery.py
import_models
def import_models(module): """ | Given a module `service`, try to import its models module. :param module: The module's name to import the models. :type module: str :rtype: list :returns: all the models defined. """ try: module = importlib.import_module('{0}.models'.format(modul...
python
def import_models(module): """ | Given a module `service`, try to import its models module. :param module: The module's name to import the models. :type module: str :rtype: list :returns: all the models defined. """ try: module = importlib.import_module('{0}.models'.format(modul...
[ "def", "import_models", "(", "module", ")", ":", "try", ":", "module", "=", "importlib", ".", "import_module", "(", "'{0}.models'", ".", "format", "(", "module", ")", ")", "except", "ImportError", ":", "return", "[", "]", "else", ":", "clsmembers", "=", ...
| Given a module `service`, try to import its models module. :param module: The module's name to import the models. :type module: str :rtype: list :returns: all the models defined.
[ "|", "Given", "a", "module", "service", "try", "to", "import", "its", "models", "module", "." ]
train
https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/discovery.py#L36-L51
baguette-io/baguette-messaging
farine/discovery.py
start
def start(): """ | Start all the registered entrypoints | that have been added to `ENTRYPOINTS`. :rtype: None """ pool = gevent.threadpool.ThreadPool(len(ENTRYPOINTS)) for entrypoint, callback, args, kwargs in ENTRYPOINTS: cname = callback.__name__ #1. Retrieve the class whi...
python
def start(): """ | Start all the registered entrypoints | that have been added to `ENTRYPOINTS`. :rtype: None """ pool = gevent.threadpool.ThreadPool(len(ENTRYPOINTS)) for entrypoint, callback, args, kwargs in ENTRYPOINTS: cname = callback.__name__ #1. Retrieve the class whi...
[ "def", "start", "(", ")", ":", "pool", "=", "gevent", ".", "threadpool", ".", "ThreadPool", "(", "len", "(", "ENTRYPOINTS", ")", ")", "for", "entrypoint", ",", "callback", ",", "args", ",", "kwargs", "in", "ENTRYPOINTS", ":", "cname", "=", "callback", ...
| Start all the registered entrypoints | that have been added to `ENTRYPOINTS`. :rtype: None
[ "|", "Start", "all", "the", "registered", "entrypoints", "|", "that", "have", "been", "added", "to", "ENTRYPOINTS", "." ]
train
https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/discovery.py#L53-L75
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.register_service
def register_service(cls, service): """Add a service to the thread's StackInABox instance. :param service: StackInABoxService instance to add to the test For return value and errors see StackInABox.register() """ logger.debug('Registering service {0}'.format(service.name)) ...
python
def register_service(cls, service): """Add a service to the thread's StackInABox instance. :param service: StackInABoxService instance to add to the test For return value and errors see StackInABox.register() """ logger.debug('Registering service {0}'.format(service.name)) ...
[ "def", "register_service", "(", "cls", ",", "service", ")", ":", "logger", ".", "debug", "(", "'Registering service {0}'", ".", "format", "(", "service", ".", "name", ")", ")", "return", "local_store", ".", "instance", ".", "register", "(", "service", ")" ]
Add a service to the thread's StackInABox instance. :param service: StackInABoxService instance to add to the test For return value and errors see StackInABox.register()
[ "Add", "a", "service", "to", "the", "thread", "s", "StackInABox", "instance", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L45-L54
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.call_into
def call_into(cls, method, request, uri, headers): """Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param h...
python
def call_into(cls, method, request, uri, headers): """Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param h...
[ "def", "call_into", "(", "cls", ",", "method", ",", "request", ",", "uri", ",", "headers", ")", ":", "logger", ".", "debug", "(", "'Request: {0} - {1}'", ".", "format", "(", "method", ",", "uri", ")", ")", "return", "local_store", ".", "instance", ".", ...
Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param headers: the return headers in a Case-Insensitive dict ...
[ "Make", "a", "call", "into", "the", "thread", "s", "StackInABox", "instance", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L57-L72
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.hold_onto
def hold_onto(cls, name, obj): """Add data into the a storage area provided by the framework. Note: The data is stored with the thread local instance. :param name: name of the data to be stored :param obj: data to be stored For return value and errors see StackInABox.into_hold...
python
def hold_onto(cls, name, obj): """Add data into the a storage area provided by the framework. Note: The data is stored with the thread local instance. :param name: name of the data to be stored :param obj: data to be stored For return value and errors see StackInABox.into_hold...
[ "def", "hold_onto", "(", "cls", ",", "name", ",", "obj", ")", ":", "logger", ".", "debug", "(", "'Holding on {0} of type {1} with id {2}'", ".", "format", "(", "name", ",", "type", "(", "obj", ")", ",", "id", "(", "obj", ")", ")", ")", "local_store", "...
Add data into the a storage area provided by the framework. Note: The data is stored with the thread local instance. :param name: name of the data to be stored :param obj: data to be stored For return value and errors see StackInABox.into_hold()
[ "Add", "data", "into", "the", "a", "storage", "area", "provided", "by", "the", "framework", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L75-L88
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.hold_out
def hold_out(cls, name): """Get data from the storage area provided by the framework. Note: The data is retrieved from the thread local instance. :param name: name of the data to be retrieved :returns: The data associated with the specified name. For errors see StackInABox.fr...
python
def hold_out(cls, name): """Get data from the storage area provided by the framework. Note: The data is retrieved from the thread local instance. :param name: name of the data to be retrieved :returns: The data associated with the specified name. For errors see StackInABox.fr...
[ "def", "hold_out", "(", "cls", ",", "name", ")", ":", "logger", ".", "debug", "(", "'Retreiving {0} from hold'", ".", "format", "(", "name", ")", ")", "obj", "=", "local_store", ".", "instance", ".", "from_hold", "(", "name", ")", "logger", ".", "debug",...
Get data from the storage area provided by the framework. Note: The data is retrieved from the thread local instance. :param name: name of the data to be retrieved :returns: The data associated with the specified name. For errors see StackInABox.from_hold()
[ "Get", "data", "from", "the", "storage", "area", "provided", "by", "the", "framework", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L91-L108
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.update_uri
def update_uri(cls, uri): """Set the URI of the StackInABox framework. :param uri: the base URI used to match the service. """ logger.debug('Request: Update URI to {0}'.format(uri)) local_store.instance.base_url = uri
python
def update_uri(cls, uri): """Set the URI of the StackInABox framework. :param uri: the base URI used to match the service. """ logger.debug('Request: Update URI to {0}'.format(uri)) local_store.instance.base_url = uri
[ "def", "update_uri", "(", "cls", ",", "uri", ")", ":", "logger", ".", "debug", "(", "'Request: Update URI to {0}'", ".", "format", "(", "uri", ")", ")", "local_store", ".", "instance", ".", "base_url", "=", "uri" ]
Set the URI of the StackInABox framework. :param uri: the base URI used to match the service.
[ "Set", "the", "URI", "of", "the", "StackInABox", "framework", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L111-L118
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.get_services_url
def get_services_url(url, base_url): """Get the URI from a given URL. :returns: URI within the URL """ length = len(base_url) checks = ['http://', 'https://'] for check in checks: if url.startswith(check): length = length + len(check) ...
python
def get_services_url(url, base_url): """Get the URI from a given URL. :returns: URI within the URL """ length = len(base_url) checks = ['http://', 'https://'] for check in checks: if url.startswith(check): length = length + len(check) ...
[ "def", "get_services_url", "(", "url", ",", "base_url", ")", ":", "length", "=", "len", "(", "base_url", ")", "checks", "=", "[", "'http://'", ",", "'https://'", "]", "for", "check", "in", "checks", ":", "if", "url", ".", "startswith", "(", "check", ")...
Get the URI from a given URL. :returns: URI within the URL
[ "Get", "the", "URI", "from", "a", "given", "URL", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L149-L165
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.base_url
def base_url(self, value): """Set the Base URL property, updating all associated services.""" logger.debug('StackInABox({0}): Updating URL from {1} to {2}' .format(self.__id, self.__base_url, value)) self.__base_url = value for k, v in six.iteritems(self.services): ...
python
def base_url(self, value): """Set the Base URL property, updating all associated services.""" logger.debug('StackInABox({0}): Updating URL from {1} to {2}' .format(self.__id, self.__base_url, value)) self.__base_url = value for k, v in six.iteritems(self.services): ...
[ "def", "base_url", "(", "self", ",", "value", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Updating URL from {1} to {2}'", ".", "format", "(", "self", ".", "__id", ",", "self", ".", "__base_url", ",", "value", ")", ")", "self", ".", "__base_url...
Set the Base URL property, updating all associated services.
[ "Set", "the", "Base", "URL", "property", "updating", "all", "associated", "services", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L173-L183
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.reset
def reset(self): """Reset StackInABox to a like-new state.""" logger.debug('StackInABox({0}): Resetting...' .format(self.__id)) for k, v in six.iteritems(self.services): matcher, service = v logger.debug('StackInABox({0}): Resetting Service {1}' ...
python
def reset(self): """Reset StackInABox to a like-new state.""" logger.debug('StackInABox({0}): Resetting...' .format(self.__id)) for k, v in six.iteritems(self.services): matcher, service = v logger.debug('StackInABox({0}): Resetting Service {1}' ...
[ "def", "reset", "(", "self", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Resetting...'", ".", "format", "(", "self", ".", "__id", ")", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "self", ".", "services", ")", ":", "m...
Reset StackInABox to a like-new state.
[ "Reset", "StackInABox", "to", "a", "like", "-", "new", "state", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L185-L199
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.register
def register(self, service): """Add a service to the thread's StackInABox instance. :param service: StackInABoxService instance to add to the test :returns: None :raises: ServiceAlreadyRegisteredError if the service already exists """ if service.name not in self.servic...
python
def register(self, service): """Add a service to the thread's StackInABox instance. :param service: StackInABoxService instance to add to the test :returns: None :raises: ServiceAlreadyRegisteredError if the service already exists """ if service.name not in self.servic...
[ "def", "register", "(", "self", ",", "service", ")", ":", "if", "service", ".", "name", "not", "in", "self", ".", "services", ".", "keys", "(", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Registering Service {1}'", ".", "format", "(", "self"...
Add a service to the thread's StackInABox instance. :param service: StackInABoxService instance to add to the test :returns: None :raises: ServiceAlreadyRegisteredError if the service already exists
[ "Add", "a", "service", "to", "the", "thread", "s", "StackInABox", "instance", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L201-L224
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.call
def call(self, method, request, uri, headers): """Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param heade...
python
def call(self, method, request, uri, headers): """Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param heade...
[ "def", "call", "(", "self", ",", "method", ",", "request", ",", "uri", ",", "headers", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Received call to {1} - {2}'", ".", "format", "(", "self", ".", "__id", ",", "method", ",", "uri", ")", ")", ...
Make a call into the thread's StackInABox instance. :param method: HTTP Method (e.g GET, POST) :param request: a Request object containing the request data :param uri: the URI of the request submitted with the method :param headers: the return headers in a Case-Insensitive dict ...
[ "Make", "a", "call", "into", "the", "thread", "s", "StackInABox", "instance", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L226-L268
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.into_hold
def into_hold(self, name, obj): """Add data into the a storage area provided by the framework. Note: The data is stored with the thread local instance. :param name: name of the data to be stored :param obj: data to be stored :returns: N/A :raises: N/A """ ...
python
def into_hold(self, name, obj): """Add data into the a storage area provided by the framework. Note: The data is stored with the thread local instance. :param name: name of the data to be stored :param obj: data to be stored :returns: N/A :raises: N/A """ ...
[ "def", "into_hold", "(", "self", ",", "name", ",", "obj", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Holding onto {1} of type {2} '", "'with id {3}'", ".", "format", "(", "self", ".", "__id", ",", "name", ",", "type", "(", "obj", ")", ",", ...
Add data into the a storage area provided by the framework. Note: The data is stored with the thread local instance. :param name: name of the data to be stored :param obj: data to be stored :returns: N/A :raises: N/A
[ "Add", "data", "into", "the", "a", "storage", "area", "provided", "by", "the", "framework", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L270-L285
TestInABox/stackInABox
stackinabox/stack.py
StackInABox.from_hold
def from_hold(self, name): """Get data from the storage area provided by the framework. Note: The data is retrieved from the thread local instance. :param name: name of the data to be retrieved :returns: The data associated with the specified name. :raises: Lookup/KeyError err...
python
def from_hold(self, name): """Get data from the storage area provided by the framework. Note: The data is retrieved from the thread local instance. :param name: name of the data to be retrieved :returns: The data associated with the specified name. :raises: Lookup/KeyError err...
[ "def", "from_hold", "(", "self", ",", "name", ")", ":", "logger", ".", "debug", "(", "'StackInABox({0}): Retreiving {1} from the hold'", ".", "format", "(", "self", ".", "__id", ",", "name", ")", ")", "obj", "=", "self", ".", "holds", "[", "name", "]", "...
Get data from the storage area provided by the framework. Note: The data is retrieved from the thread local instance. :param name: name of the data to be retrieved :returns: The data associated with the specified name. :raises: Lookup/KeyError error if the name does not match ...
[ "Get", "data", "from", "the", "storage", "area", "provided", "by", "the", "framework", "." ]
train
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/stack.py#L287-L305
baguette-io/baguette-messaging
farine/mixins.py
EntryPointMixin.main_callback
def main_callback(self, *args, **kwargs): """ Main callback called when an event is received from an entry point. :returns: The entry point's callback. :rtype: function :raises NotImplementedError: When the entrypoint doesn't have the required attributes. """ if ...
python
def main_callback(self, *args, **kwargs): """ Main callback called when an event is received from an entry point. :returns: The entry point's callback. :rtype: function :raises NotImplementedError: When the entrypoint doesn't have the required attributes. """ if ...
[ "def", "main_callback", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "callback", ":", "raise", "NotImplementedError", "(", "'Entrypoints must declare `callback`'", ")", "if", "not", "self", ".", "settings", ":",...
Main callback called when an event is received from an entry point. :returns: The entry point's callback. :rtype: function :raises NotImplementedError: When the entrypoint doesn't have the required attributes.
[ "Main", "callback", "called", "when", "an", "event", "is", "received", "from", "an", "entry", "point", "." ]
train
https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/mixins.py#L20-L40
baguette-io/baguette-messaging
farine/mixins.py
EntryPointMixin.database
def database(self): """ Before the callback is called, initialize the database if needed. :rtype: None """ #1. Initialize self.callback.im_self.db = sql.setup(self.settings) if self.callback.im_self.db: module = '.'.join(self.callback.im_self.__module_...
python
def database(self): """ Before the callback is called, initialize the database if needed. :rtype: None """ #1. Initialize self.callback.im_self.db = sql.setup(self.settings) if self.callback.im_self.db: module = '.'.join(self.callback.im_self.__module_...
[ "def", "database", "(", "self", ")", ":", "#1. Initialize", "self", ".", "callback", ".", "im_self", ".", "db", "=", "sql", ".", "setup", "(", "self", ".", "settings", ")", "if", "self", ".", "callback", ".", "im_self", ".", "db", ":", "module", "=",...
Before the callback is called, initialize the database if needed. :rtype: None
[ "Before", "the", "callback", "is", "called", "initialize", "the", "database", "if", "needed", ".", ":", "rtype", ":", "None" ]
train
https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/mixins.py#L50-L64
fredericklussier/Lifepo4weredPy
lifepo4weredPy/functions.py
canRead
def canRead(variable): """ mention if an element can be read. :param variable: the element to evaluate. :type variable: Lifepo4weredEnum :return: true when read access is available, otherwise false. :rtype: bool :raises ValueError: if parameter value is not a member of Lifepo4weredEnum. ...
python
def canRead(variable): """ mention if an element can be read. :param variable: the element to evaluate. :type variable: Lifepo4weredEnum :return: true when read access is available, otherwise false. :rtype: bool :raises ValueError: if parameter value is not a member of Lifepo4weredEnum. ...
[ "def", "canRead", "(", "variable", ")", ":", "if", "variable", "not", "in", "variablesEnum", ":", "raise", "ValueError", "(", "'Use a lifepo4wered enum element as parameter.'", ")", "return", "lifepo4weredSO", ".", "access_lifepo4wered", "(", "variable", ".", "value",...
mention if an element can be read. :param variable: the element to evaluate. :type variable: Lifepo4weredEnum :return: true when read access is available, otherwise false. :rtype: bool :raises ValueError: if parameter value is not a member of Lifepo4weredEnum.
[ "mention", "if", "an", "element", "can", "be", "read", "." ]
train
https://github.com/fredericklussier/Lifepo4weredPy/blob/f5b3fedf896d0d616bf5ae603953e5541d493640/lifepo4weredPy/functions.py#L12-L25
fredericklussier/Lifepo4weredPy
lifepo4weredPy/functions.py
canWrite
def canWrite(variable): """ mention if an element can be written. :param variable: the element to evaluate. :type variable: Lifepo4weredEnum :return: true when write access is available, otherwise false :rtype: bool :raises ValueError: if parameter value is not a member of Lifepo4weredEnum ...
python
def canWrite(variable): """ mention if an element can be written. :param variable: the element to evaluate. :type variable: Lifepo4weredEnum :return: true when write access is available, otherwise false :rtype: bool :raises ValueError: if parameter value is not a member of Lifepo4weredEnum ...
[ "def", "canWrite", "(", "variable", ")", ":", "if", "variable", "not", "in", "variablesEnum", ":", "raise", "ValueError", "(", "'Use a lifepo4wered enum element as parameter.'", ")", "return", "lifepo4weredSO", ".", "access_lifepo4wered", "(", "variable", ".", "value"...
mention if an element can be written. :param variable: the element to evaluate. :type variable: Lifepo4weredEnum :return: true when write access is available, otherwise false :rtype: bool :raises ValueError: if parameter value is not a member of Lifepo4weredEnum
[ "mention", "if", "an", "element", "can", "be", "written", "." ]
train
https://github.com/fredericklussier/Lifepo4weredPy/blob/f5b3fedf896d0d616bf5ae603953e5541d493640/lifepo4weredPy/functions.py#L27-L40
fredericklussier/Lifepo4weredPy
lifepo4weredPy/functions.py
read
def read(variable): """ read an element from LiFePO4wered. :param variable: the element to read. :type variable: Lifepo4weredEnum :return: the value of the element :rtype: int :raises ValueError: if parameter value is not a member of Lifepo4weredEnum """ if variable not in variables...
python
def read(variable): """ read an element from LiFePO4wered. :param variable: the element to read. :type variable: Lifepo4weredEnum :return: the value of the element :rtype: int :raises ValueError: if parameter value is not a member of Lifepo4weredEnum """ if variable not in variables...
[ "def", "read", "(", "variable", ")", ":", "if", "variable", "not", "in", "variablesEnum", ":", "raise", "ValueError", "(", "'Use a lifepo4wered enum element as read parameter.'", ")", "if", "canRead", "(", "variable", ")", ":", "return", "lifepo4weredSO", ".", "re...
read an element from LiFePO4wered. :param variable: the element to read. :type variable: Lifepo4weredEnum :return: the value of the element :rtype: int :raises ValueError: if parameter value is not a member of Lifepo4weredEnum
[ "read", "an", "element", "from", "LiFePO4wered", "." ]
train
https://github.com/fredericklussier/Lifepo4weredPy/blob/f5b3fedf896d0d616bf5ae603953e5541d493640/lifepo4weredPy/functions.py#L42-L58
fredericklussier/Lifepo4weredPy
lifepo4weredPy/functions.py
write
def write(variable, value): """ write an element to LiFePO4wered. :param variable: the element. :type variable: Lifepo4weredEnum :param int value: the value to write. :return: the written value :rtype: int :raises ValueError: if variable parameter is not a member of Lifepo4weredEnum ...
python
def write(variable, value): """ write an element to LiFePO4wered. :param variable: the element. :type variable: Lifepo4weredEnum :param int value: the value to write. :return: the written value :rtype: int :raises ValueError: if variable parameter is not a member of Lifepo4weredEnum ...
[ "def", "write", "(", "variable", ",", "value", ")", ":", "if", "variable", "not", "in", "variablesEnum", ":", "raise", "ValueError", "(", "'Use a lifepo4wered enum element as write element.'", ")", "if", "isinstance", "(", "value", ",", "int", ")", "is", "False"...
write an element to LiFePO4wered. :param variable: the element. :type variable: Lifepo4weredEnum :param int value: the value to write. :return: the written value :rtype: int :raises ValueError: if variable parameter is not a member of Lifepo4weredEnum :raises ValueError: if value is not an ...
[ "write", "an", "element", "to", "LiFePO4wered", "." ]
train
https://github.com/fredericklussier/Lifepo4weredPy/blob/f5b3fedf896d0d616bf5ae603953e5541d493640/lifepo4weredPy/functions.py#L60-L81
majerteam/sqla_inspect
sqla_inspect/ascii.py
force_ascii
def force_ascii(value): """ Return enforced ascii string éko=>ko """ if not isinstance(value, (str, unicode)): return unicode(value) if isinstance(value, unicode): return unidecode.unidecode(value) else: return unidecode.unidecode(force_unicode(value))
python
def force_ascii(value): """ Return enforced ascii string éko=>ko """ if not isinstance(value, (str, unicode)): return unicode(value) if isinstance(value, unicode): return unidecode.unidecode(value) else: return unidecode.unidecode(force_unicode(value))
[ "def", "force_ascii", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", ":", "return", "unicode", "(", "value", ")", "if", "isinstance", "(", "value", ",", "unicode", ")", ":", "return", "unid...
Return enforced ascii string éko=>ko
[ "Return", "enforced", "ascii", "string", "éko", "=", ">", "ko" ]
train
https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/ascii.py#L15-L25
majerteam/sqla_inspect
sqla_inspect/ascii.py
force_encoding
def force_encoding(value, encoding='utf-8'): """ Return a string encoded in the provided encoding """ if not isinstance(value, (str, unicode)): value = str(value) if isinstance(value, unicode): value = value.encode(encoding) elif encoding != 'utf-8': value = value.decode(...
python
def force_encoding(value, encoding='utf-8'): """ Return a string encoded in the provided encoding """ if not isinstance(value, (str, unicode)): value = str(value) if isinstance(value, unicode): value = value.encode(encoding) elif encoding != 'utf-8': value = value.decode(...
[ "def", "force_encoding", "(", "value", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", ":", "value", "=", "str", "(", "value", ")", "if", "isinstance", "(", "value", ",", ...
Return a string encoded in the provided encoding
[ "Return", "a", "string", "encoded", "in", "the", "provided", "encoding" ]
train
https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/ascii.py#L35-L45
majerteam/sqla_inspect
sqla_inspect/ascii.py
force_unicode
def force_unicode(value): """ return an utf-8 unicode entry """ if not isinstance(value, (str, unicode)): value = unicode(value) if isinstance(value, str): value = value.decode('utf-8') return value
python
def force_unicode(value): """ return an utf-8 unicode entry """ if not isinstance(value, (str, unicode)): value = unicode(value) if isinstance(value, str): value = value.decode('utf-8') return value
[ "def", "force_unicode", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", ":", "value", "=", "unicode", "(", "value", ")", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=...
return an utf-8 unicode entry
[ "return", "an", "utf", "-", "8", "unicode", "entry" ]
train
https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/ascii.py#L48-L56
majerteam/sqla_inspect
sqla_inspect/ascii.py
camel_case_to_name
def camel_case_to_name(name): """ Used to convert a classname to a lowercase name """ def convert_func(val): return "_" + val.group(0).lower() return name[0].lower() + re.sub(r'([A-Z])', convert_func, name[1:])
python
def camel_case_to_name(name): """ Used to convert a classname to a lowercase name """ def convert_func(val): return "_" + val.group(0).lower() return name[0].lower() + re.sub(r'([A-Z])', convert_func, name[1:])
[ "def", "camel_case_to_name", "(", "name", ")", ":", "def", "convert_func", "(", "val", ")", ":", "return", "\"_\"", "+", "val", ".", "group", "(", "0", ")", ".", "lower", "(", ")", "return", "name", "[", "0", "]", ".", "lower", "(", ")", "+", "re...
Used to convert a classname to a lowercase name
[ "Used", "to", "convert", "a", "classname", "to", "a", "lowercase", "name" ]
train
https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/ascii.py#L59-L65
majerteam/sqla_inspect
sqla_inspect/ascii.py
to_utf8
def to_utf8(datas): """ Force utf8 string entries in the given datas """ res = datas if isinstance(datas, dict): res = {} for key, value in datas.items(): key = to_utf8(key) value = to_utf8(value) res[key] = value elif isinstance(datas, (list,...
python
def to_utf8(datas): """ Force utf8 string entries in the given datas """ res = datas if isinstance(datas, dict): res = {} for key, value in datas.items(): key = to_utf8(key) value = to_utf8(value) res[key] = value elif isinstance(datas, (list,...
[ "def", "to_utf8", "(", "datas", ")", ":", "res", "=", "datas", "if", "isinstance", "(", "datas", ",", "dict", ")", ":", "res", "=", "{", "}", "for", "key", ",", "value", "in", "datas", ".", "items", "(", ")", ":", "key", "=", "to_utf8", "(", "k...
Force utf8 string entries in the given datas
[ "Force", "utf8", "string", "entries", "in", "the", "given", "datas" ]
train
https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/ascii.py#L86-L106
baszoetekouw/janus-py
sr/sr.py
ServiceRegistry.list
def list(self, entityid=None): """ Return the entity with the given entity ID in short form. If no entity ID is given, all records are listed. It returns a dictionary of the form: {eid : {'id' : 'isActive' : 'name' : 'revisionNr' : 'state' : 'type' : }} """ params = {} if ent...
python
def list(self, entityid=None): """ Return the entity with the given entity ID in short form. If no entity ID is given, all records are listed. It returns a dictionary of the form: {eid : {'id' : 'isActive' : 'name' : 'revisionNr' : 'state' : 'type' : }} """ params = {} if ent...
[ "def", "list", "(", "self", ",", "entityid", "=", "None", ")", ":", "params", "=", "{", "}", "if", "entityid", ":", "params", "[", "'name'", "]", "=", "entityid", "data", "=", "self", ".", "_http_req", "(", "'connections'", ",", "params", "=", "param...
Return the entity with the given entity ID in short form. If no entity ID is given, all records are listed. It returns a dictionary of the form: {eid : {'id' : 'isActive' : 'name' : 'revisionNr' : 'state' : 'type' : }}
[ "Return", "the", "entity", "with", "the", "given", "entity", "ID", "in", "short", "form", ".", "If", "no", "entity", "ID", "is", "given", "all", "records", "are", "listed", ".", "It", "returns", "a", "dictionary", "of", "the", "form", ":", "{", "eid", ...
train
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L105-L129
baszoetekouw/janus-py
sr/sr.py
ServiceRegistry.list_full
def list_full(self, state): """ Retrieves the complete entity data of all records that are active and have the supplied state. States: 'prodaccepted': it is in the production environment 'testaccepted': it is in the test environment, used for testing, acceptation or development """ enti...
python
def list_full(self, state): """ Retrieves the complete entity data of all records that are active and have the supplied state. States: 'prodaccepted': it is in the production environment 'testaccepted': it is in the test environment, used for testing, acceptation or development """ enti...
[ "def", "list_full", "(", "self", ",", "state", ")", ":", "entities", "=", "self", ".", "list", "(", ")", "selected", "=", "{", "}", "for", "eid", ",", "entity", "in", "entities", ".", "items", "(", ")", ":", "if", "entity", "[", "'isActive'", "]", ...
Retrieves the complete entity data of all records that are active and have the supplied state. States: 'prodaccepted': it is in the production environment 'testaccepted': it is in the test environment, used for testing, acceptation or development
[ "Retrieves", "the", "complete", "entity", "data", "of", "all", "records", "that", "are", "active", "and", "have", "the", "supplied", "state", ".", "States", ":", "prodaccepted", ":", "it", "is", "in", "the", "production", "environment", "testaccepted", ":", ...
train
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L131-L147
baszoetekouw/janus-py
sr/sr.py
ServiceRegistry.list_eids
def list_eids(self): """ Returns a list of all known eids """ entities = self.list() return sorted([int(eid) for eid in entities])
python
def list_eids(self): """ Returns a list of all known eids """ entities = self.list() return sorted([int(eid) for eid in entities])
[ "def", "list_eids", "(", "self", ")", ":", "entities", "=", "self", ".", "list", "(", ")", "return", "sorted", "(", "[", "int", "(", "eid", ")", "for", "eid", "in", "entities", "]", ")" ]
Returns a list of all known eids
[ "Returns", "a", "list", "of", "all", "known", "eids" ]
train
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L150-L155
baszoetekouw/janus-py
sr/sr.py
ServiceRegistry.get_by_entityid
def get_by_entityid(self, entityid): """ Returns the entity with the given entity ID as a dict """ data = self.list(entityid=entityid) if len(data) == 0: return None eid = int( next(iter(data)) ) entity = self.get(eid) self.debug(0x01,entity) return entity
python
def get_by_entityid(self, entityid): """ Returns the entity with the given entity ID as a dict """ data = self.list(entityid=entityid) if len(data) == 0: return None eid = int( next(iter(data)) ) entity = self.get(eid) self.debug(0x01,entity) return entity
[ "def", "get_by_entityid", "(", "self", ",", "entityid", ")", ":", "data", "=", "self", ".", "list", "(", "entityid", "=", "entityid", ")", "if", "len", "(", "data", ")", "==", "0", ":", "return", "None", "eid", "=", "int", "(", "next", "(", "iter",...
Returns the entity with the given entity ID as a dict
[ "Returns", "the", "entity", "with", "the", "given", "entity", "ID", "as", "a", "dict" ]
train
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L157-L169
baszoetekouw/janus-py
sr/sr.py
ServiceRegistry.get
def get(self, eid): """ Returns a dict with the complete record of the entity with the given eID """ data = self._http_req('connections/%u' % eid) self.debug(0x01, data['decoded']) return data['decoded']
python
def get(self, eid): """ Returns a dict with the complete record of the entity with the given eID """ data = self._http_req('connections/%u' % eid) self.debug(0x01, data['decoded']) return data['decoded']
[ "def", "get", "(", "self", ",", "eid", ")", ":", "data", "=", "self", ".", "_http_req", "(", "'connections/%u'", "%", "eid", ")", "self", ".", "debug", "(", "0x01", ",", "data", "[", "'decoded'", "]", ")", "return", "data", "[", "'decoded'", "]" ]
Returns a dict with the complete record of the entity with the given eID
[ "Returns", "a", "dict", "with", "the", "complete", "record", "of", "the", "entity", "with", "the", "given", "eID" ]
train
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L171-L177
baszoetekouw/janus-py
sr/sr.py
ServiceRegistry.replace
def replace(self, eid, entity, note=None, force=False): """ replace(int, dict, string, boolean): Replaces the record of the eid with the supplied dict. Places the supplied note as update message. """ # we need to unset some fields in the entity, if they exist newentity = entity for field in ('create...
python
def replace(self, eid, entity, note=None, force=False): """ replace(int, dict, string, boolean): Replaces the record of the eid with the supplied dict. Places the supplied note as update message. """ # we need to unset some fields in the entity, if they exist newentity = entity for field in ('create...
[ "def", "replace", "(", "self", ",", "eid", ",", "entity", ",", "note", "=", "None", ",", "force", "=", "False", ")", ":", "# we need to unset some fields in the entity, if they exist", "newentity", "=", "entity", "for", "field", "in", "(", "'createdAtDate'", ","...
replace(int, dict, string, boolean): Replaces the record of the eid with the supplied dict. Places the supplied note as update message.
[ "replace", "(", "int", "dict", "string", "boolean", ")", ":", "Replaces", "the", "record", "of", "the", "eid", "with", "the", "supplied", "dict", ".", "Places", "the", "supplied", "note", "as", "update", "message", "." ]
train
https://github.com/baszoetekouw/janus-py/blob/4f2034436eef010ec8d77e168f6198123b5eb226/sr/sr.py#L179-L207