hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
⌀
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
99daf7984c25da100fbd2437403380ef4e653380
lyubadimitrova/dfoseq2seq
dfo.py
[ "MIT" ]
Python
_prep_model
null
def _prep_model(self): """ Builds and initialized the model as described in the configuration. The model can be initialized randomly or from a checkpoint. In addition, pre-trained embeddings can loaded from a different checkpoint. See configs/example.yaml for more info. """ ...
Builds and initialized the model as described in the configuration. The model can be initialized randomly or from a checkpoint. In addition, pre-trained embeddings can loaded from a different checkpoint. See configs/example.yaml for more info.
Builds and initialized the model as described in the configuration. The model can be initialized randomly or from a checkpoint. In addition, pre-trained embeddings can loaded from a different checkpoint. See configs/example.yaml for more info.
[ "Builds", "and", "initialized", "the", "model", "as", "described", "in", "the", "configuration", ".", "The", "model", "can", "be", "initialized", "randomly", "or", "from", "a", "checkpoint", ".", "In", "addition", "pre", "-", "trained", "embeddings", "can", ...
def _prep_model(self): self.model = build_model(self.model_cfg, src_vocab=self.src_vocab, trg_vocab=self.trg_vocab) self.logger.info('Model loaded.') if self.train_cfg.get('start', False): self.model_start = load_checkpoint(path=self.train_cfg['start'], use_cuda=self.use_cuda) ...
[ "def", "_prep_model", "(", "self", ")", ":", "self", ".", "model", "=", "build_model", "(", "self", ".", "model_cfg", ",", "src_vocab", "=", "self", ".", "src_vocab", ",", "trg_vocab", "=", "self", ".", "trg_vocab", ")", "self", ".", "logger", ".", "in...
Builds and initialized the model as described in the configuration.
[ "Builds", "and", "initialized", "the", "model", "as", "described", "in", "the", "configuration", "." ]
[ "\"\"\"\n Builds and initialized the model as described in the configuration.\n The model can be initialized randomly or from a checkpoint. In addition, pre-trained embeddings can\n loaded from a different checkpoint. See configs/example.yaml for more info.\n \"\"\"", "# initialize mod...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99daf7984c25da100fbd2437403380ef4e653380
lyubadimitrova/dfoseq2seq
dfo.py
[ "MIT" ]
Python
_prep_data
null
def _prep_data(self): """ Loads train/dev/test data and initializes the training data iterator. """ self.train_data, self.dev_data, self.test_data, self.src_vocab, self.trg_vocab = load_data(data_cfg=self.data_cfg) self.train_iter = data.BucketIterator(repeat=True, sort=False, d...
Loads train/dev/test data and initializes the training data iterator.
Loads train/dev/test data and initializes the training data iterator.
[ "Loads", "train", "/", "dev", "/", "test", "data", "and", "initializes", "the", "training", "data", "iterator", "." ]
def _prep_data(self): self.train_data, self.dev_data, self.test_data, self.src_vocab, self.trg_vocab = load_data(data_cfg=self.data_cfg) self.train_iter = data.BucketIterator(repeat=True, sort=False, dataset=self.train_data, batch_size=self.train_cfg['batch_size'], ...
[ "def", "_prep_data", "(", "self", ")", ":", "self", ".", "train_data", ",", "self", ".", "dev_data", ",", "self", ".", "test_data", ",", "self", ".", "src_vocab", ",", "self", ".", "trg_vocab", "=", "load_data", "(", "data_cfg", "=", "self", ".", "data...
Loads train/dev/test data and initializes the training data iterator.
[ "Loads", "train", "/", "dev", "/", "test", "data", "and", "initializes", "the", "training", "data", "iterator", "." ]
[ "\"\"\"\n Loads train/dev/test data and initializes the training data iterator.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99daf7984c25da100fbd2437403380ef4e653380
lyubadimitrova/dfoseq2seq
dfo.py
[ "MIT" ]
Python
_prep_dfo
null
def _prep_dfo(self): """ Configures the DFO training process. """ self.theta = torch.nn.utils.parameters_to_vector(self.model.parameters()) self.dim = len(self.theta) self.num_expl_directions = self.train_cfg['num_expl_directions'] self.structured = self.train_c...
Configures the DFO training process.
Configures the DFO training process.
[ "Configures", "the", "DFO", "training", "process", "." ]
def _prep_dfo(self): self.theta = torch.nn.utils.parameters_to_vector(self.model.parameters()) self.dim = len(self.theta) self.num_expl_directions = self.train_cfg['num_expl_directions'] self.structured = self.train_cfg.get('structured', False) self.step_opt_type = self.train_cfg...
[ "def", "_prep_dfo", "(", "self", ")", ":", "self", ".", "theta", "=", "torch", ".", "nn", ".", "utils", ".", "parameters_to_vector", "(", "self", ".", "model", ".", "parameters", "(", ")", ")", "self", ".", "dim", "=", "len", "(", "self", ".", "the...
Configures the DFO training process.
[ "Configures", "the", "DFO", "training", "process", "." ]
[ "\"\"\"\n Configures the DFO training process. \n \"\"\"", "# if we're retraining or continuing from a DFO checkpoint, overwrite config ", "# inform user about parallelization settings" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99daf7984c25da100fbd2437403380ef4e653380
lyubadimitrova/dfoseq2seq
dfo.py
[ "MIT" ]
Python
train_and_validate
<not_specific>
def train_and_validate(self): """ Governs the actual training. :return list valid_rewards: The obtained validation rewards. :return list params_over_time: Contains every iteration's theta. :return list gradients: Contains the gradients computed in every iteration. :retur...
Governs the actual training. :return list valid_rewards: The obtained validation rewards. :return list params_over_time: Contains every iteration's theta. :return list gradients: Contains the gradients computed in every iteration. :return list update_steps: Contains the update ...
Governs the actual training. :return list valid_rewards: The obtained validation rewards. :return list params_over_time: Contains every iteration's theta. :return list gradients: Contains the gradients computed in every iteration. :return list update_steps: Contains the update steps taken every iteration.
[ "Governs", "the", "actual", "training", ".", ":", "return", "list", "valid_rewards", ":", "The", "obtained", "validation", "rewards", ".", ":", "return", "list", "params_over_time", ":", "Contains", "every", "iteration", "'", "s", "theta", ".", ":", "return", ...
def train_and_validate(self): self._prep_data() self._prep_model() self._prep_dfo() self.valid_freq = self.train_cfg['validation_freq'] best_valid_score = 0.0 params_over_time = [self.theta.clone()] valid_rewards = [] gradients = [] update_steps = ...
[ "def", "train_and_validate", "(", "self", ")", ":", "self", ".", "_prep_data", "(", ")", "self", ".", "_prep_model", "(", ")", "self", ".", "_prep_dfo", "(", ")", "self", ".", "valid_freq", "=", "self", ".", "train_cfg", "[", "'validation_freq'", "]", "b...
Governs the actual training.
[ "Governs", "the", "actual", "training", "." ]
[ "\"\"\"\n Governs the actual training.\n\n :return list valid_rewards: The obtained validation rewards.\n :return list params_over_time: Contains every iteration's theta.\n :return list gradients: Contains the gradients computed in every iteration.\n :return list update_steps: Con...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99daf7984c25da100fbd2437403380ef4e653380
lyubadimitrova/dfoseq2seq
dfo.py
[ "MIT" ]
Python
collect_rewards
<not_specific>
def collect_rewards(self, expl_directions): """ Governs the reward function evaluations. :param expl_directions: The noise vector added to theta to create candidates theta +- sigma*expl_direction :return torch.DoubleTensor: the collected rewards """ # generates...
Governs the reward function evaluations. :param expl_directions: The noise vector added to theta to create candidates theta +- sigma*expl_direction :return torch.DoubleTensor: the collected rewards
Governs the reward function evaluations.
[ "Governs", "the", "reward", "function", "evaluations", "." ]
def collect_rewards(self, expl_directions): candidates = self.grad_estimator.get_theta_candidates(self.theta, self.sigma, expl_directions) if self.parallel_func_evals: with concurrent.futures.ThreadPoolExecutor(max_workers=self.num_workers) as executor...
[ "def", "collect_rewards", "(", "self", ",", "expl_directions", ")", ":", "candidates", "=", "self", ".", "grad_estimator", ".", "get_theta_candidates", "(", "self", ".", "theta", ",", "self", ".", "sigma", ",", "expl_directions", ")", "if", "self", ".", "par...
Governs the reward function evaluations.
[ "Governs", "the", "reward", "function", "evaluations", "." ]
[ "\"\"\"\n Governs the reward function evaluations. \n\n :param expl_directions: The noise vector added to theta to create candidates theta +- sigma*expl_direction\n :return torch.DoubleTensor: the collected rewards\n \"\"\"", "# generates the candidates; this is specific to the gradien...
[ { "param": "self", "type": null }, { "param": "expl_directions", "type": null } ]
{ "returns": [ { "docstring": "the collected rewards", "docstring_tokens": [ "the", "collected", "rewards" ], "type": "torch.DoubleTensor" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "...
99daf7984c25da100fbd2437403380ef4e653380
lyubadimitrova/dfoseq2seq
dfo.py
[ "MIT" ]
Python
save_checkpoint
null
def save_checkpoint(self, iteration): """ Saves a DFO checkpoint. This includes the weights, sigma, and the optimizer. """ # update the model to match theta torch.nn.utils.vector_to_parameters(self.theta, self.model.parameters()) state = { "model_state": sel...
Saves a DFO checkpoint. This includes the weights, sigma, and the optimizer.
Saves a DFO checkpoint. This includes the weights, sigma, and the optimizer.
[ "Saves", "a", "DFO", "checkpoint", ".", "This", "includes", "the", "weights", "sigma", "and", "the", "optimizer", "." ]
def save_checkpoint(self, iteration): torch.nn.utils.vector_to_parameters(self.theta, self.model.parameters()) state = { "model_state": self.model.state_dict(), "sigma": self.sigma, "step_opt_type": self.step_opt_type, "step_opt_params": self.step_opt.get_...
[ "def", "save_checkpoint", "(", "self", ",", "iteration", ")", ":", "torch", ".", "nn", ".", "utils", ".", "vector_to_parameters", "(", "self", ".", "theta", ",", "self", ".", "model", ".", "parameters", "(", ")", ")", "state", "=", "{", "\"model_state\""...
Saves a DFO checkpoint.
[ "Saves", "a", "DFO", "checkpoint", "." ]
[ "\"\"\"\n Saves a DFO checkpoint. This includes the weights, sigma, and the optimizer.\n \"\"\"", "# update the model to match theta" ]
[ { "param": "self", "type": null }, { "param": "iteration", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "iteration", "type": null, "docstring": null, "docstring_token...
a932132a7b5cdb5f07bc8e2e95e3d8a1b404d092
lyubadimitrova/dfoseq2seq
scripts/grad_estimators.py
[ "MIT" ]
Python
normalizer
<not_specific>
def normalizer(self, array): """ Returns a normalizing number, either the standard deviation of the array, or sigma. :param array: An array to calculate the standard deviation of. Redundant if using sigma scaling. """ if self.norm_type == 'stdev': stdev = array.std()...
Returns a normalizing number, either the standard deviation of the array, or sigma. :param array: An array to calculate the standard deviation of. Redundant if using sigma scaling.
Returns a normalizing number, either the standard deviation of the array, or sigma.
[ "Returns", "a", "normalizing", "number", "either", "the", "standard", "deviation", "of", "the", "array", "or", "sigma", "." ]
def normalizer(self, array): if self.norm_type == 'stdev': stdev = array.std() self.rewards_stdev.append(stdev) return stdev return self.sigma
[ "def", "normalizer", "(", "self", ",", "array", ")", ":", "if", "self", ".", "norm_type", "==", "'stdev'", ":", "stdev", "=", "array", ".", "std", "(", ")", "self", ".", "rewards_stdev", ".", "append", "(", "stdev", ")", "return", "stdev", "return", ...
Returns a normalizing number, either the standard deviation of the array, or sigma.
[ "Returns", "a", "normalizing", "number", "either", "the", "standard", "deviation", "of", "the", "array", "or", "sigma", "." ]
[ "\"\"\"\n Returns a normalizing number, either the standard deviation of the array, or sigma.\n\n :param array: An array to calculate the standard deviation of. Redundant if using sigma scaling.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "array", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "array", "type": null, "docstring": "An array to calculate the stand...
a932132a7b5cdb5f07bc8e2e95e3d8a1b404d092
lyubadimitrova/dfoseq2seq
scripts/grad_estimators.py
[ "MIT" ]
Python
estimate_grad_vanilla
<not_specific>
def estimate_grad_vanilla(self, expl_directions, rewards): """ Standard REINFORCE gradient estimator, with optional scaling by the stdev of the rewards. :param expl_directions: The set of perturbations. :param rewards_pos: Rewards obtained from perturbed models. rewards_pos[i] is the re...
Standard REINFORCE gradient estimator, with optional scaling by the stdev of the rewards. :param expl_directions: The set of perturbations. :param rewards_pos: Rewards obtained from perturbed models. rewards_pos[i] is the rewards of the model perturbed with expl_di...
Standard REINFORCE gradient estimator, with optional scaling by the stdev of the rewards.
[ "Standard", "REINFORCE", "gradient", "estimator", "with", "optional", "scaling", "by", "the", "stdev", "of", "the", "rewards", "." ]
def estimate_grad_vanilla(self, expl_directions, rewards): if self.use_only_best: sort_idx = torch.argsort(rewards, descending=True) rewards = rewards[sort_idx][:self.use_only_best] expl_directions = expl_directions[sort_idx][self.use_only_best] return rewards @ expl_...
[ "def", "estimate_grad_vanilla", "(", "self", ",", "expl_directions", ",", "rewards", ")", ":", "if", "self", ".", "use_only_best", ":", "sort_idx", "=", "torch", ".", "argsort", "(", "rewards", ",", "descending", "=", "True", ")", "rewards", "=", "rewards", ...
Standard REINFORCE gradient estimator, with optional scaling by the stdev of the rewards.
[ "Standard", "REINFORCE", "gradient", "estimator", "with", "optional", "scaling", "by", "the", "stdev", "of", "the", "rewards", "." ]
[ "\"\"\"\n Standard REINFORCE gradient estimator, with optional scaling by the stdev of the rewards.\n\n :param expl_directions: The set of perturbations.\n :param rewards_pos: Rewards obtained from perturbed models. rewards_pos[i] is the rewards of \n the model pertur...
[ { "param": "self", "type": null }, { "param": "expl_directions", "type": null }, { "param": "rewards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expl_directions", "type": null, "docstring": "The set of perturbati...
a932132a7b5cdb5f07bc8e2e95e3d8a1b404d092
lyubadimitrova/dfoseq2seq
scripts/grad_estimators.py
[ "MIT" ]
Python
estimate_grad_forward_fd
<not_specific>
def estimate_grad_forward_fd(self, expl_directions, rewards): """ Forward finite differences gradient estimator, with optional scaling by the stdev of the rewards. :param expl_directions: The set of perturbations. :param rewards: Rewards obtained from perturbed models: a tensor of size ...
Forward finite differences gradient estimator, with optional scaling by the stdev of the rewards. :param expl_directions: The set of perturbations. :param rewards: Rewards obtained from perturbed models: a tensor of size (num_expl_directions + 1). The last element of re...
Forward finite differences gradient estimator, with optional scaling by the stdev of the rewards.
[ "Forward", "finite", "differences", "gradient", "estimator", "with", "optional", "scaling", "by", "the", "stdev", "of", "the", "rewards", "." ]
def estimate_grad_forward_fd(self, expl_directions, rewards): rewards_pos = rewards[:-1] if self.use_only_best: sort_idx = torch.argsort(rewards_pos, descending=True) rewards_pos = rewards_pos[sort_idx][:self.use_only_best] expl_directions = expl_directions[sort_idx][...
[ "def", "estimate_grad_forward_fd", "(", "self", ",", "expl_directions", ",", "rewards", ")", ":", "rewards_pos", "=", "rewards", "[", ":", "-", "1", "]", "if", "self", ".", "use_only_best", ":", "sort_idx", "=", "torch", ".", "argsort", "(", "rewards_pos", ...
Forward finite differences gradient estimator, with optional scaling by the stdev of the rewards.
[ "Forward", "finite", "differences", "gradient", "estimator", "with", "optional", "scaling", "by", "the", "stdev", "of", "the", "rewards", "." ]
[ "\"\"\"\n Forward finite differences gradient estimator, with optional scaling by the stdev of the rewards.\n\n :param expl_directions: The set of perturbations.\n :param rewards: Rewards obtained from perturbed models: a tensor of size (num_expl_directions + 1).\n The la...
[ { "param": "self", "type": null }, { "param": "expl_directions", "type": null }, { "param": "rewards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expl_directions", "type": null, "docstring": "The set of perturbati...
a932132a7b5cdb5f07bc8e2e95e3d8a1b404d092
lyubadimitrova/dfoseq2seq
scripts/grad_estimators.py
[ "MIT" ]
Python
estimate_grad_antithetic
<not_specific>
def estimate_grad_antithetic(self, expl_directions, rewards): """ Central differences (also: antithetic) gradient estimator, with optional scaling by the stdev of the rewards. :param expl_directions: The set of perturbations. :param rewards: Rewards obtained from perturbed models, a ten...
Central differences (also: antithetic) gradient estimator, with optional scaling by the stdev of the rewards. :param expl_directions: The set of perturbations. :param rewards: Rewards obtained from perturbed models, a tensor of size (num_expl_directions * 2), where the...
Central differences (also: antithetic) gradient estimator, with optional scaling by the stdev of the rewards.
[ "Central", "differences", "(", "also", ":", "antithetic", ")", "gradient", "estimator", "with", "optional", "scaling", "by", "the", "stdev", "of", "the", "rewards", "." ]
def estimate_grad_antithetic(self, expl_directions, rewards): rewards_pos, rewards_neg = torch.chunk(rewards, 2) rewards = rewards.view((2,-1)) if self.use_only_best: sort_idx = torch.argsort(torch.max(rewards, dim=0).values, descending=True) rewards_pos = rewards_pos[...
[ "def", "estimate_grad_antithetic", "(", "self", ",", "expl_directions", ",", "rewards", ")", ":", "rewards_pos", ",", "rewards_neg", "=", "torch", ".", "chunk", "(", "rewards", ",", "2", ")", "rewards", "=", "rewards", ".", "view", "(", "(", "2", ",", "-...
Central differences (also: antithetic) gradient estimator, with optional scaling by the stdev of the rewards.
[ "Central", "differences", "(", "also", ":", "antithetic", ")", "gradient", "estimator", "with", "optional", "scaling", "by", "the", "stdev", "of", "the", "rewards", "." ]
[ "\"\"\"\n Central differences (also: antithetic) gradient estimator, with optional scaling by the stdev of the rewards.\n\n :param expl_directions: The set of perturbations.\n :param rewards: Rewards obtained from perturbed models, a tensor of size (num_expl_directions * 2), \n ...
[ { "param": "self", "type": null }, { "param": "expl_directions", "type": null }, { "param": "rewards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expl_directions", "type": null, "docstring": "The set of perturbati...
ee57332d31e2488b3922b310a2dd828b336c6f6b
Joatin/rules_jest
package.bzl
[ "MIT" ]
Python
rules_jest_dev_dependencies
null
def rules_jest_dev_dependencies(): """ Fetch dependencies needed for local development. These are in this file to keep version information in one place, and make the WORKSPACE shorter. Also this allows other repos to reference our sources with local_repository and install the needed deps. """ ...
Fetch dependencies needed for local development. These are in this file to keep version information in one place, and make the WORKSPACE shorter. Also this allows other repos to reference our sources with local_repository and install the needed deps.
Fetch dependencies needed for local development. These are in this file to keep version information in one place, and make the WORKSPACE shorter. Also this allows other repos to reference our sources with local_repository and install the needed deps.
[ "Fetch", "dependencies", "needed", "for", "local", "development", ".", "These", "are", "in", "this", "file", "to", "keep", "version", "information", "in", "one", "place", "and", "make", "the", "WORKSPACE", "shorter", ".", "Also", "this", "allows", "other", "...
def rules_jest_dev_dependencies(): _maybe( http_archive, name = "build_bazel_rules_nodejs", sha256 = "6d4edbf28ff6720aedf5f97f9b9a7679401bf7fca9d14a0fff80f644a99992b4", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.32.2/rules_nodejs-0.32.2.tar.gz"], )
[ "def", "rules_jest_dev_dependencies", "(", ")", ":", "_maybe", "(", "http_archive", ",", "name", "=", "\"build_bazel_rules_nodejs\"", ",", "sha256", "=", "\"6d4edbf28ff6720aedf5f97f9b9a7679401bf7fca9d14a0fff80f644a99992b4\"", ",", "urls", "=", "[", "\"https://github.com/bazel...
Fetch dependencies needed for local development.
[ "Fetch", "dependencies", "needed", "for", "local", "development", "." ]
[ "\"\"\"\n Fetch dependencies needed for local development.\n\n These are in this file to keep version information in one place, and make the WORKSPACE\n shorter.\n\n Also this allows other repos to reference our sources with local_repository and install the needed deps.\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
9d3173f79203f6ca9ee6d3db97e74e8fe3928913
hwoodward/Remote-Card-Games
source/client/RunManagement.py
[ "MIT" ]
Python
processRuns
<not_specific>
def processRuns(card_group, wild_numbers): """ handle sorting of run, including placement of wilds. Handles minor rule checking. processRuns does not check length requirement or that all cards are in same suit. it DOES: require that if Aces are not wild, then they are hi or low, but not both. ...
handle sorting of run, including placement of wilds. Handles minor rule checking. processRuns does not check length requirement or that all cards are in same suit. it DOES: require that if Aces are not wild, then they are hi or low, but not both. require that there must be two naturals be...
handle sorting of run, including placement of wilds. Handles minor rule checking. processRuns does not check length requirement or that all cards are in same suit. it DOES: require that if Aces are not wild, then they are hi or low, but not both. require that there must be two naturals between wild cards in runs. To p...
[ "handle", "sorting", "of", "run", "including", "placement", "of", "wilds", ".", "Handles", "minor", "rule", "checking", ".", "processRuns", "does", "not", "check", "length", "requirement", "or", "that", "all", "cards", "are", "in", "same", "suit", ".", "it",...
def processRuns(card_group, wild_numbers): card_group.sort(key=lambda wc: wc.tempnumber) groups_wilds = [] temp_run_group = [] aces_list =[] for card in card_group: if card.tempnumber in wild_numbers: groups_wilds.append(card) elif card.tempnumber == 1 and card.number == ...
[ "def", "processRuns", "(", "card_group", ",", "wild_numbers", ")", ":", "card_group", ".", "sort", "(", "key", "=", "lambda", "wc", ":", "wc", ".", "tempnumber", ")", "groups_wilds", "=", "[", "]", "temp_run_group", "=", "[", "]", "aces_list", "=", "[", ...
handle sorting of run, including placement of wilds.
[ "handle", "sorting", "of", "run", "including", "placement", "of", "wilds", "." ]
[ "\"\"\" handle sorting of run, including placement of wilds. Handles minor rule checking.\n\n processRuns does not check length requirement or that all cards are in same suit.\n it DOES:\n require that if Aces are not wild, then they are hi or low, but not both.\n require that there must be...
[ { "param": "card_group", "type": null }, { "param": "wild_numbers", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "card_group", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "wild_numbers", "type": null, "docstring": null, "docstr...
9d3173f79203f6ca9ee6d3db97e74e8fe3928913
hwoodward/Remote-Card-Games
source/client/RunManagement.py
[ "MIT" ]
Python
restoreRunAssignment
<not_specific>
def restoreRunAssignment(visible_scards_dictionary, wild_numbers, numsets): """ Convert scards to cards and assign values to Wild cards and Aces in runs from server. Needed to maintain integrity of Wilds' assigned values in runs. Server does not know tempnumbers (for backwards compatability not changing j...
Convert scards to cards and assign values to Wild cards and Aces in runs from server. Needed to maintain integrity of Wilds' assigned values in runs. Server does not know tempnumbers (for backwards compatability not changing json between server and client). There's no ambiguity except for wilds and Aces ...
Convert scards to cards and assign values to Wild cards and Aces in runs from server. Needed to maintain integrity of Wilds' assigned values in runs. Server does not know tempnumbers (for backwards compatability not changing json between server and client). There's no ambiguity except for wilds and Aces at the ends of...
[ "Convert", "scards", "to", "cards", "and", "assign", "values", "to", "Wild", "cards", "and", "Aces", "in", "runs", "from", "server", ".", "Needed", "to", "maintain", "integrity", "of", "Wilds", "'", "assigned", "values", "in", "runs", ".", "Server", "does"...
def restoreRunAssignment(visible_scards_dictionary, wild_numbers, numsets): if len(visible_scards_dictionary) == 0: return(visible_scards_dictionary) cardgroup_dictionary = {} for key, scard_group in visible_scards_dictionary.items(): card_group = [] for scard in scard_group: ...
[ "def", "restoreRunAssignment", "(", "visible_scards_dictionary", ",", "wild_numbers", ",", "numsets", ")", ":", "if", "len", "(", "visible_scards_dictionary", ")", "==", "0", ":", "return", "(", "visible_scards_dictionary", ")", "cardgroup_dictionary", "=", "{", "}"...
Convert scards to cards and assign values to Wild cards and Aces in runs from server.
[ "Convert", "scards", "to", "cards", "and", "assign", "values", "to", "Wild", "cards", "and", "Aces", "in", "runs", "from", "server", "." ]
[ "\"\"\" Convert scards to cards and assign values to Wild cards and Aces in runs from server.\n\n Needed to maintain integrity of Wilds' assigned values in runs. Server does not know tempnumbers\n (for backwards compatability not changing json between server and client).\n There's no ambiguity except for ...
[ { "param": "visible_scards_dictionary", "type": null }, { "param": "wild_numbers", "type": null }, { "param": "numsets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "visible_scards_dictionary", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "wild_numbers", "type": null, "docstring": null...
9d3173f79203f6ca9ee6d3db97e74e8fe3928913
hwoodward/Remote-Card-Games
source/client/RunManagement.py
[ "MIT" ]
Python
isWild
<not_specific>
def isWild(card, wild_numbers): """returns true if a card is a wild""" if card.number in wild_numbers: return True else: return False
returns true if a card is a wild
returns true if a card is a wild
[ "returns", "true", "if", "a", "card", "is", "a", "wild" ]
def isWild(card, wild_numbers): if card.number in wild_numbers: return True else: return False
[ "def", "isWild", "(", "card", ",", "wild_numbers", ")", ":", "if", "card", ".", "number", "in", "wild_numbers", ":", "return", "True", "else", ":", "return", "False" ]
returns true if a card is a wild
[ "returns", "true", "if", "a", "card", "is", "a", "wild" ]
[ "\"\"\"returns true if a card is a wild\"\"\"" ]
[ { "param": "card", "type": null }, { "param": "wild_numbers", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "card", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "wild_numbers", "type": null, "docstring": null, "docstring_to...
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
Connected
null
def Connected(self, channel, addr): """Called by podsixnet when a client connects and establishes a channel""" if self.in_round: print(channel, 'Client tried to connect during active round, try again between rounds') channel.Send({"action": "connectionDenied"}) else: ...
Called by podsixnet when a client connects and establishes a channel
Called by podsixnet when a client connects and establishes a channel
[ "Called", "by", "podsixnet", "when", "a", "client", "connects", "and", "establishes", "a", "channel" ]
def Connected(self, channel, addr): if self.in_round: print(channel, 'Client tried to connect during active round, try again between rounds') channel.Send({"action": "connectionDenied"}) else: self.players.append(channel) self.Send_publicInfo() ...
[ "def", "Connected", "(", "self", ",", "channel", ",", "addr", ")", ":", "if", "self", ".", "in_round", ":", "print", "(", "channel", ",", "'Client tried to connect during active round, try again between rounds'", ")", "channel", ".", "Send", "(", "{", "\"action\""...
Called by podsixnet when a client connects and establishes a channel
[ "Called", "by", "podsixnet", "when", "a", "client", "connects", "and", "establishes", "a", "channel" ]
[ "\"\"\"Called by podsixnet when a client connects and establishes a channel\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "channel", "type": null }, { "param": "addr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "channel", "type": null, "docstring": null, "docstring_tokens"...
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
disconnect
<not_specific>
def disconnect(self, channel): """Called by a channel when it disconnects""" if channel not in self.players: #Disconnecting a channel that never fully joined the game, do nothing return #For players who did join the game need to handle removing them safely self.de...
Called by a channel when it disconnects
Called by a channel when it disconnects
[ "Called", "by", "a", "channel", "when", "it", "disconnects" ]
def disconnect(self, channel): if channel not in self.players: return self.delPlayer(channel)
[ "def", "disconnect", "(", "self", ",", "channel", ")", ":", "if", "channel", "not", "in", "self", ".", "players", ":", "return", "self", ".", "delPlayer", "(", "channel", ")" ]
Called by a channel when it disconnects
[ "Called", "by", "a", "channel", "when", "it", "disconnects" ]
[ "\"\"\"Called by a channel when it disconnects\"\"\"", "#Disconnecting a channel that never fully joined the game, do nothing", "#For players who did join the game need to handle removing them safely" ]
[ { "param": "self", "type": null }, { "param": "channel", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "channel", "type": null, "docstring": null, "docstring_tokens"...
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
checkReady
<not_specific>
def checkReady(self): """Confirm if all players are ready to move on to next round""" if self.in_round: return False player_states = [p.ready for p in self.players] if False not in player_states: self.nextRound() self.Send_broadcast({"action":"clearRea...
Confirm if all players are ready to move on to next round
Confirm if all players are ready to move on to next round
[ "Confirm", "if", "all", "players", "are", "ready", "to", "move", "on", "to", "next", "round" ]
def checkReady(self): if self.in_round: return False player_states = [p.ready for p in self.players] if False not in player_states: self.nextRound() self.Send_broadcast({"action":"clearReady"})
[ "def", "checkReady", "(", "self", ")", ":", "if", "self", ".", "in_round", ":", "return", "False", "player_states", "=", "[", "p", ".", "ready", "for", "p", "in", "self", ".", "players", "]", "if", "False", "not", "in", "player_states", ":", "self", ...
Confirm if all players are ready to move on to next round
[ "Confirm", "if", "all", "players", "are", "ready", "to", "move", "on", "to", "next", "round" ]
[ "\"\"\"Confirm if all players are ready to move on to next round\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
nextRound
null
def nextRound(self): """Start the next round of play""" if self.round == -1: self.round = self.starting_round else: self.round += 1 self.in_round = True if self.round > self.rules.Number_Rounds-1: #Need to take one off Number_Rounds because we index from z...
Start the next round of play
Start the next round of play
[ "Start", "the", "next", "round", "of", "play" ]
def nextRound(self): if self.round == -1: self.round = self.starting_round else: self.round += 1 self.in_round = True if self.round > self.rules.Number_Rounds-1: print("GAME OVER - CHECK LAST SCORE REPORT FOR FINAL RESULT") self.game_over ...
[ "def", "nextRound", "(", "self", ")", ":", "if", "self", ".", "round", "==", "-", "1", ":", "self", ".", "round", "=", "self", ".", "starting_round", "else", ":", "self", ".", "round", "+=", "1", "self", ".", "in_round", "=", "True", "if", "self", ...
Start the next round of play
[ "Start", "the", "next", "round", "of", "play" ]
[ "\"\"\"Start the next round of play\"\"\"", "#Need to take one off Number_Rounds because we index from zero", "#Game is over", "# need to retransmit all the scores in case a player has joined between rounds", "# define which player starts the next round." ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
delPlayer
<not_specific>
def delPlayer(self, player): """Safely remove a player from the turn order Checks for game over if no more players and quits server Moves turn forward if it was deleted players turn. """ player_index = self.players.index(player) self.players.remove(player) ...
Safely remove a player from the turn order Checks for game over if no more players and quits server Moves turn forward if it was deleted players turn.
Safely remove a player from the turn order Checks for game over if no more players and quits server Moves turn forward if it was deleted players turn.
[ "Safely", "remove", "a", "player", "from", "the", "turn", "order", "Checks", "for", "game", "over", "if", "no", "more", "players", "and", "quits", "server", "Moves", "turn", "forward", "if", "it", "was", "deleted", "players", "turn", "." ]
def delPlayer(self, player): player_index = self.players.index(player) self.players.remove(player) if self.rules.Shared_Board: visible_cards_previous = self.visible_cards_now self.visible_cards_now = {} for old_key, card_group in visible_cards_previous.items()...
[ "def", "delPlayer", "(", "self", ",", "player", ")", ":", "player_index", "=", "self", ".", "players", ".", "index", "(", "player", ")", "self", ".", "players", ".", "remove", "(", "player", ")", "if", "self", ".", "rules", ".", "Shared_Board", ":", ...
Safely remove a player from the turn order Checks for game over if no more players and quits server Moves turn forward if it was deleted players turn.
[ "Safely", "remove", "a", "player", "from", "the", "turn", "order", "Checks", "for", "game", "over", "if", "no", "more", "players", "and", "quits", "server", "Moves", "turn", "forward", "if", "it", "was", "deleted", "players", "turn", "." ]
[ "\"\"\"Safely remove a player from the turn order\n \n Checks for game over if no more players and quits server\n Moves turn forward if it was deleted players turn.\n \"\"\"", "# if Shared_Board then need to update visible_cards_now dictionary.", "# rebuild visible_cards_now with ent...
[ { "param": "self", "type": null }, { "param": "player", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "player", "type": null, "docstring": null, "docstring_tokens":...
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
cardBuyingResolution
null
def cardBuyingResolution(self): """ Resolve who gets to purchase card for games with Buy_Option = True This is called upon player clicking on draw pile. """ timelimit = time() + self.rules.purchase_time buying_phase = True # else this routine would not be called i_max = len(self....
Resolve who gets to purchase card for games with Buy_Option = True This is called upon player clicking on draw pile.
Resolve who gets to purchase card for games with Buy_Option = True This is called upon player clicking on draw pile.
[ "Resolve", "who", "gets", "to", "purchase", "card", "for", "games", "with", "Buy_Option", "=", "True", "This", "is", "called", "upon", "player", "clicking", "on", "draw", "pile", "." ]
def cardBuyingResolution(self): timelimit = time() + self.rules.purchase_time buying_phase = True i_max = len(self.players) - 2 index = (self.turn_index + 1) % len(self.players) icount = 0 while buying_phase and icount < i_max: while self.players[index].want_...
[ "def", "cardBuyingResolution", "(", "self", ")", ":", "timelimit", "=", "time", "(", ")", "+", "self", ".", "rules", ".", "purchase_time", "buying_phase", "=", "True", "i_max", "=", "len", "(", "self", ".", "players", ")", "-", "2", "index", "=", "(", ...
Resolve who gets to purchase card for games with Buy_Option = True This is called upon player clicking on draw pile.
[ "Resolve", "who", "gets", "to", "purchase", "card", "for", "games", "with", "Buy_Option", "=", "True", "This", "is", "called", "upon", "player", "clicking", "on", "draw", "pile", "." ]
[ "\"\"\" Resolve who gets to purchase card for games with Buy_Option = True\n This is called upon player clicking on draw pile. \"\"\"", "# else this routine would not be called", "# wait patiently(?) while updating information from players, timer begins when", "# next player attempts to draw.", "# se...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
checkVisibleCardsReported
<not_specific>
def checkVisibleCardsReported(self): """Insure that no played cards were lost in update to self.visible_cards(only used when Shared_Board = True) """ max_len = 0 for key, scard_group in self.visible_cards_now.items(): max_len = max_len + len(scard_group) self.v_cards = [p.vi...
Insure that no played cards were lost in update to self.visible_cards(only used when Shared_Board = True)
Insure that no played cards were lost in update to self.visible_cards(only used when Shared_Board = True)
[ "Insure", "that", "no", "played", "cards", "were", "lost", "in", "update", "to", "self", ".", "visible_cards", "(", "only", "used", "when", "Shared_Board", "=", "True", ")" ]
def checkVisibleCardsReported(self): max_len = 0 for key, scard_group in self.visible_cards_now.items(): max_len = max_len + len(scard_group) self.v_cards = [p.visible_cards for p in self.players] if len(self.v_cards) == 0: self.v_cards = [{}] max_len = -1...
[ "def", "checkVisibleCardsReported", "(", "self", ")", ":", "max_len", "=", "0", "for", "key", ",", "scard_group", "in", "self", ".", "visible_cards_now", ".", "items", "(", ")", ":", "max_len", "=", "max_len", "+", "len", "(", "scard_group", ")", "self", ...
Insure that no played cards were lost in update to self.visible_cards(only used when Shared_Board = True)
[ "Insure", "that", "no", "played", "cards", "were", "lost", "in", "update", "to", "self", ".", "visible_cards", "(", "only", "used", "when", "Shared_Board", "=", "True", ")" ]
[ "\"\"\"Insure that no played cards were lost in update to self.visible_cards(only used when Shared_Board = True) \"\"\"", "# v_cards contains a dictionary from each player/client", "# each dictionary contains all the played cards that player/client is aware of.", "# set self.visible_cards_now to the dictionar...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
Send_scores
null
def Send_scores(self): """Send the scores to all players""" round_scores = [p.scoreForRound(self.round) for p in self.players] total_scores = [sum(p.scores) for p in self.players] if None not in round_scores: self.Send_broadcast({"action": "scores", "round_scores": round_scor...
Send the scores to all players
Send the scores to all players
[ "Send", "the", "scores", "to", "all", "players" ]
def Send_scores(self): round_scores = [p.scoreForRound(self.round) for p in self.players] total_scores = [sum(p.scores) for p in self.players] if None not in round_scores: self.Send_broadcast({"action": "scores", "round_scores": round_scores, "total_scores": total_scores})
[ "def", "Send_scores", "(", "self", ")", ":", "round_scores", "=", "[", "p", ".", "scoreForRound", "(", "self", ".", "round", ")", "for", "p", "in", "self", ".", "players", "]", "total_scores", "=", "[", "sum", "(", "p", ".", "scores", ")", "for", "...
Send the scores to all players
[ "Send", "the", "scores", "to", "all", "players" ]
[ "\"\"\"Send the scores to all players\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
Send_publicInfo
null
def Send_publicInfo(self): """Send the update to the melded cards on the table""" #NOTE: visible_cards needs to be serialized form to be transmitted. # On server keep them in serialized form. if self.rules.Shared_Board: # Shared_Board is True: (e.g. Liverpool) -- each player...
Send the update to the melded cards on the table
Send the update to the melded cards on the table
[ "Send", "the", "update", "to", "the", "melded", "cards", "on", "the", "table" ]
def Send_publicInfo(self): if self.rules.Shared_Board: self.Send_broadcast({"action": "publicInfo", "player_names": [p.name for p in self.players],"visible_cards": [self.visible_cards_now],"hand_status": [p.hand_status for p in self.players]}) else: self.Send_broadcast({"action":...
[ "def", "Send_publicInfo", "(", "self", ")", ":", "if", "self", ".", "rules", ".", "Shared_Board", ":", "self", ".", "Send_broadcast", "(", "{", "\"action\"", ":", "\"publicInfo\"", ",", "\"player_names\"", ":", "[", "p", ".", "name", "for", "p", "in", "s...
Send the update to the melded cards on the table
[ "Send", "the", "update", "to", "the", "melded", "cards", "on", "the", "table" ]
[ "\"\"\"Send the update to the melded cards on the table\"\"\"", "#NOTE: visible_cards needs to be serialized form to be transmitted.", "# On server keep them in serialized form.", "# Shared_Board is True: (e.g. Liverpool) -- each player transmits entire board of visible_cards to server.", "# Shared_Board is...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15e5e67f04e12a0e1199b2d3a5a2f869bd5354e4
hwoodward/Remote-Card-Games
source/server/GameServer.py
[ "MIT" ]
Python
Send_buyingOpportunity
null
def Send_buyingOpportunity(self): """ Let eligible players know there's a buying opportunity Used in games with with Buy_Option = True (i.e. Liverpool) where you can buy the top discard if the next player doesn't want it. If there are N players, then N-2 players are eligible to buy car...
Let eligible players know there's a buying opportunity Used in games with with Buy_Option = True (i.e. Liverpool) where you can buy the top discard if the next player doesn't want it. If there are N players, then N-2 players are eligible to buy card (neither player who discarded, nor ...
Let eligible players know there's a buying opportunity Used in games with with Buy_Option = True where you can buy the top discard if the next player doesn't want it. If there are N players, then N-2 players are eligible to buy card (neither player who discarded, nor current active player are eligible).
[ "Let", "eligible", "players", "know", "there", "'", "s", "a", "buying", "opportunity", "Used", "in", "games", "with", "with", "Buy_Option", "=", "True", "where", "you", "can", "buy", "the", "top", "discard", "if", "the", "next", "player", "doesn", "'", "...
def Send_buyingOpportunity(self): for p in self.players: p.want_card = None info = self.getDiscardInfo() i_max = len(self.players) - 2 for i_count in range(i_max): index = (self.turn_index + i_count + 1) % len(self.players) self.players[index].Sen...
[ "def", "Send_buyingOpportunity", "(", "self", ")", ":", "for", "p", "in", "self", ".", "players", ":", "p", ".", "want_card", "=", "None", "info", "=", "self", ".", "getDiscardInfo", "(", ")", "i_max", "=", "len", "(", "self", ".", "players", ")", "-...
Let eligible players know there's a buying opportunity Used in games with with Buy_Option = True (i.e.
[ "Let", "eligible", "players", "know", "there", "'", "s", "a", "buying", "opportunity", "Used", "in", "games", "with", "with", "Buy_Option", "=", "True", "(", "i", ".", "e", "." ]
[ "\"\"\" Let eligible players know there's a buying opportunity\n\n Used in games with with Buy_Option = True (i.e. Liverpool)\n where you can buy the top discard if the next player doesn't want\n it. If there are N players, then N-2 players are eligible to buy card\n (neither player who...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c69b74f885fe7ef4dc14821d6e312785990990f7
hwoodward/Remote-Card-Games
source/client/LiverpoolButtons.py
[ "MIT" ]
Python
CreateButtons
<not_specific>
def CreateButtons(hand_view, num_players=1): hand_view.num_players = num_players """This creates the buttons and text used for game. """ hand_view.draw_pile = ClickImg(UIC.Back_Img, 10, 25, UIC.Back_Img.get_width(), UIC.Back_Img.get_height(), 0) hand_view.ready_yes_btn = \ Btn.Button(UIC.White, ...
This creates the buttons and text used for game.
This creates the buttons and text used for game.
[ "This", "creates", "the", "buttons", "and", "text", "used", "for", "game", "." ]
def CreateButtons(hand_view, num_players=1): hand_view.num_players = num_players hand_view.draw_pile = ClickImg(UIC.Back_Img, 10, 25, UIC.Back_Img.get_width(), UIC.Back_Img.get_height(), 0) hand_view.ready_yes_btn = \ Btn.Button(UIC.White, (UIC.Disp_Width - 150), (UIC.Disp_Height - 70), 125, 25, tex...
[ "def", "CreateButtons", "(", "hand_view", ",", "num_players", "=", "1", ")", ":", "hand_view", ".", "num_players", "=", "num_players", "hand_view", ".", "draw_pile", "=", "ClickImg", "(", "UIC", ".", "Back_Img", ",", "10", ",", "25", ",", "UIC", ".", "Ba...
This creates the buttons and text used for game.
[ "This", "creates", "the", "buttons", "and", "text", "used", "for", "game", "." ]
[ "\"\"\"This creates the buttons and text used for game. \"\"\"", "# color of outline will be: UIC.outline_colors(ready_color_idx)", "# color of outline will be: UIC.outline_colors(ready_color_idx)", "# list of card groups (each group is a set or run) for each player.", "# do not need discard pile at beginni...
[ { "param": "hand_view", "type": null }, { "param": "num_players", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hand_view", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_players", "type": null, "docstring": null, "docstrin...
c69b74f885fe7ef4dc14821d6e312785990990f7
hwoodward/Remote-Card-Games
source/client/LiverpoolButtons.py
[ "MIT" ]
Python
newRound
null
def newRound(hand_view, sets_runs_tuple): """ At start of each round (after all players hit OK) this creates buttons used to assign cards.""" # For liverpool need multiple buttons to assign cards to appropriate set/run. # and need to do this at beginning of each round, so those buttons are in this separa...
At start of each round (after all players hit OK) this creates buttons used to assign cards.
At start of each round (after all players hit OK) this creates buttons used to assign cards.
[ "At", "start", "of", "each", "round", "(", "after", "all", "players", "hit", "OK", ")", "this", "creates", "buttons", "used", "to", "assign", "cards", "." ]
def newRound(hand_view, sets_runs_tuple): hand_view.buttons_per_player = sets_runs_tuple[0] + sets_runs_tuple[1] hand_view.assign_cards_btns = [[]] w = 75 width of following buttons h = 20 height of following buttons if hand_view.num_players > 1: players_sp_w = UIC.Disp_Width / hand_view...
[ "def", "newRound", "(", "hand_view", ",", "sets_runs_tuple", ")", ":", "hand_view", ".", "buttons_per_player", "=", "sets_runs_tuple", "[", "0", "]", "+", "sets_runs_tuple", "[", "1", "]", "hand_view", ".", "assign_cards_btns", "=", "[", "[", "]", "]", "w", ...
At start of each round (after all players hit OK) this creates buttons used to assign cards.
[ "At", "start", "of", "each", "round", "(", "after", "all", "players", "hit", "OK", ")", "this", "creates", "buttons", "used", "to", "assign", "cards", "." ]
[ "\"\"\" At start of each round (after all players hit OK) this creates buttons used to assign cards.\"\"\"", "# For liverpool need multiple buttons to assign cards to appropriate set/run.", "# and need to do this at beginning of each round, so those buttons are in this separate method.", "# btns = a list o...
[ { "param": "hand_view", "type": null }, { "param": "sets_runs_tuple", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hand_view", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sets_runs_tuple", "type": null, "docstring": null, "docs...
c69b74f885fe7ef4dc14821d6e312785990990f7
hwoodward/Remote-Card-Games
source/client/LiverpoolButtons.py
[ "MIT" ]
Python
ButtonDisplay
<not_specific>
def ButtonDisplay(hand_view): """ This updates draw pile and action buttons. It is called in HandView.update each render cycle. It also creates customized buttons for each round of Liverpool (might also be eventually used by other shared_board game. Must wait to create until all players hit OK else you w...
This updates draw pile and action buttons. It is called in HandView.update each render cycle. It also creates customized buttons for each round of Liverpool (might also be eventually used by other shared_board game. Must wait to create until all players hit OK else you won't have created buttons for pla...
This updates draw pile and action buttons. It is called in HandView.update each render cycle. It also creates customized buttons for each round of Liverpool (might also be eventually used by other shared_board game. Must wait to create until all players hit OK else you won't have created buttons for players who join a...
[ "This", "updates", "draw", "pile", "and", "action", "buttons", ".", "It", "is", "called", "in", "HandView", ".", "update", "each", "render", "cycle", ".", "It", "also", "creates", "customized", "buttons", "for", "each", "round", "of", "Liverpool", "(", "mi...
def ButtonDisplay(hand_view): if hand_view.need_updated_buttons and not hand_view.controller._state.round == -1: hand_view.RuleSetsButtons.newRound(hand_view, hand_view.Meld_Threshold[hand_view.round_index]) hand_view.need_updated_buttons = False loc_xy = (hand_view.draw_pile.x, hand_view.draw_p...
[ "def", "ButtonDisplay", "(", "hand_view", ")", ":", "if", "hand_view", ".", "need_updated_buttons", "and", "not", "hand_view", ".", "controller", ".", "_state", ".", "round", "==", "-", "1", ":", "hand_view", ".", "RuleSetsButtons", ".", "newRound", "(", "ha...
This updates draw pile and action buttons.
[ "This", "updates", "draw", "pile", "and", "action", "buttons", "." ]
[ "\"\"\" This updates draw pile and action buttons. It is called in HandView.update each render cycle. \n\n It also creates customized buttons for each round of Liverpool (might also be eventually used by\n other shared_board game. Must wait to create until all players hit OK else you won't have created\n ...
[ { "param": "hand_view", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hand_view", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c69b74f885fe7ef4dc14821d6e312785990990f7
hwoodward/Remote-Card-Games
source/client/LiverpoolButtons.py
[ "MIT" ]
Python
ClickedButton
<not_specific>
def ClickedButton(hand_view, pos): """ Carry out action after mouse clicked on button. """ if hand_view.pickup_pile_sz > 0: if hand_view.pickup_pile.isOver(pos): hand_view.controller.pickUpPile(notes[0]) if hand_view.draw_pile.isOver(pos): if hand_view.pickup_pile_sz > 0: ...
Carry out action after mouse clicked on button.
Carry out action after mouse clicked on button.
[ "Carry", "out", "action", "after", "mouse", "clicked", "on", "button", "." ]
def ClickedButton(hand_view, pos): if hand_view.pickup_pile_sz > 0: if hand_view.pickup_pile.isOver(pos): hand_view.controller.pickUpPile(notes[0]) if hand_view.draw_pile.isOver(pos): if hand_view.pickup_pile_sz > 0: hand_view.controller.drawWithBuyOption() else...
[ "def", "ClickedButton", "(", "hand_view", ",", "pos", ")", ":", "if", "hand_view", ".", "pickup_pile_sz", ">", "0", ":", "if", "hand_view", ".", "pickup_pile", ".", "isOver", "(", "pos", ")", ":", "hand_view", ".", "controller", ".", "pickUpPile", "(", "...
Carry out action after mouse clicked on button.
[ "Carry", "out", "action", "after", "mouse", "clicked", "on", "button", "." ]
[ "\"\"\" Carry out action after mouse clicked on button. \"\"\"", "# use different method for Liverpool than HandAndFoot", "# unless pile is empty (at start of each round)", "# following two buttons only appear at beginning of round, used to notify server ready to begin round.", "# color of outline will be:...
[ { "param": "hand_view", "type": null }, { "param": "pos", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "hand_view", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": null, "docstring": null, "docstring_tokens...
695ee94a0c05591d10826b896691bf67277ba83c
hwoodward/Remote-Card-Games
source/RunClient.py
[ "MIT" ]
Python
RunClient
null
def RunClient(): if getattr(sys, 'frozen', False): os.chdir(sys._MEIPASS) """This is the launch point for the client. It sets up the various classes and starts the game loop. Steps -- (i) player provides host:port info, and connection to server established. (ii) clientState initial...
This is the launch point for the client. It sets up the various classes and starts the game loop. Steps -- (i) player provides host:port info, and connection to server established. (ii) clientState initialized (iii) controller initialized (iv) ruleset imported (v) player provides nam...
This is the launch point for the client. It sets up the various classes and starts the game loop. Steps (i) player provides host:port info, and connection to server established.
[ "This", "is", "the", "launch", "point", "for", "the", "client", ".", "It", "sets", "up", "the", "various", "classes", "and", "starts", "the", "game", "loop", ".", "Steps", "(", "i", ")", "player", "provides", "host", ":", "port", "info", "and", "connec...
def RunClient(): if getattr(sys, 'frozen', False): os.chdir(sys._MEIPASS) host = str(input("Enter the host [localhost] ") or "localhost") port = str(input("Enter the port[12345] ") or "12345") connection.DoConnect((host, int(port))) ruleset = "tbd" clientState = ClientState(ruleset) ...
[ "def", "RunClient", "(", ")", ":", "if", "getattr", "(", "sys", ",", "'frozen'", ",", "False", ")", ":", "os", ".", "chdir", "(", "sys", ".", "_MEIPASS", ")", "host", "=", "str", "(", "input", "(", "\"Enter the host [localhost] \"", ")", "or", "\"local...
This is the launch point for the client.
[ "This", "is", "the", "launch", "point", "for", "the", "client", "." ]
[ "\"\"\"This is the launch point for the client.\n \n It sets up the various classes and starts the game loop.\n Steps -- \n (i) player provides host:port info, and connection to server established.\n (ii) clientState initialized \n (iii) controller initialized\n (iv) ruleset imported \n (v) ...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
isWild
<not_specific>
def isWild(card): """returns true if a card is a wild""" if card.number in wild_numbers: return True else: return False
returns true if a card is a wild
returns true if a card is a wild
[ "returns", "true", "if", "a", "card", "is", "a", "wild" ]
def isWild(card): if card.number in wild_numbers: return True else: return False
[ "def", "isWild", "(", "card", ")", ":", "if", "card", ".", "number", "in", "wild_numbers", ":", "return", "True", "else", ":", "return", "False" ]
returns true if a card is a wild
[ "returns", "true", "if", "a", "card", "is", "a", "wild" ]
[ "\"\"\"returns true if a card is a wild\"\"\"" ]
[ { "param": "card", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "card", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
canPlayGroup
<not_specific>
def canPlayGroup(key, card_group, this_round): """checks if a group can be played For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned appropriate tempnumber). returns True if it can, otherwise raises an exception with an explanation. In dictionary ke...
checks if a group can be played For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned appropriate tempnumber). returns True if it can, otherwise raises an exception with an explanation. In dictionary key of prepared (=assigned) cards = key of button = (bas...
checks if a group can be played For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned appropriate tempnumber). returns True if it can, otherwise raises an exception with an explanation. In dictionary key of prepared (=assigned) cards = key of button = (based on (player index, ...
[ "checks", "if", "a", "group", "can", "be", "played", "For", "runs", "this", "assumes", "card_group", "has", "already", "been", "processed", "(", "sorted", "with", "Aces", "and", "Wilds", "assigned", "appropriate", "tempnumber", ")", ".", "returns", "True", "...
def canPlayGroup(key, card_group, this_round): if key[1] < Meld_Threshold[this_round][0]: if len(card_group) < 3: raise Exception("Too few cards in set - minimum is 3") card_numbers = [] num_cards = len(card_group) for card in card_group: if not isWild(card...
[ "def", "canPlayGroup", "(", "key", ",", "card_group", ",", "this_round", ")", ":", "if", "key", "[", "1", "]", "<", "Meld_Threshold", "[", "this_round", "]", "[", "0", "]", ":", "if", "len", "(", "card_group", ")", "<", "3", ":", "raise", "Exception"...
checks if a group can be played For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned appropriate tempnumber).
[ "checks", "if", "a", "group", "can", "be", "played", "For", "runs", "this", "assumes", "card_group", "has", "already", "been", "processed", "(", "sorted", "with", "Aces", "and", "Wilds", "assigned", "appropriate", "tempnumber", ")", "." ]
[ "\"\"\"checks if a group can be played\n \n For runs this assumes card_group has already been processed (sorted with Aces and Wilds assigned\n appropriate tempnumber).\n returns True if it can, otherwise raises an exception with an explanation.\n In dictionary key of prepared (=assigned) cards = key ...
[ { "param": "key", "type": null }, { "param": "card_group", "type": null }, { "param": "this_round", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "key", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "card_group", "type": null, "docstring": null, "docstring_token...
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
canMeld
<not_specific>
def canMeld(prepared_cards, round_index, player_index, hand_length): """This insures that all required groups are present, but the legality of the groups is not checked until later. """ # last round -- must play all cards if round_index == len(Meld_Threshold) - 1: pc_length = sum([len(run_list) for...
This insures that all required groups are present, but the legality of the groups is not checked until later.
This insures that all required groups are present, but the legality of the groups is not checked until later.
[ "This", "insures", "that", "all", "required", "groups", "are", "present", "but", "the", "legality", "of", "the", "groups", "is", "not", "checked", "until", "later", "." ]
def canMeld(prepared_cards, round_index, player_index, hand_length): if round_index == len(Meld_Threshold) - 1: pc_length = sum([len(run_list) for key, run_list in prepared_cards.items()]) if not pc_length == hand_length: raise Exception("Final round you must play ALL your cards to meld....
[ "def", "canMeld", "(", "prepared_cards", ",", "round_index", ",", "player_index", ",", "hand_length", ")", ":", "if", "round_index", "==", "len", "(", "Meld_Threshold", ")", "-", "1", ":", "pc_length", "=", "sum", "(", "[", "len", "(", "run_list", ")", "...
This insures that all required groups are present, but the legality of the groups is not checked until later.
[ "This", "insures", "that", "all", "required", "groups", "are", "present", "but", "the", "legality", "of", "the", "groups", "is", "not", "checked", "until", "later", "." ]
[ "\"\"\"This insures that all required groups are present, but the legality of the groups is not checked until later. \"\"\"", "# last round -- must play all cards" ]
[ { "param": "prepared_cards", "type": null }, { "param": "round_index", "type": null }, { "param": "player_index", "type": null }, { "param": "hand_length", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "prepared_cards", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "round_index", "type": null, "docstring": null, "doc...
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
canPlay
<not_specific>
def canPlay(processed_full_board, round_index): """Confirms each group to be played meets Liverpool requirements. Some rule checking (such as have enough groups to meld) were checked when processed_full_board was created.""" for k_group, card_group in processed_full_board.items(): canPlayGroup(k_gr...
Confirms each group to be played meets Liverpool requirements. Some rule checking (such as have enough groups to meld) were checked when processed_full_board was created.
Confirms each group to be played meets Liverpool requirements. Some rule checking (such as have enough groups to meld) were checked when processed_full_board was created.
[ "Confirms", "each", "group", "to", "be", "played", "meets", "Liverpool", "requirements", ".", "Some", "rule", "checking", "(", "such", "as", "have", "enough", "groups", "to", "meld", ")", "were", "checked", "when", "processed_full_board", "was", "created", "."...
def canPlay(processed_full_board, round_index): for k_group, card_group in processed_full_board.items(): canPlayGroup(k_group, card_group, round_index) return
[ "def", "canPlay", "(", "processed_full_board", ",", "round_index", ")", ":", "for", "k_group", ",", "card_group", "in", "processed_full_board", ".", "items", "(", ")", ":", "canPlayGroup", "(", "k_group", ",", "card_group", ",", "round_index", ")", "return" ]
Confirms each group to be played meets Liverpool requirements.
[ "Confirms", "each", "group", "to", "be", "played", "meets", "Liverpool", "requirements", "." ]
[ "\"\"\"Confirms each group to be played meets Liverpool requirements.\n\n Some rule checking (such as have enough groups to meld) were checked when processed_full_board was created.\"\"\"" ]
[ { "param": "processed_full_board", "type": null }, { "param": "round_index", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "processed_full_board", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "round_index", "type": null, "docstring": null, ...
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
combineCardDicts
<not_specific>
def combineCardDicts(dict1, dict2): """Combine two dictionaries of cards, such as played and to be played cards. This should work for both cards and serialized cards.""" combined_cards = {} for key in set(dict1).union(dict2): combo_list = [] for card in dict1.setdefault(key, []): ...
Combine two dictionaries of cards, such as played and to be played cards. This should work for both cards and serialized cards.
Combine two dictionaries of cards, such as played and to be played cards. This should work for both cards and serialized cards.
[ "Combine", "two", "dictionaries", "of", "cards", "such", "as", "played", "and", "to", "be", "played", "cards", ".", "This", "should", "work", "for", "both", "cards", "and", "serialized", "cards", "." ]
def combineCardDicts(dict1, dict2): combined_cards = {} for key in set(dict1).union(dict2): combo_list = [] for card in dict1.setdefault(key, []): combo_list.append(card) for card in dict2.setdefault(key, []): combo_list.append(card) combined_cards[key] = ...
[ "def", "combineCardDicts", "(", "dict1", ",", "dict2", ")", ":", "combined_cards", "=", "{", "}", "for", "key", "in", "set", "(", "dict1", ")", ".", "union", "(", "dict2", ")", ":", "combo_list", "=", "[", "]", "for", "card", "in", "dict1", ".", "s...
Combine two dictionaries of cards, such as played and to be played cards.
[ "Combine", "two", "dictionaries", "of", "cards", "such", "as", "played", "and", "to", "be", "played", "cards", "." ]
[ "\"\"\"Combine two dictionaries of cards, such as played and to be played cards.\n\n This should work for both cards and serialized cards.\"\"\"" ]
[ { "param": "dict1", "type": null }, { "param": "dict2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "dict1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dict2", "type": null, "docstring": null, "docstring_tokens":...
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
cardValue
<not_specific>
def cardValue(card): """Returns the point value for a card""" if card.number in [2, 3, 4, 5, 6, 7, 8, 9]: return 5 if card.number in [10, 11, 12, 13]: return 10 if card.number == 1: return 15 if card.number == 0: return 20 raise ValueError("Card submitted is not a...
Returns the point value for a card
Returns the point value for a card
[ "Returns", "the", "point", "value", "for", "a", "card" ]
def cardValue(card): if card.number in [2, 3, 4, 5, 6, 7, 8, 9]: return 5 if card.number in [10, 11, 12, 13]: return 10 if card.number == 1: return 15 if card.number == 0: return 20 raise ValueError("Card submitted is not a legal playing card option")
[ "def", "cardValue", "(", "card", ")", ":", "if", "card", ".", "number", "in", "[", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", "]", ":", "return", "5", "if", "card", ".", "number", "in", "[", "10", ",", "11"...
Returns the point value for a card
[ "Returns", "the", "point", "value", "for", "a", "card" ]
[ "\"\"\"Returns the point value for a card\"\"\"" ]
[ { "param": "card", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "card", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
goneOut
<not_specific>
def goneOut(played_cards): """Returns true if the played set of cards meets the requirements to go out This DOES NOT confirm that a player has no cards, that is the controllers job Review note: For Liverpool if the player has no cards, then they've gone out. Need to let server know, but no additional r...
Returns true if the played set of cards meets the requirements to go out This DOES NOT confirm that a player has no cards, that is the controllers job Review note: For Liverpool if the player has no cards, then they've gone out. Need to let server know, but no additional requirements. Function needed f...
Returns true if the played set of cards meets the requirements to go out This DOES NOT confirm that a player has no cards, that is the controllers job Review note: For Liverpool if the player has no cards, then they've gone out. Need to let server know, but no additional requirements. Function needed for HandAndFoot, s...
[ "Returns", "true", "if", "the", "played", "set", "of", "cards", "meets", "the", "requirements", "to", "go", "out", "This", "DOES", "NOT", "confirm", "that", "a", "player", "has", "no", "cards", "that", "is", "the", "controllers", "job", "Review", "note", ...
def goneOut(played_cards): return True
[ "def", "goneOut", "(", "played_cards", ")", ":", "return", "True" ]
Returns true if the played set of cards meets the requirements to go out This DOES NOT confirm that a player has no cards, that is the controllers job Review note: For Liverpool if the player has no cards, then they've gone out.
[ "Returns", "true", "if", "the", "played", "set", "of", "cards", "meets", "the", "requirements", "to", "go", "out", "This", "DOES", "NOT", "confirm", "that", "a", "player", "has", "no", "cards", "that", "is", "the", "controllers", "job", "Review", "note", ...
[ "\"\"\"Returns true if the played set of cards meets the requirements to go out\n\n This DOES NOT confirm that a player has no cards, that is the controllers job\n Review note: For Liverpool if the player has no cards, then they've gone out.\n Need to let server know, but no additional requirements.\n F...
[ { "param": "played_cards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "played_cards", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9ac67dfeab7d28905a5874e54f5a4d2a599b989f
hwoodward/Remote-Card-Games
source/common/Liverpool.py
[ "MIT" ]
Python
scoreGroup
<not_specific>
def scoreGroup(card_group): """Scores a group of cards for raw value""" score = 0 for card in card_group: score += cardValue(card) return score
Scores a group of cards for raw value
Scores a group of cards for raw value
[ "Scores", "a", "group", "of", "cards", "for", "raw", "value" ]
def scoreGroup(card_group): score = 0 for card in card_group: score += cardValue(card) return score
[ "def", "scoreGroup", "(", "card_group", ")", ":", "score", "=", "0", "for", "card", "in", "card_group", ":", "score", "+=", "cardValue", "(", "card", ")", "return", "score" ]
Scores a group of cards for raw value
[ "Scores", "a", "group", "of", "cards", "for", "raw", "value" ]
[ "\"\"\"Scores a group of cards for raw value\"\"\"" ]
[ { "param": "card_group", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "card_group", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aecceeaafadfd8b63a99a5d20fb004387b41c990
hwoodward/Remote-Card-Games
source/client/ClientState.py
[ "MIT" ]
Python
nextHand
null
def nextHand(self): """Transition to the next hand in the hand_list""" if len(self.hand_cards) > 0: raise Exception("You can't pick up your foot while you have cards left in your hand.") self.hand_cards = self.hand_list.pop()
Transition to the next hand in the hand_list
Transition to the next hand in the hand_list
[ "Transition", "to", "the", "next", "hand", "in", "the", "hand_list" ]
def nextHand(self): if len(self.hand_cards) > 0: raise Exception("You can't pick up your foot while you have cards left in your hand.") self.hand_cards = self.hand_list.pop()
[ "def", "nextHand", "(", "self", ")", ":", "if", "len", "(", "self", ".", "hand_cards", ")", ">", "0", ":", "raise", "Exception", "(", "\"You can't pick up your foot while you have cards left in your hand.\"", ")", "self", ".", "hand_cards", "=", "self", ".", "ha...
Transition to the next hand in the hand_list
[ "Transition", "to", "the", "next", "hand", "in", "the", "hand_list" ]
[ "\"\"\"Transition to the next hand in the hand_list\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aecceeaafadfd8b63a99a5d20fb004387b41c990
hwoodward/Remote-Card-Games
source/client/ClientState.py
[ "MIT" ]
Python
checkGoneOut
<not_specific>
def checkGoneOut(self): """Check if a player has gone out""" if len(self.hand_cards) > 0: return False if len(self.hand_list) > 0: return False return self.rules.goneOut(self.played_cards)
Check if a player has gone out
Check if a player has gone out
[ "Check", "if", "a", "player", "has", "gone", "out" ]
def checkGoneOut(self): if len(self.hand_cards) > 0: return False if len(self.hand_list) > 0: return False return self.rules.goneOut(self.played_cards)
[ "def", "checkGoneOut", "(", "self", ")", ":", "if", "len", "(", "self", ".", "hand_cards", ")", ">", "0", ":", "return", "False", "if", "len", "(", "self", ".", "hand_list", ")", ">", "0", ":", "return", "False", "return", "self", ".", "rules", "."...
Check if a player has gone out
[ "Check", "if", "a", "player", "has", "gone", "out" ]
[ "\"\"\"Check if a player has gone out\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aecceeaafadfd8b63a99a5d20fb004387b41c990
hwoodward/Remote-Card-Games
source/client/ClientState.py
[ "MIT" ]
Python
reset
null
def reset(self): """Clear out round specific state to prepare for next round to start""" self.hand_list = [] self.hand_cards = [] # If self.rules.Shared_Board is False (HandAndFoot) # self.played_cards is dictionary of cards played by this client. # If self.rules.Sh...
Clear out round specific state to prepare for next round to start
Clear out round specific state to prepare for next round to start
[ "Clear", "out", "round", "specific", "state", "to", "prepare", "for", "next", "round", "to", "start" ]
def reset(self): self.hand_list = [] self.hand_cards = [] self.played_cards = {} self.went_out = False self.discard_info = [None, 0]
[ "def", "reset", "(", "self", ")", ":", "self", ".", "hand_list", "=", "[", "]", "self", ".", "hand_cards", "=", "[", "]", "self", ".", "played_cards", "=", "{", "}", "self", ".", "went_out", "=", "False", "self", ".", "discard_info", "=", "[", "Non...
Clear out round specific state to prepare for next round to start
[ "Clear", "out", "round", "specific", "state", "to", "prepare", "for", "next", "round", "to", "start" ]
[ "\"\"\"Clear out round specific state to prepare for next round to start\"\"\"", "# If self.rules.Shared_Board is False (HandAndFoot)", "# self.played_cards is dictionary of cards played by this client.", "# If self.rules.Shared_Board is True (Liverpool)", "# it is a dictionary containing cards play...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aecceeaafadfd8b63a99a5d20fb004387b41c990
hwoodward/Remote-Card-Games
source/client/ClientState.py
[ "MIT" ]
Python
playCards
null
def playCards(self, prepared_cards, processed_full_board={}): """Move cards from hand to board if play follows rules, else inform what rule is broken.""" # First check that all the cards are in your hand. tempHand = [x for x in self.hand_cards] try: for card_group in prepare...
Move cards from hand to board if play follows rules, else inform what rule is broken.
Move cards from hand to board if play follows rules, else inform what rule is broken.
[ "Move", "cards", "from", "hand", "to", "board", "if", "play", "follows", "rules", "else", "inform", "what", "rule", "is", "broken", "." ]
def playCards(self, prepared_cards, processed_full_board={}): tempHand = [x for x in self.hand_cards] try: for card_group in prepared_cards.values(): for card in card_group: tempHand.remove(card) except ValueError: raise Exception("Atte...
[ "def", "playCards", "(", "self", ",", "prepared_cards", ",", "processed_full_board", "=", "{", "}", ")", ":", "tempHand", "=", "[", "x", "for", "x", "in", "self", ".", "hand_cards", "]", "try", ":", "for", "card_group", "in", "prepared_cards", ".", "valu...
Move cards from hand to board if play follows rules, else inform what rule is broken.
[ "Move", "cards", "from", "hand", "to", "board", "if", "play", "follows", "rules", "else", "inform", "what", "rule", "is", "broken", "." ]
[ "\"\"\"Move cards from hand to board if play follows rules, else inform what rule is broken.\"\"\"", "# First check that all the cards are in your hand." ]
[ { "param": "self", "type": null }, { "param": "prepared_cards", "type": null }, { "param": "processed_full_board", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prepared_cards", "type": null, "docstring": null, "docstring_...
aecceeaafadfd8b63a99a5d20fb004387b41c990
hwoodward/Remote-Card-Games
source/client/ClientState.py
[ "MIT" ]
Python
pickupPileRuleCheck
<not_specific>
def pickupPileRuleCheck(self, prepared_cards): """Confirm a player can pick up the pile with the prepared cards""" # check there are enough cards if self.discard_info[1] < self.rules.Pickup_Size: text = 'Cannot pickup the pile until there are ' + str(self.rules.Pickup_Size) + ' cards...
Confirm a player can pick up the pile with the prepared cards
Confirm a player can pick up the pile with the prepared cards
[ "Confirm", "a", "player", "can", "pick", "up", "the", "pile", "with", "the", "prepared", "cards" ]
def pickupPileRuleCheck(self, prepared_cards): if self.discard_info[1] < self.rules.Pickup_Size: text = 'Cannot pickup the pile until there are ' + str(self.rules.Pickup_Size) + ' cards.' raise Exception(text) return self.rules.canPickupPile(self.discard_info[0], prepared_cards, ...
[ "def", "pickupPileRuleCheck", "(", "self", ",", "prepared_cards", ")", ":", "if", "self", ".", "discard_info", "[", "1", "]", "<", "self", ".", "rules", ".", "Pickup_Size", ":", "text", "=", "'Cannot pickup the pile until there are '", "+", "str", "(", "self",...
Confirm a player can pick up the pile with the prepared cards
[ "Confirm", "a", "player", "can", "pick", "up", "the", "pile", "with", "the", "prepared", "cards" ]
[ "\"\"\"Confirm a player can pick up the pile with the prepared cards\"\"\"", "# check there are enough cards" ]
[ { "param": "self", "type": null }, { "param": "prepared_cards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prepared_cards", "type": null, "docstring": null, "docstring_...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
draw
<not_specific>
def draw(self): """Request a draw from the server""" if self._state.turn_phase != Turn_Phases[1]: self.note = "You can only draw at the start of your turn" return connection.Send({"action": "draw"}) #Transition phase immediately to avoid double draw self._...
Request a draw from the server
Request a draw from the server
[ "Request", "a", "draw", "from", "the", "server" ]
def draw(self): if self._state.turn_phase != Turn_Phases[1]: self.note = "You can only draw at the start of your turn" return connection.Send({"action": "draw"}) self._state.turn_phase = Turn_Phases[3]
[ "def", "draw", "(", "self", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "!=", "Turn_Phases", "[", "1", "]", ":", "self", ".", "note", "=", "\"You can only draw at the start of your turn\"", "return", "connection", ".", "Send", "(", "{", "\"acti...
Request a draw from the server
[ "Request", "a", "draw", "from", "the", "server" ]
[ "\"\"\"Request a draw from the server\"\"\"", "#Transition phase immediately to avoid double draw" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
drawWithBuyOption
<not_specific>
def drawWithBuyOption(self): """ in games with buy option use this method instead of draw (above)""" if self._state.turn_phase != Turn_Phases[1]: self.note = "You can only draw at the start of your turn" return connection.Send({"action": "drawWithBuyOption"}) # Tr...
in games with buy option use this method instead of draw (above)
in games with buy option use this method instead of draw (above)
[ "in", "games", "with", "buy", "option", "use", "this", "method", "instead", "of", "draw", "(", "above", ")" ]
def drawWithBuyOption(self): if self._state.turn_phase != Turn_Phases[1]: self.note = "You can only draw at the start of your turn" return connection.Send({"action": "drawWithBuyOption"}) self._state.turn_phase = Turn_Phases[3]
[ "def", "drawWithBuyOption", "(", "self", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "!=", "Turn_Phases", "[", "1", "]", ":", "self", ".", "note", "=", "\"You can only draw at the start of your turn\"", "return", "connection", ".", "Send", "(", "...
in games with buy option use this method instead of draw (above)
[ "in", "games", "with", "buy", "option", "use", "this", "method", "instead", "of", "draw", "(", "above", ")" ]
[ "\"\"\" in games with buy option use this method instead of draw (above)\"\"\"", "# Transition phase immediately to avoid double draw" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
pickUpPile
<not_specific>
def pickUpPile(self, note): """Attempt to pick up the pile""" if self._state.turn_phase != Turn_Phases[1]: self.note = note return try: self._state.pickupPileRuleCheck(self.prepared_cards) except Exception as err: self.note = "{0}".format(e...
Attempt to pick up the pile
Attempt to pick up the pile
[ "Attempt", "to", "pick", "up", "the", "pile" ]
def pickUpPile(self, note): if self._state.turn_phase != Turn_Phases[1]: self.note = note return try: self._state.pickupPileRuleCheck(self.prepared_cards) except Exception as err: self.note = "{0}".format(err) else: if self._sta...
[ "def", "pickUpPile", "(", "self", ",", "note", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "!=", "Turn_Phases", "[", "1", "]", ":", "self", ".", "note", "=", "note", "return", "try", ":", "self", ".", "_state", ".", "pickupPileRuleCheck",...
Attempt to pick up the pile
[ "Attempt", "to", "pick", "up", "the", "pile" ]
[ "\"\"\"Attempt to pick up the pile\"\"\"", "#Set turn phase to reflect forced action", "# No action required if rules.play_pick_up = False" ]
[ { "param": "self", "type": null }, { "param": "note", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "note", "type": null, "docstring": null, "docstring_tokens": [...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
makeForcedPlay
null
def makeForcedPlay(self, top_card): """Complete the required play for picking up the pile, (used for games with play_pick_up true)""" self.note = "Performing the play required to pick up the pile." #Get key for top_card (we know it can be auto-keyed), and then prepare it key = self._stat...
Complete the required play for picking up the pile, (used for games with play_pick_up true)
Complete the required play for picking up the pile, (used for games with play_pick_up true)
[ "Complete", "the", "required", "play", "for", "picking", "up", "the", "pile", "(", "used", "for", "games", "with", "play_pick_up", "true", ")" ]
def makeForcedPlay(self, top_card): self.note = "Performing the play required to pick up the pile." key = self._state.getValidKeys(top_card)[0] self.prepared_cards.setdefault(key, []).append(top_card) self._state.turn_phase = Turn_Phases[3] self.play()
[ "def", "makeForcedPlay", "(", "self", ",", "top_card", ")", ":", "self", ".", "note", "=", "\"Performing the play required to pick up the pile.\"", "key", "=", "self", ".", "_state", ".", "getValidKeys", "(", "top_card", ")", "[", "0", "]", "self", ".", "prepa...
Complete the required play for picking up the pile, (used for games with play_pick_up true)
[ "Complete", "the", "required", "play", "for", "picking", "up", "the", "pile", "(", "used", "for", "games", "with", "play_pick_up", "true", ")" ]
[ "\"\"\"Complete the required play for picking up the pile, (used for games with play_pick_up true)\"\"\"", "#Get key for top_card (we know it can be auto-keyed), and then prepare it", "#Can't just call prepared card b/c of turn phase checking", "#Set turn phase to allow play and then immediately make play" ]
[ { "param": "self", "type": null }, { "param": "top_card", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "top_card", "type": null, "docstring": null, "docstring_tokens...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
automaticallyPrepareCards
<not_specific>
def automaticallyPrepareCards(self, selected_cards): """HandAndFoot specific: Prepare selected cards to be played. Called from HandAndFootButtons.py. Assumes all groups are sets Fully prepares natural cards Returns options for where to play wild cards Returns message th...
HandAndFoot specific: Prepare selected cards to be played. Called from HandAndFootButtons.py. Assumes all groups are sets Fully prepares natural cards Returns options for where to play wild cards Returns message that you can't play 3s
HandAndFoot specific: Prepare selected cards to be played.
[ "HandAndFoot", "specific", ":", "Prepare", "selected", "cards", "to", "be", "played", "." ]
def automaticallyPrepareCards(self, selected_cards): if self._state.turn_phase == Turn_Phases[2]: self.note = "You can't change prepared cards while waiting to finish picking up the pile" return user_input_cards = [] for wrappedcard in selected_cards: card = w...
[ "def", "automaticallyPrepareCards", "(", "self", ",", "selected_cards", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "==", "Turn_Phases", "[", "2", "]", ":", "self", ".", "note", "=", "\"You can't change prepared cards while waiting to finish picking up t...
HandAndFoot specific: Prepare selected cards to be played.
[ "HandAndFoot", "specific", ":", "Prepare", "selected", "cards", "to", "be", "played", "." ]
[ "\"\"\"HandAndFoot specific: Prepare selected cards to be played. Called from HandAndFootButtons.py.\n \n Assumes all groups are sets\n Fully prepares natural cards\n Returns options for where to play wild cards\n Returns message that you can't play 3s\n \"\"\"", "#This ...
[ { "param": "self", "type": null }, { "param": "selected_cards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "selected_cards", "type": null, "docstring": null, "docstring_...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
assignCardsToGroup
<not_specific>
def assignCardsToGroup(self, assigned_key, selected_cards): """Assign cards to specific groups based on button clicked. Wilds are assigned to group, but it's assigned value is not determined until group is played. This method is needed in games where player explicitly assigns cards to groups ...
Assign cards to specific groups based on button clicked. Wilds are assigned to group, but it's assigned value is not determined until group is played. This method is needed in games where player explicitly assigns cards to groups (such as Liverpool). In games that are purely set-based (such ...
Assign cards to specific groups based on button clicked. Wilds are assigned to group, but it's assigned value is not determined until group is played. This method is needed in games where player explicitly assigns cards to groups (such as Liverpool). In games that are purely set-based (such as Hand and Foot) this is no...
[ "Assign", "cards", "to", "specific", "groups", "based", "on", "button", "clicked", ".", "Wilds", "are", "assigned", "to", "group", "but", "it", "'", "s", "assigned", "value", "is", "not", "determined", "until", "group", "is", "played", ".", "This", "method...
def assignCardsToGroup(self, assigned_key, selected_cards): for wrappedcard in selected_cards: card = wrappedcard.card self.prepareCard(assigned_key, card) return
[ "def", "assignCardsToGroup", "(", "self", ",", "assigned_key", ",", "selected_cards", ")", ":", "for", "wrappedcard", "in", "selected_cards", ":", "card", "=", "wrappedcard", ".", "card", "self", ".", "prepareCard", "(", "assigned_key", ",", "card", ")", "retu...
Assign cards to specific groups based on button clicked.
[ "Assign", "cards", "to", "specific", "groups", "based", "on", "button", "clicked", "." ]
[ "\"\"\"Assign cards to specific groups based on button clicked.\n\n Wilds are assigned to group, but it's assigned value is not determined until group is played.\n This method is needed in games where player explicitly assigns cards to groups (such as Liverpool).\n In games that are purely s...
[ { "param": "self", "type": null }, { "param": "assigned_key", "type": null }, { "param": "selected_cards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "assigned_key", "type": null, "docstring": null, "docstring_to...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
prepareCard
<not_specific>
def prepareCard(self, key, card): """Prepare the selected card with the specified key""" if self._state.turn_phase == Turn_Phases[2]: self.note = "You can't change prepared cards while waiting to finish picking up the pile" return self.prepared_cards.setdefault(key, []).a...
Prepare the selected card with the specified key
Prepare the selected card with the specified key
[ "Prepare", "the", "selected", "card", "with", "the", "specified", "key" ]
def prepareCard(self, key, card): if self._state.turn_phase == Turn_Phases[2]: self.note = "You can't change prepared cards while waiting to finish picking up the pile" return self.prepared_cards.setdefault(key, []).append(card)
[ "def", "prepareCard", "(", "self", ",", "key", ",", "card", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "==", "Turn_Phases", "[", "2", "]", ":", "self", ".", "note", "=", "\"You can't change prepared cards while waiting to finish picking up the pile\...
Prepare the selected card with the specified key
[ "Prepare", "the", "selected", "card", "with", "the", "specified", "key" ]
[ "\"\"\"Prepare the selected card with the specified key\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "key", "type": null }, { "param": "card", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": null, "docstring": null, "docstring_tokens": []...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
play
<not_specific>
def play(self): """Send the server the current set of played cards player_index and visible_scards needed for rules checking in games with Shared_Board. """ if self._state.turn_phase != Turn_Phases[3]: self.note = "You can only play on your turn after you draw" ...
Send the server the current set of played cards player_index and visible_scards needed for rules checking in games with Shared_Board.
Send the server the current set of played cards player_index and visible_scards needed for rules checking in games with Shared_Board.
[ "Send", "the", "server", "the", "current", "set", "of", "played", "cards", "player_index", "and", "visible_scards", "needed", "for", "rules", "checking", "in", "games", "with", "Shared_Board", "." ]
def play(self): if self._state.turn_phase != Turn_Phases[3]: self.note = "You can only play on your turn after you draw" return try: if self._state.rules.Shared_Board: self._state.playCards(self.prepared_cards, self.processed_full_board) el...
[ "def", "play", "(", "self", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "!=", "Turn_Phases", "[", "3", "]", ":", "self", ".", "note", "=", "\"You can only play on your turn after you draw\"", "return", "try", ":", "if", "self", ".", "_state", ...
Send the server the current set of played cards player_index and visible_scards needed for rules checking in games with Shared_Board.
[ "Send", "the", "server", "the", "current", "set", "of", "played", "cards", "player_index", "and", "visible_scards", "needed", "for", "rules", "checking", "in", "games", "with", "Shared_Board", "." ]
[ "\"\"\"Send the server the current set of played cards\n\n player_index and visible_scards needed for rules checking in games with Shared_Board.\n \"\"\"", "# Some rule checking on runs is performed in self.processCards (called before this).", "# In Liverpool and other shared_board games reset A...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
resetPreparedWildsAces
null
def resetPreparedWildsAces(self): """ If prepared cards cannot be played, then the values of WildCards and Aces should be reset""" for card_group in self.prepared_cards.values(): for card in card_group: card.tempnumber = card.number
If prepared cards cannot be played, then the values of WildCards and Aces should be reset
If prepared cards cannot be played, then the values of WildCards and Aces should be reset
[ "If", "prepared", "cards", "cannot", "be", "played", "then", "the", "values", "of", "WildCards", "and", "Aces", "should", "be", "reset" ]
def resetPreparedWildsAces(self): for card_group in self.prepared_cards.values(): for card in card_group: card.tempnumber = card.number
[ "def", "resetPreparedWildsAces", "(", "self", ")", ":", "for", "card_group", "in", "self", ".", "prepared_cards", ".", "values", "(", ")", ":", "for", "card", "in", "card_group", ":", "card", ".", "tempnumber", "=", "card", ".", "number" ]
If prepared cards cannot be played, then the values of WildCards and Aces should be reset
[ "If", "prepared", "cards", "cannot", "be", "played", "then", "the", "values", "of", "WildCards", "and", "Aces", "should", "be", "reset" ]
[ "\"\"\" If prepared cards cannot be played, then the values of WildCards and Aces should be reset\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
sharedBoardPrepAndPlay
<not_specific>
def sharedBoardPrepAndPlay(self, visible_scards): """ Playing cards is a 4 step process: 1. Verify it's your turn. 2. process cards, this will set tempnumbers properly and put them in dictionary controller.processed_cards. in the process, some rules of runs are verified (have mel...
Playing cards is a 4 step process: 1. Verify it's your turn. 2. process cards, this will set tempnumbers properly and put them in dictionary controller.processed_cards. in the process, some rules of runs are verified (have meld requirement, not playing on other players, no r...
Playing cards is a 4 step process: 1. Verify it's your turn. 2. process cards, this will set tempnumbers properly and put them in dictionary controller.processed_cards. in the process, some rules of runs are verified (have meld requirement, not playing on other players, no repeats of cards in runs, and Aces can't tur...
[ "Playing", "cards", "is", "a", "4", "step", "process", ":", "1", ".", "Verify", "it", "'", "s", "your", "turn", ".", "2", ".", "process", "cards", "this", "will", "set", "tempnumbers", "properly", "and", "put", "them", "in", "dictionary", "controller", ...
def sharedBoardPrepAndPlay(self, visible_scards): if self._state.turn_phase != Turn_Phases[3]: self.note = "You can only play on your turn and only after you draw" return self.processed_full_board = {} try: self.processCards(visible_scards) except Exce...
[ "def", "sharedBoardPrepAndPlay", "(", "self", ",", "visible_scards", ")", ":", "if", "self", ".", "_state", ".", "turn_phase", "!=", "Turn_Phases", "[", "3", "]", ":", "self", ".", "note", "=", "\"You can only play on your turn and only after you draw\"", "return", ...
Playing cards is a 4 step process: 1.
[ "Playing", "cards", "is", "a", "4", "step", "process", ":", "1", "." ]
[ "\"\"\" Playing cards is a 4 step process:\n 1. Verify it's your turn.\n 2. process cards, this will set tempnumbers properly and put them in dictionary controller.processed_cards.\n in the process, some rules of runs are verified (have meld requirement, not playing on other players,\n ...
[ { "param": "self", "type": null }, { "param": "visible_scards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "visible_scards", "type": null, "docstring": null, "docstring_...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
processCards
<not_specific>
def processCards(self, visible_scards): """ Combine prepared cards and cards already on shared board. Runs must be processed a fair bit to determine location of wilds--this is done in processRuns. Some rule checking is performed here (before prepared and cards on shared board are combined: ...
Combine prepared cards and cards already on shared board. Runs must be processed a fair bit to determine location of wilds--this is done in processRuns. Some rule checking is performed here (before prepared and cards on shared board are combined: (i) Players cannot commence play by another ...
Combine prepared cards and cards already on shared board. Runs must be processed a fair bit to determine location of wilds--this is done in processRuns. Some rule checking is performed here (before prepared and cards on shared board are combined: (i) Players cannot commence play by another player & (ii) must have all ...
[ "Combine", "prepared", "cards", "and", "cards", "already", "on", "shared", "board", ".", "Runs", "must", "be", "processed", "a", "fair", "bit", "to", "determine", "location", "of", "wilds", "--", "this", "is", "done", "in", "processRuns", ".", "Some", "rul...
def processCards(self, visible_scards): played_groups = [] for key, card_group in visible_scards[0].items(): if len(card_group) > 0: played_groups.append(key) for key, card_group in self.prepared_cards.items(): if len(card_group) > 0: g...
[ "def", "processCards", "(", "self", ",", "visible_scards", ")", ":", "played_groups", "=", "[", "]", "for", "key", ",", "card_group", "in", "visible_scards", "[", "0", "]", ".", "items", "(", ")", ":", "if", "len", "(", "card_group", ")", ">", "0", "...
Combine prepared cards and cards already on shared board.
[ "Combine", "prepared", "cards", "and", "cards", "already", "on", "shared", "board", "." ]
[ "\"\"\" Combine prepared cards and cards already on shared board.\n\n Runs must be processed a fair bit to determine location of wilds--this is done in processRuns.\n Some rule checking is performed here (before prepared and cards on shared board are combined:\n (i) Players cannot commence p...
[ { "param": "self", "type": null }, { "param": "visible_scards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "visible_scards", "type": null, "docstring": null, "docstring_...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
resetProcessedCards
<not_specific>
def resetProcessedCards(self, visible_scards): """ used in games with Shared_Board True after a player disconnects Resets processed_full_board and played_cards to remove disconnected player from board.""" numsets = self._state.rules.Meld_Threshold[self._state.round][0] self.played_cards...
used in games with Shared_Board True after a player disconnects Resets processed_full_board and played_cards to remove disconnected player from board.
used in games with Shared_Board True after a player disconnects Resets processed_full_board and played_cards to remove disconnected player from board.
[ "used", "in", "games", "with", "Shared_Board", "True", "after", "a", "player", "disconnects", "Resets", "processed_full_board", "and", "played_cards", "to", "remove", "disconnected", "player", "from", "board", "." ]
def resetProcessedCards(self, visible_scards): numsets = self._state.rules.Meld_Threshold[self._state.round][0] self.played_cards = restoreRunAssignment(visible_scards[0], self._state.rules.wild_numbers, numsets) self.processed_full_board = self.played_cards self._state.played_cards = se...
[ "def", "resetProcessedCards", "(", "self", ",", "visible_scards", ")", ":", "numsets", "=", "self", ".", "_state", ".", "rules", ".", "Meld_Threshold", "[", "self", ".", "_state", ".", "round", "]", "[", "0", "]", "self", ".", "played_cards", "=", "resto...
used in games with Shared_Board True after a player disconnects Resets processed_full_board and played_cards to remove disconnected player from board.
[ "used", "in", "games", "with", "Shared_Board", "True", "after", "a", "player", "disconnects", "Resets", "processed_full_board", "and", "played_cards", "to", "remove", "disconnected", "player", "from", "board", "." ]
[ "\"\"\" used in games with Shared_Board True after a player disconnects\n\n Resets processed_full_board and played_cards to remove disconnected player from board.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "visible_scards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "visible_scards", "type": null, "docstring": null, "docstring_...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
handleEmptyHand
<not_specific>
def handleEmptyHand(self, isDiscard): """Checks for and handles empty hand. If they are out of their hand, transitions to the next hand. If they are out of all their hands checks if they are actually out If they are out notifies the server """ if len(self._state...
Checks for and handles empty hand. If they are out of their hand, transitions to the next hand. If they are out of all their hands checks if they are actually out If they are out notifies the server
Checks for and handles empty hand. If they are out of their hand, transitions to the next hand. If they are out of all their hands checks if they are actually out If they are out notifies the server
[ "Checks", "for", "and", "handles", "empty", "hand", ".", "If", "they", "are", "out", "of", "their", "hand", "transitions", "to", "the", "next", "hand", ".", "If", "they", "are", "out", "of", "all", "their", "hands", "checks", "if", "they", "are", "actu...
def handleEmptyHand(self, isDiscard): if len(self._state.hand_cards) > 0: return False elif len(self._state.hand_list) > 0: self._state.nextHand() return False elif self._state.checkGoneOut(): self.note = "You went out to end the round!" ...
[ "def", "handleEmptyHand", "(", "self", ",", "isDiscard", ")", ":", "if", "len", "(", "self", ".", "_state", ".", "hand_cards", ")", ">", "0", ":", "return", "False", "elif", "len", "(", "self", ".", "_state", ".", "hand_list", ")", ">", "0", ":", "...
Checks for and handles empty hand.
[ "Checks", "for", "and", "handles", "empty", "hand", "." ]
[ "\"\"\"Checks for and handles empty hand. \n \n If they are out of their hand, transitions to the next hand.\n If they are out of all their hands checks if they are actually out\n If they are out notifies the server\n \"\"\"", "# end active state after going out.", "#If you pl...
[ { "param": "self", "type": null }, { "param": "isDiscard", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "isDiscard", "type": null, "docstring": null, "docstring_token...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
sendPublicInfo
null
def sendPublicInfo(self): """Utility method to send public information to the server""" serialized_cards = {key:[card.serialize() for card in card_group] for (key, card_group) in self._state.played_cards.items()} status_info = self._state.getHandStatus() connection.Send({"action": "publi...
Utility method to send public information to the server
Utility method to send public information to the server
[ "Utility", "method", "to", "send", "public", "information", "to", "the", "server" ]
def sendPublicInfo(self): serialized_cards = {key:[card.serialize() for card in card_group] for (key, card_group) in self._state.played_cards.items()} status_info = self._state.getHandStatus() connection.Send({"action": "publicInfo", "visible_cards":serialized_cards, "hand_status":status_info})
[ "def", "sendPublicInfo", "(", "self", ")", ":", "serialized_cards", "=", "{", "key", ":", "[", "card", ".", "serialize", "(", ")", "for", "card", "in", "card_group", "]", "for", "(", "key", ",", "card_group", ")", "in", "self", ".", "_state", ".", "p...
Utility method to send public information to the server
[ "Utility", "method", "to", "send", "public", "information", "to", "the", "server" ]
[ "\"\"\"Utility method to send public information to the server\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
Network_connectionDenied
null
def Network_connectionDenied(self, data): """Server denied the connection, likely due to a game already in progress""" print('Server denied connection request') self.note = "Server denied connection request :(" connection.Close()
Server denied the connection, likely due to a game already in progress
Server denied the connection, likely due to a game already in progress
[ "Server", "denied", "the", "connection", "likely", "due", "to", "a", "game", "already", "in", "progress" ]
def Network_connectionDenied(self, data): print('Server denied connection request') self.note = "Server denied connection request :(" connection.Close()
[ "def", "Network_connectionDenied", "(", "self", ",", "data", ")", ":", "print", "(", "'Server denied connection request'", ")", "self", ".", "note", "=", "\"Server denied connection request :(\"", "connection", ".", "Close", "(", ")" ]
Server denied the connection, likely due to a game already in progress
[ "Server", "denied", "the", "connection", "likely", "due", "to", "a", "game", "already", "in", "progress" ]
[ "\"\"\"Server denied the connection, likely due to a game already in progress\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [...
3592269eb722c0a3fadd925ac7bdeaa0a88d6a36
hwoodward/Remote-Card-Games
source/client/Controller.py
[ "MIT" ]
Python
Network_endRound
null
def Network_endRound(self, data): """Notification that specified player has gone out to end the round""" out_player = data["player"] self.note = "{0} has gone out to end the round!".format(out_player) self._state.round = -1 score = self._state.scoreRound() connection.Send...
Notification that specified player has gone out to end the round
Notification that specified player has gone out to end the round
[ "Notification", "that", "specified", "player", "has", "gone", "out", "to", "end", "the", "round" ]
def Network_endRound(self, data): out_player = data["player"] self.note = "{0} has gone out to end the round!".format(out_player) self._state.round = -1 score = self._state.scoreRound() connection.Send({"action": "reportScore", "score": score}) self.setReady(False)
[ "def", "Network_endRound", "(", "self", ",", "data", ")", ":", "out_player", "=", "data", "[", "\"player\"", "]", "self", ".", "note", "=", "\"{0} has gone out to end the round!\"", ".", "format", "(", "out_player", ")", "self", ".", "_state", ".", "round", ...
Notification that specified player has gone out to end the round
[ "Notification", "that", "specified", "player", "has", "gone", "out", "to", "end", "the", "round" ]
[ "\"\"\"Notification that specified player has gone out to end the round\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [...
003bb8649f9286f7db0a21d46ad8f17c656e6412
hwoodward/Remote-Card-Games
source/client/TableView.py
[ "MIT" ]
Python
compressSets
null
def compressSets(self, v_scards): """ HandAndFoot specific: Don't have space to display every card. Summarize sets of cards here. """ self.compressed_info = {} for idx in range(len(v_scards)): summary = {} key_player = self.player_names[idx] melded = dict(v_s...
HandAndFoot specific: Don't have space to display every card. Summarize sets of cards here.
HandAndFoot specific: Don't have space to display every card. Summarize sets of cards here.
[ "HandAndFoot", "specific", ":", "Don", "'", "t", "have", "space", "to", "display", "every", "card", ".", "Summarize", "sets", "of", "cards", "here", "." ]
def compressSets(self, v_scards): self.compressed_info = {} for idx in range(len(v_scards)): summary = {} key_player = self.player_names[idx] melded = dict(v_scards[idx]) for key in melded: set = melded[key] length_set = len...
[ "def", "compressSets", "(", "self", ",", "v_scards", ")", ":", "self", ".", "compressed_info", "=", "{", "}", "for", "idx", "in", "range", "(", "len", "(", "v_scards", ")", ")", ":", "summary", "=", "{", "}", "key_player", "=", "self", ".", "player_n...
HandAndFoot specific: Don't have space to display every card.
[ "HandAndFoot", "specific", ":", "Don", "'", "t", "have", "space", "to", "display", "every", "card", "." ]
[ "\"\"\" HandAndFoot specific: Don't have space to display every card. Summarize sets of cards here. \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "v_scards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v_scards", "type": null, "docstring": null, "docstring_tokens...
003bb8649f9286f7db0a21d46ad8f17c656e6412
hwoodward/Remote-Card-Games
source/client/TableView.py
[ "MIT" ]
Python
compressGroups
null
def compressGroups(self, v_scards): """ Liverpool specific: Don't have space to display every card. Summarize groups of cards here. """ # In Liverpool: # visible cards structure: # a list containing 1 dictionary where each entry in dictionary is a list of serialized cards # play...
Liverpool specific: Don't have space to display every card. Summarize groups of cards here.
Liverpool specific: Don't have space to display every card. Summarize groups of cards here.
[ "Liverpool", "specific", ":", "Don", "'", "t", "have", "space", "to", "display", "every", "card", ".", "Summarize", "groups", "of", "cards", "here", "." ]
def compressGroups(self, v_scards): Don't reset i_num_sets in new round until player has hit OK key, which resets v_scards. if len(v_scards) == 0: self.i_num_sets = int(self.Meld_Threshold[self.round_index][0]) else: if len(v_scards[0]) == 0: self.i_num_s...
[ "def", "compressGroups", "(", "self", ",", "v_scards", ")", ":", "if", "len", "(", "v_scards", ")", "==", "0", ":", "self", ".", "i_num_sets", "=", "int", "(", "self", ".", "Meld_Threshold", "[", "self", ".", "round_index", "]", "[", "0", "]", ")", ...
Liverpool specific: Don't have space to display every card.
[ "Liverpool", "specific", ":", "Don", "'", "t", "have", "space", "to", "display", "every", "card", "." ]
[ "\"\"\" Liverpool specific: Don't have space to display every card. Summarize groups of cards here. \"\"\"", "# In Liverpool:", "# visible cards structure:", "# a list containing 1 dictionary where each entry in dictionary is a list of serialized cards", "# played with key =(player, group) tuple. Cards are...
[ { "param": "self", "type": null }, { "param": "v_scards", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v_scards", "type": null, "docstring": null, "docstring_tokens...
003bb8649f9286f7db0a21d46ad8f17c656e6412
hwoodward/Remote-Card-Games
source/client/TableView.py
[ "MIT" ]
Python
Network_scores
null
def Network_scores(self, data): """Notification from the server of the scores, in turn order""" round_scores = data["round_scores"] total_scores = data["total_scores"] self.results = {} self.results_cmdscreen = '' for idx in range(len(self.player_names)): sel...
Notification from the server of the scores, in turn order
Notification from the server of the scores, in turn order
[ "Notification", "from", "the", "server", "of", "the", "scores", "in", "turn", "order" ]
def Network_scores(self, data): round_scores = data["round_scores"] total_scores = data["total_scores"] self.results = {} self.results_cmdscreen = '' for idx in range(len(self.player_names)): self.results[self.player_names[idx]] = total_scores[idx] self.re...
[ "def", "Network_scores", "(", "self", ",", "data", ")", ":", "round_scores", "=", "data", "[", "\"round_scores\"", "]", "total_scores", "=", "data", "[", "\"total_scores\"", "]", "self", ".", "results", "=", "{", "}", "self", ".", "results_cmdscreen", "=", ...
Notification from the server of the scores, in turn order
[ "Notification", "from", "the", "server", "of", "the", "scores", "in", "turn", "order" ]
[ "\"\"\"Notification from the server of the scores, in turn order\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [...
2bcd5af304582e84a6d30a584ec6059bfb920e4f
bnesposito/client-attrition
code/work_data.py
[ "Apache-2.0" ]
Python
basic_descriptive
<not_specific>
def basic_descriptive(my_df): """ Report basic descriptive stats for a pd.DataFrame. Args: my_df (pd.DataFrame): target DataFrame. Returns: Nothing. All results are printed. """ n_row, n_col = my_df.shape cols = my_df.columns logger.info('# observations: {0}'.format(n_ro...
Report basic descriptive stats for a pd.DataFrame. Args: my_df (pd.DataFrame): target DataFrame. Returns: Nothing. All results are printed.
Report basic descriptive stats for a pd.DataFrame.
[ "Report", "basic", "descriptive", "stats", "for", "a", "pd", ".", "DataFrame", "." ]
def basic_descriptive(my_df): n_row, n_col = my_df.shape cols = my_df.columns logger.info('# observations: {0}'.format(n_row)) logger.info('# features: {0}'.format(n_col)) logger.info('Features: {0}'.format(cols)) return
[ "def", "basic_descriptive", "(", "my_df", ")", ":", "n_row", ",", "n_col", "=", "my_df", ".", "shape", "cols", "=", "my_df", ".", "columns", "logger", ".", "info", "(", "'# observations: {0}'", ".", "format", "(", "n_row", ")", ")", "logger", ".", "info"...
Report basic descriptive stats for a pd.DataFrame.
[ "Report", "basic", "descriptive", "stats", "for", "a", "pd", ".", "DataFrame", "." ]
[ "\"\"\"\n Report basic descriptive stats for a pd.DataFrame.\n Args:\n my_df (pd.DataFrame): target DataFrame.\n\n Returns:\n Nothing. All results are printed.\n \"\"\"" ]
[ { "param": "my_df", "type": null } ]
{ "returns": [ { "docstring": "Nothing. All results are printed.", "docstring_tokens": [ "Nothing", ".", "All", "results", "are", "printed", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "my_df...
2bcd5af304582e84a6d30a584ec6059bfb920e4f
bnesposito/client-attrition
code/work_data.py
[ "Apache-2.0" ]
Python
extract_last_n_from_df
<not_specific>
def extract_last_n_from_df(my_df, columns, n): """ Replace the columns in {columns} with their last {n} characters converted to int. Args: my_df (pd.DataFrame): target DataFrame. Columns will be extracted from it. columns (list): contains target column names. n (int): number of chara...
Replace the columns in {columns} with their last {n} characters converted to int. Args: my_df (pd.DataFrame): target DataFrame. Columns will be extracted from it. columns (list): contains target column names. n (int): number of characters to be extracted. Returns: pd.DataFr...
Replace the columns in {columns} with their last {n} characters converted to int.
[ "Replace", "the", "columns", "in", "{", "columns", "}", "with", "their", "last", "{", "n", "}", "characters", "converted", "to", "int", "." ]
def extract_last_n_from_df(my_df, columns, n): my_df = my_df.copy() for column in columns: target = my_df.pop(column) target.replace('Cero', '00', inplace=True) my_df[column] = target.apply(lambda x: last_n_to_int(x, n)) return my_df
[ "def", "extract_last_n_from_df", "(", "my_df", ",", "columns", ",", "n", ")", ":", "my_df", "=", "my_df", ".", "copy", "(", ")", "for", "column", "in", "columns", ":", "target", "=", "my_df", ".", "pop", "(", "column", ")", "target", ".", "replace", ...
Replace the columns in {columns} with their last {n} characters converted to int.
[ "Replace", "the", "columns", "in", "{", "columns", "}", "with", "their", "last", "{", "n", "}", "characters", "converted", "to", "int", "." ]
[ "\"\"\"\n Replace the columns in {columns} with their last {n} characters converted to int.\n Args:\n my_df (pd.DataFrame): target DataFrame. Columns will be extracted from it.\n columns (list): contains target column names.\n n (int): number of characters to be extracted.\n\n Returns:...
[ { "param": "my_df", "type": null }, { "param": "columns", "type": null }, { "param": "n", "type": null } ]
{ "returns": [ { "docstring": "target columns have been replace with the last two characters\nof each observation converted to int.", "docstring_tokens": [ "target", "columns", "have", "been", "replace", "with", "the", "last", "tw...
2bcd5af304582e84a6d30a584ec6059bfb920e4f
bnesposito/client-attrition
code/work_data.py
[ "Apache-2.0" ]
Python
str_variables_with_int
<not_specific>
def str_variables_with_int(): """ Columns with observations which last two characters are digits. We will extract these. Returns: list: contains the column names. """ return ['RANG_INGRESO', 'RANG_SDO_PASIVO_MENOS0', 'RANG_NRO_PRODUCTOS_MENOS0']
Columns with observations which last two characters are digits. We will extract these. Returns: list: contains the column names.
Columns with observations which last two characters are digits. We will extract these.
[ "Columns", "with", "observations", "which", "last", "two", "characters", "are", "digits", ".", "We", "will", "extract", "these", "." ]
def str_variables_with_int(): return ['RANG_INGRESO', 'RANG_SDO_PASIVO_MENOS0', 'RANG_NRO_PRODUCTOS_MENOS0']
[ "def", "str_variables_with_int", "(", ")", ":", "return", "[", "'RANG_INGRESO'", ",", "'RANG_SDO_PASIVO_MENOS0'", ",", "'RANG_NRO_PRODUCTOS_MENOS0'", "]" ]
Columns with observations which last two characters are digits.
[ "Columns", "with", "observations", "which", "last", "two", "characters", "are", "digits", "." ]
[ "\"\"\"\n Columns with observations which last two characters are digits. We will extract these.\n Returns:\n list: contains the column names.\n \"\"\"" ]
[]
{ "returns": [ { "docstring": "contains the column names.", "docstring_tokens": [ "contains", "the", "column", "names", "." ], "type": "list" } ], "raises": [], "params": [], "outlier_params": [], "others": [] }
eca01cf5f0f2b004d717546043245063b810dfd1
Lurker-Coding/UniversalBot
modules/informational.py
[ "Apache-2.0" ]
Python
serverinfo
null
async def serverinfo(self, ctx): """Get information on the server.""" region = { "us-west": "US West", "us-east": "US East", "us-south": "US South", "us-central": "US Central", "eu-west": "EU West", "eu-central": "EU Central", ...
Get information on the server.
Get information on the server.
[ "Get", "information", "on", "the", "server", "." ]
async def serverinfo(self, ctx): region = { "us-west": "US West", "us-east": "US East", "us-south": "US South", "us-central": "US Central", "eu-west": "EU West", "eu-central": "EU Central", "singapore": "Singapore", ...
[ "async", "def", "serverinfo", "(", "self", ",", "ctx", ")", ":", "region", "=", "{", "\"us-west\"", ":", "\"US West\"", ",", "\"us-east\"", ":", "\"US East\"", ",", "\"us-south\"", ":", "\"US South\"", ",", "\"us-central\"", ":", "\"US Central\"", ",", "\"eu-w...
Get information on the server.
[ "Get", "information", "on", "the", "server", "." ]
[ "\"\"\"Get information on the server.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
eca01cf5f0f2b004d717546043245063b810dfd1
Lurker-Coding/UniversalBot
modules/informational.py
[ "Apache-2.0" ]
Python
userinfo
null
async def userinfo(self, ctx, user: discord.Member=None): """Shows information on a user or yourself.""" if user is None: user = ctx.author try: playing = user.activity.name except: playing = "None" Status = { "online": "Online", ...
Shows information on a user or yourself.
Shows information on a user or yourself.
[ "Shows", "information", "on", "a", "user", "or", "yourself", "." ]
async def userinfo(self, ctx, user: discord.Member=None): if user is None: user = ctx.author try: playing = user.activity.name except: playing = "None" Status = { "online": "Online", "idle": "Idle", "dnd": "Do Not Di...
[ "async", "def", "userinfo", "(", "self", ",", "ctx", ",", "user", ":", "discord", ".", "Member", "=", "None", ")", ":", "if", "user", "is", "None", ":", "user", "=", "ctx", ".", "author", "try", ":", "playing", "=", "user", ".", "activity", ".", ...
Shows information on a user or yourself.
[ "Shows", "information", "on", "a", "user", "or", "yourself", "." ]
[ "\"\"\"Shows information on a user or yourself.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "user", "type": "discord.Member" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
eca01cf5f0f2b004d717546043245063b810dfd1
Lurker-Coding/UniversalBot
modules/informational.py
[ "Apache-2.0" ]
Python
avatar
<not_specific>
async def avatar(self, ctx, user: discord.Member=None): """Sends avatar of the user mentioned or you.""" if user is None: user = ctx.author if user.avatar_url is None: return await ctx.send("User has no avatar.") embed = discord.Embed(title=f"{user.name}'s avatar:...
Sends avatar of the user mentioned or you.
Sends avatar of the user mentioned or you.
[ "Sends", "avatar", "of", "the", "user", "mentioned", "or", "you", "." ]
async def avatar(self, ctx, user: discord.Member=None): if user is None: user = ctx.author if user.avatar_url is None: return await ctx.send("User has no avatar.") embed = discord.Embed(title=f"{user.name}'s avatar:", colour=3553599) embed.set_image(url=user.avata...
[ "async", "def", "avatar", "(", "self", ",", "ctx", ",", "user", ":", "discord", ".", "Member", "=", "None", ")", ":", "if", "user", "is", "None", ":", "user", "=", "ctx", ".", "author", "if", "user", ".", "avatar_url", "is", "None", ":", "return", ...
Sends avatar of the user mentioned or you.
[ "Sends", "avatar", "of", "the", "user", "mentioned", "or", "you", "." ]
[ "\"\"\"Sends avatar of the user mentioned or you.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "user", "type": "discord.Member" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
eca01cf5f0f2b004d717546043245063b810dfd1
Lurker-Coding/UniversalBot
modules/informational.py
[ "Apache-2.0" ]
Python
invite
<not_specific>
async def invite(self, ctx): """Sends the bot's invite and an invite to the support server.""" if ctx.guild.id == 472302438490046494: return await ctx.send(f"<https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}&scope=bot&permissions=0>\n" f"...
Sends the bot's invite and an invite to the support server.
Sends the bot's invite and an invite to the support server.
[ "Sends", "the", "bot", "'", "s", "invite", "and", "an", "invite", "to", "the", "support", "server", "." ]
async def invite(self, ctx): if ctx.guild.id == 472302438490046494: return await ctx.send(f"<https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}&scope=bot&permissions=0>\n" f"\nHere is my invite, make sure to give it the right permissions for what y...
[ "async", "def", "invite", "(", "self", ",", "ctx", ")", ":", "if", "ctx", ".", "guild", ".", "id", "==", "472302438490046494", ":", "return", "await", "ctx", ".", "send", "(", "f\"<https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}&scope=bot&permissi...
Sends the bot's invite and an invite to the support server.
[ "Sends", "the", "bot", "'", "s", "invite", "and", "an", "invite", "to", "the", "support", "server", "." ]
[ "\"\"\"Sends the bot's invite and an invite to the support server.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
eca01cf5f0f2b004d717546043245063b810dfd1
Lurker-Coding/UniversalBot
modules/informational.py
[ "Apache-2.0" ]
Python
twitch
null
async def twitch(self, ctx, account): """Returns information on the Twitch account you want information on.""" try: async with aiohttp.ClientSession() as cs: async with cs.get(f"https://api.twitch.tv/kraken/channels/{account}?client_id={twitch_clientID}") as r: ...
Returns information on the Twitch account you want information on.
Returns information on the Twitch account you want information on.
[ "Returns", "information", "on", "the", "Twitch", "account", "you", "want", "information", "on", "." ]
async def twitch(self, ctx, account): try: async with aiohttp.ClientSession() as cs: async with cs.get(f"https://api.twitch.tv/kraken/channels/{account}?client_id={twitch_clientID}") as r: res = await r.json() creationdate = datetime.strptime(s...
[ "async", "def", "twitch", "(", "self", ",", "ctx", ",", "account", ")", ":", "try", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "f\"https://api.twitch.tv/kraken/channels/{account}?...
Returns information on the Twitch account you want information on.
[ "Returns", "information", "on", "the", "Twitch", "account", "you", "want", "information", "on", "." ]
[ "\"\"\"Returns information on the Twitch account you want information on.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "account", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
eca01cf5f0f2b004d717546043245063b810dfd1
Lurker-Coding/UniversalBot
modules/informational.py
[ "Apache-2.0" ]
Python
stats
null
async def stats(self, ctx): """Gives you stats on the bot.""" memory = psutil.virtual_memory().total >> 20 mem_usage = psutil.virtual_memory().used >> 20 embed = discord.Embed(colour=3553599) embed.set_author(name=f"{self.bot.user.name}'s Statistics", icon_url=self.bot.user.avat...
Gives you stats on the bot.
Gives you stats on the bot.
[ "Gives", "you", "stats", "on", "the", "bot", "." ]
async def stats(self, ctx): memory = psutil.virtual_memory().total >> 20 mem_usage = psutil.virtual_memory().used >> 20 embed = discord.Embed(colour=3553599) embed.set_author(name=f"{self.bot.user.name}'s Statistics", icon_url=self.bot.user.avatar_url) embed.add_field( ...
[ "async", "def", "stats", "(", "self", ",", "ctx", ")", ":", "memory", "=", "psutil", ".", "virtual_memory", "(", ")", ".", "total", ">>", "20", "mem_usage", "=", "psutil", ".", "virtual_memory", "(", ")", ".", "used", ">>", "20", "embed", "=", "disco...
Gives you stats on the bot.
[ "Gives", "you", "stats", "on", "the", "bot", "." ]
[ "\"\"\"Gives you stats on the bot.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
neko
null
async def neko(self, ctx): """Sends a pic of a neko.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://nekos.life/api/neko") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["neko"]) await ...
Sends a pic of a neko.
Sends a pic of a neko.
[ "Sends", "a", "pic", "of", "a", "neko", "." ]
async def neko(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://nekos.life/api/neko") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["neko"]) await ctx.send(embed=embed)
[ "async", "def", "neko", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://nekos.life/api/neko\"", ")", "as", "r", ":", "res", "=", "await",...
Sends a pic of a neko.
[ "Sends", "a", "pic", "of", "a", "neko", "." ]
[ "\"\"\"Sends a pic of a neko.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
dog
null
async def dog(self, ctx): """Sends a pic of a dog.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://random.dog/woof.json") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["url"]) await ct...
Sends a pic of a dog.
Sends a pic of a dog.
[ "Sends", "a", "pic", "of", "a", "dog", "." ]
async def dog(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://random.dog/woof.json") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["url"]) await ctx.send(embed=embed)
[ "async", "def", "dog", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://random.dog/woof.json\"", ")", "as", "r", ":", "res", "=", "await",...
Sends a pic of a dog.
[ "Sends", "a", "pic", "of", "a", "dog", "." ]
[ "\"\"\"Sends a pic of a dog.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
cat
null
async def cat(self, ctx): """Sends a pic of a cat.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://aws.random.cat/meow") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["file"]) await ct...
Sends a pic of a cat.
Sends a pic of a cat.
[ "Sends", "a", "pic", "of", "a", "cat", "." ]
async def cat(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://aws.random.cat/meow") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["file"]) await ctx.send(embed=embed)
[ "async", "def", "cat", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://aws.random.cat/meow\"", ")", "as", "r", ":", "res", "=", "await", ...
Sends a pic of a cat.
[ "Sends", "a", "pic", "of", "a", "cat", "." ]
[ "\"\"\"Sends a pic of a cat.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
lizard
null
async def lizard(self, ctx): """Sends a pic of a lizard.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://nekos.life/api/lizard") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["url"]) a...
Sends a pic of a lizard.
Sends a pic of a lizard.
[ "Sends", "a", "pic", "of", "a", "lizard", "." ]
async def lizard(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://nekos.life/api/lizard") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["url"]) await ctx.send(embed=embed)
[ "async", "def", "lizard", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://nekos.life/api/lizard\"", ")", "as", "r", ":", "res", "=", "awa...
Sends a pic of a lizard.
[ "Sends", "a", "pic", "of", "a", "lizard", "." ]
[ "\"\"\"Sends a pic of a lizard.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
duck
null
async def duck(self, ctx): """Sends a pic of a duck.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://random-d.uk/api/v1/random") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["url"]) a...
Sends a pic of a duck.
Sends a pic of a duck.
[ "Sends", "a", "pic", "of", "a", "duck", "." ]
async def duck(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://random-d.uk/api/v1/random") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["url"]) await ctx.send(embed=embed)
[ "async", "def", "duck", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://random-d.uk/api/v1/random\"", ")", "as", "r", ":", "res", "=", "a...
Sends a pic of a duck.
[ "Sends", "a", "pic", "of", "a", "duck", "." ]
[ "\"\"\"Sends a pic of a duck.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
panda
null
async def panda(self, ctx): """Sends a pic of a panda.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/panda") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) ...
Sends a pic of a panda.
Sends a pic of a panda.
[ "Sends", "a", "pic", "of", "a", "panda", "." ]
async def panda(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/panda") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) await ctx.send(embed=embed)
[ "async", "def", "panda", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://animals.anidiots.guide/panda\"", ")", "as", "r", ":", "res", "=", ...
Sends a pic of a panda.
[ "Sends", "a", "pic", "of", "a", "panda", "." ]
[ "\"\"\"Sends a pic of a panda.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
penguin
null
async def penguin(self, ctx): """Sends a pic of a penguin.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/penguin") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"...
Sends a pic of a penguin.
Sends a pic of a penguin.
[ "Sends", "a", "pic", "of", "a", "penguin", "." ]
async def penguin(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/penguin") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) await ctx.send(embed=embed)
[ "async", "def", "penguin", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://animals.anidiots.guide/penguin\"", ")", "as", "r", ":", "res", "...
Sends a pic of a penguin.
[ "Sends", "a", "pic", "of", "a", "penguin", "." ]
[ "\"\"\"Sends a pic of a penguin.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
tiger
null
async def tiger(self, ctx): """Sends a pic of a tiger.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/tiger") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) ...
Sends a pic of a tiger.
Sends a pic of a tiger.
[ "Sends", "a", "pic", "of", "a", "tiger", "." ]
async def tiger(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/tiger") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) await ctx.send(embed=embed)
[ "async", "def", "tiger", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://animals.anidiots.guide/tiger\"", ")", "as", "r", ":", "res", "=", ...
Sends a pic of a tiger.
[ "Sends", "a", "pic", "of", "a", "tiger", "." ]
[ "\"\"\"Sends a pic of a tiger.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
e0d2ca5122612170724224bf46b5bb6038fb2e1b
Lurker-Coding/UniversalBot
modules/image.py
[ "Apache-2.0" ]
Python
lion
null
async def lion(self, ctx): """Sends a pic of a lion.""" async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/lion") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) ...
Sends a pic of a lion.
Sends a pic of a lion.
[ "Sends", "a", "pic", "of", "a", "lion", "." ]
async def lion(self, ctx): async with aiohttp.ClientSession() as cs: async with cs.get("https://animals.anidiots.guide/lion") as r: res = await r.json() embed = discord.Embed(colour=3553599) embed.set_image(url=res["link"]) await ctx.send(embed=embed)
[ "async", "def", "lion", "(", "self", ",", "ctx", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "cs", ":", "async", "with", "cs", ".", "get", "(", "\"https://animals.anidiots.guide/lion\"", ")", "as", "r", ":", "res", "=", ...
Sends a pic of a lion.
[ "Sends", "a", "pic", "of", "a", "lion", "." ]
[ "\"\"\"Sends a pic of a lion.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
caec7dc14844dd2189b3785f40b3dff7abdaa0db
Lurker-Coding/UniversalBot
modules/utils/paginator.py
[ "Apache-2.0" ]
Python
numbered_page
<not_specific>
async def numbered_page(self): """lets you type a page number to go to""" # noinspection PyListCreation to_delete = [] to_delete.append(await self.channel.send('What page do you want to go to?')) def message_check(m): return m.author == self.author and self.channel =...
lets you type a page number to go to
lets you type a page number to go to
[ "lets", "you", "type", "a", "page", "number", "to", "go", "to" ]
async def numbered_page(self): to_delete = [] to_delete.append(await self.channel.send('What page do you want to go to?')) def message_check(m): return m.author == self.author and self.channel == m.channel and m.content.isdigit() try: msg = await self.bot.wait_for...
[ "async", "def", "numbered_page", "(", "self", ")", ":", "to_delete", "=", "[", "]", "to_delete", ".", "append", "(", "await", "self", ".", "channel", ".", "send", "(", "'What page do you want to go to?'", ")", ")", "def", "message_check", "(", "m", ")", ":...
lets you type a page number to go to
[ "lets", "you", "type", "a", "page", "number", "to", "go", "to" ]
[ "\"\"\"lets you type a page number to go to\"\"\"", "# noinspection PyListCreation", "# noinspection PyBroadException" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
caec7dc14844dd2189b3785f40b3dff7abdaa0db
Lurker-Coding/UniversalBot
modules/utils/paginator.py
[ "Apache-2.0" ]
Python
paginate
<not_specific>
async def paginate(self): """Actually paginate the entries and run the interactive loop if necessary.""" if not self.entries and not self.hide_no_results: return await self.channel.send('No results found.') first_page = self.show_page(1, first=True) if not self.pagin...
Actually paginate the entries and run the interactive loop if necessary.
Actually paginate the entries and run the interactive loop if necessary.
[ "Actually", "paginate", "the", "entries", "and", "run", "the", "interactive", "loop", "if", "necessary", "." ]
async def paginate(self): if not self.entries and not self.hide_no_results: return await self.channel.send('No results found.') first_page = self.show_page(1, first=True) if not self.paginating: await first_page else: self.bot.loop.create_task(first_pa...
[ "async", "def", "paginate", "(", "self", ")", ":", "if", "not", "self", ".", "entries", "and", "not", "self", ".", "hide_no_results", ":", "return", "await", "self", ".", "channel", ".", "send", "(", "'No results found.'", ")", "first_page", "=", "self", ...
Actually paginate the entries and run the interactive loop if necessary.
[ "Actually", "paginate", "the", "entries", "and", "run", "the", "interactive", "loop", "if", "necessary", "." ]
[ "\"\"\"Actually paginate the entries and\n run the interactive loop if necessary.\"\"\"", "# noinspection PyBroadException", "# noinspection PyBroadException" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
caec7dc14844dd2189b3785f40b3dff7abdaa0db
Lurker-Coding/UniversalBot
modules/utils/paginator.py
[ "Apache-2.0" ]
Python
paginate
null
async def paginate(self): """Actually paginate the entries and run the interactive loop if necessary.""" first_page = self.show_page(1, first=True) if not self.paginating: await first_page else: self.bot.loop.create_task(first_page) while self.pag...
Actually paginate the entries and run the interactive loop if necessary.
Actually paginate the entries and run the interactive loop if necessary.
[ "Actually", "paginate", "the", "entries", "and", "run", "the", "interactive", "loop", "if", "necessary", "." ]
async def paginate(self): first_page = self.show_page(1, first=True) if not self.paginating: await first_page else: self.bot.loop.create_task(first_page) while self.paginating: try: reaction, user = await self.bot.wait_for('reaction_add...
[ "async", "def", "paginate", "(", "self", ")", ":", "first_page", "=", "self", ".", "show_page", "(", "1", ",", "first", "=", "True", ")", "if", "not", "self", ".", "paginating", ":", "await", "first_page", "else", ":", "self", ".", "bot", ".", "loop"...
Actually paginate the entries and run the interactive loop if necessary.
[ "Actually", "paginate", "the", "entries", "and", "run", "the", "interactive", "loop", "if", "necessary", "." ]
[ "\"\"\"Actually paginate the entries and\n run the interactive loop if necessary.\"\"\"", "# noinspection PyBroadException", "# noinspection PyBroadException" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
caec7dc14844dd2189b3785f40b3dff7abdaa0db
Lurker-Coding/UniversalBot
modules/utils/paginator.py
[ "Apache-2.0" ]
Python
show_bot_help
null
async def show_bot_help(self): """shows how to use the bot""" self.embed.title = 'Using the bot' self.embed.description = 'Hello! Welcome to the help page.' self.embed.clear_fields() entries = ( ('<argument>', 'This means the argument is __**required**__.'), ...
shows how to use the bot
shows how to use the bot
[ "shows", "how", "to", "use", "the", "bot" ]
async def show_bot_help(self): self.embed.title = 'Using the bot' self.embed.description = 'Hello! Welcome to the help page.' self.embed.clear_fields() entries = ( ('<argument>', 'This means the argument is __**required**__.'), ('[argument]', 'This means the argum...
[ "async", "def", "show_bot_help", "(", "self", ")", ":", "self", ".", "embed", ".", "title", "=", "'Using the bot'", "self", ".", "embed", ".", "description", "=", "'Hello! Welcome to the help page.'", "self", ".", "embed", ".", "clear_fields", "(", ")", "entri...
shows how to use the bot
[ "shows", "how", "to", "use", "the", "bot" ]
[ "\"\"\"shows how to use the bot\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1748e22c170dc2c3fbf44e6cc39be73d04f8ffb5
Lurker-Coding/UniversalBot
modules/economy.py
[ "Apache-2.0" ]
Python
balance
null
async def balance(self, ctx, user:discord.Member=None): """Shows yours or another users balance.""" if not user: user = ctx.author await self.__check_level_account(user.id) if await self.__has_account(user.id): balance = await self.__get_balance(user.id) ...
Shows yours or another users balance.
Shows yours or another users balance.
[ "Shows", "yours", "or", "another", "users", "balance", "." ]
async def balance(self, ctx, user:discord.Member=None): if not user: user = ctx.author await self.__check_level_account(user.id) if await self.__has_account(user.id): balance = await self.__get_balance(user.id) await ctx.send(f"Balance: **${balance}**") ...
[ "async", "def", "balance", "(", "self", ",", "ctx", ",", "user", ":", "discord", ".", "Member", "=", "None", ")", ":", "if", "not", "user", ":", "user", "=", "ctx", ".", "author", "await", "self", ".", "__check_level_account", "(", "user", ".", "id",...
Shows yours or another users balance.
[ "Shows", "yours", "or", "another", "users", "balance", "." ]
[ "\"\"\"Shows yours or another users balance.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "user", "type": "discord.Member" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
1748e22c170dc2c3fbf44e6cc39be73d04f8ffb5
Lurker-Coding/UniversalBot
modules/economy.py
[ "Apache-2.0" ]
Python
daily
<not_specific>
async def daily(self, ctx): """Grab yourself some free money.""" user = ctx.author await self.__check_level_account(user.id) if not await self.__has_account(user.id): return await ctx.send(f"You do not have an account made. Please make one with `{prefixes[0]}register`.") ...
Grab yourself some free money.
Grab yourself some free money.
[ "Grab", "yourself", "some", "free", "money", "." ]
async def daily(self, ctx): user = ctx.author await self.__check_level_account(user.id) if not await self.__has_account(user.id): return await ctx.send(f"You do not have an account made. Please make one with `{prefixes[0]}register`.") user_data = await r.table("economy").get(...
[ "async", "def", "daily", "(", "self", ",", "ctx", ")", ":", "user", "=", "ctx", ".", "author", "await", "self", ".", "__check_level_account", "(", "user", ".", "id", ")", "if", "not", "await", "self", ".", "__has_account", "(", "user", ".", "id", ")"...
Grab yourself some free money.
[ "Grab", "yourself", "some", "free", "money", "." ]
[ "\"\"\"Grab yourself some free money.\"\"\"", "# change this so it changes amount if user has donated (at some point)" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
a30bb786a704011241f3a6d222a011177b97f743
Lurker-Coding/UniversalBot
modules/developer.py
[ "Apache-2.0" ]
Python
cleanup_code
<not_specific>
def cleanup_code(self, content): """Automatically removes code blocks from the code.""" if content.startswith("```") and content.endswith("```"): return '\n'.join(content.split("\n")[1:-1]) return content.strip("` \n")
Automatically removes code blocks from the code.
Automatically removes code blocks from the code.
[ "Automatically", "removes", "code", "blocks", "from", "the", "code", "." ]
def cleanup_code(self, content): if content.startswith("```") and content.endswith("```"): return '\n'.join(content.split("\n")[1:-1]) return content.strip("` \n")
[ "def", "cleanup_code", "(", "self", ",", "content", ")", ":", "if", "content", ".", "startswith", "(", "\"```\"", ")", "and", "content", ".", "endswith", "(", "\"```\"", ")", ":", "return", "'\\n'", ".", "join", "(", "content", ".", "split", "(", "\"\\...
Automatically removes code blocks from the code.
[ "Automatically", "removes", "code", "blocks", "from", "the", "code", "." ]
[ "\"\"\"Automatically removes code blocks from the code.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "content", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "content", "type": null, "docstring": null, "docstring_tokens"...
a30bb786a704011241f3a6d222a011177b97f743
Lurker-Coding/UniversalBot
modules/developer.py
[ "Apache-2.0" ]
Python
speedtest
null
async def speedtest(self, ctx): """Return the vps' speedtest results""" await ctx.trigger_typing() data = subprocess.getoutput("speedtest --share --simple") data = re.search("(?P<url>https?://[^\s]+)", str(data)).group("url") embed = discord.Embed(colour=3553599) embed.s...
Return the vps' speedtest results
Return the vps' speedtest results
[ "Return", "the", "vps", "'", "speedtest", "results" ]
async def speedtest(self, ctx): await ctx.trigger_typing() data = subprocess.getoutput("speedtest --share --simple") data = re.search("(?P<url>https?://[^\s]+)", str(data)).group("url") embed = discord.Embed(colour=3553599) embed.set_image(url=data) await ctx.send(embed=e...
[ "async", "def", "speedtest", "(", "self", ",", "ctx", ")", ":", "await", "ctx", ".", "trigger_typing", "(", ")", "data", "=", "subprocess", ".", "getoutput", "(", "\"speedtest --share --simple\"", ")", "data", "=", "re", ".", "search", "(", "\"(?P<url>https?...
Return the vps' speedtest results
[ "Return", "the", "vps", "'", "speedtest", "results" ]
[ "\"\"\"Return the vps' speedtest results\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
a30bb786a704011241f3a6d222a011177b97f743
Lurker-Coding/UniversalBot
modules/developer.py
[ "Apache-2.0" ]
Python
traceback
null
async def traceback(self, ctx, public: bool=False): """ Sends the last command exception. public: default False """ if not public: destination = ctx.author else: destination = ctx.channel if self.bot._last_exception: for p...
Sends the last command exception. public: default False
Sends the last command exception. public: default False
[ "Sends", "the", "last", "command", "exception", ".", "public", ":", "default", "False" ]
async def traceback(self, ctx, public: bool=False): if not public: destination = ctx.author else: destination = ctx.channel if self.bot._last_exception: for page in pagify(self.bot._last_exception): await destination.send(box(text=page, lang="p...
[ "async", "def", "traceback", "(", "self", ",", "ctx", ",", "public", ":", "bool", "=", "False", ")", ":", "if", "not", "public", ":", "destination", "=", "ctx", ".", "author", "else", ":", "destination", "=", "ctx", ".", "channel", "if", "self", ".",...
Sends the last command exception.
[ "Sends", "the", "last", "command", "exception", "." ]
[ "\"\"\"\n Sends the last command exception.\n\n public: default False\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "public", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
a30bb786a704011241f3a6d222a011177b97f743
Lurker-Coding/UniversalBot
modules/developer.py
[ "Apache-2.0" ]
Python
force
null
async def force(self, ctx, user: discord.Member, *, command): """Forces a user to run the specified command.""" message = ctx.message message.author = user message.content = f"{prefixes[0]}{''.join(command)}" await self.bot.process_commands(message) await ctx.message.add...
Forces a user to run the specified command.
Forces a user to run the specified command.
[ "Forces", "a", "user", "to", "run", "the", "specified", "command", "." ]
async def force(self, ctx, user: discord.Member, *, command): message = ctx.message message.author = user message.content = f"{prefixes[0]}{''.join(command)}" await self.bot.process_commands(message) await ctx.message.add_reaction(u"\U0001F44C")
[ "async", "def", "force", "(", "self", ",", "ctx", ",", "user", ":", "discord", ".", "Member", ",", "*", ",", "command", ")", ":", "message", "=", "ctx", ".", "message", "message", ".", "author", "=", "user", "message", ".", "content", "=", "f\"{prefi...
Forces a user to run the specified command.
[ "Forces", "a", "user", "to", "run", "the", "specified", "command", "." ]
[ "\"\"\"Forces a user to run the specified command.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "user", "type": "discord.Member" }, { "param": "command", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
8f77ee80b2899984124337c69b53c0630c0d7a03
Lurker-Coding/UniversalBot
modules/_help.py
[ "Apache-2.0" ]
Python
help
<not_specific>
async def help(self, ctx, command: str=None): """Gives you a list of all of the commands""" if command: entity = self.bot.get_cog(command) or self.bot.get_command(command) if entity is None: clean = command.replace('@', '@\u200b') return await ct...
Gives you a list of all of the commands
Gives you a list of all of the commands
[ "Gives", "you", "a", "list", "of", "all", "of", "the", "commands" ]
async def help(self, ctx, command: str=None): if command: entity = self.bot.get_cog(command) or self.bot.get_command(command) if entity is None: clean = command.replace('@', '@\u200b') return await ctx.send(f"Command or category \"{clean}\" not found.") ...
[ "async", "def", "help", "(", "self", ",", "ctx", ",", "command", ":", "str", "=", "None", ")", ":", "if", "command", ":", "entity", "=", "self", ".", "bot", ".", "get_cog", "(", "command", ")", "or", "self", ".", "bot", ".", "get_command", "(", "...
Gives you a list of all of the commands
[ "Gives", "you", "a", "list", "of", "all", "of", "the", "commands" ]
[ "\"\"\"Gives you a list of all of the commands\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "ctx", "type": null }, { "param": "command", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": null, "docstring": null, "docstring_tokens": []...
0cb325a89fc0a0b8952145a15484eba291d978ab
jianligu/django-celery-boilerplate
taskapp/tasks.py
[ "MIT" ]
Python
long_computing
<not_specific>
def long_computing(): """Computing task running a long time""" t0 = time.time() time.sleep(10 * random.random()) result = random.randint(1000, 10000) elapsed_time = time.time() - t0 return result, elapsed_time
Computing task running a long time
Computing task running a long time
[ "Computing", "task", "running", "a", "long", "time" ]
def long_computing(): t0 = time.time() time.sleep(10 * random.random()) result = random.randint(1000, 10000) elapsed_time = time.time() - t0 return result, elapsed_time
[ "def", "long_computing", "(", ")", ":", "t0", "=", "time", ".", "time", "(", ")", "time", ".", "sleep", "(", "10", "*", "random", ".", "random", "(", ")", ")", "result", "=", "random", ".", "randint", "(", "1000", ",", "10000", ")", "elapsed_time",...
Computing task running a long time
[ "Computing", "task", "running", "a", "long", "time" ]
[ "\"\"\"Computing task running a long time\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
e31289d2df975db3e9cd9209ccd278e772c84e8e
theLaborInVain/thelaborinvain_com
blog/app/admin/__init__.py
[ "MIT" ]
Python
initialize
null
def initialize(self): """ Purges all posts and images from the DB and filesystem. """ print(" - Initializing MDB collections!") collections = ['posts','images','attachments','tags'] for collection in collections: removed = app.config['MDB'][collection].remove() p...
Purges all posts and images from the DB and filesystem.
Purges all posts and images from the DB and filesystem.
[ "Purges", "all", "posts", "and", "images", "from", "the", "DB", "and", "filesystem", "." ]
def initialize(self): print(" - Initializing MDB collections!") collections = ['posts','images','attachments','tags'] for collection in collections: removed = app.config['MDB'][collection].remove() print(" Removed %s records from %s.%s" % ( removed['n'], ...
[ "def", "initialize", "(", "self", ")", ":", "print", "(", "\" - Initializing MDB collections!\"", ")", "collections", "=", "[", "'posts'", ",", "'images'", ",", "'attachments'", ",", "'tags'", "]", "for", "collection", "in", "collections", ":", "removed", "=", ...
Purges all posts and images from the DB and filesystem.
[ "Purges", "all", "posts", "and", "images", "from", "the", "DB", "and", "filesystem", "." ]
[ "\"\"\" Purges all posts and images from the DB and filesystem. \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
682d4bd027f72457f2575f1165c3a33075b27381
theLaborInVain/thelaborinvain_com
blog/app/models/images.py
[ "MIT" ]
Python
expand_image
<not_specific>
def expand_image(oid=None): """ Pass in an image OID to get the MDB record for that image back as a dict. """ if not ObjectId.is_valid(oid): raise ValueError("Invalid image asset OID! %s" % oid) record = app.config['MDB'].images.find_one({'_id': oid}) if record is None: err = "OID ...
Pass in an image OID to get the MDB record for that image back as a dict.
Pass in an image OID to get the MDB record for that image back as a dict.
[ "Pass", "in", "an", "image", "OID", "to", "get", "the", "MDB", "record", "for", "that", "image", "back", "as", "a", "dict", "." ]
def expand_image(oid=None): if not ObjectId.is_valid(oid): raise ValueError("Invalid image asset OID! %s" % oid) record = app.config['MDB'].images.find_one({'_id': oid}) if record is None: err = "OID '%s' not associated with an image!" % oid app.logger.error(err) app.logger.e...
[ "def", "expand_image", "(", "oid", "=", "None", ")", ":", "if", "not", "ObjectId", ".", "is_valid", "(", "oid", ")", ":", "raise", "ValueError", "(", "\"Invalid image asset OID! %s\"", "%", "oid", ")", "record", "=", "app", ".", "config", "[", "'MDB'", "...
Pass in an image OID to get the MDB record for that image back as a dict.
[ "Pass", "in", "an", "image", "OID", "to", "get", "the", "MDB", "record", "for", "that", "image", "back", "as", "a", "dict", "." ]
[ "\"\"\" Pass in an image OID to get the MDB record for that image back as a\n dict. \"\"\"" ]
[ { "param": "oid", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "oid", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
682d4bd027f72457f2575f1165c3a33075b27381
theLaborInVain/thelaborinvain_com
blog/app/models/images.py
[ "MIT" ]
Python
delete
<not_specific>
def delete(self): """ Removes the record and the file. """ os.remove(self.get_abs_path()) self.logger.warn('Removed file! %s' % self.get_abs_path()) super().delete() return True
Removes the record and the file.
Removes the record and the file.
[ "Removes", "the", "record", "and", "the", "file", "." ]
def delete(self): os.remove(self.get_abs_path()) self.logger.warn('Removed file! %s' % self.get_abs_path()) super().delete() return True
[ "def", "delete", "(", "self", ")", ":", "os", ".", "remove", "(", "self", ".", "get_abs_path", "(", ")", ")", "self", ".", "logger", ".", "warn", "(", "'Removed file! %s'", "%", "self", ".", "get_abs_path", "(", ")", ")", "super", "(", ")", ".", "d...
Removes the record and the file.
[ "Removes", "the", "record", "and", "the", "file", "." ]
[ "\"\"\" Removes the record and the file. \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ae56e08bd4f2eaf8c11f0b5e3e335878a8523e54
theLaborInVain/thelaborinvain_com
blog/app/models/figures.py
[ "MIT" ]
Python
save
<not_specific>
def save(self, verbose=True): """ Forces OID lists to be OID lists. """ for image_list in ['concept_art', 'unpainted', 'tags']: corrected_list = [] for image_oid in getattr(self, image_list, []): corrected_list.append(ObjectId(image_oid)) setattr(self...
Forces OID lists to be OID lists.
Forces OID lists to be OID lists.
[ "Forces", "OID", "lists", "to", "be", "OID", "lists", "." ]
def save(self, verbose=True): for image_list in ['concept_art', 'unpainted', 'tags']: corrected_list = [] for image_oid in getattr(self, image_list, []): corrected_list.append(ObjectId(image_oid)) setattr(self, image_list, corrected_list) return super(...
[ "def", "save", "(", "self", ",", "verbose", "=", "True", ")", ":", "for", "image_list", "in", "[", "'concept_art'", ",", "'unpainted'", ",", "'tags'", "]", ":", "corrected_list", "=", "[", "]", "for", "image_oid", "in", "getattr", "(", "self", ",", "im...
Forces OID lists to be OID lists.
[ "Forces", "OID", "lists", "to", "be", "OID", "lists", "." ]
[ "\"\"\" Forces OID lists to be OID lists. \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "verbose", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "verbose", "type": null, "docstring": null, "docstring_tokens"...
ae56e08bd4f2eaf8c11f0b5e3e335878a8523e54
theLaborInVain/thelaborinvain_com
blog/app/models/figures.py
[ "MIT" ]
Python
serialize
<not_specific>
def serialize(self): """ Returns a fancy version of a figure, with expanded image lists. """ output = copy(self.record) for image_list in ['concept_art', 'unpainted']: expanded_list = [] for image_oid in output.get(image_list, []): expanded_list.append(i...
Returns a fancy version of a figure, with expanded image lists.
Returns a fancy version of a figure, with expanded image lists.
[ "Returns", "a", "fancy", "version", "of", "a", "figure", "with", "expanded", "image", "lists", "." ]
def serialize(self): output = copy(self.record) for image_list in ['concept_art', 'unpainted']: expanded_list = [] for image_oid in output.get(image_list, []): expanded_list.append(images.expand_image(image_oid)) output[image_list] = expanded_list ...
[ "def", "serialize", "(", "self", ")", ":", "output", "=", "copy", "(", "self", ".", "record", ")", "for", "image_list", "in", "[", "'concept_art'", ",", "'unpainted'", "]", ":", "expanded_list", "=", "[", "]", "for", "image_oid", "in", "output", ".", "...
Returns a fancy version of a figure, with expanded image lists.
[ "Returns", "a", "fancy", "version", "of", "a", "figure", "with", "expanded", "image", "lists", "." ]
[ "\"\"\" Returns a fancy version of a figure, with expanded image lists. \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
31edc33bd7fc14ebdbf2a144a34584d2e3d7fb81
theLaborInVain/thelaborinvain_com
blog/app/util/__init__.py
[ "MIT" ]
Python
string_to_handle
<not_specific>
def string_to_handle(s): """ Turns a string into a handle, suitable for use as a URL. """ s = s.lower() trans_table = str.maketrans('', '', string.punctuation) s = s.translate(trans_table) s = s.replace(" ", "_") return s
Turns a string into a handle, suitable for use as a URL.
Turns a string into a handle, suitable for use as a URL.
[ "Turns", "a", "string", "into", "a", "handle", "suitable", "for", "use", "as", "a", "URL", "." ]
def string_to_handle(s): s = s.lower() trans_table = str.maketrans('', '', string.punctuation) s = s.translate(trans_table) s = s.replace(" ", "_") return s
[ "def", "string_to_handle", "(", "s", ")", ":", "s", "=", "s", ".", "lower", "(", ")", "trans_table", "=", "str", ".", "maketrans", "(", "''", ",", "''", ",", "string", ".", "punctuation", ")", "s", "=", "s", ".", "translate", "(", "trans_table", ")...
Turns a string into a handle, suitable for use as a URL.
[ "Turns", "a", "string", "into", "a", "handle", "suitable", "for", "use", "as", "a", "URL", "." ]
[ "\"\"\" Turns a string into a handle, suitable for use as a URL. \"\"\"" ]
[ { "param": "s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
31edc33bd7fc14ebdbf2a144a34584d2e3d7fb81
theLaborInVain/thelaborinvain_com
blog/app/util/__init__.py
[ "MIT" ]
Python
fancy_html
<not_specific>
def fancy_html(s, apply_p_blocks=True): """ Accepts a string; returns fancy-ass HTML with all of our cool stuff.""" s = str(s) if apply_p_blocks: raw = "".join(["<p>%s</p>" % p for p in s.split('\n') if p != '']) else: raw = str(s) # expand links -- do this before we get to HTML ju...
Accepts a string; returns fancy-ass HTML with all of our cool stuff.
Accepts a string; returns fancy-ass HTML with all of our cool stuff.
[ "Accepts", "a", "string", ";", "returns", "fancy", "-", "ass", "HTML", "with", "all", "of", "our", "cool", "stuff", "." ]
def fancy_html(s, apply_p_blocks=True): s = str(s) if apply_p_blocks: raw = "".join(["<p>%s</p>" % p for p in s.split('\n') if p != '']) else: raw = str(s) raw_list = raw.split(" ") for word in raw_list: if word[:8] == 'https://': index = raw_list.index(word) ...
[ "def", "fancy_html", "(", "s", ",", "apply_p_blocks", "=", "True", ")", ":", "s", "=", "str", "(", "s", ")", "if", "apply_p_blocks", ":", "raw", "=", "\"\"", ".", "join", "(", "[", "\"<p>%s</p>\"", "%", "p", "for", "p", "in", "s", ".", "split", "...
Accepts a string; returns fancy-ass HTML with all of our cool stuff.
[ "Accepts", "a", "string", ";", "returns", "fancy", "-", "ass", "HTML", "with", "all", "of", "our", "cool", "stuff", "." ]
[ "\"\"\" Accepts a string; returns fancy-ass HTML with all of our cool stuff.\"\"\"", "# expand links -- do this before we get to HTML junk", "# fix anchors" ]
[ { "param": "s", "type": null }, { "param": "apply_p_blocks", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "apply_p_blocks", "type": null, "docstring": null, "docstring_tok...
165a83b94a4ded18c8d30df32707f5df9a36823e
theLaborInVain/thelaborinvain_com
blog/app/routes.py
[ "MIT" ]
Python
search_collection
<not_specific>
def search_collection(target_collection): """ Searches posts for posts with a tag. URL should be like this: /search/posts?tag=Munchkin (or similar) """ if target_collection != 'posts': return flask.Response(response='Not implemented!', status=501) if flask.request.args.get('tag', N...
Searches posts for posts with a tag. URL should be like this: /search/posts?tag=Munchkin (or similar)
Searches posts for posts with a tag. URL should be like this: search/posts?tag=Munchkin (or similar)
[ "Searches", "posts", "for", "posts", "with", "a", "tag", ".", "URL", "should", "be", "like", "this", ":", "search", "/", "posts?tag", "=", "Munchkin", "(", "or", "similar", ")" ]
def search_collection(target_collection): if target_collection != 'posts': return flask.Response(response='Not implemented!', status=501) if flask.request.args.get('tag', None) is None: return flask.Response(response='Tag param is required!', status=400) tag_obj = app.config['MDB'].tags.find...
[ "def", "search_collection", "(", "target_collection", ")", ":", "if", "target_collection", "!=", "'posts'", ":", "return", "flask", ".", "Response", "(", "response", "=", "'Not implemented!'", ",", "status", "=", "501", ")", "if", "flask", ".", "request", ".",...
Searches posts for posts with a tag.
[ "Searches", "posts", "for", "posts", "with", "a", "tag", "." ]
[ "\"\"\" Searches posts for posts with a tag. URL should be like this:\n /search/posts?tag=Munchkin (or similar)\n \"\"\"", "# get the tag's object or return None" ]
[ { "param": "target_collection", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "target_collection", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
165a83b94a4ded18c8d30df32707f5df9a36823e
theLaborInVain/thelaborinvain_com
blog/app/routes.py
[ "MIT" ]
Python
login
<not_specific>
def login(): """ We handle admin panel logins here. """ form = LoginForm() if form.validate_on_submit(): def fail(): flask.flash("Invalid username or password") return flask.redirect(flask.url_for('login')) try: user_obj = models.User(email=form.email.d...
We handle admin panel logins here.
We handle admin panel logins here.
[ "We", "handle", "admin", "panel", "logins", "here", "." ]
def login(): form = LoginForm() if form.validate_on_submit(): def fail(): flask.flash("Invalid username or password") return flask.redirect(flask.url_for('login')) try: user_obj = models.User(email=form.email.data) except Exception as e: ...
[ "def", "login", "(", ")", ":", "form", "=", "LoginForm", "(", ")", "if", "form", ".", "validate_on_submit", "(", ")", ":", "def", "fail", "(", ")", ":", "flask", ".", "flash", "(", "\"Invalid username or password\"", ")", "return", "flask", ".", "redirec...
We handle admin panel logins here.
[ "We", "handle", "admin", "panel", "logins", "here", "." ]
[ "\"\"\" We handle admin panel logins here. \"\"\"", "# unknown user", "# success--log the user in!" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }