repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
honzamach/pydgets | pydgets/widgets.py | ProgressBarWidget.list_settings | def list_settings(self):
"""
Get list of all appropriate settings and their default values.
"""
result = super().list_settings()
result.append((self.SETTING_BAR_FORMATING, {}))
result.append((self.SETTING_BAR_CHAR, '='))
result.append((self.SETTING_BAR_WIDTH, 0))
... | python | def list_settings(self):
"""
Get list of all appropriate settings and their default values.
"""
result = super().list_settings()
result.append((self.SETTING_BAR_FORMATING, {}))
result.append((self.SETTING_BAR_CHAR, '='))
result.append((self.SETTING_BAR_WIDTH, 0))
... | [
"def",
"list_settings",
"(",
"self",
")",
":",
"result",
"=",
"super",
"(",
")",
".",
"list_settings",
"(",
")",
"result",
".",
"append",
"(",
"(",
"self",
".",
"SETTING_BAR_FORMATING",
",",
"{",
"}",
")",
")",
"result",
".",
"append",
"(",
"(",
"sel... | Get list of all appropriate settings and their default values. | [
"Get",
"list",
"of",
"all",
"appropriate",
"settings",
"and",
"their",
"default",
"values",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1282-L1290 |
honzamach/pydgets | pydgets/widgets.py | ProgressBarWidget._render_content | def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
bar_len = int(settings[self.SETTING_BAR_WIDTH])
if not bar_len:
bar_len = TERMINAL_WIDTH - 10
percent = content
progress = ""
progress ... | python | def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
bar_len = int(settings[self.SETTING_BAR_WIDTH])
if not bar_len:
bar_len = TERMINAL_WIDTH - 10
percent = content
progress = ""
progress ... | [
"def",
"_render_content",
"(",
"self",
",",
"content",
",",
"*",
"*",
"settings",
")",
":",
"bar_len",
"=",
"int",
"(",
"settings",
"[",
"self",
".",
"SETTING_BAR_WIDTH",
"]",
")",
"if",
"not",
"bar_len",
":",
"bar_len",
"=",
"TERMINAL_WIDTH",
"-",
"10",... | Perform widget rendering, but do not print anything. | [
"Perform",
"widget",
"rendering",
"but",
"do",
"not",
"print",
"anything",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1294-L1308 |
honzamach/pydgets | pydgets/widgets.py | ProgressBarWidget.display | def display(self, content = None, **settings):
"""
Perform widget rendering and output the result.
"""
sys.stdout.write("\r")
sys.stdout.write(self.render(content, **settings))
sys.stdout.flush() | python | def display(self, content = None, **settings):
"""
Perform widget rendering and output the result.
"""
sys.stdout.write("\r")
sys.stdout.write(self.render(content, **settings))
sys.stdout.flush() | [
"def",
"display",
"(",
"self",
",",
"content",
"=",
"None",
",",
"*",
"*",
"settings",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"\\r\"",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"self",
".",
"render",
"(",
"content",
",",
"*",
"*... | Perform widget rendering and output the result. | [
"Perform",
"widget",
"rendering",
"and",
"output",
"the",
"result",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1310-L1316 |
honzamach/pydgets | pydgets/widgets.py | BarChartWidget.chart_measure | def chart_measure(self, bars):
"""
Measure the width of each table column.
"""
width = 0
for bar in bars:
# Calculate maximum from:
width = max(
width, # current label max width
len(bar.get('label', ''))... | python | def chart_measure(self, bars):
"""
Measure the width of each table column.
"""
width = 0
for bar in bars:
# Calculate maximum from:
width = max(
width, # current label max width
len(bar.get('label', ''))... | [
"def",
"chart_measure",
"(",
"self",
",",
"bars",
")",
":",
"width",
"=",
"0",
"for",
"bar",
"in",
"bars",
":",
"# Calculate maximum from:",
"width",
"=",
"max",
"(",
"width",
",",
"# current label max width",
"len",
"(",
"bar",
".",
"get",
"(",
"'label'",... | Measure the width of each table column. | [
"Measure",
"the",
"width",
"of",
"each",
"table",
"column",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1343-L1355 |
honzamach/pydgets | pydgets/widgets.py | BarChartWidget._render_bar | def _render_bar(self, bar, value, max_value, label_width, bar_width, **settings):
"""
Render single chart bar.
"""
percent = value / max_value
barstr = ""
barstr += str(settings[self.SETTING_BAR_CHAR]) * int(bar_width * percent)
s = {k: settings[k] for k in (self.... | python | def _render_bar(self, bar, value, max_value, label_width, bar_width, **settings):
"""
Render single chart bar.
"""
percent = value / max_value
barstr = ""
barstr += str(settings[self.SETTING_BAR_CHAR]) * int(bar_width * percent)
s = {k: settings[k] for k in (self.... | [
"def",
"_render_bar",
"(",
"self",
",",
"bar",
",",
"value",
",",
"max_value",
",",
"label_width",
",",
"bar_width",
",",
"*",
"*",
"settings",
")",
":",
"percent",
"=",
"value",
"/",
"max_value",
"barstr",
"=",
"\"\"",
"barstr",
"+=",
"str",
"(",
"set... | Render single chart bar. | [
"Render",
"single",
"chart",
"bar",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1359-L1371 |
honzamach/pydgets | pydgets/widgets.py | BarChartWidget._render_content | def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
result = []
bars = settings[self.SETTING_BARS]
label_width = self.chart_measure(bars)
if not settings[self.SETTING_BAR_WIDTH]:
settings[self.S... | python | def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
result = []
bars = settings[self.SETTING_BARS]
label_width = self.chart_measure(bars)
if not settings[self.SETTING_BAR_WIDTH]:
settings[self.S... | [
"def",
"_render_content",
"(",
"self",
",",
"content",
",",
"*",
"*",
"settings",
")",
":",
"result",
"=",
"[",
"]",
"bars",
"=",
"settings",
"[",
"self",
".",
"SETTING_BARS",
"]",
"label_width",
"=",
"self",
".",
"chart_measure",
"(",
"bars",
")",
"if... | Perform widget rendering, but do not print anything. | [
"Perform",
"widget",
"rendering",
"but",
"do",
"not",
"print",
"anything",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1373-L1388 |
firstprayer/monsql | monsql/sql.py | build_select | def build_select(query_obj):
"""
Given a Query obj, return the corresponding sql
"""
return build_select_query(query_obj.source, query_obj.fields, query_obj.filter, skip=query_obj.skip, \
limit=query_obj.limit, sort=query_obj.sort, distinct=query_obj.distinct) | python | def build_select(query_obj):
"""
Given a Query obj, return the corresponding sql
"""
return build_select_query(query_obj.source, query_obj.fields, query_obj.filter, skip=query_obj.skip, \
limit=query_obj.limit, sort=query_obj.sort, distinct=query_obj.distinct) | [
"def",
"build_select",
"(",
"query_obj",
")",
":",
"return",
"build_select_query",
"(",
"query_obj",
".",
"source",
",",
"query_obj",
".",
"fields",
",",
"query_obj",
".",
"filter",
",",
"skip",
"=",
"query_obj",
".",
"skip",
",",
"limit",
"=",
"query_obj",
... | Given a Query obj, return the corresponding sql | [
"Given",
"a",
"Query",
"obj",
"return",
"the",
"corresponding",
"sql"
] | train | https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/sql.py#L62-L67 |
firstprayer/monsql | monsql/sql.py | build_insert | def build_insert(table_name, attributes):
"""
Given the table_name and the data, return the sql to insert the data
"""
sql = "INSERT INTO %s" %(table_name)
column_str = u""
value_str = u""
for index, (key, value) in enumerate(attributes.items()):
if index > 0:
column_str ... | python | def build_insert(table_name, attributes):
"""
Given the table_name and the data, return the sql to insert the data
"""
sql = "INSERT INTO %s" %(table_name)
column_str = u""
value_str = u""
for index, (key, value) in enumerate(attributes.items()):
if index > 0:
column_str ... | [
"def",
"build_insert",
"(",
"table_name",
",",
"attributes",
")",
":",
"sql",
"=",
"\"INSERT INTO %s\"",
"%",
"(",
"table_name",
")",
"column_str",
"=",
"u\"\"",
"value_str",
"=",
"u\"\"",
"for",
"index",
",",
"(",
"key",
",",
"value",
")",
"in",
"enumerat... | Given the table_name and the data, return the sql to insert the data | [
"Given",
"the",
"table_name",
"and",
"the",
"data",
"return",
"the",
"sql",
"to",
"insert",
"the",
"data"
] | train | https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/sql.py#L70-L84 |
mayfield/cellulario | cellulario/tier.py | Tier.make_gatherer | def make_gatherer(cls, cell, source_tiers, gatherby):
""" Produce a single source tier that gathers from a set of tiers when
the key function returns a unique result for each tier. """
pending = collections.defaultdict(dict)
tier_hashes = [hash(x) for x in source_tiers]
@asyncio... | python | def make_gatherer(cls, cell, source_tiers, gatherby):
""" Produce a single source tier that gathers from a set of tiers when
the key function returns a unique result for each tier. """
pending = collections.defaultdict(dict)
tier_hashes = [hash(x) for x in source_tiers]
@asyncio... | [
"def",
"make_gatherer",
"(",
"cls",
",",
"cell",
",",
"source_tiers",
",",
"gatherby",
")",
":",
"pending",
"=",
"collections",
".",
"defaultdict",
"(",
"dict",
")",
"tier_hashes",
"=",
"[",
"hash",
"(",
"x",
")",
"for",
"x",
"in",
"source_tiers",
"]",
... | Produce a single source tier that gathers from a set of tiers when
the key function returns a unique result for each tier. | [
"Produce",
"a",
"single",
"source",
"tier",
"that",
"gathers",
"from",
"a",
"set",
"of",
"tiers",
"when",
"the",
"key",
"function",
"returns",
"a",
"unique",
"result",
"for",
"each",
"tier",
"."
] | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L77-L93 |
mayfield/cellulario | cellulario/tier.py | Tier.enqueue_task | def enqueue_task(self, source, *args):
""" Enqueue a task execution. It will run in the background as soon
as the coordinator clears it to do so. """
yield from self.cell.coord.enqueue(self)
route = Route(source, self.cell, self.spec, self.emit)
self.cell.loop.create_task(self.c... | python | def enqueue_task(self, source, *args):
""" Enqueue a task execution. It will run in the background as soon
as the coordinator clears it to do so. """
yield from self.cell.coord.enqueue(self)
route = Route(source, self.cell, self.spec, self.emit)
self.cell.loop.create_task(self.c... | [
"def",
"enqueue_task",
"(",
"self",
",",
"source",
",",
"*",
"args",
")",
":",
"yield",
"from",
"self",
".",
"cell",
".",
"coord",
".",
"enqueue",
"(",
"self",
")",
"route",
"=",
"Route",
"(",
"source",
",",
"self",
".",
"cell",
",",
"self",
".",
... | Enqueue a task execution. It will run in the background as soon
as the coordinator clears it to do so. | [
"Enqueue",
"a",
"task",
"execution",
".",
"It",
"will",
"run",
"in",
"the",
"background",
"as",
"soon",
"as",
"the",
"coordinator",
"clears",
"it",
"to",
"do",
"so",
"."
] | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L132-L141 |
mayfield/cellulario | cellulario/tier.py | Tier.coord_wrap | def coord_wrap(self, *args):
""" Wrap the coroutine with coordination throttles. """
yield from self.cell.coord.start(self)
yield from self.coro(*args)
yield from self.cell.coord.finish(self) | python | def coord_wrap(self, *args):
""" Wrap the coroutine with coordination throttles. """
yield from self.cell.coord.start(self)
yield from self.coro(*args)
yield from self.cell.coord.finish(self) | [
"def",
"coord_wrap",
"(",
"self",
",",
"*",
"args",
")",
":",
"yield",
"from",
"self",
".",
"cell",
".",
"coord",
".",
"start",
"(",
"self",
")",
"yield",
"from",
"self",
".",
"coro",
"(",
"*",
"args",
")",
"yield",
"from",
"self",
".",
"cell",
"... | Wrap the coroutine with coordination throttles. | [
"Wrap",
"the",
"coroutine",
"with",
"coordination",
"throttles",
"."
] | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L144-L148 |
mayfield/cellulario | cellulario/tier.py | Tier.emit | def emit(self, *args):
""" Send data to the next tier(s). This call can be delayed if the
coordinator thinks the backlog is too high for any of the emit
destinations. Likewise when buffering emit values prior to enqueuing
them we ask the coordinator if we should flush the buffer each t... | python | def emit(self, *args):
""" Send data to the next tier(s). This call can be delayed if the
coordinator thinks the backlog is too high for any of the emit
destinations. Likewise when buffering emit values prior to enqueuing
them we ask the coordinator if we should flush the buffer each t... | [
"def",
"emit",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"buffer",
"is",
"not",
"None",
":",
"self",
".",
"buffer",
".",
"extend",
"(",
"args",
")",
"if",
"self",
".",
"buffer_max_size",
"is",
"not",
"None",
":",
"flush",
"=",
"... | Send data to the next tier(s). This call can be delayed if the
coordinator thinks the backlog is too high for any of the emit
destinations. Likewise when buffering emit values prior to enqueuing
them we ask the coordinator if we should flush the buffer each time in
case the coordinator... | [
"Send",
"data",
"to",
"the",
"next",
"tier",
"(",
"s",
")",
".",
"This",
"call",
"can",
"be",
"delayed",
"if",
"the",
"coordinator",
"thinks",
"the",
"backlog",
"is",
"too",
"high",
"for",
"any",
"of",
"the",
"emit",
"destinations",
".",
"Likewise",
"w... | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L151-L168 |
mayfield/cellulario | cellulario/tier.py | Tier.flush | def flush(self):
""" Flush the buffer of buffered tiers to our destination tiers. """
if self.buffer is None:
return
data = self.buffer
self.buffer = []
for x in self.dests:
yield from x.enqueue_task(self, *data) | python | def flush(self):
""" Flush the buffer of buffered tiers to our destination tiers. """
if self.buffer is None:
return
data = self.buffer
self.buffer = []
for x in self.dests:
yield from x.enqueue_task(self, *data) | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"buffer",
"is",
"None",
":",
"return",
"data",
"=",
"self",
".",
"buffer",
"self",
".",
"buffer",
"=",
"[",
"]",
"for",
"x",
"in",
"self",
".",
"dests",
":",
"yield",
"from",
"x",
".",
"... | Flush the buffer of buffered tiers to our destination tiers. | [
"Flush",
"the",
"buffer",
"of",
"buffered",
"tiers",
"to",
"our",
"destination",
"tiers",
"."
] | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L171-L178 |
mayfield/cellulario | cellulario/tier.py | Tier.add_source | def add_source(self, tier):
""" Schedule this tier to be called when another tier emits. """
tier.add_dest(self)
self.sources.append(tier) | python | def add_source(self, tier):
""" Schedule this tier to be called when another tier emits. """
tier.add_dest(self)
self.sources.append(tier) | [
"def",
"add_source",
"(",
"self",
",",
"tier",
")",
":",
"tier",
".",
"add_dest",
"(",
"self",
")",
"self",
".",
"sources",
".",
"append",
"(",
"tier",
")"
] | Schedule this tier to be called when another tier emits. | [
"Schedule",
"this",
"tier",
"to",
"be",
"called",
"when",
"another",
"tier",
"emits",
"."
] | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L180-L183 |
mayfield/cellulario | cellulario/tier.py | Tier.close | def close(self):
""" Free any potential cycles. """
self.cell = None
self.coro = None
self.buffer = None
del self.dests[:]
del self.sources[:] | python | def close(self):
""" Free any potential cycles. """
self.cell = None
self.coro = None
self.buffer = None
del self.dests[:]
del self.sources[:] | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"cell",
"=",
"None",
"self",
".",
"coro",
"=",
"None",
"self",
".",
"buffer",
"=",
"None",
"del",
"self",
".",
"dests",
"[",
":",
"]",
"del",
"self",
".",
"sources",
"[",
":",
"]"
] | Free any potential cycles. | [
"Free",
"any",
"potential",
"cycles",
"."
] | train | https://github.com/mayfield/cellulario/blob/e9dc10532a0357bc90ebaa2655b36822f9249673/cellulario/tier.py#L189-L195 |
diffeo/yakonfig | yakonfig/toplevel.py | add_arguments | def add_arguments(parser):
'''Add command-line arguments for yakonfig proper.
This is part of the :class:`~yakonfig.Configurable` interface, and
is usually run by including :mod:`yakonfig` in the
:func:`parse_args()` module list.
:param argparse.ArgumentParser parser: command-line argument
p... | python | def add_arguments(parser):
'''Add command-line arguments for yakonfig proper.
This is part of the :class:`~yakonfig.Configurable` interface, and
is usually run by including :mod:`yakonfig` in the
:func:`parse_args()` module list.
:param argparse.ArgumentParser parser: command-line argument
p... | [
"def",
"add_arguments",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--config'",
",",
"'-c'",
",",
"metavar",
"=",
"'FILE'",
",",
"help",
"=",
"'read configuration from FILE'",
")",
"parser",
".",
"add_argument",
"(",
"'--dump-config'",
",",
... | Add command-line arguments for yakonfig proper.
This is part of the :class:`~yakonfig.Configurable` interface, and
is usually run by including :mod:`yakonfig` in the
:func:`parse_args()` module list.
:param argparse.ArgumentParser parser: command-line argument
parser | [
"Add",
"command",
"-",
"line",
"arguments",
"for",
"yakonfig",
"proper",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L50-L65 |
diffeo/yakonfig | yakonfig/toplevel.py | parse_args | def parse_args(parser, modules, args=None):
"""Set up global configuration for command-line tools.
`modules` is an iterable of
:class:`yakonfig.Configurable` objects, or anything
equivalently typed. This function iterates through those objects
and calls
:meth:`~yakonfig.Configurable.add_argume... | python | def parse_args(parser, modules, args=None):
"""Set up global configuration for command-line tools.
`modules` is an iterable of
:class:`yakonfig.Configurable` objects, or anything
equivalently typed. This function iterates through those objects
and calls
:meth:`~yakonfig.Configurable.add_argume... | [
"def",
"parse_args",
"(",
"parser",
",",
"modules",
",",
"args",
"=",
"None",
")",
":",
"collect_add_argparse",
"(",
"parser",
",",
"modules",
")",
"namespace",
"=",
"parser",
".",
"parse_args",
"(",
"args",
")",
"try",
":",
"do_dump_config",
"=",
"getattr... | Set up global configuration for command-line tools.
`modules` is an iterable of
:class:`yakonfig.Configurable` objects, or anything
equivalently typed. This function iterates through those objects
and calls
:meth:`~yakonfig.Configurable.add_arguments` on
each to build up a complete list of com... | [
"Set",
"up",
"global",
"configuration",
"for",
"command",
"-",
"line",
"tools",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L69-L115 |
diffeo/yakonfig | yakonfig/toplevel.py | set_default_config | def set_default_config(modules, params=None, yaml=None, filename=None,
config=None, validate=True):
"""Set up global configuration for tests and noninteractive tools.
`modules` is an iterable of
:class:`yakonfig.Configurable` objects, or anything
equivalently typed. This functio... | python | def set_default_config(modules, params=None, yaml=None, filename=None,
config=None, validate=True):
"""Set up global configuration for tests and noninteractive tools.
`modules` is an iterable of
:class:`yakonfig.Configurable` objects, or anything
equivalently typed. This functio... | [
"def",
"set_default_config",
"(",
"modules",
",",
"params",
"=",
"None",
",",
"yaml",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
",",
"validate",
"=",
"True",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{"... | Set up global configuration for tests and noninteractive tools.
`modules` is an iterable of
:class:`yakonfig.Configurable` objects, or anything
equivalently typed. This function iterates through those objects
to produce a default configuration, reads `yaml` as though it were
the configuration file... | [
"Set",
"up",
"global",
"configuration",
"for",
"tests",
"and",
"noninteractive",
"tools",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L118-L197 |
diffeo/yakonfig | yakonfig/toplevel.py | defaulted_config | def defaulted_config(modules, params=None, yaml=None, filename=None,
config=None, validate=True):
"""Context manager version of :func:`set_default_config()`.
Use this with a Python 'with' statement, like
>>> config_yaml = '''
... toplevel:
... param: value
... '''
>>... | python | def defaulted_config(modules, params=None, yaml=None, filename=None,
config=None, validate=True):
"""Context manager version of :func:`set_default_config()`.
Use this with a Python 'with' statement, like
>>> config_yaml = '''
... toplevel:
... param: value
... '''
>>... | [
"def",
"defaulted_config",
"(",
"modules",
",",
"params",
"=",
"None",
",",
"yaml",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
",",
"validate",
"=",
"True",
")",
":",
"with",
"_temporary_config",
"(",
")",
":",
"set_default_co... | Context manager version of :func:`set_default_config()`.
Use this with a Python 'with' statement, like
>>> config_yaml = '''
... toplevel:
... param: value
... '''
>>> with yakonfig.defaulted_config([toplevel], yaml=config_yaml) as config:
... assert 'param' in config['toplevel']
... | [
"Context",
"manager",
"version",
"of",
":",
"func",
":",
"set_default_config",
"()",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L201-L231 |
diffeo/yakonfig | yakonfig/toplevel.py | check_toplevel_config | def check_toplevel_config(what, who):
"""Verify that some dependent configuration is present and correct.
This will generally be called from a
:meth:`~yakonfig.Configurable.check_config` implementation.
`what` is a :class:`~yakonfig.Configurable`-like object. If the
corresponding configuration isn... | python | def check_toplevel_config(what, who):
"""Verify that some dependent configuration is present and correct.
This will generally be called from a
:meth:`~yakonfig.Configurable.check_config` implementation.
`what` is a :class:`~yakonfig.Configurable`-like object. If the
corresponding configuration isn... | [
"def",
"check_toplevel_config",
"(",
"what",
",",
"who",
")",
":",
"config_name",
"=",
"what",
".",
"config_name",
"config",
"=",
"get_global_config",
"(",
")",
"if",
"config_name",
"not",
"in",
"config",
":",
"raise",
"ConfigurationError",
"(",
"'{0} requires t... | Verify that some dependent configuration is present and correct.
This will generally be called from a
:meth:`~yakonfig.Configurable.check_config` implementation.
`what` is a :class:`~yakonfig.Configurable`-like object. If the
corresponding configuration isn't present in the global
configuration, r... | [
"Verify",
"that",
"some",
"dependent",
"configuration",
"is",
"present",
"and",
"correct",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L234-L259 |
diffeo/yakonfig | yakonfig/toplevel.py | _recurse_config | def _recurse_config(parent_config, modules, f, prefix=''):
'''Walk through the module tree.
This is a helper function for :func:`create_config_tree` and
:func:`_walk_config`. It calls `f` once for each module in the
configuration tree with parameters `parent_config`, `config_name`,
`prefix`, and `... | python | def _recurse_config(parent_config, modules, f, prefix=''):
'''Walk through the module tree.
This is a helper function for :func:`create_config_tree` and
:func:`_walk_config`. It calls `f` once for each module in the
configuration tree with parameters `parent_config`, `config_name`,
`prefix`, and `... | [
"def",
"_recurse_config",
"(",
"parent_config",
",",
"modules",
",",
"f",
",",
"prefix",
"=",
"''",
")",
":",
"for",
"module",
"in",
"modules",
":",
"config_name",
"=",
"getattr",
"(",
"module",
",",
"'config_name'",
",",
"None",
")",
"if",
"config_name",
... | Walk through the module tree.
This is a helper function for :func:`create_config_tree` and
:func:`_walk_config`. It calls `f` once for each module in the
configuration tree with parameters `parent_config`, `config_name`,
`prefix`, and `module`. `parent_config[config_name]` may or may
not exist (b... | [
"Walk",
"through",
"the",
"module",
"tree",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L262-L300 |
diffeo/yakonfig | yakonfig/toplevel.py | create_config_tree | def create_config_tree(config, modules, prefix=''):
'''Cause every possible configuration sub-dictionary to exist.
This is intended to be called very early in the configuration
sequence. For each module, it checks that the corresponding
configuration item exists in `config` and creates it as an empty
... | python | def create_config_tree(config, modules, prefix=''):
'''Cause every possible configuration sub-dictionary to exist.
This is intended to be called very early in the configuration
sequence. For each module, it checks that the corresponding
configuration item exists in `config` and creates it as an empty
... | [
"def",
"create_config_tree",
"(",
"config",
",",
"modules",
",",
"prefix",
"=",
"''",
")",
":",
"def",
"work_in",
"(",
"parent_config",
",",
"config_name",
",",
"prefix",
",",
"module",
")",
":",
"if",
"config_name",
"not",
"in",
"parent_config",
":",
"# t... | Cause every possible configuration sub-dictionary to exist.
This is intended to be called very early in the configuration
sequence. For each module, it checks that the corresponding
configuration item exists in `config` and creates it as an empty
dictionary if required, and then recurses into child
... | [
"Cause",
"every",
"possible",
"configuration",
"sub",
"-",
"dictionary",
"to",
"exist",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L303-L332 |
diffeo/yakonfig | yakonfig/toplevel.py | _walk_config | def _walk_config(config, modules, f, prefix=''):
"""Recursively walk through a module list.
For every module, calls ``f(config, module, name)`` where
`config` is the configuration scoped to that module, `module`
is the Configurable-like object, and `name` is the complete
path (ending in the module ... | python | def _walk_config(config, modules, f, prefix=''):
"""Recursively walk through a module list.
For every module, calls ``f(config, module, name)`` where
`config` is the configuration scoped to that module, `module`
is the Configurable-like object, and `name` is the complete
path (ending in the module ... | [
"def",
"_walk_config",
"(",
"config",
",",
"modules",
",",
"f",
",",
"prefix",
"=",
"''",
")",
":",
"def",
"work_in",
"(",
"parent_config",
",",
"config_name",
",",
"prefix",
",",
"module",
")",
":",
"# create_config_tree() needs to have been called by now",
"# ... | Recursively walk through a module list.
For every module, calls ``f(config, module, name)`` where
`config` is the configuration scoped to that module, `module`
is the Configurable-like object, and `name` is the complete
path (ending in the module name).
:param dict config: configuration to walk an... | [
"Recursively",
"walk",
"through",
"a",
"module",
"list",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L335-L364 |
diffeo/yakonfig | yakonfig/toplevel.py | collect_add_argparse | def collect_add_argparse(parser, modules):
"""Add all command-line options.
`modules` is an iterable of
:class:`yakonfig.configurable.Configurable` objects, or anything
equivalently typed. This calls
:meth:`~yakonfig.configurable.Configurable.add_arguments` (if
present) on all of them to set t... | python | def collect_add_argparse(parser, modules):
"""Add all command-line options.
`modules` is an iterable of
:class:`yakonfig.configurable.Configurable` objects, or anything
equivalently typed. This calls
:meth:`~yakonfig.configurable.Configurable.add_arguments` (if
present) on all of them to set t... | [
"def",
"collect_add_argparse",
"(",
"parser",
",",
"modules",
")",
":",
"def",
"work_in",
"(",
"parent_config",
",",
"config_name",
",",
"prefix",
",",
"module",
")",
":",
"f",
"=",
"getattr",
"(",
"module",
",",
"'add_arguments'",
",",
"None",
")",
"if",
... | Add all command-line options.
`modules` is an iterable of
:class:`yakonfig.configurable.Configurable` objects, or anything
equivalently typed. This calls
:meth:`~yakonfig.configurable.Configurable.add_arguments` (if
present) on all of them to set the global command-line arguments.
:param argp... | [
"Add",
"all",
"command",
"-",
"line",
"options",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L367-L386 |
diffeo/yakonfig | yakonfig/toplevel.py | assemble_default_config | def assemble_default_config(modules):
"""Build the default configuration from a set of modules.
`modules` is an iterable of
:class:`yakonfig.configurable.Configurable` objects, or anything
equivalently typed. This produces the default configuration from
that list of modules.
:param modules: ... | python | def assemble_default_config(modules):
"""Build the default configuration from a set of modules.
`modules` is an iterable of
:class:`yakonfig.configurable.Configurable` objects, or anything
equivalently typed. This produces the default configuration from
that list of modules.
:param modules: ... | [
"def",
"assemble_default_config",
"(",
"modules",
")",
":",
"def",
"work_in",
"(",
"parent_config",
",",
"config_name",
",",
"prefix",
",",
"module",
")",
":",
"my_config",
"=",
"dict",
"(",
"getattr",
"(",
"module",
",",
"'default_config'",
",",
"{",
"}",
... | Build the default configuration from a set of modules.
`modules` is an iterable of
:class:`yakonfig.configurable.Configurable` objects, or anything
equivalently typed. This produces the default configuration from
that list of modules.
:param modules: modules or Configurable instances to use
:... | [
"Build",
"the",
"default",
"configuration",
"from",
"a",
"set",
"of",
"modules",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L389-L411 |
diffeo/yakonfig | yakonfig/toplevel.py | fill_in_arguments | def fill_in_arguments(config, modules, args):
"""Fill in configuration fields from command-line arguments.
`config` is a dictionary holding the initial configuration,
probably the result of :func:`assemble_default_config`. It reads
through `modules`, and for each, fills in any configuration values
... | python | def fill_in_arguments(config, modules, args):
"""Fill in configuration fields from command-line arguments.
`config` is a dictionary holding the initial configuration,
probably the result of :func:`assemble_default_config`. It reads
through `modules`, and for each, fills in any configuration values
... | [
"def",
"fill_in_arguments",
"(",
"config",
",",
"modules",
",",
"args",
")",
":",
"def",
"work_in",
"(",
"config",
",",
"module",
",",
"name",
")",
":",
"rkeys",
"=",
"getattr",
"(",
"module",
",",
"'runtime_keys'",
",",
"{",
"}",
")",
"for",
"(",
"a... | Fill in configuration fields from command-line arguments.
`config` is a dictionary holding the initial configuration,
probably the result of :func:`assemble_default_config`. It reads
through `modules`, and for each, fills in any configuration values
that are provided in `args`.
`config` is modifi... | [
"Fill",
"in",
"configuration",
"fields",
"from",
"command",
"-",
"line",
"arguments",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L414-L441 |
diffeo/yakonfig | yakonfig/toplevel.py | do_config_discovery | def do_config_discovery(config, modules):
'''Let modules detect additional configuration values.
`config` is the initial dictionary with command-line and
file-derived values, but nothing else, filled in. This calls
:meth:`yakonfig.configurable.Configurable.discover_config` on
every configuration m... | python | def do_config_discovery(config, modules):
'''Let modules detect additional configuration values.
`config` is the initial dictionary with command-line and
file-derived values, but nothing else, filled in. This calls
:meth:`yakonfig.configurable.Configurable.discover_config` on
every configuration m... | [
"def",
"do_config_discovery",
"(",
"config",
",",
"modules",
")",
":",
"def",
"work_in",
"(",
"config",
",",
"module",
",",
"name",
")",
":",
"f",
"=",
"getattr",
"(",
"module",
",",
"'discover_config'",
",",
"None",
")",
"if",
"f",
":",
"f",
"(",
"c... | Let modules detect additional configuration values.
`config` is the initial dictionary with command-line and
file-derived values, but nothing else, filled in. This calls
:meth:`yakonfig.configurable.Configurable.discover_config` on
every configuration module. It is expect that this method will
mo... | [
"Let",
"modules",
"detect",
"additional",
"configuration",
"values",
"."
] | train | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/toplevel.py#L444-L463 |
shi-cong/PYSTUDY | PYSTUDY/ml/tensorflowlib.py | NeuralNetworks.example_load_data | def example_load_data(self):
"""
加载数据
"""
# 特征向量
self.x = constant([[0.7, 0.9]])
# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层
self.w1 = Variable(random_normal([2, 3], stddev=1, seed=1))
self.w2 = Variable(random_normal([3, 1], stddev=1, seed=1)) | python | def example_load_data(self):
"""
加载数据
"""
# 特征向量
self.x = constant([[0.7, 0.9]])
# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层
self.w1 = Variable(random_normal([2, 3], stddev=1, seed=1))
self.w2 = Variable(random_normal([3, 1], stddev=1, seed=1)) | [
"def",
"example_load_data",
"(",
"self",
")",
":",
"# 特征向量",
"self",
".",
"x",
"=",
"constant",
"(",
"[",
"[",
"0.7",
",",
"0.9",
"]",
"]",
")",
"# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层",
"self",
".",
"w1",
"=",
"Variable",
"(",
"random_normal",
"(",
"[",
"2",... | 加载数据 | [
"加载数据"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/ml/tensorflowlib.py#L163-L172 |
shi-cong/PYSTUDY | PYSTUDY/ml/tensorflowlib.py | NeuralNetworks.example_compute | def example_compute(self):
"""
简单的神经网络实现前向传播的算法
这里为什么能用矩阵乘法来计算呢?因为,通过求加权和发现
正好是矩阵的乘法运算结果。所以,这里充分的体现了数学的美
"""
a = matmul(self.x, self.w1)
y = matmul(a, self.w2)
sess = Session()
sess.run(self.w1.initializer)
sess.run(self.w2.initializer)
... | python | def example_compute(self):
"""
简单的神经网络实现前向传播的算法
这里为什么能用矩阵乘法来计算呢?因为,通过求加权和发现
正好是矩阵的乘法运算结果。所以,这里充分的体现了数学的美
"""
a = matmul(self.x, self.w1)
y = matmul(a, self.w2)
sess = Session()
sess.run(self.w1.initializer)
sess.run(self.w2.initializer)
... | [
"def",
"example_compute",
"(",
"self",
")",
":",
"a",
"=",
"matmul",
"(",
"self",
".",
"x",
",",
"self",
".",
"w1",
")",
"y",
"=",
"matmul",
"(",
"a",
",",
"self",
".",
"w2",
")",
"sess",
"=",
"Session",
"(",
")",
"sess",
".",
"run",
"(",
"se... | 简单的神经网络实现前向传播的算法
这里为什么能用矩阵乘法来计算呢?因为,通过求加权和发现
正好是矩阵的乘法运算结果。所以,这里充分的体现了数学的美 | [
"简单的神经网络实现前向传播的算法",
"这里为什么能用矩阵乘法来计算呢?因为,通过求加权和发现",
"正好是矩阵的乘法运算结果。所以,这里充分的体现了数学的美"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/ml/tensorflowlib.py#L174-L187 |
shi-cong/PYSTUDY | PYSTUDY/ml/tensorflowlib.py | NeuralNetworks.example_2_load_data | def example_2_load_data(self):
"""
加载数据
"""
# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层
self.w1 = Variable(random_normal([2, 3], stddev=1, seed=1))
self.w2 = Variable(random_normal([3, 1], stddev=1, seed=1))
# 特征向量, 区别是,这里不会在计算图中生成节点
#self.x = placeholder(float32, s... | python | def example_2_load_data(self):
"""
加载数据
"""
# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层
self.w1 = Variable(random_normal([2, 3], stddev=1, seed=1))
self.w2 = Variable(random_normal([3, 1], stddev=1, seed=1))
# 特征向量, 区别是,这里不会在计算图中生成节点
#self.x = placeholder(float32, s... | [
"def",
"example_2_load_data",
"(",
"self",
")",
":",
"# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层",
"self",
".",
"w1",
"=",
"Variable",
"(",
"random_normal",
"(",
"[",
"2",
",",
"3",
"]",
",",
"stddev",
"=",
"1",
",",
"seed",
"=",
"1",
")",
")",
"self",
".",
"w2... | 加载数据 | [
"加载数据"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/ml/tensorflowlib.py#L189-L198 |
shi-cong/PYSTUDY | PYSTUDY/ml/tensorflowlib.py | NeuralNetworks.example_2_compute | def example_2_compute(self):
"""
实现前向传播算法,减少计算图中节点的个数
"""
a = matmul(self.x, self.w1) # 计算神经网络的第一层的输出向量
y = matmul(a, self.w2) # 以第一层的输出作为第二层的输入再次计算第二层的输出
sess = Session()
initOp = global_variables_initializer() # 初始化所有变量
sess.run(initOp)
#print('... | python | def example_2_compute(self):
"""
实现前向传播算法,减少计算图中节点的个数
"""
a = matmul(self.x, self.w1) # 计算神经网络的第一层的输出向量
y = matmul(a, self.w2) # 以第一层的输出作为第二层的输入再次计算第二层的输出
sess = Session()
initOp = global_variables_initializer() # 初始化所有变量
sess.run(initOp)
#print('... | [
"def",
"example_2_compute",
"(",
"self",
")",
":",
"a",
"=",
"matmul",
"(",
"self",
".",
"x",
",",
"self",
".",
"w1",
")",
"# 计算神经网络的第一层的输出向量",
"y",
"=",
"matmul",
"(",
"a",
",",
"self",
".",
"w2",
")",
"# 以第一层的输出作为第二层的输入再次计算第二层的输出",
"sess",
"=",
"Sess... | 实现前向传播算法,减少计算图中节点的个数 | [
"实现前向传播算法,减少计算图中节点的个数"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/ml/tensorflowlib.py#L200-L212 |
kejbaly2/idid | idid/cli.py | main | def main(arguments=None, config=None):
"""
Parse arguments for ``idid`` command.
Pass optional parameter ``arguments`` as either command line
string or list of options. This is mainly useful for testing.
``config`` can be passed in as a path or string to access user defined
values for importan... | python | def main(arguments=None, config=None):
"""
Parse arguments for ``idid`` command.
Pass optional parameter ``arguments`` as either command line
string or list of options. This is mainly useful for testing.
``config`` can be passed in as a path or string to access user defined
values for importan... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"# Parse options, initialize gathered stats",
"options",
"=",
"LoggOptions",
"(",
"arguments",
"=",
"arguments",
")",
".",
"parse",
"(",
")",
"# FIXME: pass in only config; set confi... | Parse arguments for ``idid`` command.
Pass optional parameter ``arguments`` as either command line
string or list of options. This is mainly useful for testing.
``config`` can be passed in as a path or string to access user defined
values for important variables manually. YAML only.
Returns the s... | [
"Parse",
"arguments",
"for",
"idid",
"command",
"."
] | train | https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/cli.py#L241-L263 |
kejbaly2/idid | idid/cli.py | Options.parse | def parse(self, arguments=None):
""" Parse the shared [i]did arguments """
arguments = self.arguments or arguments
# FIXME: prep/normalize arguments in __init__
# Split arguments if given as string and run the parser
if isinstance(arguments, basestring):
arguments = u... | python | def parse(self, arguments=None):
""" Parse the shared [i]did arguments """
arguments = self.arguments or arguments
# FIXME: prep/normalize arguments in __init__
# Split arguments if given as string and run the parser
if isinstance(arguments, basestring):
arguments = u... | [
"def",
"parse",
"(",
"self",
",",
"arguments",
"=",
"None",
")",
":",
"arguments",
"=",
"self",
".",
"arguments",
"or",
"arguments",
"# FIXME: prep/normalize arguments in __init__",
"# Split arguments if given as string and run the parser",
"if",
"isinstance",
"(",
"argum... | Parse the shared [i]did arguments | [
"Parse",
"the",
"shared",
"[",
"i",
"]",
"did",
"arguments"
] | train | https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/cli.py#L79-L113 |
kejbaly2/idid | idid/cli.py | LoggOptions._parse_date | def _parse_date(self, dt, fmt=None):
""" Try to convert a given value to a utils.Date() instance """
try:
# test if it's not a datelike instance ...
_dt = utils.Date(dt, fmt=fmt)
except ValueError:
# nope, not a datelike instance
_dt = None
... | python | def _parse_date(self, dt, fmt=None):
""" Try to convert a given value to a utils.Date() instance """
try:
# test if it's not a datelike instance ...
_dt = utils.Date(dt, fmt=fmt)
except ValueError:
# nope, not a datelike instance
_dt = None
... | [
"def",
"_parse_date",
"(",
"self",
",",
"dt",
",",
"fmt",
"=",
"None",
")",
":",
"try",
":",
"# test if it's not a datelike instance ...",
"_dt",
"=",
"utils",
".",
"Date",
"(",
"dt",
",",
"fmt",
"=",
"fmt",
")",
"except",
"ValueError",
":",
"# nope, not a... | Try to convert a given value to a utils.Date() instance | [
"Try",
"to",
"convert",
"a",
"given",
"value",
"to",
"a",
"utils",
".",
"Date",
"()",
"instance"
] | train | https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/cli.py#L119-L127 |
kejbaly2/idid | idid/cli.py | LoggOptions._parse | def _parse(self, opts, args):
""" Perform additional check for ``idid`` command arguments """
k_args = len(args)
_dt = opts.date = None
logg = opts.logg = None
journal = opts.journal = None
default_journal = self.config.get('default_journal')
_journals = self.con... | python | def _parse(self, opts, args):
""" Perform additional check for ``idid`` command arguments """
k_args = len(args)
_dt = opts.date = None
logg = opts.logg = None
journal = opts.journal = None
default_journal = self.config.get('default_journal')
_journals = self.con... | [
"def",
"_parse",
"(",
"self",
",",
"opts",
",",
"args",
")",
":",
"k_args",
"=",
"len",
"(",
"args",
")",
"_dt",
"=",
"opts",
".",
"date",
"=",
"None",
"logg",
"=",
"opts",
".",
"logg",
"=",
"None",
"journal",
"=",
"opts",
".",
"journal",
"=",
... | Perform additional check for ``idid`` command arguments | [
"Perform",
"additional",
"check",
"for",
"idid",
"command",
"arguments"
] | train | https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/cli.py#L129-L233 |
jonathansick/paperweight | paperweight/texutils.py | find_root_tex_document | def find_root_tex_document(base_dir="."):
"""Find the tex article in the current directory that can be considered
a root. We do this by searching contents for ``'\documentclass'``.
Parameters
----------
base_dir : str
Directory to search for LaTeX documents, relative to the current
... | python | def find_root_tex_document(base_dir="."):
"""Find the tex article in the current directory that can be considered
a root. We do this by searching contents for ``'\documentclass'``.
Parameters
----------
base_dir : str
Directory to search for LaTeX documents, relative to the current
... | [
"def",
"find_root_tex_document",
"(",
"base_dir",
"=",
"\".\"",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"for",
"tex_path",
"in",
"iter_tex_documents",
"(",
"base_dir",
"=",
"base_dir",
")",
":",
"with",
"codecs",
".",
"open",... | Find the tex article in the current directory that can be considered
a root. We do this by searching contents for ``'\documentclass'``.
Parameters
----------
base_dir : str
Directory to search for LaTeX documents, relative to the current
working directory.
Returns
-------
t... | [
"Find",
"the",
"tex",
"article",
"in",
"the",
"current",
"directory",
"that",
"can",
"be",
"considered",
"a",
"root",
".",
"We",
"do",
"this",
"by",
"searching",
"contents",
"for",
"\\",
"documentclass",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/texutils.py#L30-L54 |
jonathansick/paperweight | paperweight/texutils.py | iter_tex_documents | def iter_tex_documents(base_dir="."):
"""Iterate through all .tex documents in the current directory."""
for path, dirlist, filelist in os.walk(base_dir):
for name in fnmatch.filter(filelist, "*.tex"):
yield os.path.join(path, name) | python | def iter_tex_documents(base_dir="."):
"""Iterate through all .tex documents in the current directory."""
for path, dirlist, filelist in os.walk(base_dir):
for name in fnmatch.filter(filelist, "*.tex"):
yield os.path.join(path, name) | [
"def",
"iter_tex_documents",
"(",
"base_dir",
"=",
"\".\"",
")",
":",
"for",
"path",
",",
"dirlist",
",",
"filelist",
"in",
"os",
".",
"walk",
"(",
"base_dir",
")",
":",
"for",
"name",
"in",
"fnmatch",
".",
"filter",
"(",
"filelist",
",",
"\"*.tex\"",
... | Iterate through all .tex documents in the current directory. | [
"Iterate",
"through",
"all",
".",
"tex",
"documents",
"in",
"the",
"current",
"directory",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/texutils.py#L57-L61 |
jonathansick/paperweight | paperweight/texutils.py | inline_bbl | def inline_bbl(root_tex, bbl_tex):
"""Inline a compiled bibliography (.bbl) in place of a bibliography
environment.
Parameters
----------
root_tex : unicode
Text to process.
bbl_tex : unicode
Text of bibliography file.
Returns
-------
txt : unicode
Text with... | python | def inline_bbl(root_tex, bbl_tex):
"""Inline a compiled bibliography (.bbl) in place of a bibliography
environment.
Parameters
----------
root_tex : unicode
Text to process.
bbl_tex : unicode
Text of bibliography file.
Returns
-------
txt : unicode
Text with... | [
"def",
"inline_bbl",
"(",
"root_tex",
",",
"bbl_tex",
")",
":",
"bbl_tex",
"=",
"bbl_tex",
".",
"replace",
"(",
"u'\\\\'",
",",
"u'\\\\\\\\'",
")",
"result",
"=",
"bib_pattern",
".",
"sub",
"(",
"bbl_tex",
",",
"root_tex",
")",
"return",
"result"
] | Inline a compiled bibliography (.bbl) in place of a bibliography
environment.
Parameters
----------
root_tex : unicode
Text to process.
bbl_tex : unicode
Text of bibliography file.
Returns
-------
txt : unicode
Text with bibliography included. | [
"Inline",
"a",
"compiled",
"bibliography",
"(",
".",
"bbl",
")",
"in",
"place",
"of",
"a",
"bibliography",
"environment",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/texutils.py#L68-L86 |
jonathansick/paperweight | paperweight/texutils.py | inline | def inline(root_text,
base_dir="",
replacer=None,
ifexists_replacer=None):
"""Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (... | python | def inline(root_text,
base_dir="",
replacer=None,
ifexists_replacer=None):
"""Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (... | [
"def",
"inline",
"(",
"root_text",
",",
"base_dir",
"=",
"\"\"",
",",
"replacer",
"=",
"None",
",",
"ifexists_replacer",
"=",
"None",
")",
":",
"def",
"_sub_line",
"(",
"match",
")",
":",
"\"\"\"Function to be used with re.sub to inline files for each match.\"\"\"",
... | Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing ``root_text``. Defaults t... | [
"Inline",
"all",
"input",
"latex",
"files",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/texutils.py#L89-L164 |
jonathansick/paperweight | paperweight/texutils.py | inline_blob | def inline_blob(commit_ref, root_text, base_dir='.', repo_dir=""):
"""Inline all input latex files that exist as git blobs in a tree object.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
commit_ref : str
String identifying ... | python | def inline_blob(commit_ref, root_text, base_dir='.', repo_dir=""):
"""Inline all input latex files that exist as git blobs in a tree object.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
commit_ref : str
String identifying ... | [
"def",
"inline_blob",
"(",
"commit_ref",
",",
"root_text",
",",
"base_dir",
"=",
"'.'",
",",
"repo_dir",
"=",
"\"\"",
")",
":",
"def",
"_sub_blob",
"(",
"match",
")",
":",
"\"\"\"Function to be used with re.sub to inline files for each match.\"\"\"",
"fname",
"=",
"... | Inline all input latex files that exist as git blobs in a tree object.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
commit_ref : str
String identifying a git commit/tag.
root_text : unicode
Text of tex document whe... | [
"Inline",
"all",
"input",
"latex",
"files",
"that",
"exist",
"as",
"git",
"blobs",
"in",
"a",
"tree",
"object",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/texutils.py#L167-L246 |
shi-cong/PYSTUDY | PYSTUDY/middleware/redislib.py | RedisPool.set | def set(self, name, value, ex=None, px=None, nx=False, xx=False):
"""设置值,不存在则创建,存在则修改
:param name: key
:param value: value
:param ex: 过期时间(秒)
:param px: 过期时间(毫秒)
:param nx: 如果设置为True,则只有name不存在时,当前的set操作才执行
:param xx: 如果设置为True,则只有nmae存在时,当前的set操作才执行
"""
... | python | def set(self, name, value, ex=None, px=None, nx=False, xx=False):
"""设置值,不存在则创建,存在则修改
:param name: key
:param value: value
:param ex: 过期时间(秒)
:param px: 过期时间(毫秒)
:param nx: 如果设置为True,则只有name不存在时,当前的set操作才执行
:param xx: 如果设置为True,则只有nmae存在时,当前的set操作才执行
"""
... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
",",
"ex",
"=",
"None",
",",
"px",
"=",
"None",
",",
"nx",
"=",
"False",
",",
"xx",
"=",
"False",
")",
":",
"self",
".",
"client",
".",
"set",
"(",
"name",
"=",
"name",
",",
"value",
"=",
... | 设置值,不存在则创建,存在则修改
:param name: key
:param value: value
:param ex: 过期时间(秒)
:param px: 过期时间(毫秒)
:param nx: 如果设置为True,则只有name不存在时,当前的set操作才执行
:param xx: 如果设置为True,则只有nmae存在时,当前的set操作才执行 | [
"设置值,不存在则创建,存在则修改",
":",
"param",
"name",
":",
"key",
":",
"param",
"value",
":",
"value",
":",
"param",
"ex",
":",
"过期时间(秒)",
":",
"param",
"px",
":",
"过期时间(毫秒)",
":",
"param",
"nx",
":",
"如果设置为True,则只有name不存在时,当前的set操作才执行",
":",
"param",
"xx",
":",
"如果设置... | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/middleware/redislib.py#L15-L24 |
shi-cong/PYSTUDY | PYSTUDY/middleware/redislib.py | RedisPool.incr | def incr(self, name, amount=1):
"""自增key的对应的值,当key不存在时则为默认值,否则在基础上自增整数amount
:param name: key
:param amount: 默认值
:return: 返回自增后的值
"""
return self.client.incr(name, amount=amount) | python | def incr(self, name, amount=1):
"""自增key的对应的值,当key不存在时则为默认值,否则在基础上自增整数amount
:param name: key
:param amount: 默认值
:return: 返回自增后的值
"""
return self.client.incr(name, amount=amount) | [
"def",
"incr",
"(",
"self",
",",
"name",
",",
"amount",
"=",
"1",
")",
":",
"return",
"self",
".",
"client",
".",
"incr",
"(",
"name",
",",
"amount",
"=",
"amount",
")"
] | 自增key的对应的值,当key不存在时则为默认值,否则在基础上自增整数amount
:param name: key
:param amount: 默认值
:return: 返回自增后的值 | [
"自增key的对应的值,当key不存在时则为默认值,否则在基础上自增整数amount",
":",
"param",
"name",
":",
"key",
":",
"param",
"amount",
":",
"默认值",
":",
"return",
":",
"返回自增后的值"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/middleware/redislib.py#L33-L39 |
shi-cong/PYSTUDY | PYSTUDY/middleware/redislib.py | RedisPool.decr | def decr(self, name, amount=1):
"""递减key的对应的值,当key不存在时则为默认值,否则在基础上递减整数amount
:param name: key
:param amount: 默认值
:return: 返回递减后的值
"""
return self.client.decr(name, amount=amount) | python | def decr(self, name, amount=1):
"""递减key的对应的值,当key不存在时则为默认值,否则在基础上递减整数amount
:param name: key
:param amount: 默认值
:return: 返回递减后的值
"""
return self.client.decr(name, amount=amount) | [
"def",
"decr",
"(",
"self",
",",
"name",
",",
"amount",
"=",
"1",
")",
":",
"return",
"self",
".",
"client",
".",
"decr",
"(",
"name",
",",
"amount",
"=",
"amount",
")"
] | 递减key的对应的值,当key不存在时则为默认值,否则在基础上递减整数amount
:param name: key
:param amount: 默认值
:return: 返回递减后的值 | [
"递减key的对应的值,当key不存在时则为默认值,否则在基础上递减整数amount",
":",
"param",
"name",
":",
"key",
":",
"param",
"amount",
":",
"默认值",
":",
"return",
":",
"返回递减后的值"
] | train | https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/middleware/redislib.py#L41-L47 |
codingjester/pycitibike | pycitibike/__init__.py | Citibike._get | def _get(self, uri, options):
"""
Quick and dirty wrapper around the requests object to do
some simple data catching
:params uri: a string, the uri you want to request
:params options: a dict, the list of parameters you want to use
"""
url = "http://%s/%s" % (sel... | python | def _get(self, uri, options):
"""
Quick and dirty wrapper around the requests object to do
some simple data catching
:params uri: a string, the uri you want to request
:params options: a dict, the list of parameters you want to use
"""
url = "http://%s/%s" % (sel... | [
"def",
"_get",
"(",
"self",
",",
"uri",
",",
"options",
")",
":",
"url",
"=",
"\"http://%s/%s\"",
"%",
"(",
"self",
".",
"host",
",",
"uri",
")",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"options",
")",
"if",
"r",
".",
... | Quick and dirty wrapper around the requests object to do
some simple data catching
:params uri: a string, the uri you want to request
:params options: a dict, the list of parameters you want to use | [
"Quick",
"and",
"dirty",
"wrapper",
"around",
"the",
"requests",
"object",
"to",
"do",
"some",
"simple",
"data",
"catching"
] | train | https://github.com/codingjester/pycitibike/blob/740a6f9da60a1e0ff97a9c61ae4469ec2e207443/pycitibike/__init__.py#L39-L54 |
the01/python-paps | examples/measure/echo_server.py | create | def create(host, port):
"""
Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None
"""
wrapper = WrapperEchoServer({
'server': None
})
d = {
'listen_port': port,
'changer': wrapper
}
if host:
... | python | def create(host, port):
"""
Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None
"""
wrapper = WrapperEchoServer({
'server': None
})
d = {
'listen_port': port,
'changer': wrapper
}
if host:
... | [
"def",
"create",
"(",
"host",
",",
"port",
")",
":",
"wrapper",
"=",
"WrapperEchoServer",
"(",
"{",
"'server'",
":",
"None",
"}",
")",
"d",
"=",
"{",
"'listen_port'",
":",
"port",
",",
"'changer'",
":",
"wrapper",
"}",
"if",
"host",
":",
"d",
"[",
... | Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None | [
"Prepare",
"server",
"to",
"execute"
] | train | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/measure/echo_server.py#L56-L75 |
shreyaspotnis/rampage | rampage/widgets/MainWindow.py | MainWindow.loadSettings | def loadSettings(self):
"""Load window state from self.settings"""
self.settings.beginGroup('mainwindow')
geometry = self.settings.value('geometry').toByteArray()
state = self.settings.value('windowstate').toByteArray()
default_ramp_path = os.path.join(main_package_dir,
... | python | def loadSettings(self):
"""Load window state from self.settings"""
self.settings.beginGroup('mainwindow')
geometry = self.settings.value('geometry').toByteArray()
state = self.settings.value('windowstate').toByteArray()
default_ramp_path = os.path.join(main_package_dir,
... | [
"def",
"loadSettings",
"(",
"self",
")",
":",
"self",
".",
"settings",
".",
"beginGroup",
"(",
"'mainwindow'",
")",
"geometry",
"=",
"self",
".",
"settings",
".",
"value",
"(",
"'geometry'",
")",
".",
"toByteArray",
"(",
")",
"state",
"=",
"self",
".",
... | Load window state from self.settings | [
"Load",
"window",
"state",
"from",
"self",
".",
"settings"
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/widgets/MainWindow.py#L49-L67 |
shreyaspotnis/rampage | rampage/widgets/MainWindow.py | MainWindow.saveSettings | def saveSettings(self):
"""Save window state to self.settings."""
self.settings.beginGroup('mainwindow')
self.settings.setValue('geometry', self.saveGeometry())
self.settings.setValue('windowstate', self.saveState())
self.settings.setValue('path_to_ramp_file', self.path_to_ramp_f... | python | def saveSettings(self):
"""Save window state to self.settings."""
self.settings.beginGroup('mainwindow')
self.settings.setValue('geometry', self.saveGeometry())
self.settings.setValue('windowstate', self.saveState())
self.settings.setValue('path_to_ramp_file', self.path_to_ramp_f... | [
"def",
"saveSettings",
"(",
"self",
")",
":",
"self",
".",
"settings",
".",
"beginGroup",
"(",
"'mainwindow'",
")",
"self",
".",
"settings",
".",
"setValue",
"(",
"'geometry'",
",",
"self",
".",
"saveGeometry",
"(",
")",
")",
"self",
".",
"settings",
"."... | Save window state to self.settings. | [
"Save",
"window",
"state",
"to",
"self",
".",
"settings",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/widgets/MainWindow.py#L69-L77 |
shreyaspotnis/rampage | rampage/widgets/MainWindow.py | MainWindow.setWindowTitle | def setWindowTitle(self, newTitle=''):
"""Prepend Rampage to all window titles."""
title = 'Rampage - ' + newTitle
super(MainWindow, self).setWindowTitle(title) | python | def setWindowTitle(self, newTitle=''):
"""Prepend Rampage to all window titles."""
title = 'Rampage - ' + newTitle
super(MainWindow, self).setWindowTitle(title) | [
"def",
"setWindowTitle",
"(",
"self",
",",
"newTitle",
"=",
"''",
")",
":",
"title",
"=",
"'Rampage - '",
"+",
"newTitle",
"super",
"(",
"MainWindow",
",",
"self",
")",
".",
"setWindowTitle",
"(",
"title",
")"
] | Prepend Rampage to all window titles. | [
"Prepend",
"Rampage",
"to",
"all",
"window",
"titles",
"."
] | train | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/widgets/MainWindow.py#L105-L108 |
musicmetric/mmpy | src/artist.py | Artist.fetch_summary | def fetch_summary(self):
"""
grabs the summary info and sets the corisponding attributes.
Note: overides existing attribute values for these attributes
"""
self.response_from()
#should really clean up the triple nest
for k,v in self.response.items():
i... | python | def fetch_summary(self):
"""
grabs the summary info and sets the corisponding attributes.
Note: overides existing attribute values for these attributes
"""
self.response_from()
#should really clean up the triple nest
for k,v in self.response.items():
i... | [
"def",
"fetch_summary",
"(",
"self",
")",
":",
"self",
".",
"response_from",
"(",
")",
"#should really clean up the triple nest",
"for",
"k",
",",
"v",
"in",
"self",
".",
"response",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"v",
",",
... | grabs the summary info and sets the corisponding attributes.
Note: overides existing attribute values for these attributes | [
"grabs",
"the",
"summary",
"info",
"and",
"sets",
"the",
"corisponding",
"attributes",
".",
"Note",
":",
"overides",
"existing",
"attribute",
"values",
"for",
"these",
"attributes"
] | train | https://github.com/musicmetric/mmpy/blob/2b5d975c61f9ea8c7f19f76a90b59771833ef881/src/artist.py#L39-L56 |
Amsterdam/authorization_django | authorization_django/jwks.py | load | def load(jwks):
"""Parse a JWKSet and return a dictionary that maps key IDs on keys."""
sign_keys = {}
verify_keys = {}
try:
keyset = json.loads(jwks)
for key in keyset['keys']:
for op in key['key_ops']:
if op == 'sign':
k = sign_keys
... | python | def load(jwks):
"""Parse a JWKSet and return a dictionary that maps key IDs on keys."""
sign_keys = {}
verify_keys = {}
try:
keyset = json.loads(jwks)
for key in keyset['keys']:
for op in key['key_ops']:
if op == 'sign':
k = sign_keys
... | [
"def",
"load",
"(",
"jwks",
")",
":",
"sign_keys",
"=",
"{",
"}",
"verify_keys",
"=",
"{",
"}",
"try",
":",
"keyset",
"=",
"json",
".",
"loads",
"(",
"jwks",
")",
"for",
"key",
"in",
"keyset",
"[",
"'keys'",
"]",
":",
"for",
"op",
"in",
"key",
... | Parse a JWKSet and return a dictionary that maps key IDs on keys. | [
"Parse",
"a",
"JWKSet",
"and",
"return",
"a",
"dictionary",
"that",
"maps",
"key",
"IDs",
"on",
"keys",
"."
] | train | https://github.com/Amsterdam/authorization_django/blob/71da52b38a7f5a16a2bde8f8ea97b3c11ccb1be1/authorization_django/jwks.py#L21-L45 |
vinu76jsr/pipsort | setup.py | version | def version():
""" Get the local package version.
"""
path = join("lib", _CONFIG["name"], "__version__.py")
with open(path) as stream:
exec(stream.read())
return __version__ | python | def version():
""" Get the local package version.
"""
path = join("lib", _CONFIG["name"], "__version__.py")
with open(path) as stream:
exec(stream.read())
return __version__ | [
"def",
"version",
"(",
")",
":",
"path",
"=",
"join",
"(",
"\"lib\"",
",",
"_CONFIG",
"[",
"\"name\"",
"]",
",",
"\"__version__.py\"",
")",
"with",
"open",
"(",
"path",
")",
"as",
"stream",
":",
"exec",
"(",
"stream",
".",
"read",
"(",
")",
")",
"r... | Get the local package version. | [
"Get",
"the",
"local",
"package",
"version",
"."
] | train | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/setup.py#L49-L56 |
vinu76jsr/pipsort | setup.py | UpdateCommand.run | def run(self):
""" Execute the command.
"""
args = {"remote": self.remote, "branch": self.branch}
cmdl = "git pull --ff-only {remote:s} {branch:s}".format(**args)
try:
check_call(cmdl.split())
except CalledProcessError:
raise SystemExit(1)
... | python | def run(self):
""" Execute the command.
"""
args = {"remote": self.remote, "branch": self.branch}
cmdl = "git pull --ff-only {remote:s} {branch:s}".format(**args)
try:
check_call(cmdl.split())
except CalledProcessError:
raise SystemExit(1)
... | [
"def",
"run",
"(",
"self",
")",
":",
"args",
"=",
"{",
"\"remote\"",
":",
"self",
".",
"remote",
",",
"\"branch\"",
":",
"self",
".",
"branch",
"}",
"cmdl",
"=",
"\"git pull --ff-only {remote:s} {branch:s}\"",
".",
"format",
"(",
"*",
"*",
"args",
")",
"... | Execute the command. | [
"Execute",
"the",
"command",
"."
] | train | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/setup.py#L111-L122 |
vinu76jsr/pipsort | setup.py | VirtualenvCommand.run | def run(self):
""" Execute the command.
"""
venv = "virtualenv {:s}"
if self.python:
venv += " -p {:s}"
pip = "{0:s}/bin/pip install -r {2:s}" if self.requirements else None
args = self.name, self.python, self.requirements
try:
check_call(... | python | def run(self):
""" Execute the command.
"""
venv = "virtualenv {:s}"
if self.python:
venv += " -p {:s}"
pip = "{0:s}/bin/pip install -r {2:s}" if self.requirements else None
args = self.name, self.python, self.requirements
try:
check_call(... | [
"def",
"run",
"(",
"self",
")",
":",
"venv",
"=",
"\"virtualenv {:s}\"",
"if",
"self",
".",
"python",
":",
"venv",
"+=",
"\" -p {:s}\"",
"pip",
"=",
"\"{0:s}/bin/pip install -r {2:s}\"",
"if",
"self",
".",
"requirements",
"else",
"None",
"args",
"=",
"self",
... | Execute the command. | [
"Execute",
"the",
"command",
"."
] | train | https://github.com/vinu76jsr/pipsort/blob/71ead1269de85ee0255741390bf1da85d81b7d16/setup.py#L145-L161 |
konture/CloeePy | cloeepy/config.py | Config._set_config_path | def _set_config_path(self):
"""
Reads config path from environment variable CLOEEPY_CONFIG_PATH
and sets as instance attr
"""
self._path = os.getenv("CLOEEPY_CONFIG_PATH")
if self._path is None:
msg = "CLOEEPY_CONFIG_PATH is not set. Exiting..."
sy... | python | def _set_config_path(self):
"""
Reads config path from environment variable CLOEEPY_CONFIG_PATH
and sets as instance attr
"""
self._path = os.getenv("CLOEEPY_CONFIG_PATH")
if self._path is None:
msg = "CLOEEPY_CONFIG_PATH is not set. Exiting..."
sy... | [
"def",
"_set_config_path",
"(",
"self",
")",
":",
"self",
".",
"_path",
"=",
"os",
".",
"getenv",
"(",
"\"CLOEEPY_CONFIG_PATH\"",
")",
"if",
"self",
".",
"_path",
"is",
"None",
":",
"msg",
"=",
"\"CLOEEPY_CONFIG_PATH is not set. Exiting...\"",
"sys",
".",
"exi... | Reads config path from environment variable CLOEEPY_CONFIG_PATH
and sets as instance attr | [
"Reads",
"config",
"path",
"from",
"environment",
"variable",
"CLOEEPY_CONFIG_PATH",
"and",
"sets",
"as",
"instance",
"attr"
] | train | https://github.com/konture/CloeePy/blob/dcb21284d2df405d92ac6868ea7215792c9323b9/cloeepy/config.py#L45-L53 |
konture/CloeePy | cloeepy/config.py | Config._load_config | def _load_config(self):
"""
Loads the YAML configuration file and sets python dictionary and raw contents
as instance attrs.
"""
if not os.path.exists(self._path):
sys.exit("Config path %s does not exist" % self._path)
# create empty config object
self... | python | def _load_config(self):
"""
Loads the YAML configuration file and sets python dictionary and raw contents
as instance attrs.
"""
if not os.path.exists(self._path):
sys.exit("Config path %s does not exist" % self._path)
# create empty config object
self... | [
"def",
"_load_config",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_path",
")",
":",
"sys",
".",
"exit",
"(",
"\"Config path %s does not exist\"",
"%",
"self",
".",
"_path",
")",
"# create empty config object",
... | Loads the YAML configuration file and sets python dictionary and raw contents
as instance attrs. | [
"Loads",
"the",
"YAML",
"configuration",
"file",
"and",
"sets",
"python",
"dictionary",
"and",
"raw",
"contents",
"as",
"instance",
"attrs",
"."
] | train | https://github.com/konture/CloeePy/blob/dcb21284d2df405d92ac6868ea7215792c9323b9/cloeepy/config.py#L56-L68 |
konture/CloeePy | cloeepy/config.py | Config._set_attributes | def _set_attributes(self):
"""
Recursively transforms config dictionaries into instance attrs to make
for easy dot attribute access instead of dictionary access.
"""
# turn config dict into nested objects
config = obj(self._config_dict)
# set the attributes onto i... | python | def _set_attributes(self):
"""
Recursively transforms config dictionaries into instance attrs to make
for easy dot attribute access instead of dictionary access.
"""
# turn config dict into nested objects
config = obj(self._config_dict)
# set the attributes onto i... | [
"def",
"_set_attributes",
"(",
"self",
")",
":",
"# turn config dict into nested objects",
"config",
"=",
"obj",
"(",
"self",
".",
"_config_dict",
")",
"# set the attributes onto instance",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_config_dict",
".",
"items",
"("... | Recursively transforms config dictionaries into instance attrs to make
for easy dot attribute access instead of dictionary access. | [
"Recursively",
"transforms",
"config",
"dictionaries",
"into",
"instance",
"attrs",
"to",
"make",
"for",
"easy",
"dot",
"attribute",
"access",
"instead",
"of",
"dictionary",
"access",
"."
] | train | https://github.com/konture/CloeePy/blob/dcb21284d2df405d92ac6868ea7215792c9323b9/cloeepy/config.py#L83-L92 |
JNRowe/jnrbase | jnrbase/template.py | colourise | def colourise(__text: str, *args, **kwargs) -> str:
"""Colourise text using click’s style function.
Returns text untouched if colour output is not enabled, or ``stdout`` is
not a tty.
See :func:`click.style` for parameters
Args:
__text: Text to colourise
Returns:
Colourised te... | python | def colourise(__text: str, *args, **kwargs) -> str:
"""Colourise text using click’s style function.
Returns text untouched if colour output is not enabled, or ``stdout`` is
not a tty.
See :func:`click.style` for parameters
Args:
__text: Text to colourise
Returns:
Colourised te... | [
"def",
"colourise",
"(",
"__text",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"if",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
":",
"__text",
"=",
"style",
"(",
"__text",
",",
"*",
"args",
",",
"*",
"*",
... | Colourise text using click’s style function.
Returns text untouched if colour output is not enabled, or ``stdout`` is
not a tty.
See :func:`click.style` for parameters
Args:
__text: Text to colourise
Returns:
Colourised text, when possible | [
"Colourise",
"text",
"using",
"click’s",
"style",
"function",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/template.py#L58-L73 |
JNRowe/jnrbase | jnrbase/template.py | highlight | def highlight(__text: str, *, lexer: str = 'diff',
formatter: str = 'terminal') -> str:
"""Highlight text highlighted using ``pygments``.
Returns text untouched if colour output is not enabled.
See also: :pypi:`Pygments`
Args:
__text: Text to highlight
lexer: Jinja lexer... | python | def highlight(__text: str, *, lexer: str = 'diff',
formatter: str = 'terminal') -> str:
"""Highlight text highlighted using ``pygments``.
Returns text untouched if colour output is not enabled.
See also: :pypi:`Pygments`
Args:
__text: Text to highlight
lexer: Jinja lexer... | [
"def",
"highlight",
"(",
"__text",
":",
"str",
",",
"*",
",",
"lexer",
":",
"str",
"=",
"'diff'",
",",
"formatter",
":",
"str",
"=",
"'terminal'",
")",
"->",
"str",
":",
"if",
"sys",
".",
"stdout",
".",
"isatty",
"(",
")",
":",
"lexer",
"=",
"get... | Highlight text highlighted using ``pygments``.
Returns text untouched if colour output is not enabled.
See also: :pypi:`Pygments`
Args:
__text: Text to highlight
lexer: Jinja lexer to use
formatter: Jinja formatter to use
Returns:
Syntax highlighted output, when possib... | [
"Highlight",
"text",
"highlighted",
"using",
"pygments",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/template.py#L77-L96 |
JNRowe/jnrbase | jnrbase/template.py | html2text | def html2text(__html: str, *, width: int = 80,
ascii_replacements: bool = False) -> str:
"""HTML to plain text renderer.
See also: :pypi:`html2text`
Args:
__html: Text to process
width: Paragraph width
ascii_replacements: Use pseudo-ASCII replacements for Unicode
... | python | def html2text(__html: str, *, width: int = 80,
ascii_replacements: bool = False) -> str:
"""HTML to plain text renderer.
See also: :pypi:`html2text`
Args:
__html: Text to process
width: Paragraph width
ascii_replacements: Use pseudo-ASCII replacements for Unicode
... | [
"def",
"html2text",
"(",
"__html",
":",
"str",
",",
"*",
",",
"width",
":",
"int",
"=",
"80",
",",
"ascii_replacements",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"html2",
".",
"BODY_WIDTH",
"=",
"width",
"html2",
".",
"UNICODE_SNOB",
"=",
"a... | HTML to plain text renderer.
See also: :pypi:`html2text`
Args:
__html: Text to process
width: Paragraph width
ascii_replacements: Use pseudo-ASCII replacements for Unicode
Returns:
Rendered text | [
"HTML",
"to",
"plain",
"text",
"renderer",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/template.py#L100-L115 |
JNRowe/jnrbase | jnrbase/template.py | regexp | def regexp(__string: str, __pattern: str, __repl: Union[Callable, str], *,
count: int = 0, flags: int = 0) -> str:
"""Jinja filter for regexp replacements.
See :func:`re.sub` for documentation.
Returns:
Text with substitutions applied
"""
return re.sub(__pattern, __repl, __strin... | python | def regexp(__string: str, __pattern: str, __repl: Union[Callable, str], *,
count: int = 0, flags: int = 0) -> str:
"""Jinja filter for regexp replacements.
See :func:`re.sub` for documentation.
Returns:
Text with substitutions applied
"""
return re.sub(__pattern, __repl, __strin... | [
"def",
"regexp",
"(",
"__string",
":",
"str",
",",
"__pattern",
":",
"str",
",",
"__repl",
":",
"Union",
"[",
"Callable",
",",
"str",
"]",
",",
"*",
",",
"count",
":",
"int",
"=",
"0",
",",
"flags",
":",
"int",
"=",
"0",
")",
"->",
"str",
":",
... | Jinja filter for regexp replacements.
See :func:`re.sub` for documentation.
Returns:
Text with substitutions applied | [
"Jinja",
"filter",
"for",
"regexp",
"replacements",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/template.py#L119-L128 |
JNRowe/jnrbase | jnrbase/template.py | setup | def setup(__pkg: str) -> jinja2.Environment:
"""Configure a new Jinja environment with our filters.
Args:
__pkg: Package name to use as base for templates searches
Returns:
Configured Jinja environment
"""
dirs = [path.join(d, 'templates')
for d in xdg_basedir.get_data_d... | python | def setup(__pkg: str) -> jinja2.Environment:
"""Configure a new Jinja environment with our filters.
Args:
__pkg: Package name to use as base for templates searches
Returns:
Configured Jinja environment
"""
dirs = [path.join(d, 'templates')
for d in xdg_basedir.get_data_d... | [
"def",
"setup",
"(",
"__pkg",
":",
"str",
")",
"->",
"jinja2",
".",
"Environment",
":",
"dirs",
"=",
"[",
"path",
".",
"join",
"(",
"d",
",",
"'templates'",
")",
"for",
"d",
"in",
"xdg_basedir",
".",
"get_data_dirs",
"(",
"__pkg",
")",
"]",
"env",
... | Configure a new Jinja environment with our filters.
Args:
__pkg: Package name to use as base for templates searches
Returns:
Configured Jinja environment | [
"Configure",
"a",
"new",
"Jinja",
"environment",
"with",
"our",
"filters",
"."
] | train | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/template.py#L145-L162 |
ArabellaTech/aa-intercom | aa_intercom/utils.py | upload_intercom_user | def upload_intercom_user(obj_id):
"""Creates or updates single user account on intercom"""
UserModel = get_user_model()
intercom_user = False
instance = UserModel.objects.get(pk=obj_id)
data = instance.get_intercom_data()
if not getattr(settings, "SKIP_INTERCOM", False):
try:
... | python | def upload_intercom_user(obj_id):
"""Creates or updates single user account on intercom"""
UserModel = get_user_model()
intercom_user = False
instance = UserModel.objects.get(pk=obj_id)
data = instance.get_intercom_data()
if not getattr(settings, "SKIP_INTERCOM", False):
try:
... | [
"def",
"upload_intercom_user",
"(",
"obj_id",
")",
":",
"UserModel",
"=",
"get_user_model",
"(",
")",
"intercom_user",
"=",
"False",
"instance",
"=",
"UserModel",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"obj_id",
")",
"data",
"=",
"instance",
".",
"get... | Creates or updates single user account on intercom | [
"Creates",
"or",
"updates",
"single",
"user",
"account",
"on",
"intercom"
] | train | https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/utils.py#L14-L31 |
ArabellaTech/aa-intercom | aa_intercom/utils.py | upload_not_registered_user_data | def upload_not_registered_user_data(data):
"""
Upload user data to intercom, actually any data passed
data: Dict
Required:
"email"
"""
if type(data) != dict:
raise NotImplementedError("Incorrect data type")
if not data.get("email"):
raise KeyError("user_i... | python | def upload_not_registered_user_data(data):
"""
Upload user data to intercom, actually any data passed
data: Dict
Required:
"email"
"""
if type(data) != dict:
raise NotImplementedError("Incorrect data type")
if not data.get("email"):
raise KeyError("user_i... | [
"def",
"upload_not_registered_user_data",
"(",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"!=",
"dict",
":",
"raise",
"NotImplementedError",
"(",
"\"Incorrect data type\"",
")",
"if",
"not",
"data",
".",
"get",
"(",
"\"email\"",
")",
":",
"raise",
"Ke... | Upload user data to intercom, actually any data passed
data: Dict
Required:
"email" | [
"Upload",
"user",
"data",
"to",
"intercom",
"actually",
"any",
"data",
"passed",
"data",
":",
"Dict",
"Required",
":",
"email"
] | train | https://github.com/ArabellaTech/aa-intercom/blob/f7e2ab63967529660f9c2fe4f1d0bf3cec1502c2/aa_intercom/utils.py#L34-L61 |
Basic-Components/msgpack-rpc-protocol | python/pymprpc/mixins/encoder_decoder_mixin.py | EncoderDecoderMixin.encoder | def encoder(self, query: Dict[str, Any]):
"""编码请求为bytes.
检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.
Parameters:
query (Dict[str, Any]): - python字典形式的请求数据
Return:
(bytes): - 请求的字节串
"""
if self.debug is True:
queryb = json.... | python | def encoder(self, query: Dict[str, Any]):
"""编码请求为bytes.
检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.
Parameters:
query (Dict[str, Any]): - python字典形式的请求数据
Return:
(bytes): - 请求的字节串
"""
if self.debug is True:
queryb = json.... | [
"def",
"encoder",
"(",
"self",
",",
"query",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"if",
"self",
".",
"debug",
"is",
"True",
":",
"queryb",
"=",
"json",
".",
"dumps",
"(",
"query",
",",
"ensure_ascii",
"=",
"False",
")",
".",
"encod... | 编码请求为bytes.
检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.
Parameters:
query (Dict[str, Any]): - python字典形式的请求数据
Return:
(bytes): - 请求的字节串 | [
"编码请求为bytes",
"."
] | train | https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/mixins/encoder_decoder_mixin.py#L40-L64 |
Basic-Components/msgpack-rpc-protocol | python/pymprpc/mixins/encoder_decoder_mixin.py | EncoderDecoderMixin.decoder | def decoder(self, response: bytes):
"""编码请求为bytes.
检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.
Parameters:
response (bytes): - 响应的字节串编码
Return:
(Dict[str, Any]): - python字典形式的响应
"""
response = response[:-(len(self.SEPARATOR))]
... | python | def decoder(self, response: bytes):
"""编码请求为bytes.
检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.
Parameters:
response (bytes): - 响应的字节串编码
Return:
(Dict[str, Any]): - python字典形式的响应
"""
response = response[:-(len(self.SEPARATOR))]
... | [
"def",
"decoder",
"(",
"self",
",",
"response",
":",
"bytes",
")",
":",
"response",
"=",
"response",
"[",
":",
"-",
"(",
"len",
"(",
"self",
".",
"SEPARATOR",
")",
")",
"]",
"if",
"self",
".",
"compreser",
"is",
"not",
"None",
":",
"response",
"=",... | 编码请求为bytes.
检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串.
Parameters:
response (bytes): - 响应的字节串编码
Return:
(Dict[str, Any]): - python字典形式的响应 | [
"编码请求为bytes",
"."
] | train | https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/mixins/encoder_decoder_mixin.py#L66-L91 |
edwards-lab/libGWAS | libgwas/boundary.py | BoundaryCheck.LoadExclusions | def LoadExclusions(self, snps):
""" Load locus exclusions.
:param snps: Can either be a list of rsids or a file containing rsids.
:return: None
If snps is a file, the file must only contain RSIDs separated
by whitespace (tabs, spaces and return characters).
"""
... | python | def LoadExclusions(self, snps):
""" Load locus exclusions.
:param snps: Can either be a list of rsids or a file containing rsids.
:return: None
If snps is a file, the file must only contain RSIDs separated
by whitespace (tabs, spaces and return characters).
"""
... | [
"def",
"LoadExclusions",
"(",
"self",
",",
"snps",
")",
":",
"snp_names",
"=",
"[",
"]",
"if",
"len",
"(",
"snps",
")",
"==",
"1",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"snps",
"[",
"0",
"]",
")",
":",
"snp_names",
"=",
"open",
"(",
"sn... | Load locus exclusions.
:param snps: Can either be a list of rsids or a file containing rsids.
:return: None
If snps is a file, the file must only contain RSIDs separated
by whitespace (tabs, spaces and return characters). | [
"Load",
"locus",
"exclusions",
"."
] | train | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/boundary.py#L97-L114 |
edwards-lab/libGWAS | libgwas/boundary.py | BoundaryCheck.ReportConfiguration | def ReportConfiguration(self, f):
"""Report the boundary configuration details
:param f: File (or standard out/err)
:return: None
"""
if BoundaryCheck.chrom != -1:
print >> f, BuildReportLine("CHROM", BoundaryCheck.chrom)
if len(self.bounds) > 0:
... | python | def ReportConfiguration(self, f):
"""Report the boundary configuration details
:param f: File (or standard out/err)
:return: None
"""
if BoundaryCheck.chrom != -1:
print >> f, BuildReportLine("CHROM", BoundaryCheck.chrom)
if len(self.bounds) > 0:
... | [
"def",
"ReportConfiguration",
"(",
"self",
",",
"f",
")",
":",
"if",
"BoundaryCheck",
".",
"chrom",
"!=",
"-",
"1",
":",
"print",
">>",
"f",
",",
"BuildReportLine",
"(",
"\"CHROM\"",
",",
"BoundaryCheck",
".",
"chrom",
")",
"if",
"len",
"(",
"self",
".... | Report the boundary configuration details
:param f: File (or standard out/err)
:return: None | [
"Report",
"the",
"boundary",
"configuration",
"details"
] | train | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/boundary.py#L162-L177 |
edwards-lab/libGWAS | libgwas/boundary.py | BoundaryCheck.LoadSNPs | def LoadSNPs(self, snps=[]):
"""Define the SNP inclusions (by RSID). This overrides true boundary \
definition.
:param snps: array of RSIDs
:return: None
This doesn't define RSID ranges, so it throws InvalidBoundarySpec if it
encounters what appears to be a range (S... | python | def LoadSNPs(self, snps=[]):
"""Define the SNP inclusions (by RSID). This overrides true boundary \
definition.
:param snps: array of RSIDs
:return: None
This doesn't define RSID ranges, so it throws InvalidBoundarySpec if it
encounters what appears to be a range (S... | [
"def",
"LoadSNPs",
"(",
"self",
",",
"snps",
"=",
"[",
"]",
")",
":",
"for",
"snp",
"in",
"snps",
":",
"bounds",
"=",
"snp",
".",
"split",
"(",
"\"-\"",
")",
"if",
"len",
"(",
"bounds",
")",
"==",
"1",
":",
"if",
"bounds",
"[",
"0",
"]",
"!="... | Define the SNP inclusions (by RSID). This overrides true boundary \
definition.
:param snps: array of RSIDs
:return: None
This doesn't define RSID ranges, so it throws InvalidBoundarySpec if it
encounters what appears to be a range (SNP contains a "-") | [
"Define",
"the",
"SNP",
"inclusions",
"(",
"by",
"RSID",
")",
".",
"This",
"overrides",
"true",
"boundary",
"\\",
"definition",
"."
] | train | https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/boundary.py#L179-L196 |
scivision/histutils | histutils/rawDMCreader.py | getserialnum | def getserialnum(flist):
"""
This function assumes the serial number of the camera is in a particular place in the filename.
Yes, this is a little lame, but it's how the original 2011 image-writing program worked, and I've
carried over the scheme rather than appending bits to dozens of TB of files.
... | python | def getserialnum(flist):
"""
This function assumes the serial number of the camera is in a particular place in the filename.
Yes, this is a little lame, but it's how the original 2011 image-writing program worked, and I've
carried over the scheme rather than appending bits to dozens of TB of files.
... | [
"def",
"getserialnum",
"(",
"flist",
")",
":",
"sn",
"=",
"[",
"]",
"for",
"f",
"in",
"flist",
":",
"tmp",
"=",
"search",
"(",
"r'(?<=CamSer)\\d{3,6}'",
",",
"f",
")",
"if",
"tmp",
":",
"ser",
"=",
"int",
"(",
"tmp",
".",
"group",
"(",
")",
")",
... | This function assumes the serial number of the camera is in a particular place in the filename.
Yes, this is a little lame, but it's how the original 2011 image-writing program worked, and I've
carried over the scheme rather than appending bits to dozens of TB of files. | [
"This",
"function",
"assumes",
"the",
"serial",
"number",
"of",
"the",
"camera",
"is",
"in",
"a",
"particular",
"place",
"in",
"the",
"filename",
".",
"Yes",
"this",
"is",
"a",
"little",
"lame",
"but",
"it",
"s",
"how",
"the",
"original",
"2011",
"image"... | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/rawDMCreader.py#L80-L94 |
scivision/histutils | histutils/rawDMCreader.py | getDMCparam | def getDMCparam(fn: Path, xyPix, xyBin,
FrameIndReq=None, ut1req=None, kineticsec=None, startUTC=None, nHeadBytes=4, verbose=0):
"""
nHeadBytes=4 for 2013-2016 data
nHeadBytes=0 for 2011 data
"""
Nmetadata = nHeadBytes // 2 # FIXME for DMCdata version 1 only
if not fn.is_file()... | python | def getDMCparam(fn: Path, xyPix, xyBin,
FrameIndReq=None, ut1req=None, kineticsec=None, startUTC=None, nHeadBytes=4, verbose=0):
"""
nHeadBytes=4 for 2013-2016 data
nHeadBytes=0 for 2011 data
"""
Nmetadata = nHeadBytes // 2 # FIXME for DMCdata version 1 only
if not fn.is_file()... | [
"def",
"getDMCparam",
"(",
"fn",
":",
"Path",
",",
"xyPix",
",",
"xyBin",
",",
"FrameIndReq",
"=",
"None",
",",
"ut1req",
"=",
"None",
",",
"kineticsec",
"=",
"None",
",",
"startUTC",
"=",
"None",
",",
"nHeadBytes",
"=",
"4",
",",
"verbose",
"=",
"0"... | nHeadBytes=4 for 2013-2016 data
nHeadBytes=0 for 2011 data | [
"nHeadBytes",
"=",
"4",
"for",
"2013",
"-",
"2016",
"data",
"nHeadBytes",
"=",
"0",
"for",
"2011",
"data"
] | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/rawDMCreader.py#L97-L126 |
scivision/histutils | histutils/rawDMCreader.py | getNeoParam | def getNeoParam(fn, FrameIndReq=None, ut1req=None, kineticsec=None, startUTC=None, cmosinit={}, verbose=False):
""" assumption is that this is a Neo sCMOS FITS/TIFF file, where Solis chooses to break up the recordings
into smaller files. Verify if this timing estimate makes sense for your application!
I did... | python | def getNeoParam(fn, FrameIndReq=None, ut1req=None, kineticsec=None, startUTC=None, cmosinit={}, verbose=False):
""" assumption is that this is a Neo sCMOS FITS/TIFF file, where Solis chooses to break up the recordings
into smaller files. Verify if this timing estimate makes sense for your application!
I did... | [
"def",
"getNeoParam",
"(",
"fn",
",",
"FrameIndReq",
"=",
"None",
",",
"ut1req",
"=",
"None",
",",
"kineticsec",
"=",
"None",
",",
"startUTC",
"=",
"None",
",",
"cmosinit",
"=",
"{",
"}",
",",
"verbose",
"=",
"False",
")",
":",
"fn",
"=",
"Path",
"... | assumption is that this is a Neo sCMOS FITS/TIFF file, where Solis chooses to break up the recordings
into smaller files. Verify if this timing estimate makes sense for your application!
I did not want to do regexp on the filename or USERTXT1 as I felt this too prone to error.
inputs:
-------
cmosi... | [
"assumption",
"is",
"that",
"this",
"is",
"a",
"Neo",
"sCMOS",
"FITS",
"/",
"TIFF",
"file",
"where",
"Solis",
"chooses",
"to",
"break",
"up",
"the",
"recordings",
"into",
"smaller",
"files",
".",
"Verify",
"if",
"this",
"timing",
"estimate",
"makes",
"sens... | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/rawDMCreader.py#L129-L198 |
scivision/histutils | histutils/rawDMCreader.py | whichframes | def whichframes(fn, FrameIndReq, kineticsec, ut1req, startUTC, firstRawInd, lastRawInd,
BytesPerImage, BytesPerFrame, verbose):
ext = Path(fn).suffix
# %% get file size
fileSizeBytes = fn.stat().st_size
if fileSizeBytes < BytesPerImage:
raise ValueError(
f'File size {fil... | python | def whichframes(fn, FrameIndReq, kineticsec, ut1req, startUTC, firstRawInd, lastRawInd,
BytesPerImage, BytesPerFrame, verbose):
ext = Path(fn).suffix
# %% get file size
fileSizeBytes = fn.stat().st_size
if fileSizeBytes < BytesPerImage:
raise ValueError(
f'File size {fil... | [
"def",
"whichframes",
"(",
"fn",
",",
"FrameIndReq",
",",
"kineticsec",
",",
"ut1req",
",",
"startUTC",
",",
"firstRawInd",
",",
"lastRawInd",
",",
"BytesPerImage",
",",
"BytesPerFrame",
",",
"verbose",
")",
":",
"ext",
"=",
"Path",
"(",
"fn",
")",
".",
... | if no requested frames were specified, read all frames. Otherwise, just
return the requested frames
Assignments have to be "int64", not just python "int".
Windows python 2.7 64-bit on files >2.1GB, the bytes will wrap | [
"if",
"no",
"requested",
"frames",
"were",
"specified",
"read",
"all",
"frames",
".",
"Otherwise",
"just",
"return",
"the",
"requested",
"frames",
"Assignments",
"have",
"to",
"be",
"int64",
"not",
"just",
"python",
"int",
".",
"Windows",
"python",
"2",
".",... | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/rawDMCreader.py#L208-L266 |
scivision/histutils | histutils/rawDMCreader.py | getDMCframe | def getDMCframe(f, iFrm: int, finf: dict, verbose: bool=False):
"""
f is open file handle
"""
# on windows, "int" is int32 and overflows at 2.1GB! We need np.int64
currByte = iFrm * finf['bytesperframe']
# %% advance to start of frame in bytes
if verbose:
print(f'seeking to byte {currBy... | python | def getDMCframe(f, iFrm: int, finf: dict, verbose: bool=False):
"""
f is open file handle
"""
# on windows, "int" is int32 and overflows at 2.1GB! We need np.int64
currByte = iFrm * finf['bytesperframe']
# %% advance to start of frame in bytes
if verbose:
print(f'seeking to byte {currBy... | [
"def",
"getDMCframe",
"(",
"f",
",",
"iFrm",
":",
"int",
",",
"finf",
":",
"dict",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
":",
"# on windows, \"int\" is int32 and overflows at 2.1GB! We need np.int64",
"currByte",
"=",
"iFrm",
"*",
"finf",
"[",
"'bytes... | f is open file handle | [
"f",
"is",
"open",
"file",
"handle"
] | train | https://github.com/scivision/histutils/blob/859a91d3894cb57faed34881c6ea16130b90571e/histutils/rawDMCreader.py#L269-L299 |
a-tal/kezmenu3 | kezmenu3/kezmenu.py | KezMenu._fixSize | def _fixSize(self):
"""Fix the menu size. Commonly called when the font is changed"""
self.height = 0
for o in self.options:
text = o['label']
font = o['font']
ren = font.render(text, 1, (0, 0, 0))
if ren.get_width() > self.width:
s... | python | def _fixSize(self):
"""Fix the menu size. Commonly called when the font is changed"""
self.height = 0
for o in self.options:
text = o['label']
font = o['font']
ren = font.render(text, 1, (0, 0, 0))
if ren.get_width() > self.width:
s... | [
"def",
"_fixSize",
"(",
"self",
")",
":",
"self",
".",
"height",
"=",
"0",
"for",
"o",
"in",
"self",
".",
"options",
":",
"text",
"=",
"o",
"[",
"'label'",
"]",
"font",
"=",
"o",
"[",
"'font'",
"]",
"ren",
"=",
"font",
".",
"render",
"(",
"text... | Fix the menu size. Commonly called when the font is changed | [
"Fix",
"the",
"menu",
"size",
".",
"Commonly",
"called",
"when",
"the",
"font",
"is",
"changed"
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu.py#L72-L81 |
a-tal/kezmenu3 | kezmenu3/kezmenu.py | KezMenu.draw | def draw(self, surface):
"""Blit the menu to a surface."""
offset = 0
i = 0
ol, ot = self.screen_topleft_offset
first = self.options and self.options[0]
last = self.options and self.options[-1]
for o in self.options:
indent = o.get('padding_col', 0)
... | python | def draw(self, surface):
"""Blit the menu to a surface."""
offset = 0
i = 0
ol, ot = self.screen_topleft_offset
first = self.options and self.options[0]
last = self.options and self.options[-1]
for o in self.options:
indent = o.get('padding_col', 0)
... | [
"def",
"draw",
"(",
"self",
",",
"surface",
")",
":",
"offset",
"=",
"0",
"i",
"=",
"0",
"ol",
",",
"ot",
"=",
"self",
".",
"screen_topleft_offset",
"first",
"=",
"self",
".",
"options",
"and",
"self",
".",
"options",
"[",
"0",
"]",
"last",
"=",
... | Blit the menu to a surface. | [
"Blit",
"the",
"menu",
"to",
"a",
"surface",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu.py#L83-L117 |
a-tal/kezmenu3 | kezmenu3/kezmenu.py | KezMenu.update | def update(self, events, time_passed=None):
"""Update the menu and get input for the menu.
@events: the pygame catched events
@time_passed: delta time since the last call
"""
for e in events:
if e.type == pygame.QUIT:
raise SystemExit
if ... | python | def update(self, events, time_passed=None):
"""Update the menu and get input for the menu.
@events: the pygame catched events
@time_passed: delta time since the last call
"""
for e in events:
if e.type == pygame.QUIT:
raise SystemExit
if ... | [
"def",
"update",
"(",
"self",
",",
"events",
",",
"time_passed",
"=",
"None",
")",
":",
"for",
"e",
"in",
"events",
":",
"if",
"e",
".",
"type",
"==",
"pygame",
".",
"QUIT",
":",
"raise",
"SystemExit",
"if",
"e",
".",
"type",
"==",
"pygame",
".",
... | Update the menu and get input for the menu.
@events: the pygame catched events
@time_passed: delta time since the last call | [
"Update",
"the",
"menu",
"and",
"get",
"input",
"for",
"the",
"menu",
"."
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu.py#L119-L152 |
a-tal/kezmenu3 | kezmenu3/kezmenu.py | KezMenu._checkMousePositionForFocus | def _checkMousePositionForFocus(self):
"""Check the mouse position to know if move focus on a option"""
i = 0
cur_pos = pygame.mouse.get_pos()
ml, mt = self.position
for o in self.options:
rect = o.get('label_rect')
if rect:
if rect.collide... | python | def _checkMousePositionForFocus(self):
"""Check the mouse position to know if move focus on a option"""
i = 0
cur_pos = pygame.mouse.get_pos()
ml, mt = self.position
for o in self.options:
rect = o.get('label_rect')
if rect:
if rect.collide... | [
"def",
"_checkMousePositionForFocus",
"(",
"self",
")",
":",
"i",
"=",
"0",
"cur_pos",
"=",
"pygame",
".",
"mouse",
".",
"get_pos",
"(",
")",
"ml",
",",
"mt",
"=",
"self",
".",
"position",
"for",
"o",
"in",
"self",
".",
"options",
":",
"rect",
"=",
... | Check the mouse position to know if move focus on a option | [
"Check",
"the",
"mouse",
"position",
"to",
"know",
"if",
"move",
"focus",
"on",
"a",
"option"
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu.py#L154-L166 |
a-tal/kezmenu3 | kezmenu3/kezmenu.py | KezMenu.center_at | def center_at(self, x, y):
"""Center the menu at x, y"""
self.x = x - (self.width / 2)
self.y = y - (self.height / 2) | python | def center_at(self, x, y):
"""Center the menu at x, y"""
self.x = x - (self.width / 2)
self.y = y - (self.height / 2) | [
"def",
"center_at",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"self",
".",
"x",
"=",
"x",
"-",
"(",
"self",
".",
"width",
"/",
"2",
")",
"self",
".",
"y",
"=",
"y",
"-",
"(",
"self",
".",
"height",
"/",
"2",
")"
] | Center the menu at x, y | [
"Center",
"the",
"menu",
"at",
"x",
"y"
] | train | https://github.com/a-tal/kezmenu3/blob/3b06f9cb67fdc98a73928f877eea86692f832fa4/kezmenu3/kezmenu.py#L189-L193 |
jashort/SmartFileSorter | smartfilesorter/actionplugins/renameto.py | RenameTo.do_action | def do_action(self, target, dry_run=False):
"""
:param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action. No effect for this rule.
:return: filename: Full path and filename after action completes
"""
original_path =... | python | def do_action(self, target, dry_run=False):
"""
:param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action. No effect for this rule.
:return: filename: Full path and filename after action completes
"""
original_path =... | [
"def",
"do_action",
"(",
"self",
",",
"target",
",",
"dry_run",
"=",
"False",
")",
":",
"original_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"target",
")",
"original_filename",
",",
"original_extension",
"=",
"os",
".",
"path",
".",
"splitext",
... | :param target: Full path and filename
:param dry_run: True - don't actually perform action. False: perform action. No effect for this rule.
:return: filename: Full path and filename after action completes | [
":",
"param",
"target",
":",
"Full",
"path",
"and",
"filename",
":",
"param",
"dry_run",
":",
"True",
"-",
"don",
"t",
"actually",
"perform",
"action",
".",
"False",
":",
"perform",
"action",
".",
"No",
"effect",
"for",
"this",
"rule",
".",
":",
"retur... | train | https://github.com/jashort/SmartFileSorter/blob/77faf09e5a737da93e16e71a64707366b8307910/smartfilesorter/actionplugins/renameto.py#L28-L57 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | run_bots | def run_bots(bots):
"""
Run many bots in parallel.
:param bots: IRC bots to run.
:type bots: list
"""
greenlets = [spawn(bot.run) for bot in bots]
try:
joinall(greenlets)
except KeyboardInterrupt:
for bot in bots:
bot.disconnect()
finally:
killall... | python | def run_bots(bots):
"""
Run many bots in parallel.
:param bots: IRC bots to run.
:type bots: list
"""
greenlets = [spawn(bot.run) for bot in bots]
try:
joinall(greenlets)
except KeyboardInterrupt:
for bot in bots:
bot.disconnect()
finally:
killall... | [
"def",
"run_bots",
"(",
"bots",
")",
":",
"greenlets",
"=",
"[",
"spawn",
"(",
"bot",
".",
"run",
")",
"for",
"bot",
"in",
"bots",
"]",
"try",
":",
"joinall",
"(",
"greenlets",
")",
"except",
"KeyboardInterrupt",
":",
"for",
"bot",
"in",
"bots",
":",... | Run many bots in parallel.
:param bots: IRC bots to run.
:type bots: list | [
"Run",
"many",
"bots",
"in",
"parallel",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L417-L431 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | Message.parse | def parse(cls, data):
"""
Extracts message informations from `data`.
:param data: received line.
:type data: unicode
:return: extracted informations (source, destination, command, args).
:rtype: tuple(Source, str, str, list)
:raise: :class:`fatbotslim.irc.NullMes... | python | def parse(cls, data):
"""
Extracts message informations from `data`.
:param data: received line.
:type data: unicode
:return: extracted informations (source, destination, command, args).
:rtype: tuple(Source, str, str, list)
:raise: :class:`fatbotslim.irc.NullMes... | [
"def",
"parse",
"(",
"cls",
",",
"data",
")",
":",
"src",
"=",
"u''",
"dst",
"=",
"None",
"if",
"data",
"[",
"0",
"]",
"==",
"u':'",
":",
"src",
",",
"data",
"=",
"data",
"[",
"1",
":",
"]",
".",
"split",
"(",
"u' '",
",",
"1",
")",
"if",
... | Extracts message informations from `data`.
:param data: received line.
:type data: unicode
:return: extracted informations (source, destination, command, args).
:rtype: tuple(Source, str, str, list)
:raise: :class:`fatbotslim.irc.NullMessage` if `data` is empty. | [
"Extracts",
"message",
"informations",
"from",
"data",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L75-L101 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | Source.parse | def parse(cls, prefix):
"""
Extracts informations from `prefix`.
:param prefix: prefix with format ``<servername>|<nick>['!'<user>]['@'<host>]``.
:type prefix: unicode
:return: extracted informations (nickname or host, mode, username, host).
:rtype: tuple(str, str, str, ... | python | def parse(cls, prefix):
"""
Extracts informations from `prefix`.
:param prefix: prefix with format ``<servername>|<nick>['!'<user>]['@'<host>]``.
:type prefix: unicode
:return: extracted informations (nickname or host, mode, username, host).
:rtype: tuple(str, str, str, ... | [
"def",
"parse",
"(",
"cls",
",",
"prefix",
")",
":",
"try",
":",
"nick",
",",
"rest",
"=",
"prefix",
".",
"split",
"(",
"u'!'",
")",
"except",
"ValueError",
":",
"return",
"prefix",
",",
"None",
",",
"None",
",",
"None",
"try",
":",
"mode",
",",
... | Extracts informations from `prefix`.
:param prefix: prefix with format ``<servername>|<nick>['!'<user>]['@'<host>]``.
:type prefix: unicode
:return: extracted informations (nickname or host, mode, username, host).
:rtype: tuple(str, str, str, str) | [
"Extracts",
"informations",
"from",
"prefix",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L124-L145 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC._create_connection | def _create_connection(self):
"""
Creates a transport channel.
:return: transport channel instance
:rtype: :class:`fatbotslim.irc.tcp.TCP` or :class:`fatbotslim.irc.tcp.SSL`
"""
transport = SSL if self.ssl else TCP
return transport(self.server, self.port) | python | def _create_connection(self):
"""
Creates a transport channel.
:return: transport channel instance
:rtype: :class:`fatbotslim.irc.tcp.TCP` or :class:`fatbotslim.irc.tcp.SSL`
"""
transport = SSL if self.ssl else TCP
return transport(self.server, self.port) | [
"def",
"_create_connection",
"(",
"self",
")",
":",
"transport",
"=",
"SSL",
"if",
"self",
".",
"ssl",
"else",
"TCP",
"return",
"transport",
"(",
"self",
".",
"server",
",",
"self",
".",
"port",
")"
] | Creates a transport channel.
:return: transport channel instance
:rtype: :class:`fatbotslim.irc.tcp.TCP` or :class:`fatbotslim.irc.tcp.SSL` | [
"Creates",
"a",
"transport",
"channel",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L188-L196 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC._connect | def _connect(self):
"""
Connects the bot to the server and identifies itself.
"""
self.conn = self._create_connection()
spawn(self.conn.connect)
self.set_nick(self.nick)
self.cmd(u'USER', u'{0} 3 * {1}'.format(self.nick, self.realname)) | python | def _connect(self):
"""
Connects the bot to the server and identifies itself.
"""
self.conn = self._create_connection()
spawn(self.conn.connect)
self.set_nick(self.nick)
self.cmd(u'USER', u'{0} 3 * {1}'.format(self.nick, self.realname)) | [
"def",
"_connect",
"(",
"self",
")",
":",
"self",
".",
"conn",
"=",
"self",
".",
"_create_connection",
"(",
")",
"spawn",
"(",
"self",
".",
"conn",
".",
"connect",
")",
"self",
".",
"set_nick",
"(",
"self",
".",
"nick",
")",
"self",
".",
"cmd",
"("... | Connects the bot to the server and identifies itself. | [
"Connects",
"the",
"bot",
"to",
"the",
"server",
"and",
"identifies",
"itself",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L198-L205 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC._send | def _send(self, command):
"""
Sends a raw line to the server.
:param command: line to send.
:type command: unicode
"""
command = command.encode('utf-8')
log.debug('>> ' + command)
self.conn.oqueue.put(command) | python | def _send(self, command):
"""
Sends a raw line to the server.
:param command: line to send.
:type command: unicode
"""
command = command.encode('utf-8')
log.debug('>> ' + command)
self.conn.oqueue.put(command) | [
"def",
"_send",
"(",
"self",
",",
"command",
")",
":",
"command",
"=",
"command",
".",
"encode",
"(",
"'utf-8'",
")",
"log",
".",
"debug",
"(",
"'>> '",
"+",
"command",
")",
"self",
".",
"conn",
".",
"oqueue",
".",
"put",
"(",
"command",
")"
] | Sends a raw line to the server.
:param command: line to send.
:type command: unicode | [
"Sends",
"a",
"raw",
"line",
"to",
"the",
"server",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L207-L216 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC._event_loop | def _event_loop(self):
"""
The main event loop.
Data from the server is parsed here using :func:`_parse_msg`.
Parsed events are put in the object's event queue (`self.events`).
"""
while True:
orig_line = self.conn.iqueue.get()
log.debug('<< ' + or... | python | def _event_loop(self):
"""
The main event loop.
Data from the server is parsed here using :func:`_parse_msg`.
Parsed events are put in the object's event queue (`self.events`).
"""
while True:
orig_line = self.conn.iqueue.get()
log.debug('<< ' + or... | [
"def",
"_event_loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"orig_line",
"=",
"self",
".",
"conn",
".",
"iqueue",
".",
"get",
"(",
")",
"log",
".",
"debug",
"(",
"'<< '",
"+",
"orig_line",
")",
"line",
"=",
"u",
"(",
"orig_line",
",",
"error... | The main event loop.
Data from the server is parsed here using :func:`_parse_msg`.
Parsed events are put in the object's event queue (`self.events`). | [
"The",
"main",
"event",
"loop",
".",
"Data",
"from",
"the",
"server",
"is",
"parsed",
"here",
"using",
":",
"func",
":",
"_parse_msg",
".",
"Parsed",
"events",
"are",
"put",
"in",
"the",
"object",
"s",
"event",
"queue",
"(",
"self",
".",
"events",
")",... | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L218-L241 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC._handle | def _handle(self, msg):
"""
Pass a received message to the registered handlers.
:param msg: received message
:type msg: :class:`fatbotslim.irc.Message`
"""
def handler_yielder():
for handler in self.handlers:
yield handler
def handle... | python | def _handle(self, msg):
"""
Pass a received message to the registered handlers.
:param msg: received message
:type msg: :class:`fatbotslim.irc.Message`
"""
def handler_yielder():
for handler in self.handlers:
yield handler
def handle... | [
"def",
"_handle",
"(",
"self",
",",
"msg",
")",
":",
"def",
"handler_yielder",
"(",
")",
":",
"for",
"handler",
"in",
"self",
".",
"handlers",
":",
"yield",
"handler",
"def",
"handler_callback",
"(",
"_",
")",
":",
"if",
"msg",
".",
"propagate",
":",
... | Pass a received message to the registered handlers.
:param msg: received message
:type msg: :class:`fatbotslim.irc.Message` | [
"Pass",
"a",
"received",
"message",
"to",
"the",
"registered",
"handlers",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L243-L276 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.randomize_nick | def randomize_nick(cls, base, suffix_length=3):
"""
Generates a pseudo-random nickname.
:param base: prefix to use for the generated nickname.
:type base: unicode
:param suffix_length: amount of digits to append to `base`
:type suffix_length: int
:return: generat... | python | def randomize_nick(cls, base, suffix_length=3):
"""
Generates a pseudo-random nickname.
:param base: prefix to use for the generated nickname.
:type base: unicode
:param suffix_length: amount of digits to append to `base`
:type suffix_length: int
:return: generat... | [
"def",
"randomize_nick",
"(",
"cls",
",",
"base",
",",
"suffix_length",
"=",
"3",
")",
":",
"suffix",
"=",
"u''",
".",
"join",
"(",
"choice",
"(",
"u'0123456789'",
")",
"for",
"_",
"in",
"range",
"(",
"suffix_length",
")",
")",
"return",
"u'{0}{1}'",
"... | Generates a pseudo-random nickname.
:param base: prefix to use for the generated nickname.
:type base: unicode
:param suffix_length: amount of digits to append to `base`
:type suffix_length: int
:return: generated nickname.
:rtype: unicode | [
"Generates",
"a",
"pseudo",
"-",
"random",
"nickname",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L279-L291 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.enable_rights | def enable_rights(self):
"""
Enables rights management provided by :class:`fatbotslim.handlers.RightsHandler`.
"""
if self.rights is None:
handler_instance = RightsHandler(self)
self.handlers.insert(len(self.default_handlers), handler_instance) | python | def enable_rights(self):
"""
Enables rights management provided by :class:`fatbotslim.handlers.RightsHandler`.
"""
if self.rights is None:
handler_instance = RightsHandler(self)
self.handlers.insert(len(self.default_handlers), handler_instance) | [
"def",
"enable_rights",
"(",
"self",
")",
":",
"if",
"self",
".",
"rights",
"is",
"None",
":",
"handler_instance",
"=",
"RightsHandler",
"(",
"self",
")",
"self",
".",
"handlers",
".",
"insert",
"(",
"len",
"(",
"self",
".",
"default_handlers",
")",
",",... | Enables rights management provided by :class:`fatbotslim.handlers.RightsHandler`. | [
"Enables",
"rights",
"management",
"provided",
"by",
":",
"class",
":",
"fatbotslim",
".",
"handlers",
".",
"RightsHandler",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L293-L299 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.disable_rights | def disable_rights(self):
"""
Disables rights management provided by :class:`fatbotslim.handlers.RightsHandler`.
"""
for handler in self.handlers:
if isinstance(handler, RightsHandler):
self.handlers.remove(handler)
break
self.rights = ... | python | def disable_rights(self):
"""
Disables rights management provided by :class:`fatbotslim.handlers.RightsHandler`.
"""
for handler in self.handlers:
if isinstance(handler, RightsHandler):
self.handlers.remove(handler)
break
self.rights = ... | [
"def",
"disable_rights",
"(",
"self",
")",
":",
"for",
"handler",
"in",
"self",
".",
"handlers",
":",
"if",
"isinstance",
"(",
"handler",
",",
"RightsHandler",
")",
":",
"self",
".",
"handlers",
".",
"remove",
"(",
"handler",
")",
"break",
"self",
".",
... | Disables rights management provided by :class:`fatbotslim.handlers.RightsHandler`. | [
"Disables",
"rights",
"management",
"provided",
"by",
":",
"class",
":",
"fatbotslim",
".",
"handlers",
".",
"RightsHandler",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L301-L309 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.add_handler | def add_handler(self, handler, args=None, kwargs=None):
"""
Registers a new handler.
:param handler: handler to register.
:type handler: :class:`fatbotslim.handlers.BaseHandler`
:param args: positional arguments to pass to the handler's constructor.
:type args: list
... | python | def add_handler(self, handler, args=None, kwargs=None):
"""
Registers a new handler.
:param handler: handler to register.
:type handler: :class:`fatbotslim.handlers.BaseHandler`
:param args: positional arguments to pass to the handler's constructor.
:type args: list
... | [
"def",
"add_handler",
"(",
"self",
",",
"handler",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"args",
"=",
"[",
"]",
"if",
"args",
"is",
"None",
"else",
"args",
"kwargs",
"=",
"{",
"}",
"if",
"kwargs",
"is",
"None",
"else",
"... | Registers a new handler.
:param handler: handler to register.
:type handler: :class:`fatbotslim.handlers.BaseHandler`
:param args: positional arguments to pass to the handler's constructor.
:type args: list
:param kwargs: keyword arguments to pass to the handler's constructor.
... | [
"Registers",
"a",
"new",
"handler",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L311-L328 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.cmd | def cmd(self, command, args, prefix=None):
"""
Sends a command to the server.
:param command: IRC code to send.
:type command: unicode
:param args: arguments to pass with the command.
:type args: basestring
:param prefix: optional prefix to prepend to the command... | python | def cmd(self, command, args, prefix=None):
"""
Sends a command to the server.
:param command: IRC code to send.
:type command: unicode
:param args: arguments to pass with the command.
:type args: basestring
:param prefix: optional prefix to prepend to the command... | [
"def",
"cmd",
"(",
"self",
",",
"command",
",",
"args",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"prefix",
"is",
"None",
":",
"prefix",
"=",
"u''",
"raw_cmd",
"=",
"u'{0} {1} {2}'",
".",
"format",
"(",
"prefix",
",",
"command",
",",
"args",
")",
... | Sends a command to the server.
:param command: IRC code to send.
:type command: unicode
:param args: arguments to pass with the command.
:type args: basestring
:param prefix: optional prefix to prepend to the command.
:type prefix: str or None | [
"Sends",
"a",
"command",
"to",
"the",
"server",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L330-L344 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.ctcp_reply | def ctcp_reply(self, command, dst, message=None):
"""
Sends a reply to a CTCP request.
:param command: CTCP command to use.
:type command: str
:param dst: sender of the initial request.
:type dst: str
:param message: data to attach to the reply.
:type mes... | python | def ctcp_reply(self, command, dst, message=None):
"""
Sends a reply to a CTCP request.
:param command: CTCP command to use.
:type command: str
:param dst: sender of the initial request.
:type dst: str
:param message: data to attach to the reply.
:type mes... | [
"def",
"ctcp_reply",
"(",
"self",
",",
"command",
",",
"dst",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"None",
":",
"raw_cmd",
"=",
"u'\\x01{0}\\x01'",
".",
"format",
"(",
"command",
")",
"else",
":",
"raw_cmd",
"=",
"u'\\x01{0} {1}\... | Sends a reply to a CTCP request.
:param command: CTCP command to use.
:type command: str
:param dst: sender of the initial request.
:type dst: str
:param message: data to attach to the reply.
:type message: str | [
"Sends",
"a",
"reply",
"to",
"a",
"CTCP",
"request",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L346-L361 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.msg | def msg(self, target, msg):
"""
Sends a message to an user or channel.
:param target: user or channel to send to.
:type target: str
:param msg: message to send.
:type msg: str
"""
self.cmd(u'PRIVMSG', u'{0} :{1}'.format(target, msg)) | python | def msg(self, target, msg):
"""
Sends a message to an user or channel.
:param target: user or channel to send to.
:type target: str
:param msg: message to send.
:type msg: str
"""
self.cmd(u'PRIVMSG', u'{0} :{1}'.format(target, msg)) | [
"def",
"msg",
"(",
"self",
",",
"target",
",",
"msg",
")",
":",
"self",
".",
"cmd",
"(",
"u'PRIVMSG'",
",",
"u'{0} :{1}'",
".",
"format",
"(",
"target",
",",
"msg",
")",
")"
] | Sends a message to an user or channel.
:param target: user or channel to send to.
:type target: str
:param msg: message to send.
:type msg: str | [
"Sends",
"a",
"message",
"to",
"an",
"user",
"or",
"channel",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L363-L372 |
mdeous/fatbotslim | fatbotslim/irc/bot.py | IRC.notice | def notice(self, target, msg):
"""
Sends a NOTICE to an user or channel.
:param target: user or channel to send to.
:type target: str
:param msg: message to send.
:type msg: basestring
"""
self.cmd(u'NOTICE', u'{0} :{1}'.format(target, msg)) | python | def notice(self, target, msg):
"""
Sends a NOTICE to an user or channel.
:param target: user or channel to send to.
:type target: str
:param msg: message to send.
:type msg: basestring
"""
self.cmd(u'NOTICE', u'{0} :{1}'.format(target, msg)) | [
"def",
"notice",
"(",
"self",
",",
"target",
",",
"msg",
")",
":",
"self",
".",
"cmd",
"(",
"u'NOTICE'",
",",
"u'{0} :{1}'",
".",
"format",
"(",
"target",
",",
"msg",
")",
")"
] | Sends a NOTICE to an user or channel.
:param target: user or channel to send to.
:type target: str
:param msg: message to send.
:type msg: basestring | [
"Sends",
"a",
"NOTICE",
"to",
"an",
"user",
"or",
"channel",
"."
] | train | https://github.com/mdeous/fatbotslim/blob/341595d24454a79caee23750eac271f9d0626c88/fatbotslim/irc/bot.py#L374-L383 |
csaez/wishlib | wishlib/si/utils.py | siget | def siget(fullname=""):
"""Returns a softimage object given its fullname."""
fullname = str(fullname)
if not len(fullname):
return None
return sidict.GetObject(fullname, False) | python | def siget(fullname=""):
"""Returns a softimage object given its fullname."""
fullname = str(fullname)
if not len(fullname):
return None
return sidict.GetObject(fullname, False) | [
"def",
"siget",
"(",
"fullname",
"=",
"\"\"",
")",
":",
"fullname",
"=",
"str",
"(",
"fullname",
")",
"if",
"not",
"len",
"(",
"fullname",
")",
":",
"return",
"None",
"return",
"sidict",
".",
"GetObject",
"(",
"fullname",
",",
"False",
")"
] | Returns a softimage object given its fullname. | [
"Returns",
"a",
"softimage",
"object",
"given",
"its",
"fullname",
"."
] | train | https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/si/utils.py#L30-L35 |
csaez/wishlib | wishlib/si/utils.py | cmd_wrapper | def cmd_wrapper(cmd_name, **kwds):
"""Wrap and execute a softimage command accepting named arguments"""
cmd = si.Commands(cmd_name)
if not cmd:
raise Exception(cmd_name + " doesnt found!")
for arg in cmd.Arguments:
value = kwds.get(arg.Name)
if value:
arg.Value = valu... | python | def cmd_wrapper(cmd_name, **kwds):
"""Wrap and execute a softimage command accepting named arguments"""
cmd = si.Commands(cmd_name)
if not cmd:
raise Exception(cmd_name + " doesnt found!")
for arg in cmd.Arguments:
value = kwds.get(arg.Name)
if value:
arg.Value = valu... | [
"def",
"cmd_wrapper",
"(",
"cmd_name",
",",
"*",
"*",
"kwds",
")",
":",
"cmd",
"=",
"si",
".",
"Commands",
"(",
"cmd_name",
")",
"if",
"not",
"cmd",
":",
"raise",
"Exception",
"(",
"cmd_name",
"+",
"\" doesnt found!\"",
")",
"for",
"arg",
"in",
"cmd",
... | Wrap and execute a softimage command accepting named arguments | [
"Wrap",
"and",
"execute",
"a",
"softimage",
"command",
"accepting",
"named",
"arguments"
] | train | https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/si/utils.py#L38-L47 |
Amsterdam/authorization_django | authorization_django/middleware.py | _create_logger | def _create_logger(middleware_settings):
""" Creates a logger using the given settings.
"""
if django_settings.DEBUG:
level = logging.DEBUG
formatter = logging.Formatter(
middleware_settings['LOGGER_FORMAT_DEBUG'])
else:
level = middleware_settings['LOGGER_LEVEL']
... | python | def _create_logger(middleware_settings):
""" Creates a logger using the given settings.
"""
if django_settings.DEBUG:
level = logging.DEBUG
formatter = logging.Formatter(
middleware_settings['LOGGER_FORMAT_DEBUG'])
else:
level = middleware_settings['LOGGER_LEVEL']
... | [
"def",
"_create_logger",
"(",
"middleware_settings",
")",
":",
"if",
"django_settings",
".",
"DEBUG",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"middleware_settings",
"[",
"'LOGGER_FORMAT_DEBUG'",
"]",
")",
"... | Creates a logger using the given settings. | [
"Creates",
"a",
"logger",
"using",
"the",
"given",
"settings",
"."
] | train | https://github.com/Amsterdam/authorization_django/blob/71da52b38a7f5a16a2bde8f8ea97b3c11ccb1be1/authorization_django/middleware.py#L15-L41 |
Amsterdam/authorization_django | authorization_django/middleware.py | authorization_middleware | def authorization_middleware(get_response):
""" Django middleware to parse incoming access tokens, validate them and
set an authorization function on the request.
The decision to use a generic middleware rather than an
AuthenticationMiddleware is explicitly made, because inctances of the
latter com... | python | def authorization_middleware(get_response):
""" Django middleware to parse incoming access tokens, validate them and
set an authorization function on the request.
The decision to use a generic middleware rather than an
AuthenticationMiddleware is explicitly made, because inctances of the
latter com... | [
"def",
"authorization_middleware",
"(",
"get_response",
")",
":",
"middleware_settings",
"=",
"settings",
"(",
")",
"logger",
"=",
"_create_logger",
"(",
"middleware_settings",
")",
"min_scope",
"=",
"middleware_settings",
"[",
"'MIN_SCOPE'",
"]",
"def",
"get_token_su... | Django middleware to parse incoming access tokens, validate them and
set an authorization function on the request.
The decision to use a generic middleware rather than an
AuthenticationMiddleware is explicitly made, because inctances of the
latter come with a number of assumptions (i.e. that user.is_au... | [
"Django",
"middleware",
"to",
"parse",
"incoming",
"access",
"tokens",
"validate",
"them",
"and",
"set",
"an",
"authorization",
"function",
"on",
"the",
"request",
"."
] | train | https://github.com/Amsterdam/authorization_django/blob/71da52b38a7f5a16a2bde8f8ea97b3c11ccb1be1/authorization_django/middleware.py#L50-L254 |
EwilDawe/typy | typy/keyboard.py | press | def press(*keys):
"""
Simulates a key-press for all the keys passed to the function
:param keys: list of keys to be pressed
:return: None
"""
for key in keys:
win32api.keybd_event(codes[key], 0, 0, 0)
release(key) | python | def press(*keys):
"""
Simulates a key-press for all the keys passed to the function
:param keys: list of keys to be pressed
:return: None
"""
for key in keys:
win32api.keybd_event(codes[key], 0, 0, 0)
release(key) | [
"def",
"press",
"(",
"*",
"keys",
")",
":",
"for",
"key",
"in",
"keys",
":",
"win32api",
".",
"keybd_event",
"(",
"codes",
"[",
"key",
"]",
",",
"0",
",",
"0",
",",
"0",
")",
"release",
"(",
"key",
")"
] | Simulates a key-press for all the keys passed to the function
:param keys: list of keys to be pressed
:return: None | [
"Simulates",
"a",
"key",
"-",
"press",
"for",
"all",
"the",
"keys",
"passed",
"to",
"the",
"function"
] | train | https://github.com/EwilDawe/typy/blob/0349e7176567a4dbef318e75d9b3d6868950a1a9/typy/keyboard.py#L11-L21 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.