repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
williamjameshandley/fgivenx | fgivenx/samples.py | compute_samples | def compute_samples(f, x, samples, **kwargs):
r""" Apply f(x,theta) to x array and theta in samples.
Parameters
----------
f: function
list of functions :math:`f(x;\theta)` with dependent variable
:math:`x`, parameterised by :math:`\theta`.
x: 1D array-like
x values to eva... | python | def compute_samples(f, x, samples, **kwargs):
r""" Apply f(x,theta) to x array and theta in samples.
Parameters
----------
f: function
list of functions :math:`f(x;\theta)` with dependent variable
:math:`x`, parameterised by :math:`\theta`.
x: 1D array-like
x values to eva... | [
"def",
"compute_samples",
"(",
"f",
",",
"x",
",",
"samples",
",",
"*",
"*",
"kwargs",
")",
":",
"parallel",
"=",
"kwargs",
".",
"pop",
"(",
"'parallel'",
",",
"False",
")",
"cache",
"=",
"kwargs",
".",
"pop",
"(",
"'cache'",
",",
"''",
")",
"tqdm_... | r""" Apply f(x,theta) to x array and theta in samples.
Parameters
----------
f: function
list of functions :math:`f(x;\theta)` with dependent variable
:math:`x`, parameterised by :math:`\theta`.
x: 1D array-like
x values to evaluate :math:`f(x;\theta)` at.
samples: 2D arr... | [
"r",
"Apply",
"f",
"(",
"x",
"theta",
")",
"to",
"x",
"array",
"and",
"theta",
"in",
"samples",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/samples.py#L6-L60 |
williamjameshandley/fgivenx | fgivenx/samples.py | samples_from_getdist_chains | def samples_from_getdist_chains(params, file_root, latex=False):
""" Extract samples and weights from getdist chains.
Parameters
----------
params: list(str)
Names of parameters to be supplied to second argument of f(x|theta).
file_root: str, optional
Root name for getdist chains f... | python | def samples_from_getdist_chains(params, file_root, latex=False):
""" Extract samples and weights from getdist chains.
Parameters
----------
params: list(str)
Names of parameters to be supplied to second argument of f(x|theta).
file_root: str, optional
Root name for getdist chains f... | [
"def",
"samples_from_getdist_chains",
"(",
"params",
",",
"file_root",
",",
"latex",
"=",
"False",
")",
":",
"import",
"getdist",
"samples",
"=",
"getdist",
".",
"loadMCSamples",
"(",
"file_root",
")",
"weights",
"=",
"samples",
".",
"weights",
"indices",
"=",... | Extract samples and weights from getdist chains.
Parameters
----------
params: list(str)
Names of parameters to be supplied to second argument of f(x|theta).
file_root: str, optional
Root name for getdist chains files. This variable automatically
defines:
- chains_file ... | [
"Extract",
"samples",
"and",
"weights",
"from",
"getdist",
"chains",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/samples.py#L63-L104 |
caxap/python-boxview | boxview/boxview.py | BoxView.get_session_url | def get_session_url(session_id, type='view', **params):
""" Allowed types are: `view`, `assets`, `download`. """
url = 'sessions/{}/{}'.format(session_id, type)
url = urljoin(API_URL, url)
return add_to_url(url, **params) | python | def get_session_url(session_id, type='view', **params):
""" Allowed types are: `view`, `assets`, `download`. """
url = 'sessions/{}/{}'.format(session_id, type)
url = urljoin(API_URL, url)
return add_to_url(url, **params) | [
"def",
"get_session_url",
"(",
"session_id",
",",
"type",
"=",
"'view'",
",",
"*",
"*",
"params",
")",
":",
"url",
"=",
"'sessions/{}/{}'",
".",
"format",
"(",
"session_id",
",",
"type",
")",
"url",
"=",
"urljoin",
"(",
"API_URL",
",",
"url",
")",
"ret... | Allowed types are: `view`, `assets`, `download`. | [
"Allowed",
"types",
"are",
":",
"view",
"assets",
"download",
"."
] | train | https://github.com/caxap/python-boxview/blob/3322fe60df88867cd5d50951145235dc1a73f263/boxview/boxview.py#L296-L300 |
lemieuxl/pyGenClean | pyGenClean/HeteroHap/remove_heterozygous_haploid.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: a an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` cl... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: a an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` cl... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check if we have the tped and the tfam files",
"for",
"fileName",
"in",
"[",
"args",
".",
"bfile",
"+",
"i",
"for",
"i",
"in",
"[",
"\".bed\"",
",",
"\".bim\"",
",",
"\".fam\"",
"]",
"]",
":",
"if",
"not",
"os"... | Checks the arguments and options.
:param args: a an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/HeteroHap/remove_heterozygous_haploid.py#L72-L92 |
jtmoulia/switchboard-python | examples/apnsworker.py | main | def main(cert, key, pushtoken, url):
"""Create, connect, and block on the listener worker."""
try:
worker = APNSWorker(cert=cert, key=key, pushtoken=pushtoken, url=url)
worker.connect()
worker.run_forever()
except KeyboardInterrupt:
worker.close() | python | def main(cert, key, pushtoken, url):
"""Create, connect, and block on the listener worker."""
try:
worker = APNSWorker(cert=cert, key=key, pushtoken=pushtoken, url=url)
worker.connect()
worker.run_forever()
except KeyboardInterrupt:
worker.close() | [
"def",
"main",
"(",
"cert",
",",
"key",
",",
"pushtoken",
",",
"url",
")",
":",
"try",
":",
"worker",
"=",
"APNSWorker",
"(",
"cert",
"=",
"cert",
",",
"key",
"=",
"key",
",",
"pushtoken",
"=",
"pushtoken",
",",
"url",
"=",
"url",
")",
"worker",
... | Create, connect, and block on the listener worker. | [
"Create",
"connect",
"and",
"block",
"on",
"the",
"listener",
"worker",
"."
] | train | https://github.com/jtmoulia/switchboard-python/blob/c9b0cb74cb12a64385465091be633e78d39f08b1/examples/apnsworker.py#L94-L101 |
jtmoulia/switchboard-python | examples/apnsworker.py | APNSWorker.opened | def opened(self):
"""Connect to the websocket, and ensure the account is connected and
the INBOX is being watched, and then start watchingAll.
"""
def post_setup((cmds, resps)):
"""Post setup callback."""
logger.info("Setup complete, listening...")
self.s... | python | def opened(self):
"""Connect to the websocket, and ensure the account is connected and
the INBOX is being watched, and then start watchingAll.
"""
def post_setup((cmds, resps)):
"""Post setup callback."""
logger.info("Setup complete, listening...")
self.s... | [
"def",
"opened",
"(",
"self",
")",
":",
"def",
"post_setup",
"(",
"(",
"cmds",
",",
"resps",
")",
")",
":",
"\"\"\"Post setup callback.\"\"\"",
"logger",
".",
"info",
"(",
"\"Setup complete, listening...\"",
")",
"self",
".",
"send_cmds",
"(",
"(",
"'connect'"... | Connect to the websocket, and ensure the account is connected and
the INBOX is being watched, and then start watchingAll. | [
"Connect",
"to",
"the",
"websocket",
"and",
"ensure",
"the",
"account",
"is",
"connected",
"and",
"the",
"INBOX",
"is",
"being",
"watched",
"and",
"then",
"start",
"watchingAll",
"."
] | train | https://github.com/jtmoulia/switchboard-python/blob/c9b0cb74cb12a64385465091be633e78d39f08b1/examples/apnsworker.py#L44-L55 |
what-studio/valuedispatch | valuedispatch.py | valuedispatch | def valuedispatch(func):
"""Decorates a function to dispatch handler of the value of the first
argument.
"""
registry = {}
def dispatch(value):
return registry.get(value, func)
def register(value, func=None):
if func is None:
return lambda f: register(value, f)
... | python | def valuedispatch(func):
"""Decorates a function to dispatch handler of the value of the first
argument.
"""
registry = {}
def dispatch(value):
return registry.get(value, func)
def register(value, func=None):
if func is None:
return lambda f: register(value, f)
... | [
"def",
"valuedispatch",
"(",
"func",
")",
":",
"registry",
"=",
"{",
"}",
"def",
"dispatch",
"(",
"value",
")",
":",
"return",
"registry",
".",
"get",
"(",
"value",
",",
"func",
")",
"def",
"register",
"(",
"value",
",",
"func",
"=",
"None",
")",
"... | Decorates a function to dispatch handler of the value of the first
argument. | [
"Decorates",
"a",
"function",
"to",
"dispatch",
"handler",
"of",
"the",
"value",
"of",
"the",
"first",
"argument",
"."
] | train | https://github.com/what-studio/valuedispatch/blob/95683c3bc7e8d501b556f628a6090514a6bc823d/valuedispatch.py#L32-L50 |
cag/sphinxcontrib-soliditydomain | sphinxcontrib/soliditydomain/domain.py | SolidityDomain.resolve_xref | def resolve_xref(self, env, fromdocname, builder,
typ, target, node, contnode):
# type: (BuildEnvironment, unicode, Builder, unicode, unicode, nodes.Node, nodes.Node) -> nodes.Node # NOQA
"""Resolve the pending_xref *node* with the given *typ* and *target*.
This method sho... | python | def resolve_xref(self, env, fromdocname, builder,
typ, target, node, contnode):
# type: (BuildEnvironment, unicode, Builder, unicode, unicode, nodes.Node, nodes.Node) -> nodes.Node # NOQA
"""Resolve the pending_xref *node* with the given *typ* and *target*.
This method sho... | [
"def",
"resolve_xref",
"(",
"self",
",",
"env",
",",
"fromdocname",
",",
"builder",
",",
"typ",
",",
"target",
",",
"node",
",",
"contnode",
")",
":",
"# type: (BuildEnvironment, unicode, Builder, unicode, unicode, nodes.Node, nodes.Node) -> nodes.Node # NOQA",
"for",
"f... | Resolve the pending_xref *node* with the given *typ* and *target*.
This method should return a new node, to replace the xref node,
containing the *contnode* which is the markup content of the
cross-reference.
If no resolution can be found, None can be returned; the xref node will
... | [
"Resolve",
"the",
"pending_xref",
"*",
"node",
"*",
"with",
"the",
"given",
"*",
"typ",
"*",
"and",
"*",
"target",
"*",
"."
] | train | https://github.com/cag/sphinxcontrib-soliditydomain/blob/b004b6e43727771027b4065fab18fcb9ccb2c826/sphinxcontrib/soliditydomain/domain.py#L351-L370 |
radujica/baloo | baloo/weld/weld_joins.py | weld_merge_join | def weld_merge_join(arrays_self, weld_types_self, arrays_other, weld_types_other,
how, is_on_sorted, is_on_unique, readable_text):
"""Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.ndarray or W... | python | def weld_merge_join(arrays_self, weld_types_self, arrays_other, weld_types_other,
how, is_on_sorted, is_on_unique, readable_text):
"""Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.ndarray or W... | [
"def",
"weld_merge_join",
"(",
"arrays_self",
",",
"weld_types_self",
",",
"arrays_other",
",",
"weld_types_other",
",",
"how",
",",
"is_on_sorted",
",",
"is_on_unique",
",",
"readable_text",
")",
":",
"assert",
"is_on_unique",
"weld_obj_vec_of_struct_self",
"=",
"wel... | Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.ndarray or WeldObject)
Columns from the self DataFrame on which to join.
weld_types_self : list of WeldType
Corresponding Weld types.
arrays_other... | [
"Applies",
"merge",
"-",
"join",
"on",
"the",
"arrays",
"returning",
"indices",
"from",
"each",
"to",
"keep",
"in",
"the",
"resulting"
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_joins.py#L110-L156 |
radujica/baloo | baloo/weld/weld_joins.py | weld_merge_outer_join | def weld_merge_outer_join(arrays_self, weld_types_self, arrays_other, weld_types_other,
how, is_on_sorted, is_on_unique, readable_text):
"""Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.... | python | def weld_merge_outer_join(arrays_self, weld_types_self, arrays_other, weld_types_other,
how, is_on_sorted, is_on_unique, readable_text):
"""Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.... | [
"def",
"weld_merge_outer_join",
"(",
"arrays_self",
",",
"weld_types_self",
",",
"arrays_other",
",",
"weld_types_other",
",",
"how",
",",
"is_on_sorted",
",",
"is_on_unique",
",",
"readable_text",
")",
":",
"assert",
"is_on_unique",
"weld_obj_vec_of_struct_self",
"=",
... | Applies merge-join on the arrays returning indices from each to keep in the resulting
Parameters
----------
arrays_self : list of (numpy.ndarray or WeldObject)
Columns from the self DataFrame on which to join.
weld_types_self : list of WeldType
Corresponding Weld types.
arrays_other... | [
"Applies",
"merge",
"-",
"join",
"on",
"the",
"arrays",
"returning",
"indices",
"from",
"each",
"to",
"keep",
"in",
"the",
"resulting"
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_joins.py#L232-L286 |
radujica/baloo | baloo/weld/weld_joins.py | weld_align | def weld_align(df_index_arrays, df_index_weld_types,
series_index_arrays, series_index_weld_types,
series_data, series_weld_type):
"""Returns the data from the Series aligned to the DataFrame index.
Parameters
----------
df_index_arrays : list of (numpy.ndarray or WeldObje... | python | def weld_align(df_index_arrays, df_index_weld_types,
series_index_arrays, series_index_weld_types,
series_data, series_weld_type):
"""Returns the data from the Series aligned to the DataFrame index.
Parameters
----------
df_index_arrays : list of (numpy.ndarray or WeldObje... | [
"def",
"weld_align",
"(",
"df_index_arrays",
",",
"df_index_weld_types",
",",
"series_index_arrays",
",",
"series_index_weld_types",
",",
"series_data",
",",
"series_weld_type",
")",
":",
"weld_obj_index_df",
"=",
"weld_arrays_to_vec_of_struct",
"(",
"df_index_arrays",
",",... | Returns the data from the Series aligned to the DataFrame index.
Parameters
----------
df_index_arrays : list of (numpy.ndarray or WeldObject)
The index columns as a list.
df_index_weld_types : list of WeldType
series_index_arrays : numpy.ndarray or WeldObject
The index of the Serie... | [
"Returns",
"the",
"data",
"from",
"the",
"Series",
"aligned",
"to",
"the",
"DataFrame",
"index",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_joins.py#L289-L344 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/heterozygosity_plot.py | main | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Checks the number of samples in the ``tfam`` file
(:py:func:`compute_nb_samples`).
3. Computes the heterozygosity rate ... | python | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Checks the number of samples in the ``tfam`` file
(:py:func:`compute_nb_samples`).
3. Computes the heterozygosity rate ... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"# Check the number of samples",
"nb_samples",
"=",
"compute_nb_samples",
"(",
"args",
".",
... | The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Checks the number of samples in the ``tfam`` file
(:py:func:`compute_nb_samples`).
3. Computes the heterozygosity rate (:py:func:`compute_heterozygosity... | [
"The",
"main",
"function",
"of",
"the",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/heterozygosity_plot.py#L32-L63 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/heterozygosity_plot.py | save_heterozygosity | def save_heterozygosity(heterozygosity, samples, out_prefix):
"""Saves the heterozygosity data.
:param heterozygosity: the heterozygosity data.
:param samples: the list of samples.
:param out_prefix: the prefix of the output files.
:type heterozygosity: numpy.array
:type samples: list of tuple... | python | def save_heterozygosity(heterozygosity, samples, out_prefix):
"""Saves the heterozygosity data.
:param heterozygosity: the heterozygosity data.
:param samples: the list of samples.
:param out_prefix: the prefix of the output files.
:type heterozygosity: numpy.array
:type samples: list of tuple... | [
"def",
"save_heterozygosity",
"(",
"heterozygosity",
",",
"samples",
",",
"out_prefix",
")",
":",
"# The output file",
"o_file",
"=",
"None",
"try",
":",
"o_file",
"=",
"open",
"(",
"out_prefix",
"+",
"\".het\"",
",",
"'wb'",
")",
"except",
"IOError",
":",
"... | Saves the heterozygosity data.
:param heterozygosity: the heterozygosity data.
:param samples: the list of samples.
:param out_prefix: the prefix of the output files.
:type heterozygosity: numpy.array
:type samples: list of tuples of str
:type out_prefix: str | [
"Saves",
"the",
"heterozygosity",
"data",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/heterozygosity_plot.py#L66-L91 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/heterozygosity_plot.py | compute_nb_samples | def compute_nb_samples(in_prefix):
"""Check the number of samples.
:param in_prefix: the prefix of the input file.
:type in_prefix: str
:returns: the number of sample in ``prefix.fam``.
"""
file_name = in_prefix + ".tfam"
nb = None
with open(file_name, 'rb') as input_file:
nb... | python | def compute_nb_samples(in_prefix):
"""Check the number of samples.
:param in_prefix: the prefix of the input file.
:type in_prefix: str
:returns: the number of sample in ``prefix.fam``.
"""
file_name = in_prefix + ".tfam"
nb = None
with open(file_name, 'rb') as input_file:
nb... | [
"def",
"compute_nb_samples",
"(",
"in_prefix",
")",
":",
"file_name",
"=",
"in_prefix",
"+",
"\".tfam\"",
"nb",
"=",
"None",
"with",
"open",
"(",
"file_name",
",",
"'rb'",
")",
"as",
"input_file",
":",
"nb",
"=",
"len",
"(",
"input_file",
".",
"readlines",... | Check the number of samples.
:param in_prefix: the prefix of the input file.
:type in_prefix: str
:returns: the number of sample in ``prefix.fam``. | [
"Check",
"the",
"number",
"of",
"samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/heterozygosity_plot.py#L94-L108 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/heterozygosity_plot.py | compute_heterozygosity | def compute_heterozygosity(in_prefix, nb_samples):
"""Computes the heterozygosity ratio of samples (from tped)."""
tped_name = in_prefix + ".tped"
tfam_name = in_prefix + ".tfam"
# The function we want to use
check_heterozygosity = np.vectorize(is_heterozygous)
# The autosomes
autosomes = ... | python | def compute_heterozygosity(in_prefix, nb_samples):
"""Computes the heterozygosity ratio of samples (from tped)."""
tped_name = in_prefix + ".tped"
tfam_name = in_prefix + ".tfam"
# The function we want to use
check_heterozygosity = np.vectorize(is_heterozygous)
# The autosomes
autosomes = ... | [
"def",
"compute_heterozygosity",
"(",
"in_prefix",
",",
"nb_samples",
")",
":",
"tped_name",
"=",
"in_prefix",
"+",
"\".tped\"",
"tfam_name",
"=",
"in_prefix",
"+",
"\".tfam\"",
"# The function we want to use",
"check_heterozygosity",
"=",
"np",
".",
"vectorize",
"(",... | Computes the heterozygosity ratio of samples (from tped). | [
"Computes",
"the",
"heterozygosity",
"ratio",
"of",
"samples",
"(",
"from",
"tped",
")",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/heterozygosity_plot.py#L141-L179 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/heterozygosity_plot.py | plot_heterozygosity | def plot_heterozygosity(heterozygosity, options):
"""Plots the heterozygosity rate distribution.
:param heterozygosity: the heterozygosity data.
:param options: the options.
:type heterozygosity: numpy.array
:type options: argparse.Namespace
Plots a histogram or a boxplot of the heterozygosit... | python | def plot_heterozygosity(heterozygosity, options):
"""Plots the heterozygosity rate distribution.
:param heterozygosity: the heterozygosity data.
:param options: the options.
:type heterozygosity: numpy.array
:type options: argparse.Namespace
Plots a histogram or a boxplot of the heterozygosit... | [
"def",
"plot_heterozygosity",
"(",
"heterozygosity",
",",
"options",
")",
":",
"# importing important stuff",
"import",
"matplotlib",
"as",
"mpl",
"if",
"options",
".",
"format",
"!=",
"\"X11\"",
"and",
"mpl",
".",
"get_backend",
"(",
")",
"!=",
"\"agg\"",
":",
... | Plots the heterozygosity rate distribution.
:param heterozygosity: the heterozygosity data.
:param options: the options.
:type heterozygosity: numpy.array
:type options: argparse.Namespace
Plots a histogram or a boxplot of the heterozygosity distribution. | [
"Plots",
"the",
"heterozygosity",
"rate",
"distribution",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/heterozygosity_plot.py#L182-L280 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/heterozygosity_plot.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Checking the input file",
"for",
"file_name",
"in",
"[",
"args",
".",
"tfile",
"+",
"i",
"for",
"i",
"in",
"{",
"\".tfam\"",
",",
"\".tped\"",
"}",
"]",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to t... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/heterozygosity_plot.py#L283-L315 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/FwTabWidget.py | FwTabWidget.addEmptyTab | def addEmptyTab(self, text=''):
"""
Add a new DEFAULT_TAB_WIDGET, open editor to set text if no text is given
"""
tab = self.defaultTabWidget()
c = self.count()
self.addTab(tab, text)
self.setCurrentIndex(c)
if not text:
self.tabBar().editTab(c... | python | def addEmptyTab(self, text=''):
"""
Add a new DEFAULT_TAB_WIDGET, open editor to set text if no text is given
"""
tab = self.defaultTabWidget()
c = self.count()
self.addTab(tab, text)
self.setCurrentIndex(c)
if not text:
self.tabBar().editTab(c... | [
"def",
"addEmptyTab",
"(",
"self",
",",
"text",
"=",
"''",
")",
":",
"tab",
"=",
"self",
".",
"defaultTabWidget",
"(",
")",
"c",
"=",
"self",
".",
"count",
"(",
")",
"self",
".",
"addTab",
"(",
"tab",
",",
"text",
")",
"self",
".",
"setCurrentIndex... | Add a new DEFAULT_TAB_WIDGET, open editor to set text if no text is given | [
"Add",
"a",
"new",
"DEFAULT_TAB_WIDGET",
"open",
"editor",
"to",
"set",
"text",
"if",
"no",
"text",
"is",
"given"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/FwTabWidget.py#L57-L68 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/FwTabWidget.py | FwTabWidget._mkAddBtnVisible | def _mkAddBtnVisible(self):
"""
Ensure that the Add button is visible also when there are no tabs
"""
if not self._btn_add_height:
# self._btn_add_height = self.cornerWidget().height()
self._btn_add_height = self._cwBtn.height()
if self.count() == 0:
... | python | def _mkAddBtnVisible(self):
"""
Ensure that the Add button is visible also when there are no tabs
"""
if not self._btn_add_height:
# self._btn_add_height = self.cornerWidget().height()
self._btn_add_height = self._cwBtn.height()
if self.count() == 0:
... | [
"def",
"_mkAddBtnVisible",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_btn_add_height",
":",
"# self._btn_add_height = self.cornerWidget().height()",
"self",
".",
"_btn_add_height",
"=",
"self",
".",
"_cwBtn",
".",
"height",
"(",
")",
"if",
"self"... | Ensure that the Add button is visible also when there are no tabs | [
"Ensure",
"that",
"the",
"Add",
"button",
"is",
"visible",
"also",
"when",
"there",
"are",
"no",
"tabs"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/FwTabWidget.py#L70-L81 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/FwTabWidget.py | FwTabWidget.removeTab | def removeTab(self, tab):
"""allows to remove a tab directly -not only by giving its index"""
if not isinstance(tab, int):
tab = self.indexOf(tab)
return super(FwTabWidget, self).removeTab(tab) | python | def removeTab(self, tab):
"""allows to remove a tab directly -not only by giving its index"""
if not isinstance(tab, int):
tab = self.indexOf(tab)
return super(FwTabWidget, self).removeTab(tab) | [
"def",
"removeTab",
"(",
"self",
",",
"tab",
")",
":",
"if",
"not",
"isinstance",
"(",
"tab",
",",
"int",
")",
":",
"tab",
"=",
"self",
".",
"indexOf",
"(",
"tab",
")",
"return",
"super",
"(",
"FwTabWidget",
",",
"self",
")",
".",
"removeTab",
"(",... | allows to remove a tab directly -not only by giving its index | [
"allows",
"to",
"remove",
"a",
"tab",
"directly",
"-",
"not",
"only",
"by",
"giving",
"its",
"index"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/FwTabWidget.py#L98-L102 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/FwTabWidget.py | FwTabWidget.tabText | def tabText(self, tab):
""" allow index or tab widget instance"""
if not isinstance(tab, int):
tab = self.indexOf(tab)
return super(FwTabWidget, self).tabText(tab) | python | def tabText(self, tab):
""" allow index or tab widget instance"""
if not isinstance(tab, int):
tab = self.indexOf(tab)
return super(FwTabWidget, self).tabText(tab) | [
"def",
"tabText",
"(",
"self",
",",
"tab",
")",
":",
"if",
"not",
"isinstance",
"(",
"tab",
",",
"int",
")",
":",
"tab",
"=",
"self",
".",
"indexOf",
"(",
"tab",
")",
"return",
"super",
"(",
"FwTabWidget",
",",
"self",
")",
".",
"tabText",
"(",
"... | allow index or tab widget instance | [
"allow",
"index",
"or",
"tab",
"widget",
"instance"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/FwTabWidget.py#L104-L108 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.on_failure | def on_failure(self, entity):
"""
Callback function when there is a failure in a connection to whatsapp
server
"""
logger.error("Login failed, reason: %s" % entity.getReason())
self.connected = False | python | def on_failure(self, entity):
"""
Callback function when there is a failure in a connection to whatsapp
server
"""
logger.error("Login failed, reason: %s" % entity.getReason())
self.connected = False | [
"def",
"on_failure",
"(",
"self",
",",
"entity",
")",
":",
"logger",
".",
"error",
"(",
"\"Login failed, reason: %s\"",
"%",
"entity",
".",
"getReason",
"(",
")",
")",
"self",
".",
"connected",
"=",
"False"
] | Callback function when there is a failure in a connection to whatsapp
server | [
"Callback",
"function",
"when",
"there",
"is",
"a",
"failure",
"in",
"a",
"connection",
"to",
"whatsapp",
"server"
] | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L70-L76 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.on_message | def on_message(self, message_protocol_entity):
"""
Callback function when receiving message from whatsapp server
"""
logger.info("Message id %s received" % message_protocol_entity.getId())
# answer with receipt
self.toLower(message_protocol_entity.ack()) | python | def on_message(self, message_protocol_entity):
"""
Callback function when receiving message from whatsapp server
"""
logger.info("Message id %s received" % message_protocol_entity.getId())
# answer with receipt
self.toLower(message_protocol_entity.ack()) | [
"def",
"on_message",
"(",
"self",
",",
"message_protocol_entity",
")",
":",
"logger",
".",
"info",
"(",
"\"Message id %s received\"",
"%",
"message_protocol_entity",
".",
"getId",
"(",
")",
")",
"# answer with receipt",
"self",
".",
"toLower",
"(",
"message_protocol... | Callback function when receiving message from whatsapp server | [
"Callback",
"function",
"when",
"receiving",
"message",
"from",
"whatsapp",
"server"
] | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L89-L95 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.send_message | def send_message(self, number, content):
"""
Send message
:param str number: phone number with cc (country code)
:param str content: body text of the message
"""
outgoing_message = TextMessageProtocolEntity(content.encode("utf-8") if sys.version_info >= (3, 0)
... | python | def send_message(self, number, content):
"""
Send message
:param str number: phone number with cc (country code)
:param str content: body text of the message
"""
outgoing_message = TextMessageProtocolEntity(content.encode("utf-8") if sys.version_info >= (3, 0)
... | [
"def",
"send_message",
"(",
"self",
",",
"number",
",",
"content",
")",
":",
"outgoing_message",
"=",
"TextMessageProtocolEntity",
"(",
"content",
".",
"encode",
"(",
"\"utf-8\"",
")",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"0",
")",
"else"... | Send message
:param str number: phone number with cc (country code)
:param str content: body text of the message | [
"Send",
"message",
":",
"param",
"str",
"number",
":",
"phone",
"number",
"with",
"cc",
"(",
"country",
"code",
")",
":",
"param",
"str",
"content",
":",
"body",
"text",
"of",
"the",
"message"
] | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L142-L151 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.send_image | def send_image(self, number, path, caption=None):
"""
Send image message
:param str number: phone number with cc (country code)
:param str path: image file path
"""
return self._send_media_path(number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_IMAGE, caption) | python | def send_image(self, number, path, caption=None):
"""
Send image message
:param str number: phone number with cc (country code)
:param str path: image file path
"""
return self._send_media_path(number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_IMAGE, caption) | [
"def",
"send_image",
"(",
"self",
",",
"number",
",",
"path",
",",
"caption",
"=",
"None",
")",
":",
"return",
"self",
".",
"_send_media_path",
"(",
"number",
",",
"path",
",",
"RequestUploadIqProtocolEntity",
".",
"MEDIA_TYPE_IMAGE",
",",
"caption",
")"
] | Send image message
:param str number: phone number with cc (country code)
:param str path: image file path | [
"Send",
"image",
"message",
":",
"param",
"str",
"number",
":",
"phone",
"number",
"with",
"cc",
"(",
"country",
"code",
")",
":",
"param",
"str",
"path",
":",
"image",
"file",
"path"
] | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L175-L181 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.send_audio | def send_audio(self, number, path):
"""
Send audio message
:param str number: phone number with cc (country code)
:param str path: audio file path
"""
return self._send_media_path(number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_AUDIO) | python | def send_audio(self, number, path):
"""
Send audio message
:param str number: phone number with cc (country code)
:param str path: audio file path
"""
return self._send_media_path(number, path, RequestUploadIqProtocolEntity.MEDIA_TYPE_AUDIO) | [
"def",
"send_audio",
"(",
"self",
",",
"number",
",",
"path",
")",
":",
"return",
"self",
".",
"_send_media_path",
"(",
"number",
",",
"path",
",",
"RequestUploadIqProtocolEntity",
".",
"MEDIA_TYPE_AUDIO",
")"
] | Send audio message
:param str number: phone number with cc (country code)
:param str path: audio file path | [
"Send",
"audio",
"message",
":",
"param",
"str",
"number",
":",
"phone",
"number",
"with",
"cc",
"(",
"country",
"code",
")",
":",
"param",
"str",
"path",
":",
"audio",
"file",
"path"
] | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L184-L190 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.send_location | def send_location(self, number, name, url, latitude, longitude):
"""
Send location message
:param str number: phone number with cc (country code)
:param str name: indentifier for the location
:param str url: location url
:param str longitude: location longitude
:p... | python | def send_location(self, number, name, url, latitude, longitude):
"""
Send location message
:param str number: phone number with cc (country code)
:param str name: indentifier for the location
:param str url: location url
:param str longitude: location longitude
:p... | [
"def",
"send_location",
"(",
"self",
",",
"number",
",",
"name",
",",
"url",
",",
"latitude",
",",
"longitude",
")",
":",
"location_message",
"=",
"LocationMediaMessageProtocolEntity",
"(",
"latitude",
",",
"longitude",
",",
"name",
",",
"url",
",",
"encoding"... | Send location message
:param str number: phone number with cc (country code)
:param str name: indentifier for the location
:param str url: location url
:param str longitude: location longitude
:param str latitude: location latitude | [
"Send",
"location",
"message",
":",
"param",
"str",
"number",
":",
"phone",
"number",
"with",
"cc",
"(",
"country",
"code",
")",
":",
"param",
"str",
"name",
":",
"indentifier",
"for",
"the",
"location",
":",
"param",
"str",
"url",
":",
"location",
"url"... | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L193-L205 |
jlmadurga/yowsup-celery | yowsup_celery/layer.py | CeleryLayer.send_vcard | def send_vcard(self, number, name, data):
"""
Send location message
:param str number: phone number with cc (country code)
:param str name: indentifier for the location
:param str data: vcard format i.e.
BEGIN:VCARD
VERSION:3.0
N:;Home;;;
FN:Home
... | python | def send_vcard(self, number, name, data):
"""
Send location message
:param str number: phone number with cc (country code)
:param str name: indentifier for the location
:param str data: vcard format i.e.
BEGIN:VCARD
VERSION:3.0
N:;Home;;;
FN:Home
... | [
"def",
"send_vcard",
"(",
"self",
",",
"number",
",",
"name",
",",
"data",
")",
":",
"vcard_message",
"=",
"VCardMediaMessageProtocolEntity",
"(",
"name",
",",
"data",
",",
"to",
"=",
"self",
".",
"normalize_jid",
"(",
"number",
")",
")",
"self",
".",
"t... | Send location message
:param str number: phone number with cc (country code)
:param str name: indentifier for the location
:param str data: vcard format i.e.
BEGIN:VCARD
VERSION:3.0
N:;Home;;;
FN:Home
item1.TEL:+34 911234567
item1.X-ABLabel:Home
... | [
"Send",
"location",
"message",
":",
"param",
"str",
"number",
":",
"phone",
"number",
"with",
"cc",
"(",
"country",
"code",
")",
":",
"param",
"str",
"name",
":",
"indentifier",
"for",
"the",
"location",
":",
"param",
"str",
"data",
":",
"vcard",
"format... | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/layer.py#L208-L224 |
jaraco/jaraco.packaging | jaraco/packaging/cheese.py | open_archive | def open_archive(stream, filename):
"""
Open an archive (tarball or zip) and return the object.
"""
name, ext = os.path.splitext(os.path.basename(filename))
def targz_handler(stream):
return TarGZAdapter(tarfile.open(fileobj=stream, mode='r:gz'))
cls = [zipfile.ZipFile, targz_handler]['... | python | def open_archive(stream, filename):
"""
Open an archive (tarball or zip) and return the object.
"""
name, ext = os.path.splitext(os.path.basename(filename))
def targz_handler(stream):
return TarGZAdapter(tarfile.open(fileobj=stream, mode='r:gz'))
cls = [zipfile.ZipFile, targz_handler]['... | [
"def",
"open_archive",
"(",
"stream",
",",
"filename",
")",
":",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
")",
"def",
"targz_handler",
"(",
"stream",
")",
":",
"return... | Open an archive (tarball or zip) and return the object. | [
"Open",
"an",
"archive",
"(",
"tarball",
"or",
"zip",
")",
"and",
"return",
"the",
"object",
"."
] | train | https://github.com/jaraco/jaraco.packaging/blob/c84fd1282b222bc262a2bab7a2e668c947472f46/jaraco/packaging/cheese.py#L41-L51 |
jaraco/jaraco.packaging | jaraco/packaging/cheese.py | get_prefix_dir | def get_prefix_dir(archive):
"""
Often, all files are in a single directory. If so, they'll all have
the same prefix. Determine any such prefix.
archive is a ZipFile
"""
names = archive.namelist()
shortest_name = sorted(names, key=len)[0]
candidate_prefixes = [
shortest_name[:len... | python | def get_prefix_dir(archive):
"""
Often, all files are in a single directory. If so, they'll all have
the same prefix. Determine any such prefix.
archive is a ZipFile
"""
names = archive.namelist()
shortest_name = sorted(names, key=len)[0]
candidate_prefixes = [
shortest_name[:len... | [
"def",
"get_prefix_dir",
"(",
"archive",
")",
":",
"names",
"=",
"archive",
".",
"namelist",
"(",
")",
"shortest_name",
"=",
"sorted",
"(",
"names",
",",
"key",
"=",
"len",
")",
"[",
"0",
"]",
"candidate_prefixes",
"=",
"[",
"shortest_name",
"[",
":",
... | Often, all files are in a single directory. If so, they'll all have
the same prefix. Determine any such prefix.
archive is a ZipFile | [
"Often",
"all",
"files",
"are",
"in",
"a",
"single",
"directory",
".",
"If",
"so",
"they",
"ll",
"all",
"have",
"the",
"same",
"prefix",
".",
"Determine",
"any",
"such",
"prefix",
".",
"archive",
"is",
"a",
"ZipFile"
] | train | https://github.com/jaraco/jaraco.packaging/blob/c84fd1282b222bc262a2bab7a2e668c947472f46/jaraco/packaging/cheese.py#L54-L69 |
jaraco/jaraco.packaging | jaraco/packaging/cheese.py | RevivedDistribution._clean_metadata | def _clean_metadata(self):
"""
the long description doesn't load properly (gets unwanted indents),
so fix it.
"""
desc = self.metadata.get_long_description()
if not isinstance(desc, six.text_type):
desc = desc.decode('utf-8')
lines = io.StringIO(desc)
... | python | def _clean_metadata(self):
"""
the long description doesn't load properly (gets unwanted indents),
so fix it.
"""
desc = self.metadata.get_long_description()
if not isinstance(desc, six.text_type):
desc = desc.decode('utf-8')
lines = io.StringIO(desc)
... | [
"def",
"_clean_metadata",
"(",
"self",
")",
":",
"desc",
"=",
"self",
".",
"metadata",
".",
"get_long_description",
"(",
")",
"if",
"not",
"isinstance",
"(",
"desc",
",",
"six",
".",
"text_type",
")",
":",
"desc",
"=",
"desc",
".",
"decode",
"(",
"'utf... | the long description doesn't load properly (gets unwanted indents),
so fix it. | [
"the",
"long",
"description",
"doesn",
"t",
"load",
"properly",
"(",
"gets",
"unwanted",
"indents",
")",
"so",
"fix",
"it",
"."
] | train | https://github.com/jaraco/jaraco.packaging/blob/c84fd1282b222bc262a2bab7a2e668c947472f46/jaraco/packaging/cheese.py#L103-L121 |
coins13/twins | twins/misc.py | get_nendo | def get_nendo ():
"""今は何年度?"""
y, m = map(int, time.strftime("%Y %m").split())
return y if m >= 4 else y - 1 | python | def get_nendo ():
"""今は何年度?"""
y, m = map(int, time.strftime("%Y %m").split())
return y if m >= 4 else y - 1 | [
"def",
"get_nendo",
"(",
")",
":",
"y",
",",
"m",
"=",
"map",
"(",
"int",
",",
"time",
".",
"strftime",
"(",
"\"%Y %m\"",
")",
".",
"split",
"(",
")",
")",
"return",
"y",
"if",
"m",
">=",
"4",
"else",
"y",
"-",
"1"
] | 今は何年度? | [
"今は何年度?"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/misc.py#L5-L8 |
seanbrant/pykss | pykss/parser.py | Parser.find_files | def find_files(self):
'''Find files in `paths` which match valid extensions'''
for path in self.paths:
for subpath, dirs, files in os.walk(path):
for filename in files:
(name, ext) = os.path.splitext(filename)
if ext in self.extensions:... | python | def find_files(self):
'''Find files in `paths` which match valid extensions'''
for path in self.paths:
for subpath, dirs, files in os.walk(path):
for filename in files:
(name, ext) = os.path.splitext(filename)
if ext in self.extensions:... | [
"def",
"find_files",
"(",
"self",
")",
":",
"for",
"path",
"in",
"self",
".",
"paths",
":",
"for",
"subpath",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"filename",
"in",
"files",
":",
"(",
"name",
",",
"ext... | Find files in `paths` which match valid extensions | [
"Find",
"files",
"in",
"paths",
"which",
"match",
"valid",
"extensions"
] | train | https://github.com/seanbrant/pykss/blob/c01b0f97c3ebfff32b4bdb3e6e2e1616c5c4ea3e/pykss/parser.py#L29-L36 |
omaraboumrad/mastool | mastool/helpers.py | is_boolean | def is_boolean(node):
"""Checks if node is True or False"""
return any([
isinstance(node, ast.Name)
and node.id in ('True', 'False'),
hasattr(ast, 'NameConstant') # Support for Python 3 NameConstant
and isinstance(node, getattr(ast, 'NameConstant')) # screw you pylint!
... | python | def is_boolean(node):
"""Checks if node is True or False"""
return any([
isinstance(node, ast.Name)
and node.id in ('True', 'False'),
hasattr(ast, 'NameConstant') # Support for Python 3 NameConstant
and isinstance(node, getattr(ast, 'NameConstant')) # screw you pylint!
... | [
"def",
"is_boolean",
"(",
"node",
")",
":",
"return",
"any",
"(",
"[",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Name",
")",
"and",
"node",
".",
"id",
"in",
"(",
"'True'",
",",
"'False'",
")",
",",
"hasattr",
"(",
"ast",
",",
"'NameConstant'",
"... | Checks if node is True or False | [
"Checks",
"if",
"node",
"is",
"True",
"or",
"False"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/helpers.py#L15-L23 |
omaraboumrad/mastool | mastool/helpers.py | call_name_is | def call_name_is(siter, name):
"""Checks the function call name"""
return (
isinstance(siter, ast.Call)
and hasattr(siter.func, 'attr')
and siter.func.attr == name
) | python | def call_name_is(siter, name):
"""Checks the function call name"""
return (
isinstance(siter, ast.Call)
and hasattr(siter.func, 'attr')
and siter.func.attr == name
) | [
"def",
"call_name_is",
"(",
"siter",
",",
"name",
")",
":",
"return",
"(",
"isinstance",
"(",
"siter",
",",
"ast",
".",
"Call",
")",
"and",
"hasattr",
"(",
"siter",
".",
"func",
",",
"'attr'",
")",
"and",
"siter",
".",
"func",
".",
"attr",
"==",
"n... | Checks the function call name | [
"Checks",
"the",
"function",
"call",
"name"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/helpers.py#L26-L32 |
omaraboumrad/mastool | mastool/helpers.py | target_names | def target_names(targets):
"""Retrieves the target names"""
names = []
for entry in targets:
if isinstance(entry, ast.Name):
names.append(entry.id)
elif isinstance(entry, ast.Tuple):
for element in entry.elts:
if isinstance(element, ast.Name):
... | python | def target_names(targets):
"""Retrieves the target names"""
names = []
for entry in targets:
if isinstance(entry, ast.Name):
names.append(entry.id)
elif isinstance(entry, ast.Tuple):
for element in entry.elts:
if isinstance(element, ast.Name):
... | [
"def",
"target_names",
"(",
"targets",
")",
":",
"names",
"=",
"[",
"]",
"for",
"entry",
"in",
"targets",
":",
"if",
"isinstance",
"(",
"entry",
",",
"ast",
".",
"Name",
")",
":",
"names",
".",
"append",
"(",
"entry",
".",
"id",
")",
"elif",
"isins... | Retrieves the target names | [
"Retrieves",
"the",
"target",
"names"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/helpers.py#L35-L46 |
omaraboumrad/mastool | mastool/helpers.py | labeled | def labeled(**kwargs):
"""decorator to give practices labels"""
def for_practice(practice):
"""assigns label to practice"""
practice.code = kwargs.pop('code')
practice.msg = kwargs.pop('msg')
practice.solution = kwargs.pop('solution')
return practice
return for_practi... | python | def labeled(**kwargs):
"""decorator to give practices labels"""
def for_practice(practice):
"""assigns label to practice"""
practice.code = kwargs.pop('code')
practice.msg = kwargs.pop('msg')
practice.solution = kwargs.pop('solution')
return practice
return for_practi... | [
"def",
"labeled",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"for_practice",
"(",
"practice",
")",
":",
"\"\"\"assigns label to practice\"\"\"",
"practice",
".",
"code",
"=",
"kwargs",
".",
"pop",
"(",
"'code'",
")",
"practice",
".",
"msg",
"=",
"kwargs",
"... | decorator to give practices labels | [
"decorator",
"to",
"give",
"practices",
"labels"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/helpers.py#L54-L62 |
whyscream/dspam-milter | dspam/utils.py | daemonize | def daemonize(pidfile=None):
"""
Turn the running process into a proper daemon according to PEP3143.
Args:
pidfile --The pidfile to create.
"""
# Prevent core dumps
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
# Change working directory
os.chdir("/")
# Change file creati... | python | def daemonize(pidfile=None):
"""
Turn the running process into a proper daemon according to PEP3143.
Args:
pidfile --The pidfile to create.
"""
# Prevent core dumps
resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
# Change working directory
os.chdir("/")
# Change file creati... | [
"def",
"daemonize",
"(",
"pidfile",
"=",
"None",
")",
":",
"# Prevent core dumps",
"resource",
".",
"setrlimit",
"(",
"resource",
".",
"RLIMIT_CORE",
",",
"(",
"0",
",",
"0",
")",
")",
"# Change working directory",
"os",
".",
"chdir",
"(",
"\"/\"",
")",
"#... | Turn the running process into a proper daemon according to PEP3143.
Args:
pidfile --The pidfile to create. | [
"Turn",
"the",
"running",
"process",
"into",
"a",
"proper",
"daemon",
"according",
"to",
"PEP3143",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/utils.py#L18-L84 |
whyscream/dspam-milter | dspam/utils.py | config_str2dict | def config_str2dict(option_value):
"""
Parse the value of a config option and convert it to a dictionary.
The configuration allows lines formatted like:
foo = Bar:1,Baz,Flub:0.75
This gets converted to a dictionary:
foo = { 'Bar': 1, 'Baz': 0, 'Flub': 0.75 }
Args:
option_value -- The c... | python | def config_str2dict(option_value):
"""
Parse the value of a config option and convert it to a dictionary.
The configuration allows lines formatted like:
foo = Bar:1,Baz,Flub:0.75
This gets converted to a dictionary:
foo = { 'Bar': 1, 'Baz': 0, 'Flub': 0.75 }
Args:
option_value -- The c... | [
"def",
"config_str2dict",
"(",
"option_value",
")",
":",
"dict",
"=",
"{",
"}",
"for",
"key",
"in",
"option_value",
".",
"split",
"(",
"','",
")",
":",
"if",
"':'",
"in",
"key",
":",
"key",
",",
"value",
"=",
"pair",
".",
"split",
"(",
"':'",
")",
... | Parse the value of a config option and convert it to a dictionary.
The configuration allows lines formatted like:
foo = Bar:1,Baz,Flub:0.75
This gets converted to a dictionary:
foo = { 'Bar': 1, 'Baz': 0, 'Flub': 0.75 }
Args:
option_value -- The config string to parse. | [
"Parse",
"the",
"value",
"of",
"a",
"config",
"option",
"and",
"convert",
"it",
"to",
"a",
"dictionary",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/utils.py#L87-L108 |
whyscream/dspam-milter | dspam/utils.py | log_to_syslog | def log_to_syslog():
"""
Configure logging to syslog.
"""
# Get root logger
rl = logging.getLogger()
rl.setLevel('INFO')
# Stderr gets critical messages (mostly config/setup issues)
# only when not daemonized
stderr = logging.StreamHandler(stream=sys.stderr)
stderr.setLevel(l... | python | def log_to_syslog():
"""
Configure logging to syslog.
"""
# Get root logger
rl = logging.getLogger()
rl.setLevel('INFO')
# Stderr gets critical messages (mostly config/setup issues)
# only when not daemonized
stderr = logging.StreamHandler(stream=sys.stderr)
stderr.setLevel(l... | [
"def",
"log_to_syslog",
"(",
")",
":",
"# Get root logger",
"rl",
"=",
"logging",
".",
"getLogger",
"(",
")",
"rl",
".",
"setLevel",
"(",
"'INFO'",
")",
"# Stderr gets critical messages (mostly config/setup issues)",
"# only when not daemonized",
"stderr",
"=",
"loggi... | Configure logging to syslog. | [
"Configure",
"logging",
"to",
"syslog",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/utils.py#L111-L132 |
jtmoulia/switchboard-python | examples/twilioworker.py | main | def main(sid, token, to, from_, url):
"""Create, connect, and block on the listener worker."""
try:
worker = APNSWorker(sid=sid, token=token, to=to, from_=from_, url=url)
worker.connect()
worker.run_forever()
except KeyboardInterrupt:
worker.close() | python | def main(sid, token, to, from_, url):
"""Create, connect, and block on the listener worker."""
try:
worker = APNSWorker(sid=sid, token=token, to=to, from_=from_, url=url)
worker.connect()
worker.run_forever()
except KeyboardInterrupt:
worker.close() | [
"def",
"main",
"(",
"sid",
",",
"token",
",",
"to",
",",
"from_",
",",
"url",
")",
":",
"try",
":",
"worker",
"=",
"APNSWorker",
"(",
"sid",
"=",
"sid",
",",
"token",
"=",
"token",
",",
"to",
"=",
"to",
",",
"from_",
"=",
"from_",
",",
"url",
... | Create, connect, and block on the listener worker. | [
"Create",
"connect",
"and",
"block",
"on",
"the",
"listener",
"worker",
"."
] | train | https://github.com/jtmoulia/switchboard-python/blob/c9b0cb74cb12a64385465091be633e78d39f08b1/examples/twilioworker.py#L78-L85 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/Dialogs.py | Dialogs.getSaveFileName | def getSaveFileName(self, *args, **kwargs):
"""
analogue to QtWidgets.QFileDialog.getSaveFileNameAndFilter
but returns the filename + chosen file ending even if not typed in gui
"""
if 'directory' not in kwargs:
if self.opts['save']:
if self.opts['save... | python | def getSaveFileName(self, *args, **kwargs):
"""
analogue to QtWidgets.QFileDialog.getSaveFileNameAndFilter
but returns the filename + chosen file ending even if not typed in gui
"""
if 'directory' not in kwargs:
if self.opts['save']:
if self.opts['save... | [
"def",
"getSaveFileName",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'directory'",
"not",
"in",
"kwargs",
":",
"if",
"self",
".",
"opts",
"[",
"'save'",
"]",
":",
"if",
"self",
".",
"opts",
"[",
"'save'",
"]",
":",
"... | analogue to QtWidgets.QFileDialog.getSaveFileNameAndFilter
but returns the filename + chosen file ending even if not typed in gui | [
"analogue",
"to",
"QtWidgets",
".",
"QFileDialog",
".",
"getSaveFileNameAndFilter",
"but",
"returns",
"the",
"filename",
"+",
"chosen",
"file",
"ending",
"even",
"if",
"not",
"typed",
"in",
"gui"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/Dialogs.py#L34-L59 |
jaraco/jaraco.packaging | jaraco/packaging/depends.py | check_dependencies | def check_dependencies(req, indent=1, history=None):
"""
Given a setuptools package requirement (e.g. 'gryphon==2.42' or just
'gryphon'), print a tree of dependencies as they resolve in this
environment.
"""
# keep a history to avoid infinite loops
if history is None:
history = set()... | python | def check_dependencies(req, indent=1, history=None):
"""
Given a setuptools package requirement (e.g. 'gryphon==2.42' or just
'gryphon'), print a tree of dependencies as they resolve in this
environment.
"""
# keep a history to avoid infinite loops
if history is None:
history = set()... | [
"def",
"check_dependencies",
"(",
"req",
",",
"indent",
"=",
"1",
",",
"history",
"=",
"None",
")",
":",
"# keep a history to avoid infinite loops",
"if",
"history",
"is",
"None",
":",
"history",
"=",
"set",
"(",
")",
"if",
"req",
"in",
"history",
":",
"re... | Given a setuptools package requirement (e.g. 'gryphon==2.42' or just
'gryphon'), print a tree of dependencies as they resolve in this
environment. | [
"Given",
"a",
"setuptools",
"package",
"requirement",
"(",
"e",
".",
"g",
".",
"gryphon",
"==",
"2",
".",
"42",
"or",
"just",
"gryphon",
")",
"print",
"a",
"tree",
"of",
"dependencies",
"as",
"they",
"resolve",
"in",
"this",
"environment",
"."
] | train | https://github.com/jaraco/jaraco.packaging/blob/c84fd1282b222bc262a2bab7a2e668c947472f46/jaraco/packaging/depends.py#L47-L65 |
jaraco/jaraco.packaging | jaraco/packaging/depends.py | load_dependencies | def load_dependencies(req, history=None):
"""
Load the dependency tree as a Python object tree,
suitable for JSON serialization.
>>> deps = load_dependencies('jaraco.packaging')
>>> import json
>>> doc = json.dumps(deps)
"""
if history is None:
history = set()
dist = pkg_res... | python | def load_dependencies(req, history=None):
"""
Load the dependency tree as a Python object tree,
suitable for JSON serialization.
>>> deps = load_dependencies('jaraco.packaging')
>>> import json
>>> doc = json.dumps(deps)
"""
if history is None:
history = set()
dist = pkg_res... | [
"def",
"load_dependencies",
"(",
"req",
",",
"history",
"=",
"None",
")",
":",
"if",
"history",
"is",
"None",
":",
"history",
"=",
"set",
"(",
")",
"dist",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"req",
")",
"spec",
"=",
"dict",
"(",
"requi... | Load the dependency tree as a Python object tree,
suitable for JSON serialization.
>>> deps = load_dependencies('jaraco.packaging')
>>> import json
>>> doc = json.dumps(deps) | [
"Load",
"the",
"dependency",
"tree",
"as",
"a",
"Python",
"object",
"tree",
"suitable",
"for",
"JSON",
"serialization",
"."
] | train | https://github.com/jaraco/jaraco.packaging/blob/c84fd1282b222bc262a2bab7a2e668c947472f46/jaraco/packaging/depends.py#L68-L94 |
jaraco/jaraco.packaging | jaraco/packaging/depends.py | check_dependencies_remote | def check_dependencies_remote(args):
"""
Invoke this command on a remote Python.
"""
cmd = [args.python, '-m', 'depends', args.requirement]
env = dict(PYTHONPATH=os.path.dirname(__file__))
return subprocess.check_call(cmd, env=env) | python | def check_dependencies_remote(args):
"""
Invoke this command on a remote Python.
"""
cmd = [args.python, '-m', 'depends', args.requirement]
env = dict(PYTHONPATH=os.path.dirname(__file__))
return subprocess.check_call(cmd, env=env) | [
"def",
"check_dependencies_remote",
"(",
"args",
")",
":",
"cmd",
"=",
"[",
"args",
".",
"python",
",",
"'-m'",
",",
"'depends'",
",",
"args",
".",
"requirement",
"]",
"env",
"=",
"dict",
"(",
"PYTHONPATH",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
... | Invoke this command on a remote Python. | [
"Invoke",
"this",
"command",
"on",
"a",
"remote",
"Python",
"."
] | train | https://github.com/jaraco/jaraco.packaging/blob/c84fd1282b222bc262a2bab7a2e668c947472f46/jaraco/packaging/depends.py#L117-L123 |
whyscream/dspam-milter | dspam/client.py | DspamClient._send | def _send(self, line):
"""
Write a line of data to the server.
Args:
line -- A single line of data to write to the socket.
"""
if not line.endswith('\r\n'):
if line.endswith('\n'):
logger.debug('Fixing bare LF before sending data to socket')
... | python | def _send(self, line):
"""
Write a line of data to the server.
Args:
line -- A single line of data to write to the socket.
"""
if not line.endswith('\r\n'):
if line.endswith('\n'):
logger.debug('Fixing bare LF before sending data to socket')
... | [
"def",
"_send",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"line",
".",
"endswith",
"(",
"'\\r\\n'",
")",
":",
"if",
"line",
".",
"endswith",
"(",
"'\\n'",
")",
":",
"logger",
".",
"debug",
"(",
"'Fixing bare LF before sending data to socket'",
")",
... | Write a line of data to the server.
Args:
line -- A single line of data to write to the socket. | [
"Write",
"a",
"line",
"of",
"data",
"to",
"the",
"server",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L92-L109 |
whyscream/dspam-milter | dspam/client.py | DspamClient._read | def _read(self):
"""
Read a single response line from the server.
"""
line = ''
finished = False
while not finished:
char = self._socket.recv(1)
if char == '':
return ''
elif char == '\r':
continue
... | python | def _read(self):
"""
Read a single response line from the server.
"""
line = ''
finished = False
while not finished:
char = self._socket.recv(1)
if char == '':
return ''
elif char == '\r':
continue
... | [
"def",
"_read",
"(",
"self",
")",
":",
"line",
"=",
"''",
"finished",
"=",
"False",
"while",
"not",
"finished",
":",
"char",
"=",
"self",
".",
"_socket",
".",
"recv",
"(",
"1",
")",
"if",
"char",
"==",
"''",
":",
"return",
"''",
"elif",
"char",
"... | Read a single response line from the server. | [
"Read",
"a",
"single",
"response",
"line",
"from",
"the",
"server",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L111-L130 |
whyscream/dspam-milter | dspam/client.py | DspamClient._peek | def _peek(self, chars=1):
"""
Peek at the data in the server response.
Peeking should only be done when the response can be predicted.
Make sure that the socket will not block by requesting too
much data from it while peeking.
Args:
chars -- the number of charac... | python | def _peek(self, chars=1):
"""
Peek at the data in the server response.
Peeking should only be done when the response can be predicted.
Make sure that the socket will not block by requesting too
much data from it while peeking.
Args:
chars -- the number of charac... | [
"def",
"_peek",
"(",
"self",
",",
"chars",
"=",
"1",
")",
":",
"line",
"=",
"self",
".",
"_socket",
".",
"recv",
"(",
"chars",
",",
"socket",
".",
"MSG_PEEK",
")",
"logger",
".",
"debug",
"(",
"'Server sent (peek): '",
"+",
"line",
".",
"rstrip",
"("... | Peek at the data in the server response.
Peeking should only be done when the response can be predicted.
Make sure that the socket will not block by requesting too
much data from it while peeking.
Args:
chars -- the number of characters to peek. | [
"Peek",
"at",
"the",
"data",
"in",
"the",
"server",
"response",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L132-L146 |
whyscream/dspam-milter | dspam/client.py | DspamClient.connect | def connect(self):
"""
Connect to TCP or domain socket, and process the server LMTP greeting.
"""
# extract proto from socket setting
try:
(proto, spec) = self.socket.split(':')
except ValueError:
raise DspamClientError(
'Failed to... | python | def connect(self):
"""
Connect to TCP or domain socket, and process the server LMTP greeting.
"""
# extract proto from socket setting
try:
(proto, spec) = self.socket.split(':')
except ValueError:
raise DspamClientError(
'Failed to... | [
"def",
"connect",
"(",
"self",
")",
":",
"# extract proto from socket setting",
"try",
":",
"(",
"proto",
",",
"spec",
")",
"=",
"self",
".",
"socket",
".",
"split",
"(",
"':'",
")",
"except",
"ValueError",
":",
"raise",
"DspamClientError",
"(",
"'Failed to ... | Connect to TCP or domain socket, and process the server LMTP greeting. | [
"Connect",
"to",
"TCP",
"or",
"domain",
"socket",
"and",
"process",
"the",
"server",
"LMTP",
"greeting",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L148-L205 |
whyscream/dspam-milter | dspam/client.py | DspamClient.lhlo | def lhlo(self):
"""
Send LMTP LHLO greeting, and process the server response.
A regular LMTP greeting is sent, and if accepted by the server, the
capabilities it returns are parsed.
DLMTP authentication starts here by announcing the dlmtp_ident in
the LHLO as our hostna... | python | def lhlo(self):
"""
Send LMTP LHLO greeting, and process the server response.
A regular LMTP greeting is sent, and if accepted by the server, the
capabilities it returns are parsed.
DLMTP authentication starts here by announcing the dlmtp_ident in
the LHLO as our hostna... | [
"def",
"lhlo",
"(",
"self",
")",
":",
"if",
"self",
".",
"dlmtp_ident",
"is",
"not",
"None",
":",
"host",
"=",
"self",
".",
"dlmtp_ident",
"else",
":",
"host",
"=",
"socket",
".",
"getfqdn",
"(",
")",
"self",
".",
"_send",
"(",
"'LHLO '",
"+",
"hos... | Send LMTP LHLO greeting, and process the server response.
A regular LMTP greeting is sent, and if accepted by the server, the
capabilities it returns are parsed.
DLMTP authentication starts here by announcing the dlmtp_ident in
the LHLO as our hostname. When the ident is accepted and D... | [
"Send",
"LMTP",
"LHLO",
"greeting",
"and",
"process",
"the",
"server",
"response",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L207-L239 |
whyscream/dspam-milter | dspam/client.py | DspamClient.mailfrom | def mailfrom(self, sender=None, client_args=None):
"""
Send LMTP MAIL FROM command, and process the server response.
In DLMTP mode, the server expects the client to identify itself.
Because the envelope sender is of no importance to DSPAM, the client
is expected to send an ident... | python | def mailfrom(self, sender=None, client_args=None):
"""
Send LMTP MAIL FROM command, and process the server response.
In DLMTP mode, the server expects the client to identify itself.
Because the envelope sender is of no importance to DSPAM, the client
is expected to send an ident... | [
"def",
"mailfrom",
"(",
"self",
",",
"sender",
"=",
"None",
",",
"client_args",
"=",
"None",
")",
":",
"if",
"sender",
"and",
"client_args",
":",
"raise",
"DspamClientError",
"(",
"'Arguments are mutually exclusive'",
")",
"if",
"client_args",
"and",
"not",
"s... | Send LMTP MAIL FROM command, and process the server response.
In DLMTP mode, the server expects the client to identify itself.
Because the envelope sender is of no importance to DSPAM, the client
is expected to send an identity and a password (dspam.conf:
ServerPass.<ident>="<password>"... | [
"Send",
"LMTP",
"MAIL",
"FROM",
"command",
"and",
"process",
"the",
"server",
"response",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L241-L293 |
whyscream/dspam-milter | dspam/client.py | DspamClient.rcptto | def rcptto(self, recipients):
"""
Send LMTP RCPT TO command, and process the server response.
The DSPAM server expects to find one or more valid DSPAM users as
envelope recipients. The set recipient will be the user DSPAM
processes mail for.
When you need want DSPAM to ... | python | def rcptto(self, recipients):
"""
Send LMTP RCPT TO command, and process the server response.
The DSPAM server expects to find one or more valid DSPAM users as
envelope recipients. The set recipient will be the user DSPAM
processes mail for.
When you need want DSPAM to ... | [
"def",
"rcptto",
"(",
"self",
",",
"recipients",
")",
":",
"for",
"rcpt",
"in",
"recipients",
":",
"self",
".",
"_send",
"(",
"'RCPT TO:<{}>\\r\\n'",
".",
"format",
"(",
"rcpt",
")",
")",
"resp",
"=",
"self",
".",
"_read",
"(",
")",
"if",
"not",
"res... | Send LMTP RCPT TO command, and process the server response.
The DSPAM server expects to find one or more valid DSPAM users as
envelope recipients. The set recipient will be the user DSPAM
processes mail for.
When you need want DSPAM to deliver the message itself, and need to
pa... | [
"Send",
"LMTP",
"RCPT",
"TO",
"command",
"and",
"process",
"the",
"server",
"response",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L295-L319 |
whyscream/dspam-milter | dspam/client.py | DspamClient.data | def data(self, message):
"""
Send LMTP DATA command and process the server response.
The server response is stored as a list of dicts in
<DspamClient>.results, keyed on the recipient name(s). Depending
on the server return data, different formats are available:
* LMTP mo... | python | def data(self, message):
"""
Send LMTP DATA command and process the server response.
The server response is stored as a list of dicts in
<DspamClient>.results, keyed on the recipient name(s). Depending
on the server return data, different formats are available:
* LMTP mo... | [
"def",
"data",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_send",
"(",
"'DATA\\r\\n'",
")",
"resp",
"=",
"self",
".",
"_read",
"(",
")",
"if",
"not",
"resp",
".",
"startswith",
"(",
"'354'",
")",
":",
"raise",
"DspamClientError",
"(",
"'Une... | Send LMTP DATA command and process the server response.
The server response is stored as a list of dicts in
<DspamClient>.results, keyed on the recipient name(s). Depending
on the server return data, different formats are available:
* LMTP mode -- Dict containing 'accepted', a bool i... | [
"Send",
"LMTP",
"DATA",
"command",
"and",
"process",
"the",
"server",
"response",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L321-L498 |
whyscream/dspam-milter | dspam/client.py | DspamClient.rset | def rset(self):
"""
Send LMTP RSET command and process the server response.
"""
self._send('RSET\r\n')
resp = self._read()
if not resp.startswith('250'):
logger.warn('Unexpected server response at RSET: ' + resp)
self._recipients = []
self.res... | python | def rset(self):
"""
Send LMTP RSET command and process the server response.
"""
self._send('RSET\r\n')
resp = self._read()
if not resp.startswith('250'):
logger.warn('Unexpected server response at RSET: ' + resp)
self._recipients = []
self.res... | [
"def",
"rset",
"(",
"self",
")",
":",
"self",
".",
"_send",
"(",
"'RSET\\r\\n'",
")",
"resp",
"=",
"self",
".",
"_read",
"(",
")",
"if",
"not",
"resp",
".",
"startswith",
"(",
"'250'",
")",
":",
"logger",
".",
"warn",
"(",
"'Unexpected server response ... | Send LMTP RSET command and process the server response. | [
"Send",
"LMTP",
"RSET",
"command",
"and",
"process",
"the",
"server",
"response",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L500-L510 |
whyscream/dspam-milter | dspam/client.py | DspamClient.quit | def quit(self):
"""
Send LMTP QUIT command, read the server response and disconnect.
"""
self._send('QUIT\r\n')
resp = self._read()
if not resp.startswith('221'):
logger.warning('Unexpected server response at QUIT: ' + resp)
self._socket.close()
... | python | def quit(self):
"""
Send LMTP QUIT command, read the server response and disconnect.
"""
self._send('QUIT\r\n')
resp = self._read()
if not resp.startswith('221'):
logger.warning('Unexpected server response at QUIT: ' + resp)
self._socket.close()
... | [
"def",
"quit",
"(",
"self",
")",
":",
"self",
".",
"_send",
"(",
"'QUIT\\r\\n'",
")",
"resp",
"=",
"self",
".",
"_read",
"(",
")",
"if",
"not",
"resp",
".",
"startswith",
"(",
"'221'",
")",
":",
"logger",
".",
"warning",
"(",
"'Unexpected server respon... | Send LMTP QUIT command, read the server response and disconnect. | [
"Send",
"LMTP",
"QUIT",
"command",
"read",
"the",
"server",
"response",
"and",
"disconnect",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L512-L524 |
whyscream/dspam-milter | dspam/client.py | DspamClient.process | def process(self, message, user):
"""
Process a message.
"""
if not self._socket:
self.connect()
self.lhlo()
else:
self.rset()
if not self.dlmtp:
raise DspamClientError('DLMTP mode not available')
self.mailfrom(cli... | python | def process(self, message, user):
"""
Process a message.
"""
if not self._socket:
self.connect()
self.lhlo()
else:
self.rset()
if not self.dlmtp:
raise DspamClientError('DLMTP mode not available')
self.mailfrom(cli... | [
"def",
"process",
"(",
"self",
",",
"message",
",",
"user",
")",
":",
"if",
"not",
"self",
".",
"_socket",
":",
"self",
".",
"connect",
"(",
")",
"self",
".",
"lhlo",
"(",
")",
"else",
":",
"self",
".",
"rset",
"(",
")",
"if",
"not",
"self",
".... | Process a message. | [
"Process",
"a",
"message",
"."
] | train | https://github.com/whyscream/dspam-milter/blob/f9939b718eed02cb7e56f8c5b921db4cfe1cd85a/dspam/client.py#L526-L549 |
brantai/python-rightscale | rightscale/rightscale.py | get_resource_method | def get_resource_method(name, template):
"""
Creates a function that is suitable as a method for ResourceCollection.
"""
def rsr_meth(self, **kwargs):
http_method = template['http_method']
extra_path = template.get('extra_path')
if extra_path:
fills = {'res_id': kwarg... | python | def get_resource_method(name, template):
"""
Creates a function that is suitable as a method for ResourceCollection.
"""
def rsr_meth(self, **kwargs):
http_method = template['http_method']
extra_path = template.get('extra_path')
if extra_path:
fills = {'res_id': kwarg... | [
"def",
"get_resource_method",
"(",
"name",
",",
"template",
")",
":",
"def",
"rsr_meth",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"http_method",
"=",
"template",
"[",
"'http_method'",
"]",
"extra_path",
"=",
"template",
".",
"get",
"(",
"'extra_path... | Creates a function that is suitable as a method for ResourceCollection. | [
"Creates",
"a",
"function",
"that",
"is",
"suitable",
"as",
"a",
"method",
"for",
"ResourceCollection",
"."
] | train | https://github.com/brantai/python-rightscale/blob/5fbf4089922917247be712d58645a7b1504f0944/rightscale/rightscale.py#L30-L70 |
fusionbox/django-separated | separated/utils.py | Getter | def Getter(accessor, normalizer=lambda x: x):
"""
Returns a function that will access an attribute off of an object. If that
attribute is callable, it will call it. Accepts a normalizer to call on
the value at the end.
"""
if not callable(accessor):
short_description = get_pretty_name(... | python | def Getter(accessor, normalizer=lambda x: x):
"""
Returns a function that will access an attribute off of an object. If that
attribute is callable, it will call it. Accepts a normalizer to call on
the value at the end.
"""
if not callable(accessor):
short_description = get_pretty_name(... | [
"def",
"Getter",
"(",
"accessor",
",",
"normalizer",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"if",
"not",
"callable",
"(",
"accessor",
")",
":",
"short_description",
"=",
"get_pretty_name",
"(",
"accessor",
")",
"accessor",
"=",
"attrgetter",
"(",
"accesso... | Returns a function that will access an attribute off of an object. If that
attribute is callable, it will call it. Accepts a normalizer to call on
the value at the end. | [
"Returns",
"a",
"function",
"that",
"will",
"access",
"an",
"attribute",
"off",
"of",
"an",
"object",
".",
"If",
"that",
"attribute",
"is",
"callable",
"it",
"will",
"call",
"it",
".",
"Accepts",
"a",
"normalizer",
"to",
"call",
"on",
"the",
"value",
"at... | train | https://github.com/fusionbox/django-separated/blob/17a832c0c0c1f7e88996f29bf689f72f8a2ca03b/separated/utils.py#L21-L43 |
fusionbox/django-separated | separated/utils.py | DisplayGetter | def DisplayGetter(accessor, *args, **kwargs):
"""
Returns a Getter that gets the display name for a model field with choices.
"""
short_description = get_pretty_name(accessor)
accessor = 'get_%s_display' % accessor
getter = Getter(accessor, *args, **kwargs)
getter.short_description = short_d... | python | def DisplayGetter(accessor, *args, **kwargs):
"""
Returns a Getter that gets the display name for a model field with choices.
"""
short_description = get_pretty_name(accessor)
accessor = 'get_%s_display' % accessor
getter = Getter(accessor, *args, **kwargs)
getter.short_description = short_d... | [
"def",
"DisplayGetter",
"(",
"accessor",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"short_description",
"=",
"get_pretty_name",
"(",
"accessor",
")",
"accessor",
"=",
"'get_%s_display'",
"%",
"accessor",
"getter",
"=",
"Getter",
"(",
"accessor",
"... | Returns a Getter that gets the display name for a model field with choices. | [
"Returns",
"a",
"Getter",
"that",
"gets",
"the",
"display",
"name",
"for",
"a",
"model",
"field",
"with",
"choices",
"."
] | train | https://github.com/fusionbox/django-separated/blob/17a832c0c0c1f7e88996f29bf689f72f8a2ca03b/separated/utils.py#L52-L60 |
gasparka/pyhacores | pyhacores/cordic/cordic_core.py | Cordic.initial_step | def initial_step(self, phase, x, y):
"""
Transform input to the CORDIC working quadrants
"""
self.x[0] = x
self.y[0] = y
self.phase[0] = phase
if self.MODE == CordicMode.ROTATION:
if phase > 0.5:
# > np.pi/2
self.x[0] = ... | python | def initial_step(self, phase, x, y):
"""
Transform input to the CORDIC working quadrants
"""
self.x[0] = x
self.y[0] = y
self.phase[0] = phase
if self.MODE == CordicMode.ROTATION:
if phase > 0.5:
# > np.pi/2
self.x[0] = ... | [
"def",
"initial_step",
"(",
"self",
",",
"phase",
",",
"x",
",",
"y",
")",
":",
"self",
".",
"x",
"[",
"0",
"]",
"=",
"x",
"self",
".",
"y",
"[",
"0",
"]",
"=",
"y",
"self",
".",
"phase",
"[",
"0",
"]",
"=",
"phase",
"if",
"self",
".",
"M... | Transform input to the CORDIC working quadrants | [
"Transform",
"input",
"to",
"the",
"CORDIC",
"working",
"quadrants"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/cordic/cordic_core.py#L33-L61 |
gasparka/pyhacores | pyhacores/cordic/cordic_core.py | Cordic.main | def main(self, x, y, phase):
"""
Runs one step of pipelined CORDIC
Returned phase is in 1 to -1 range
"""
self.initial_step(phase, x, y)
# pipelined CORDIC
for i in range(self.ITERATIONS - 1):
if self.MODE == CordicMode.ROTATION:
direc... | python | def main(self, x, y, phase):
"""
Runs one step of pipelined CORDIC
Returned phase is in 1 to -1 range
"""
self.initial_step(phase, x, y)
# pipelined CORDIC
for i in range(self.ITERATIONS - 1):
if self.MODE == CordicMode.ROTATION:
direc... | [
"def",
"main",
"(",
"self",
",",
"x",
",",
"y",
",",
"phase",
")",
":",
"self",
".",
"initial_step",
"(",
"phase",
",",
"x",
",",
"y",
")",
"# pipelined CORDIC",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"ITERATIONS",
"-",
"1",
")",
":",
"if",... | Runs one step of pipelined CORDIC
Returned phase is in 1 to -1 range | [
"Runs",
"one",
"step",
"of",
"pipelined",
"CORDIC",
"Returned",
"phase",
"is",
"in",
"1",
"to",
"-",
"1",
"range"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/cordic/cordic_core.py#L63-L86 |
radjkarl/fancyWidgets | DUMP/pyqtgraphBased/parametertree/Parameter.py | Parameter.blockSignals | def blockSignals(self, boolean):
"""add block/unblock of keyboard shortcut"""
pgParameter.blockSignals(self, boolean)
try:
item = self.items[0]
if item.key:
item.key.blockSignals(boolean)
except:
pass | python | def blockSignals(self, boolean):
"""add block/unblock of keyboard shortcut"""
pgParameter.blockSignals(self, boolean)
try:
item = self.items[0]
if item.key:
item.key.blockSignals(boolean)
except:
pass | [
"def",
"blockSignals",
"(",
"self",
",",
"boolean",
")",
":",
"pgParameter",
".",
"blockSignals",
"(",
"self",
",",
"boolean",
")",
"try",
":",
"item",
"=",
"self",
".",
"items",
"[",
"0",
"]",
"if",
"item",
".",
"key",
":",
"item",
".",
"key",
"."... | add block/unblock of keyboard shortcut | [
"add",
"block",
"/",
"unblock",
"of",
"keyboard",
"shortcut"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/DUMP/pyqtgraphBased/parametertree/Parameter.py#L64-L72 |
radjkarl/fancyWidgets | DUMP/pyqtgraphBased/parametertree/Parameter.py | Parameter.replaceWith | def replaceWith(self, param):
"""replace this parameter with another"""
i = self.parent().children().index(self)
# TODO: transfer the children:
p = self.parent()
self.parent().removeChild(self)
p.insertChild(i, param)
self = param | python | def replaceWith(self, param):
"""replace this parameter with another"""
i = self.parent().children().index(self)
# TODO: transfer the children:
p = self.parent()
self.parent().removeChild(self)
p.insertChild(i, param)
self = param | [
"def",
"replaceWith",
"(",
"self",
",",
"param",
")",
":",
"i",
"=",
"self",
".",
"parent",
"(",
")",
".",
"children",
"(",
")",
".",
"index",
"(",
"self",
")",
"# TODO: transfer the children:",
"p",
"=",
"self",
".",
"parent",
"(",
")",
"self",
".",... | replace this parameter with another | [
"replace",
"this",
"parameter",
"with",
"another"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/DUMP/pyqtgraphBased/parametertree/Parameter.py#L110-L117 |
sveetch/django-icomoon | icomoon/management/commands/icomoon_deploy.py | Command.deploy | def deploy(self):
"""
Open a ZIP archive, validate requirements then deploy the webfont into
project static files
"""
self._info("* Opening archive: {}", self.archive_path)
if not os.path.exists(self.archive_path):
self._error("Given path does not exists: {}",... | python | def deploy(self):
"""
Open a ZIP archive, validate requirements then deploy the webfont into
project static files
"""
self._info("* Opening archive: {}", self.archive_path)
if not os.path.exists(self.archive_path):
self._error("Given path does not exists: {}",... | [
"def",
"deploy",
"(",
"self",
")",
":",
"self",
".",
"_info",
"(",
"\"* Opening archive: {}\"",
",",
"self",
".",
"archive_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"archive_path",
")",
":",
"self",
".",
"_error",
"("... | Open a ZIP archive, validate requirements then deploy the webfont into
project static files | [
"Open",
"a",
"ZIP",
"archive",
"validate",
"requirements",
"then",
"deploy",
"the",
"webfont",
"into",
"project",
"static",
"files"
] | train | https://github.com/sveetch/django-icomoon/blob/39f363ad3fbf53400be64a6c9413bf80c6308edf/icomoon/management/commands/icomoon_deploy.py#L66-L102 |
sveetch/django-icomoon | icomoon/management/commands/icomoon_deploy.py | Command.extract | def extract(self, zip_archive, font_files):
"""
Extract files to install
"""
# Get a temp directory
tmp_container = tempfile.mkdtemp(prefix='icomoon-tmp')
self._debug("* Temporary dir for extracted archive: {}", tmp_container)
# Extract manifest to temp directory... | python | def extract(self, zip_archive, font_files):
"""
Extract files to install
"""
# Get a temp directory
tmp_container = tempfile.mkdtemp(prefix='icomoon-tmp')
self._debug("* Temporary dir for extracted archive: {}", tmp_container)
# Extract manifest to temp directory... | [
"def",
"extract",
"(",
"self",
",",
"zip_archive",
",",
"font_files",
")",
":",
"# Get a temp directory",
"tmp_container",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"'icomoon-tmp'",
")",
"self",
".",
"_debug",
"(",
"\"* Temporary dir for extracted archive... | Extract files to install | [
"Extract",
"files",
"to",
"install"
] | train | https://github.com/sveetch/django-icomoon/blob/39f363ad3fbf53400be64a6c9413bf80c6308edf/icomoon/management/commands/icomoon_deploy.py#L104-L129 |
sveetch/django-icomoon | icomoon/management/commands/icomoon_deploy.py | Command.install | def install(self, tmp_container, font_tmpdir, css_content):
"""
Install extracted files and builded css
"""
# Write builded css file to its destination
with open(self.webfont_settings['csspart_path'], 'w') as css_file:
css_file.write(css_content)
# Clean prev... | python | def install(self, tmp_container, font_tmpdir, css_content):
"""
Install extracted files and builded css
"""
# Write builded css file to its destination
with open(self.webfont_settings['csspart_path'], 'w') as css_file:
css_file.write(css_content)
# Clean prev... | [
"def",
"install",
"(",
"self",
",",
"tmp_container",
",",
"font_tmpdir",
",",
"css_content",
")",
":",
"# Write builded css file to its destination",
"with",
"open",
"(",
"self",
".",
"webfont_settings",
"[",
"'csspart_path'",
"]",
",",
"'w'",
")",
"as",
"css_file... | Install extracted files and builded css | [
"Install",
"extracted",
"files",
"and",
"builded",
"css"
] | train | https://github.com/sveetch/django-icomoon/blob/39f363ad3fbf53400be64a6c9413bf80c6308edf/icomoon/management/commands/icomoon_deploy.py#L137-L165 |
wolfhong/formic | formic/command.py | create_parser | def create_parser():
"""Creates and returns the command line parser, an
:class:`argparser.ArgumentParser` instance."""
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
description=DESCRIPTION,
epilog=EPILOG,
add_help=False)
directory = parser.add_ar... | python | def create_parser():
"""Creates and returns the command line parser, an
:class:`argparser.ArgumentParser` instance."""
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
description=DESCRIPTION,
epilog=EPILOG,
add_help=False)
directory = parser.add_ar... | [
"def",
"create_parser",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
"formatter_class",
"=",
"RawDescriptionHelpFormatter",
",",
"description",
"=",
"DESCRIPTION",
",",
"epilog",
"=",
"EPILOG",
",",
"add_help",
"=",
"False",
")",
"directory",
"=",
"parse... | Creates and returns the command line parser, an
:class:`argparser.ArgumentParser` instance. | [
"Creates",
"and",
"returns",
"the",
"command",
"line",
"parser",
"an",
":",
"class",
":",
"argparser",
".",
"ArgumentParser",
"instance",
"."
] | train | https://github.com/wolfhong/formic/blob/0d81eb88dcbb6fa705194fc6ccf2993f4abbaa76/formic/command.py#L54-L129 |
wolfhong/formic | formic/command.py | main | def main(*kw):
"""Command line entry point; arguments must match those defined in
in :meth:`create_parser()`; returns 0 for success, else 1.
Example::
command.main("-i", "**/*.py", "--no-default-excludes")
Runs formic printing out all .py files in the current working directory
and its child... | python | def main(*kw):
"""Command line entry point; arguments must match those defined in
in :meth:`create_parser()`; returns 0 for success, else 1.
Example::
command.main("-i", "**/*.py", "--no-default-excludes")
Runs formic printing out all .py files in the current working directory
and its child... | [
"def",
"main",
"(",
"*",
"kw",
")",
":",
"parser",
"=",
"create_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"kw",
"if",
"kw",
"else",
"None",
")",
"if",
"args",
".",
"help",
":",
"parser",
".",
"print_help",
"(",
")",
"elif",
... | Command line entry point; arguments must match those defined in
in :meth:`create_parser()`; returns 0 for success, else 1.
Example::
command.main("-i", "**/*.py", "--no-default-excludes")
Runs formic printing out all .py files in the current working directory
and its children to ``sys.stdout``.... | [
"Command",
"line",
"entry",
"point",
";",
"arguments",
"must",
"match",
"those",
"defined",
"in",
"in",
":",
"meth",
":",
"create_parser",
"()",
";",
"returns",
"0",
"for",
"success",
"else",
"1",
"."
] | train | https://github.com/wolfhong/formic/blob/0d81eb88dcbb6fa705194fc6ccf2993f4abbaa76/formic/command.py#L132-L247 |
david-caro/python-autosemver | autosemver/packaging.py | get_current_version | def get_current_version(project_name=None, project_dir=os.curdir,
repo_dir=None):
"""
Retrieves the version of the package, checking in this order of priority:
* From an environment variable named ${project_name}_VERSION (all in caps)
if project_name was specified.
* From ... | python | def get_current_version(project_name=None, project_dir=os.curdir,
repo_dir=None):
"""
Retrieves the version of the package, checking in this order of priority:
* From an environment variable named ${project_name}_VERSION (all in caps)
if project_name was specified.
* From ... | [
"def",
"get_current_version",
"(",
"project_name",
"=",
"None",
",",
"project_dir",
"=",
"os",
".",
"curdir",
",",
"repo_dir",
"=",
"None",
")",
":",
"if",
"project_name",
"is",
"not",
"None",
":",
"version_env_var",
"=",
"'%s_VERSION'",
"%",
"project_name",
... | Retrieves the version of the package, checking in this order of priority:
* From an environment variable named ${project_name}_VERSION (all in caps)
if project_name was specified.
* From the PKG-INFO file if inside a packaged distro.
* From the git history.
Args:
project_name(str): Name ... | [
"Retrieves",
"the",
"version",
"of",
"the",
"package",
"checking",
"in",
"this",
"order",
"of",
"priority",
":"
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L35-L92 |
david-caro/python-autosemver | autosemver/packaging.py | get_authors | def get_authors(project_dir=os.curdir):
"""
Retrieves the authors list, from the AUTHORS file (if in a package) or
generates it from the git history.
Returns:
list(str): List of authors
Raises:
RuntimeError: If the authors could not be retrieved
"""
authors = set()
pkg_... | python | def get_authors(project_dir=os.curdir):
"""
Retrieves the authors list, from the AUTHORS file (if in a package) or
generates it from the git history.
Returns:
list(str): List of authors
Raises:
RuntimeError: If the authors could not be retrieved
"""
authors = set()
pkg_... | [
"def",
"get_authors",
"(",
"project_dir",
"=",
"os",
".",
"curdir",
")",
":",
"authors",
"=",
"set",
"(",
")",
"pkg_info_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
"'PKG-INFO'",
")",
"authors_file",
"=",
"os",
".",
"path",
"."... | Retrieves the authors list, from the AUTHORS file (if in a package) or
generates it from the git history.
Returns:
list(str): List of authors
Raises:
RuntimeError: If the authors could not be retrieved | [
"Retrieves",
"the",
"authors",
"list",
"from",
"the",
"AUTHORS",
"file",
"(",
"if",
"in",
"a",
"package",
")",
"or",
"generates",
"it",
"from",
"the",
"git",
"history",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L95-L115 |
david-caro/python-autosemver | autosemver/packaging.py | get_changelog | def get_changelog(project_dir=os.curdir, bugtracker_url='', rpm_format=False):
"""
Retrieves the changelog, from the CHANGELOG file (if in a package) or
generates it from the git history. Optionally in rpm-compatible format.
:param project_dir: Path to the git repo of the project.
:type project_dir... | python | def get_changelog(project_dir=os.curdir, bugtracker_url='', rpm_format=False):
"""
Retrieves the changelog, from the CHANGELOG file (if in a package) or
generates it from the git history. Optionally in rpm-compatible format.
:param project_dir: Path to the git repo of the project.
:type project_dir... | [
"def",
"get_changelog",
"(",
"project_dir",
"=",
"os",
".",
"curdir",
",",
"bugtracker_url",
"=",
"''",
",",
"rpm_format",
"=",
"False",
")",
":",
"changelog",
"=",
"''",
"pkg_info_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
"'PK... | Retrieves the changelog, from the CHANGELOG file (if in a package) or
generates it from the git history. Optionally in rpm-compatible format.
:param project_dir: Path to the git repo of the project.
:type project_dir: str
:param bugtracker_url: Url to the bug tracker for the issues.
:type bugtracke... | [
"Retrieves",
"the",
"changelog",
"from",
"the",
"CHANGELOG",
"file",
"(",
"if",
"in",
"a",
"package",
")",
"or",
"generates",
"it",
"from",
"the",
"git",
"history",
".",
"Optionally",
"in",
"rpm",
"-",
"compatible",
"format",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L118-L146 |
david-caro/python-autosemver | autosemver/packaging.py | get_releasenotes | def get_releasenotes(project_dir=os.curdir, bugtracker_url=''):
"""
Retrieves the release notes, from the RELEASE_NOTES file (if in a package)
or generates it from the git history.
Args:
project_dir(str): Path to the git repo of the project.
bugtracker_url(str): Url to the bug tracker f... | python | def get_releasenotes(project_dir=os.curdir, bugtracker_url=''):
"""
Retrieves the release notes, from the RELEASE_NOTES file (if in a package)
or generates it from the git history.
Args:
project_dir(str): Path to the git repo of the project.
bugtracker_url(str): Url to the bug tracker f... | [
"def",
"get_releasenotes",
"(",
"project_dir",
"=",
"os",
".",
"curdir",
",",
"bugtracker_url",
"=",
"''",
")",
":",
"releasenotes",
"=",
"''",
"pkg_info_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
"'PKG-INFO'",
")",
"releasenotes_fi... | Retrieves the release notes, from the RELEASE_NOTES file (if in a package)
or generates it from the git history.
Args:
project_dir(str): Path to the git repo of the project.
bugtracker_url(str): Url to the bug tracker for the issues.
Returns:
str: release notes
Raises:
... | [
"Retrieves",
"the",
"release",
"notes",
"from",
"the",
"RELEASE_NOTES",
"file",
"(",
"if",
"in",
"a",
"package",
")",
"or",
"generates",
"it",
"from",
"the",
"git",
"history",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L149-L177 |
david-caro/python-autosemver | autosemver/packaging.py | create_authors | def create_authors(project_dir=os.curdir):
"""
Creates the authors file, if not in a package.
Returns:
None
Raises:
RuntimeError: If the authors could not be retrieved
"""
pkg_info_file = os.path.join(project_dir, 'PKG-INFO')
authors_file = os.path.join(project_dir, 'AUTHOR... | python | def create_authors(project_dir=os.curdir):
"""
Creates the authors file, if not in a package.
Returns:
None
Raises:
RuntimeError: If the authors could not be retrieved
"""
pkg_info_file = os.path.join(project_dir, 'PKG-INFO')
authors_file = os.path.join(project_dir, 'AUTHOR... | [
"def",
"create_authors",
"(",
"project_dir",
"=",
"os",
".",
"curdir",
")",
":",
"pkg_info_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
"'PKG-INFO'",
")",
"authors_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",... | Creates the authors file, if not in a package.
Returns:
None
Raises:
RuntimeError: If the authors could not be retrieved | [
"Creates",
"the",
"authors",
"file",
"if",
"not",
"in",
"a",
"package",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L180-L199 |
david-caro/python-autosemver | autosemver/packaging.py | create_changelog | def create_changelog(project_dir=os.curdir, bugtracker_url='',
rpm_format=False):
"""
Creates the changelog file, if not in a package.
:param project_dir: Path to the git repo of the project.
:type project_dir: str
:param bugtracker_url: Url to the bug tracker for the issues.
... | python | def create_changelog(project_dir=os.curdir, bugtracker_url='',
rpm_format=False):
"""
Creates the changelog file, if not in a package.
:param project_dir: Path to the git repo of the project.
:type project_dir: str
:param bugtracker_url: Url to the bug tracker for the issues.
... | [
"def",
"create_changelog",
"(",
"project_dir",
"=",
"os",
".",
"curdir",
",",
"bugtracker_url",
"=",
"''",
",",
"rpm_format",
"=",
"False",
")",
":",
"pkg_info_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
"'PKG-INFO'",
")",
"if",
... | Creates the changelog file, if not in a package.
:param project_dir: Path to the git repo of the project.
:type project_dir: str
:param bugtracker_url: Url to the bug tracker for the issues.
:type bugtracker_url: str
:param rpm_format: if set to True, will make the changelog rpm-compatible.
:ty... | [
"Creates",
"the",
"changelog",
"file",
"if",
"not",
"in",
"a",
"package",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L202-L226 |
david-caro/python-autosemver | autosemver/packaging.py | create_releasenotes | def create_releasenotes(project_dir=os.curdir, bugtracker_url=''):
"""
Creates the release notes file, if not in a package.
Args:
project_dir(str): Path to the git repo of the project.
bugtracker_url(str): Url to the bug tracker for the issues.
Returns:
None
Raises:
... | python | def create_releasenotes(project_dir=os.curdir, bugtracker_url=''):
"""
Creates the release notes file, if not in a package.
Args:
project_dir(str): Path to the git repo of the project.
bugtracker_url(str): Url to the bug tracker for the issues.
Returns:
None
Raises:
... | [
"def",
"create_releasenotes",
"(",
"project_dir",
"=",
"os",
".",
"curdir",
",",
"bugtracker_url",
"=",
"''",
")",
":",
"pkg_info_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_dir",
",",
"'PKG-INFO'",
")",
"if",
"os",
".",
"path",
".",
"exist... | Creates the release notes file, if not in a package.
Args:
project_dir(str): Path to the git repo of the project.
bugtracker_url(str): Url to the bug tracker for the issues.
Returns:
None
Raises:
RuntimeError: If the release notes could not be retrieved | [
"Creates",
"the",
"release",
"notes",
"file",
"if",
"not",
"in",
"a",
"package",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/packaging.py#L229-L253 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_rddl_block | def p_rddl_block(self, p):
'''rddl_block : rddl_block domain_block
| rddl_block instance_block
| rddl_block nonfluent_block
| empty'''
if p[1] is None:
p[0] = dict()
else:
name, block = p[2]
p[1... | python | def p_rddl_block(self, p):
'''rddl_block : rddl_block domain_block
| rddl_block instance_block
| rddl_block nonfluent_block
| empty'''
if p[1] is None:
p[0] = dict()
else:
name, block = p[2]
p[1... | [
"def",
"p_rddl_block",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"dict",
"(",
")",
"else",
":",
"name",
",",
"block",
"=",
"p",
"[",
"2",
"]",
"p",
"[",
"1",
"]",
"[",
"name",
... | rddl_block : rddl_block domain_block
| rddl_block instance_block
| rddl_block nonfluent_block
| empty | [
"rddl_block",
":",
"rddl_block",
"domain_block",
"|",
"rddl_block",
"instance_block",
"|",
"rddl_block",
"nonfluent_block",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L261-L271 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_domain_block | def p_domain_block(self, p):
'''domain_block : DOMAIN IDENT LCURLY req_section domain_list RCURLY'''
d = Domain(p[2], p[4], p[5])
p[0] = ('domain', d) | python | def p_domain_block(self, p):
'''domain_block : DOMAIN IDENT LCURLY req_section domain_list RCURLY'''
d = Domain(p[2], p[4], p[5])
p[0] = ('domain', d) | [
"def",
"p_domain_block",
"(",
"self",
",",
"p",
")",
":",
"d",
"=",
"Domain",
"(",
"p",
"[",
"2",
"]",
",",
"p",
"[",
"4",
"]",
",",
"p",
"[",
"5",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"(",
"'domain'",
",",
"d",
")"
] | domain_block : DOMAIN IDENT LCURLY req_section domain_list RCURLY | [
"domain_block",
":",
"DOMAIN",
"IDENT",
"LCURLY",
"req_section",
"domain_list",
"RCURLY"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L273-L276 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_req_section | def p_req_section(self, p):
'''req_section : REQUIREMENTS ASSIGN_EQUAL LCURLY string_list RCURLY SEMI
| REQUIREMENTS LCURLY string_list RCURLY SEMI
| empty'''
if len(p) == 7:
p[0] = p[4]
elif len(p) == 6:
p[0] = p[3]
s... | python | def p_req_section(self, p):
'''req_section : REQUIREMENTS ASSIGN_EQUAL LCURLY string_list RCURLY SEMI
| REQUIREMENTS LCURLY string_list RCURLY SEMI
| empty'''
if len(p) == 7:
p[0] = p[4]
elif len(p) == 6:
p[0] = p[3]
s... | [
"def",
"p_req_section",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"7",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"4",
"]",
"elif",
"len",
"(",
"p",
")",
"==",
"6",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"3",
"]... | req_section : REQUIREMENTS ASSIGN_EQUAL LCURLY string_list RCURLY SEMI
| REQUIREMENTS LCURLY string_list RCURLY SEMI
| empty | [
"req_section",
":",
"REQUIREMENTS",
"ASSIGN_EQUAL",
"LCURLY",
"string_list",
"RCURLY",
"SEMI",
"|",
"REQUIREMENTS",
"LCURLY",
"string_list",
"RCURLY",
"SEMI",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L278-L286 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_domain_list | def p_domain_list(self, p):
'''domain_list : domain_list type_section
| domain_list pvar_section
| domain_list cpf_section
| domain_list reward_section
| domain_list action_precond_section
| domain... | python | def p_domain_list(self, p):
'''domain_list : domain_list type_section
| domain_list pvar_section
| domain_list cpf_section
| domain_list reward_section
| domain_list action_precond_section
| domain... | [
"def",
"p_domain_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"dict",
"(",
")",
"else",
":",
"name",
",",
"section",
"=",
"p",
"[",
"2",
"]",
"p",
"[",
"1",
"]",
"[",
"name"... | domain_list : domain_list type_section
| domain_list pvar_section
| domain_list cpf_section
| domain_list reward_section
| domain_list action_precond_section
| domain_list state_action_constraint_section
... | [
"domain_list",
":",
"domain_list",
"type_section",
"|",
"domain_list",
"pvar_section",
"|",
"domain_list",
"cpf_section",
"|",
"domain_list",
"reward_section",
"|",
"domain_list",
"action_precond_section",
"|",
"domain_list",
"state_action_constraint_section",
"|",
"domain_li... | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L288-L302 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_type_list | def p_type_list(self, p):
'''type_list : type_list type_def
| empty'''
if p[1] is None:
p[0] = []
else:
p[1].append(p[2])
p[0] = p[1] | python | def p_type_list(self, p):
'''type_list : type_list type_def
| empty'''
if p[1] is None:
p[0] = []
else:
p[1].append(p[2])
p[0] = p[1] | [
"def",
"p_type_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"]",
"else",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"... | type_list : type_list type_def
| empty | [
"type_list",
":",
"type_list",
"type_def",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L309-L316 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_type_def | def p_type_def(self, p):
'''type_def : IDENT COLON OBJECT SEMI
| IDENT COLON LCURLY enum_list RCURLY SEMI'''
if len(p) == 5:
p[0] = (p[1], p[3])
elif len(p) == 7:
p[0] = (p[1], p[4]) | python | def p_type_def(self, p):
'''type_def : IDENT COLON OBJECT SEMI
| IDENT COLON LCURLY enum_list RCURLY SEMI'''
if len(p) == 5:
p[0] = (p[1], p[3])
elif len(p) == 7:
p[0] = (p[1], p[4]) | [
"def",
"p_type_def",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"5",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"7",
":",
"p",
"[",
... | type_def : IDENT COLON OBJECT SEMI
| IDENT COLON LCURLY enum_list RCURLY SEMI | [
"type_def",
":",
"IDENT",
"COLON",
"OBJECT",
"SEMI",
"|",
"IDENT",
"COLON",
"LCURLY",
"enum_list",
"RCURLY",
"SEMI"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L318-L324 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_enum_list | def p_enum_list(self, p):
'''enum_list : enum_list COMMA ENUM_VAL
| ENUM_VAL
| empty'''
if p[1] is None:
p[0] = []
elif len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_enum_list(self, p):
'''enum_list : enum_list COMMA ENUM_VAL
| ENUM_VAL
| empty'''
if p[1] is None:
p[0] = []
elif len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_enum_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"]",
"elif",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"3",
... | enum_list : enum_list COMMA ENUM_VAL
| ENUM_VAL
| empty | [
"enum_list",
":",
"enum_list",
"COMMA",
"ENUM_VAL",
"|",
"ENUM_VAL",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L326-L336 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_pvar_list | def p_pvar_list(self, p):
'''pvar_list : pvar_list pvar_def
| empty'''
if p[1] is None:
p[0] = []
else:
p[1].append(p[2])
p[0] = p[1] | python | def p_pvar_list(self, p):
'''pvar_list : pvar_list pvar_def
| empty'''
if p[1] is None:
p[0] = []
else:
p[1].append(p[2])
p[0] = p[1] | [
"def",
"p_pvar_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"]",
"else",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"... | pvar_list : pvar_list pvar_def
| empty | [
"pvar_list",
":",
"pvar_list",
"pvar_def",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L343-L350 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_nonfluent_def | def p_nonfluent_def(self, p):
'''nonfluent_def : IDENT LPAREN param_list RPAREN COLON LCURLY NON_FLUENT COMMA type_spec COMMA DEFAULT ASSIGN_EQUAL range_const RCURLY SEMI
| IDENT COLON LCURLY NON_FLUENT COMMA type_spec COMMA DEFAULT ASSIGN_EQUAL range_const RCURLY SEMI'''
if len... | python | def p_nonfluent_def(self, p):
'''nonfluent_def : IDENT LPAREN param_list RPAREN COLON LCURLY NON_FLUENT COMMA type_spec COMMA DEFAULT ASSIGN_EQUAL range_const RCURLY SEMI
| IDENT COLON LCURLY NON_FLUENT COMMA type_spec COMMA DEFAULT ASSIGN_EQUAL range_const RCURLY SEMI'''
if len... | [
"def",
"p_nonfluent_def",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"16",
":",
"p",
"[",
"0",
"]",
"=",
"PVariable",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"fluent_type",
"=",
"'non-fluent'",
",",
"range_type",
"=",
... | nonfluent_def : IDENT LPAREN param_list RPAREN COLON LCURLY NON_FLUENT COMMA type_spec COMMA DEFAULT ASSIGN_EQUAL range_const RCURLY SEMI
| IDENT COLON LCURLY NON_FLUENT COMMA type_spec COMMA DEFAULT ASSIGN_EQUAL range_const RCURLY SEMI | [
"nonfluent_def",
":",
"IDENT",
"LPAREN",
"param_list",
"RPAREN",
"COLON",
"LCURLY",
"NON_FLUENT",
"COMMA",
"type_spec",
"COMMA",
"DEFAULT",
"ASSIGN_EQUAL",
"range_const",
"RCURLY",
"SEMI",
"|",
"IDENT",
"COLON",
"LCURLY",
"NON_FLUENT",
"COMMA",
"type_spec",
"COMMA",
... | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L359-L365 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_intermfluent_def | def p_intermfluent_def(self, p):
'''intermfluent_def : IDENT LPAREN param_list RPAREN COLON LCURLY INTERMEDIATE COMMA type_spec COMMA LEVEL ASSIGN_EQUAL range_const RCURLY SEMI
| IDENT COLON LCURLY INTERMEDIATE COMMA type_spec COMMA LEVEL ASSIGN_EQUAL range_const RCURLY SEMI'''
... | python | def p_intermfluent_def(self, p):
'''intermfluent_def : IDENT LPAREN param_list RPAREN COLON LCURLY INTERMEDIATE COMMA type_spec COMMA LEVEL ASSIGN_EQUAL range_const RCURLY SEMI
| IDENT COLON LCURLY INTERMEDIATE COMMA type_spec COMMA LEVEL ASSIGN_EQUAL range_const RCURLY SEMI'''
... | [
"def",
"p_intermfluent_def",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"16",
":",
"p",
"[",
"0",
"]",
"=",
"PVariable",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"fluent_type",
"=",
"'interm-fluent'",
",",
"range_type",
... | intermfluent_def : IDENT LPAREN param_list RPAREN COLON LCURLY INTERMEDIATE COMMA type_spec COMMA LEVEL ASSIGN_EQUAL range_const RCURLY SEMI
| IDENT COLON LCURLY INTERMEDIATE COMMA type_spec COMMA LEVEL ASSIGN_EQUAL range_const RCURLY SEMI | [
"intermfluent_def",
":",
"IDENT",
"LPAREN",
"param_list",
"RPAREN",
"COLON",
"LCURLY",
"INTERMEDIATE",
"COMMA",
"type_spec",
"COMMA",
"LEVEL",
"ASSIGN_EQUAL",
"range_const",
"RCURLY",
"SEMI",
"|",
"IDENT",
"COLON",
"LCURLY",
"INTERMEDIATE",
"COMMA",
"type_spec",
"COMM... | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L383-L389 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_cpf_list | def p_cpf_list(self, p):
'''cpf_list : cpf_list cpf_def
| empty'''
if p[1] is None:
p[0] = []
else:
p[1].append(p[2])
p[0] = p[1] | python | def p_cpf_list(self, p):
'''cpf_list : cpf_list cpf_def
| empty'''
if p[1] is None:
p[0] = []
else:
p[1].append(p[2])
p[0] = p[1] | [
"def",
"p_cpf_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"]",
"else",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=... | cpf_list : cpf_list cpf_def
| empty | [
"cpf_list",
":",
"cpf_list",
"cpf_def",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L401-L408 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_action_precond_section | def p_action_precond_section(self, p):
'''action_precond_section : ACTION_PRECONDITIONS LCURLY action_precond_list RCURLY SEMI
| ACTION_PRECONDITIONS LCURLY RCURLY SEMI'''
if len(p) == 6:
p[0] = ('preconds', p[3])
elif len(p) == 5:
p[0] =... | python | def p_action_precond_section(self, p):
'''action_precond_section : ACTION_PRECONDITIONS LCURLY action_precond_list RCURLY SEMI
| ACTION_PRECONDITIONS LCURLY RCURLY SEMI'''
if len(p) == 6:
p[0] = ('preconds', p[3])
elif len(p) == 5:
p[0] =... | [
"def",
"p_action_precond_section",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"6",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'preconds'",
",",
"p",
"[",
"3",
"]",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"5",
":",
"p",
"["... | action_precond_section : ACTION_PRECONDITIONS LCURLY action_precond_list RCURLY SEMI
| ACTION_PRECONDITIONS LCURLY RCURLY SEMI | [
"action_precond_section",
":",
"ACTION_PRECONDITIONS",
"LCURLY",
"action_precond_list",
"RCURLY",
"SEMI",
"|",
"ACTION_PRECONDITIONS",
"LCURLY",
"RCURLY",
"SEMI"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L419-L426 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_action_precond_list | def p_action_precond_list(self, p):
'''action_precond_list : action_precond_list action_precond_def
| action_precond_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_action_precond_list(self, p):
'''action_precond_list : action_precond_list action_precond_def
| action_precond_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_action_precond_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"3",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"elif",
"len",
"(",... | action_precond_list : action_precond_list action_precond_def
| action_precond_def | [
"action_precond_list",
":",
"action_precond_list",
"action_precond_def",
"|",
"action_precond_def"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L428-L435 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_state_action_constraint_section | def p_state_action_constraint_section(self, p):
'''state_action_constraint_section : STATE_ACTION_CONSTRAINTS LCURLY state_cons_list RCURLY SEMI
| STATE_ACTION_CONSTRAINTS LCURLY RCURLY SEMI'''
if len(p) == 6:
p[0] = ('constraints', p[3])
el... | python | def p_state_action_constraint_section(self, p):
'''state_action_constraint_section : STATE_ACTION_CONSTRAINTS LCURLY state_cons_list RCURLY SEMI
| STATE_ACTION_CONSTRAINTS LCURLY RCURLY SEMI'''
if len(p) == 6:
p[0] = ('constraints', p[3])
el... | [
"def",
"p_state_action_constraint_section",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"6",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'constraints'",
",",
"p",
"[",
"3",
"]",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"5",
":",
... | state_action_constraint_section : STATE_ACTION_CONSTRAINTS LCURLY state_cons_list RCURLY SEMI
| STATE_ACTION_CONSTRAINTS LCURLY RCURLY SEMI | [
"state_action_constraint_section",
":",
"STATE_ACTION_CONSTRAINTS",
"LCURLY",
"state_cons_list",
"RCURLY",
"SEMI",
"|",
"STATE_ACTION_CONSTRAINTS",
"LCURLY",
"RCURLY",
"SEMI"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L441-L448 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_state_cons_list | def p_state_cons_list(self, p):
'''state_cons_list : state_cons_list state_cons_def
| state_cons_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_state_cons_list(self, p):
'''state_cons_list : state_cons_list state_cons_def
| state_cons_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_state_cons_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"3",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"elif",
"len",
"(",
"... | state_cons_list : state_cons_list state_cons_def
| state_cons_def | [
"state_cons_list",
":",
"state_cons_list",
"state_cons_def",
"|",
"state_cons_def"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L450-L457 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_state_invariant_section | def p_state_invariant_section(self, p):
'''state_invariant_section : STATE_INVARIANTS LCURLY state_invariant_list RCURLY SEMI
| STATE_INVARIANTS LCURLY RCURLY SEMI'''
if len(p) == 6:
p[0] = ('invariants', p[3])
elif len(p) == 5:
p[0] = (... | python | def p_state_invariant_section(self, p):
'''state_invariant_section : STATE_INVARIANTS LCURLY state_invariant_list RCURLY SEMI
| STATE_INVARIANTS LCURLY RCURLY SEMI'''
if len(p) == 6:
p[0] = ('invariants', p[3])
elif len(p) == 5:
p[0] = (... | [
"def",
"p_state_invariant_section",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"6",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'invariants'",
",",
"p",
"[",
"3",
"]",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"5",
":",
"p",
... | state_invariant_section : STATE_INVARIANTS LCURLY state_invariant_list RCURLY SEMI
| STATE_INVARIANTS LCURLY RCURLY SEMI | [
"state_invariant_section",
":",
"STATE_INVARIANTS",
"LCURLY",
"state_invariant_list",
"RCURLY",
"SEMI",
"|",
"STATE_INVARIANTS",
"LCURLY",
"RCURLY",
"SEMI"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L463-L470 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_state_invariant_list | def p_state_invariant_list(self, p):
'''state_invariant_list : state_invariant_list state_invariant_def
| state_invariant_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_state_invariant_list(self, p):
'''state_invariant_list : state_invariant_list state_invariant_def
| state_invariant_def'''
if len(p) == 3:
p[1].append(p[2])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_state_invariant_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"3",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"elif",
"len",
"("... | state_invariant_list : state_invariant_list state_invariant_def
| state_invariant_def | [
"state_invariant_list",
":",
"state_invariant_list",
"state_invariant_def",
"|",
"state_invariant_def"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L472-L479 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_term_list | def p_term_list(self, p):
'''term_list : term_list COMMA term
| term
| empty'''
if p[1] is None:
p[0] = []
elif len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_term_list(self, p):
'''term_list : term_list COMMA term
| term
| empty'''
if p[1] is None:
p[0] = []
elif len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_term_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"p",
"[",
"1",
"]",
"is",
"None",
":",
"p",
"[",
"0",
"]",
"=",
"[",
"]",
"elif",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"3",
... | term_list : term_list COMMA term
| term
| empty | [
"term_list",
":",
"term_list",
"COMMA",
"term",
"|",
"term",
"|",
"empty"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L485-L495 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_pvar_expr | def p_pvar_expr(self, p):
'''pvar_expr : IDENT LPAREN term_list RPAREN
| IDENT'''
if len(p) == 2:
p[0] = ('pvar_expr', (p[1], None))
elif len(p) == 5:
p[0] = ('pvar_expr', (p[1], p[3])) | python | def p_pvar_expr(self, p):
'''pvar_expr : IDENT LPAREN term_list RPAREN
| IDENT'''
if len(p) == 2:
p[0] = ('pvar_expr', (p[1], None))
elif len(p) == 5:
p[0] = ('pvar_expr', (p[1], p[3])) | [
"def",
"p_pvar_expr",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'pvar_expr'",
",",
"(",
"p",
"[",
"1",
"]",
",",
"None",
")",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"5",
... | pvar_expr : IDENT LPAREN term_list RPAREN
| IDENT | [
"pvar_expr",
":",
"IDENT",
"LPAREN",
"term_list",
"RPAREN",
"|",
"IDENT"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L516-L522 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_boolean_expr | def p_boolean_expr(self, p):
'''boolean_expr : expr AND expr
| expr AMPERSAND expr
| expr OR expr
| expr IMPLY expr
| expr EQUIV expr
| NOT expr %prec UMINUS
| bool_typ... | python | def p_boolean_expr(self, p):
'''boolean_expr : expr AND expr
| expr AMPERSAND expr
| expr OR expr
| expr IMPLY expr
| expr EQUIV expr
| NOT expr %prec UMINUS
| bool_typ... | [
"def",
"p_boolean_expr",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"p",
"[",
"2",
"]",
",",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
")",
"elif",
"len",
"(... | boolean_expr : expr AND expr
| expr AMPERSAND expr
| expr OR expr
| expr IMPLY expr
| expr EQUIV expr
| NOT expr %prec UMINUS
| bool_type | [
"boolean_expr",
":",
"expr",
"AND",
"expr",
"|",
"expr",
"AMPERSAND",
"expr",
"|",
"expr",
"OR",
"expr",
"|",
"expr",
"IMPLY",
"expr",
"|",
"expr",
"EQUIV",
"expr",
"|",
"NOT",
"expr",
"%prec",
"UMINUS",
"|",
"bool_type"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L542-L555 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_numerical_expr | def p_numerical_expr(self, p):
'''numerical_expr : expr PLUS expr
| expr MINUS expr
| expr TIMES expr
| expr DIV expr
| MINUS expr %prec UMINUS
| PLUS expr %prec UMINUS
... | python | def p_numerical_expr(self, p):
'''numerical_expr : expr PLUS expr
| expr MINUS expr
| expr TIMES expr
| expr DIV expr
| MINUS expr %prec UMINUS
| PLUS expr %prec UMINUS
... | [
"def",
"p_numerical_expr",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"p",
"[",
"2",
"]",
",",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
")",
"elif",
"len",
... | numerical_expr : expr PLUS expr
| expr MINUS expr
| expr TIMES expr
| expr DIV expr
| MINUS expr %prec UMINUS
| PLUS expr %prec UMINUS
| INTEGER
... | [
"numerical_expr",
":",
"expr",
"PLUS",
"expr",
"|",
"expr",
"MINUS",
"expr",
"|",
"expr",
"TIMES",
"expr",
"|",
"expr",
"DIV",
"expr",
"|",
"MINUS",
"expr",
"%prec",
"UMINUS",
"|",
"PLUS",
"expr",
"%prec",
"UMINUS",
"|",
"INTEGER",
"|",
"DOUBLE"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L562-L576 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_control_expr | def p_control_expr(self, p):
'''control_expr : IF LPAREN expr RPAREN THEN expr ELSE expr %prec IF
| SWITCH LPAREN term RPAREN LCURLY case_list RCURLY'''
if len(p) == 9:
p[0] = (p[1], (p[3], p[6], p[8]))
elif len(p) == 8:
p[0] = (p[1], (p[3], *p[6])... | python | def p_control_expr(self, p):
'''control_expr : IF LPAREN expr RPAREN THEN expr ELSE expr %prec IF
| SWITCH LPAREN term RPAREN LCURLY case_list RCURLY'''
if len(p) == 9:
p[0] = (p[1], (p[3], p[6], p[8]))
elif len(p) == 8:
p[0] = (p[1], (p[3], *p[6])... | [
"def",
"p_control_expr",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"9",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"p",
"[",
"1",
"]",
",",
"(",
"p",
"[",
"3",
"]",
",",
"p",
"[",
"6",
"]",
",",
"p",
"[",
"8",
"]",
... | control_expr : IF LPAREN expr RPAREN THEN expr ELSE expr %prec IF
| SWITCH LPAREN term RPAREN LCURLY case_list RCURLY | [
"control_expr",
":",
"IF",
"LPAREN",
"expr",
"RPAREN",
"THEN",
"expr",
"ELSE",
"expr",
"%prec",
"IF",
"|",
"SWITCH",
"LPAREN",
"term",
"RPAREN",
"LCURLY",
"case_list",
"RCURLY"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L582-L588 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_randomvar_expr | def p_randomvar_expr(self, p):
'''randomvar_expr : BERNOULLI LPAREN expr RPAREN
| DIRAC_DELTA LPAREN expr RPAREN
| KRON_DELTA LPAREN expr RPAREN
| UNIFORM LPAREN expr COMMA expr RPAREN
| NORMAL LPAREN expr CO... | python | def p_randomvar_expr(self, p):
'''randomvar_expr : BERNOULLI LPAREN expr RPAREN
| DIRAC_DELTA LPAREN expr RPAREN
| KRON_DELTA LPAREN expr RPAREN
| UNIFORM LPAREN expr COMMA expr RPAREN
| NORMAL LPAREN expr CO... | [
"def",
"p_randomvar_expr",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"7",
":",
"if",
"isinstance",
"(",
"p",
"[",
"5",
"]",
",",
"list",
")",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'randomvar'",
",",
"(",
"p",
"[",
"1"... | randomvar_expr : BERNOULLI LPAREN expr RPAREN
| DIRAC_DELTA LPAREN expr RPAREN
| KRON_DELTA LPAREN expr RPAREN
| UNIFORM LPAREN expr COMMA expr RPAREN
| NORMAL LPAREN expr COMMA expr RPAREN
... | [
"randomvar_expr",
":",
"BERNOULLI",
"LPAREN",
"expr",
"RPAREN",
"|",
"DIRAC_DELTA",
"LPAREN",
"expr",
"RPAREN",
"|",
"KRON_DELTA",
"LPAREN",
"expr",
"RPAREN",
"|",
"UNIFORM",
"LPAREN",
"expr",
"COMMA",
"expr",
"RPAREN",
"|",
"NORMAL",
"LPAREN",
"expr",
"COMMA",
... | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L590-L608 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_typed_var_list | def p_typed_var_list(self, p):
'''typed_var_list : typed_var_list COMMA typed_var
| typed_var'''
if len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_typed_var_list(self, p):
'''typed_var_list : typed_var_list COMMA typed_var
| typed_var'''
if len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_typed_var_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"elif",
"len",
"(",
"p... | typed_var_list : typed_var_list COMMA typed_var
| typed_var | [
"typed_var_list",
":",
"typed_var_list",
"COMMA",
"typed_var",
"|",
"typed_var"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L610-L617 |
thiagopbueno/pyrddl | pyrddl/parser.py | RDDLParser.p_expr_list | def p_expr_list(self, p):
'''expr_list : expr_list COMMA expr
| expr'''
if len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | python | def p_expr_list(self, p):
'''expr_list : expr_list COMMA expr
| expr'''
if len(p) == 4:
p[1].append(p[3])
p[0] = p[1]
elif len(p) == 2:
p[0] = [p[1]] | [
"def",
"p_expr_list",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"1",
"]",
".",
"append",
"(",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"elif",
"len",
"(",
"p",
... | expr_list : expr_list COMMA expr
| expr | [
"expr_list",
":",
"expr_list",
"COMMA",
"expr",
"|",
"expr"
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L623-L630 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.