repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.complete | def complete(self, flag_message="Complete", padding=None, force=False):
""" Log Level: :attr:COMPLETE
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area... | python | def complete(self, flag_message="Complete", padding=None, force=False):
""" Log Level: :attr:COMPLETE
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area... | [
"def",
"complete",
"(",
"self",
",",
"flag_message",
"=",
"\"Complete\"",
",",
"padding",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"should_log",
"(",
"self",
".",
"COMPLETE",
")",
"or",
"force",
":",
"self",
".",
"_print_me... | Log Level: :attr:COMPLETE
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@color: #str colorizes @flag_message using :func:colori... | [
"Log",
"Level",
":",
":",
"attr",
":",
"COMPLETE"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1642-L1667 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.notice | def notice(self, flag_message="Notice", padding=None, force=False):
""" Log Level: :attr:NOTICE
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with ... | python | def notice(self, flag_message="Notice", padding=None, force=False):
""" Log Level: :attr:NOTICE
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with ... | [
"def",
"notice",
"(",
"self",
",",
"flag_message",
"=",
"\"Notice\"",
",",
"padding",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"should_log",
"(",
"self",
".",
"NOTICE",
")",
"or",
"force",
":",
"self",
".",
"_print_message"... | Log Level: :attr:NOTICE
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@color: #str colorizes @flag_message using :func:colorize... | [
"Log",
"Level",
":",
":",
"attr",
":",
"NOTICE"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1669-L1694 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.warning | def warning(self, flag_message="Warning", padding=None, force=False):
""" Log Level: :attr:WARNING
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area wi... | python | def warning(self, flag_message="Warning", padding=None, force=False):
""" Log Level: :attr:WARNING
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area wi... | [
"def",
"warning",
"(",
"self",
",",
"flag_message",
"=",
"\"Warning\"",
",",
"padding",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"should_log",
"(",
"self",
".",
"WARNING",
")",
"or",
"force",
":",
"self",
".",
"_print_messa... | Log Level: :attr:WARNING
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@color: #str colorizes @flag_message using :func:coloriz... | [
"Log",
"Level",
":",
":",
"attr",
":",
"WARNING"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1696-L1721 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.error | def error(self, flag_message="Error", padding=None, force=False):
""" Log Level: :attr:ERROR
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :fu... | python | def error(self, flag_message="Error", padding=None, force=False):
""" Log Level: :attr:ERROR
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :fu... | [
"def",
"error",
"(",
"self",
",",
"flag_message",
"=",
"\"Error\"",
",",
"padding",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"should_log",
"(",
"self",
".",
"ERROR",
")",
"or",
"force",
":",
"self",
".",
"_print_message",
... | Log Level: :attr:ERROR
@flag_message: #str flags the message with the given text
using :func:flag
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@color: #str colorizes @flag_message using :func:colorize
... | [
"Log",
"Level",
":",
":",
"attr",
":",
"ERROR"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1723-L1748 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.timing | def timing(self, flag_message, padding=None, force=False):
""" Log Level: :attr:TIMING
@flag_message: time-like #float
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@force: #bool whether or not to force the mes... | python | def timing(self, flag_message, padding=None, force=False):
""" Log Level: :attr:TIMING
@flag_message: time-like #float
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@force: #bool whether or not to force the mes... | [
"def",
"timing",
"(",
"self",
",",
"flag_message",
",",
"padding",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"should_log",
"(",
"self",
".",
"TIMING",
")",
"or",
"force",
":",
"self",
".",
"_print_message",
"(",
"flag_messag... | Log Level: :attr:TIMING
@flag_message: time-like #float
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@force: #bool whether or not to force the message to log in spite
of the assigned log level
... | [
"Log",
"Level",
":",
":",
"attr",
":",
"TIMING"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1750-L1773 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.count | def count(self, flag_message, padding=None, force=False):
""" Log Level: :attr:COUNT
@flag_message: time-like #float
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@force: #bool whether or not to force the messa... | python | def count(self, flag_message, padding=None, force=False):
""" Log Level: :attr:COUNT
@flag_message: time-like #float
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@force: #bool whether or not to force the messa... | [
"def",
"count",
"(",
"self",
",",
"flag_message",
",",
"padding",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"should_log",
"(",
"self",
".",
"COUNT",
")",
"or",
"force",
":",
"flag_message",
"=",
"flag_message",
"if",
"isinst... | Log Level: :attr:COUNT
@flag_message: time-like #float
@padding: #str 'top', 'bottom' or 'all', adds a new line to the
specified area with :func:padd
@force: #bool whether or not to force the message to log in spite
of the assigned log level
... | [
"Log",
"Level",
":",
":",
"attr",
":",
"COUNT"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1775-L1801 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.format_message | def format_message(self, message):
""" Formats a message with :class:Look """
look = Look(message)
return look.pretty(display=False) | python | def format_message(self, message):
""" Formats a message with :class:Look """
look = Look(message)
return look.pretty(display=False) | [
"def",
"format_message",
"(",
"self",
",",
"message",
")",
":",
"look",
"=",
"Look",
"(",
"message",
")",
"return",
"look",
".",
"pretty",
"(",
"display",
"=",
"False",
")"
] | Formats a message with :class:Look | [
"Formats",
"a",
"message",
"with",
":",
"class",
":",
"Look"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1804-L1807 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg.format_messages | def format_messages(self, messages):
""" Formats several messages with :class:Look, encodes them
with :func:vital.tools.encoding.stdout_encode """
mess = ""
for message in self.message:
if self.pretty:
mess = "{}{}".format(mess, self.format_message(message... | python | def format_messages(self, messages):
""" Formats several messages with :class:Look, encodes them
with :func:vital.tools.encoding.stdout_encode """
mess = ""
for message in self.message:
if self.pretty:
mess = "{}{}".format(mess, self.format_message(message... | [
"def",
"format_messages",
"(",
"self",
",",
"messages",
")",
":",
"mess",
"=",
"\"\"",
"for",
"message",
"in",
"self",
".",
"message",
":",
"if",
"self",
".",
"pretty",
":",
"mess",
"=",
"\"{}{}\"",
".",
"format",
"(",
"mess",
",",
"self",
".",
"form... | Formats several messages with :class:Look, encodes them
with :func:vital.tools.encoding.stdout_encode | [
"Formats",
"several",
"messages",
"with",
":",
"class",
":",
"Look",
"encodes",
"them",
"with",
":",
"func",
":",
"vital",
".",
"tools",
".",
"encoding",
".",
"stdout_encode"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1809-L1821 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Logg._print_message | def _print_message(self, flag_message=None, color=None, padding=None,
reverse=False):
""" Outputs the message to the terminal """
if flag_message:
flag_message = stdout_encode(flag(flag_message,
color=color if self.pretty e... | python | def _print_message(self, flag_message=None, color=None, padding=None,
reverse=False):
""" Outputs the message to the terminal """
if flag_message:
flag_message = stdout_encode(flag(flag_message,
color=color if self.pretty e... | [
"def",
"_print_message",
"(",
"self",
",",
"flag_message",
"=",
"None",
",",
"color",
"=",
"None",
",",
"padding",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"flag_message",
":",
"flag_message",
"=",
"stdout_encode",
"(",
"flag",
"(",
"fl... | Outputs the message to the terminal | [
"Outputs",
"the",
"message",
"to",
"the",
"terminal"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1824-L1839 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | ProgressBar.format_bar | def format_bar(self):
""" Builds the progress bar """
pct = floor(round(self.progress/self.size, 2)*100)
pr = floor(pct*.33)
bar = "".join(
["‒" for x in range(pr)] + ["↦"] +
[" " for o in range(self._barsize-pr-1)])
subprogress = self.format_parent_bar() ... | python | def format_bar(self):
""" Builds the progress bar """
pct = floor(round(self.progress/self.size, 2)*100)
pr = floor(pct*.33)
bar = "".join(
["‒" for x in range(pr)] + ["↦"] +
[" " for o in range(self._barsize-pr-1)])
subprogress = self.format_parent_bar() ... | [
"def",
"format_bar",
"(",
"self",
")",
":",
"pct",
"=",
"floor",
"(",
"round",
"(",
"self",
".",
"progress",
"/",
"self",
".",
"size",
",",
"2",
")",
"*",
"100",
")",
"pr",
"=",
"floor",
"(",
"pct",
"*",
".33",
")",
"bar",
"=",
"\"\"",
".",
"... | Builds the progress bar | [
"Builds",
"the",
"progress",
"bar"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1914-L1923 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | ProgressBar.finish | def finish(self):
""" Resets the progress bar and clears it from the terminal """
pct = floor(round(self.progress/self.size, 2)*100)
pr = floor(pct*.33)
bar = "".join([" " for x in range(pr-1)] + ["↦"])
subprogress = self.format_parent_bar() if self.parent_bar else ""
fin... | python | def finish(self):
""" Resets the progress bar and clears it from the terminal """
pct = floor(round(self.progress/self.size, 2)*100)
pr = floor(pct*.33)
bar = "".join([" " for x in range(pr-1)] + ["↦"])
subprogress = self.format_parent_bar() if self.parent_bar else ""
fin... | [
"def",
"finish",
"(",
"self",
")",
":",
"pct",
"=",
"floor",
"(",
"round",
"(",
"self",
".",
"progress",
"/",
"self",
".",
"size",
",",
"2",
")",
"*",
"100",
")",
"pr",
"=",
"floor",
"(",
"pct",
"*",
".33",
")",
"bar",
"=",
"\"\"",
".",
"join... | Resets the progress bar and clears it from the terminal | [
"Resets",
"the",
"progress",
"bar",
"and",
"clears",
"it",
"from",
"the",
"terminal"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1925-L1935 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | ProgressBar.update | def update(self, progress=0):
""" Updates the progress bar with @progress if given, otherwise
increments :prop:progress by 1. Also prints the progress bar.
@progress: #int to assign to :prop:progress
"""
self.progress += (progress or 1)
if self.visible:
... | python | def update(self, progress=0):
""" Updates the progress bar with @progress if given, otherwise
increments :prop:progress by 1. Also prints the progress bar.
@progress: #int to assign to :prop:progress
"""
self.progress += (progress or 1)
if self.visible:
... | [
"def",
"update",
"(",
"self",
",",
"progress",
"=",
"0",
")",
":",
"self",
".",
"progress",
"+=",
"(",
"progress",
"or",
"1",
")",
"if",
"self",
".",
"visible",
":",
"if",
"self",
".",
"progress",
"%",
"self",
".",
"_mod",
"==",
"1",
"or",
"self"... | Updates the progress bar with @progress if given, otherwise
increments :prop:progress by 1. Also prints the progress bar.
@progress: #int to assign to :prop:progress | [
"Updates",
"the",
"progress",
"bar",
"with",
"@progress",
"if",
"given",
"otherwise",
"increments",
":",
"prop",
":",
"progress",
"by",
"1",
".",
"Also",
"prints",
"the",
"progress",
"bar",
"."
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1937-L1949 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.start | def start(self):
""" Starts the timer """
if not self._start:
self._first_start = time.perf_counter()
self._start = self._first_start
else:
self._start = time.perf_counter() | python | def start(self):
""" Starts the timer """
if not self._start:
self._first_start = time.perf_counter()
self._start = self._first_start
else:
self._start = time.perf_counter() | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_start",
":",
"self",
".",
"_first_start",
"=",
"time",
".",
"perf_counter",
"(",
")",
"self",
".",
"_start",
"=",
"self",
".",
"_first_start",
"else",
":",
"self",
".",
"_start",
"=",... | Starts the timer | [
"Starts",
"the",
"timer"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2046-L2052 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.stop | def stop(self, precision=0):
""" Stops the timer, adds it as an interval to :prop:intervals
@precision: #int number of decimal places to round to
-> #str formatted interval time
"""
self._stop = time.perf_counter()
return self.add_interval(precision) | python | def stop(self, precision=0):
""" Stops the timer, adds it as an interval to :prop:intervals
@precision: #int number of decimal places to round to
-> #str formatted interval time
"""
self._stop = time.perf_counter()
return self.add_interval(precision) | [
"def",
"stop",
"(",
"self",
",",
"precision",
"=",
"0",
")",
":",
"self",
".",
"_stop",
"=",
"time",
".",
"perf_counter",
"(",
")",
"return",
"self",
".",
"add_interval",
"(",
"precision",
")"
] | Stops the timer, adds it as an interval to :prop:intervals
@precision: #int number of decimal places to round to
-> #str formatted interval time | [
"Stops",
"the",
"timer",
"adds",
"it",
"as",
"an",
"interval",
"to",
":",
"prop",
":",
"intervals",
"@precision",
":",
"#int",
"number",
"of",
"decimal",
"places",
"to",
"round",
"to"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2054-L2061 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.format_time | def format_time(self, sec):
""" Pretty-formats a given time in a readable manner
@sec: #int or #float seconds
-> #str formatted time
"""
# µsec
if sec < 0.001:
return "{}{}".format(
colorize(round(sec*1000000, 2), "purple"), bold("µs")... | python | def format_time(self, sec):
""" Pretty-formats a given time in a readable manner
@sec: #int or #float seconds
-> #str formatted time
"""
# µsec
if sec < 0.001:
return "{}{}".format(
colorize(round(sec*1000000, 2), "purple"), bold("µs")... | [
"def",
"format_time",
"(",
"self",
",",
"sec",
")",
":",
"# µsec",
"if",
"sec",
"<",
"0.001",
":",
"return",
"\"{}{}\"",
".",
"format",
"(",
"colorize",
"(",
"round",
"(",
"sec",
"*",
"1000000",
",",
"2",
")",
",",
"\"purple\"",
")",
",",
"bold",
"... | Pretty-formats a given time in a readable manner
@sec: #int or #float seconds
-> #str formatted time | [
"Pretty",
"-",
"formats",
"a",
"given",
"time",
"in",
"a",
"readable",
"manner",
"@sec",
":",
"#int",
"or",
"#float",
"seconds"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2064-L2088 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.format_size | def format_size(self, bytes):
""" Pretty-formats given bytes size in a readable manner
@bytes: #int or #float bytes
-> #str formatted bytes
"""
# b
if bytes < 1024:
return "{}{}".format(colorize(round(
bytes, 2), "purple"),
... | python | def format_size(self, bytes):
""" Pretty-formats given bytes size in a readable manner
@bytes: #int or #float bytes
-> #str formatted bytes
"""
# b
if bytes < 1024:
return "{}{}".format(colorize(round(
bytes, 2), "purple"),
... | [
"def",
"format_size",
"(",
"self",
",",
"bytes",
")",
":",
"# b",
"if",
"bytes",
"<",
"1024",
":",
"return",
"\"{}{}\"",
".",
"format",
"(",
"colorize",
"(",
"round",
"(",
"bytes",
",",
"2",
")",
",",
"\"purple\"",
")",
",",
"bold",
"(",
"\"bytes\"",... | Pretty-formats given bytes size in a readable manner
@bytes: #int or #float bytes
-> #str formatted bytes | [
"Pretty",
"-",
"formats",
"given",
"bytes",
"size",
"in",
"a",
"readable",
"manner",
"@bytes",
":",
"#int",
"or",
"#float",
"bytes"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2090-L2110 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.add_interval | def add_interval(self, precision=0):
""" Adds an interval to :prop:intervals
-> #str formatted time
"""
precision = precision or self.precision
interval = round((self._stop - self._start), precision)
self.intervals.append(interval)
self._intervals_len += 1
... | python | def add_interval(self, precision=0):
""" Adds an interval to :prop:intervals
-> #str formatted time
"""
precision = precision or self.precision
interval = round((self._stop - self._start), precision)
self.intervals.append(interval)
self._intervals_len += 1
... | [
"def",
"add_interval",
"(",
"self",
",",
"precision",
"=",
"0",
")",
":",
"precision",
"=",
"precision",
"or",
"self",
".",
"precision",
"interval",
"=",
"round",
"(",
"(",
"self",
".",
"_stop",
"-",
"self",
".",
"_start",
")",
",",
"precision",
")",
... | Adds an interval to :prop:intervals
-> #str formatted time | [
"Adds",
"an",
"interval",
"to",
":",
"prop",
":",
"intervals",
"-",
">",
"#str",
"formatted",
"time"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2112-L2121 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.time | def time(self, intervals=1, *args, _show_progress=True, _print=True,
_collect_garbage=True, _quiet=True, **kwargs):
""" Measures the execution time of :prop:_callable for @intervals
@intervals: #int number of intervals to measure the execution time
of the function for
... | python | def time(self, intervals=1, *args, _show_progress=True, _print=True,
_collect_garbage=True, _quiet=True, **kwargs):
""" Measures the execution time of :prop:_callable for @intervals
@intervals: #int number of intervals to measure the execution time
of the function for
... | [
"def",
"time",
"(",
"self",
",",
"intervals",
"=",
"1",
",",
"*",
"args",
",",
"_show_progress",
"=",
"True",
",",
"_print",
"=",
"True",
",",
"_collect_garbage",
"=",
"True",
",",
"_quiet",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"... | Measures the execution time of :prop:_callable for @intervals
@intervals: #int number of intervals to measure the execution time
of the function for
@*args: arguments to pass to the callable being timed
@**kwargs: arguments to pass to the callable being timed
... | [
"Measures",
"the",
"execution",
"time",
"of",
":",
"prop",
":",
"_callable",
"for",
"@intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2123-L2165 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.mean | def mean(self):
""" -> #float :func:numpy.mean of the timing intervals """
return round(np.mean(self.array), self.precision)\
if len(self.array) else None | python | def mean(self):
""" -> #float :func:numpy.mean of the timing intervals """
return round(np.mean(self.array), self.precision)\
if len(self.array) else None | [
"def",
"mean",
"(",
"self",
")",
":",
"return",
"round",
"(",
"np",
".",
"mean",
"(",
"self",
".",
"array",
")",
",",
"self",
".",
"precision",
")",
"if",
"len",
"(",
"self",
".",
"array",
")",
"else",
"None"
] | -> #float :func:numpy.mean of the timing intervals | [
"-",
">",
"#float",
":",
"func",
":",
"numpy",
".",
"mean",
"of",
"the",
"timing",
"intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2168-L2171 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.median | def median(self):
""" -> #float :func:numpy.median of the timing intervals """
return round(float(np.median(self.array)), self.precision)\
if len(self.array) else None | python | def median(self):
""" -> #float :func:numpy.median of the timing intervals """
return round(float(np.median(self.array)), self.precision)\
if len(self.array) else None | [
"def",
"median",
"(",
"self",
")",
":",
"return",
"round",
"(",
"float",
"(",
"np",
".",
"median",
"(",
"self",
".",
"array",
")",
")",
",",
"self",
".",
"precision",
")",
"if",
"len",
"(",
"self",
".",
"array",
")",
"else",
"None"
] | -> #float :func:numpy.median of the timing intervals | [
"-",
">",
"#float",
":",
"func",
":",
"numpy",
".",
"median",
"of",
"the",
"timing",
"intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2174-L2177 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.max | def max(self):
""" -> #float :func:numpy.max of the timing intervals """
return round(np.max(self.array), self.precision)\
if len(self.array) else None | python | def max(self):
""" -> #float :func:numpy.max of the timing intervals """
return round(np.max(self.array), self.precision)\
if len(self.array) else None | [
"def",
"max",
"(",
"self",
")",
":",
"return",
"round",
"(",
"np",
".",
"max",
"(",
"self",
".",
"array",
")",
",",
"self",
".",
"precision",
")",
"if",
"len",
"(",
"self",
".",
"array",
")",
"else",
"None"
] | -> #float :func:numpy.max of the timing intervals | [
"-",
">",
"#float",
":",
"func",
":",
"numpy",
".",
"max",
"of",
"the",
"timing",
"intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2180-L2183 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.min | def min(self):
""" -> #float :func:numpy.min of the timing intervals """
return round(np.min(self.array), self.precision)\
if len(self.array) else None | python | def min(self):
""" -> #float :func:numpy.min of the timing intervals """
return round(np.min(self.array), self.precision)\
if len(self.array) else None | [
"def",
"min",
"(",
"self",
")",
":",
"return",
"round",
"(",
"np",
".",
"min",
"(",
"self",
".",
"array",
")",
",",
"self",
".",
"precision",
")",
"if",
"len",
"(",
"self",
".",
"array",
")",
"else",
"None"
] | -> #float :func:numpy.min of the timing intervals | [
"-",
">",
"#float",
":",
"func",
":",
"numpy",
".",
"min",
"of",
"the",
"timing",
"intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2186-L2189 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.stdev | def stdev(self):
""" -> #float :func:numpy.std of the timing intervals """
return round(np.std(self.array), self.precision)\
if len(self.array) else None | python | def stdev(self):
""" -> #float :func:numpy.std of the timing intervals """
return round(np.std(self.array), self.precision)\
if len(self.array) else None | [
"def",
"stdev",
"(",
"self",
")",
":",
"return",
"round",
"(",
"np",
".",
"std",
"(",
"self",
".",
"array",
")",
",",
"self",
".",
"precision",
")",
"if",
"len",
"(",
"self",
".",
"array",
")",
"else",
"None"
] | -> #float :func:numpy.std of the timing intervals | [
"-",
">",
"#float",
":",
"func",
":",
"numpy",
".",
"std",
"of",
"the",
"timing",
"intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2192-L2195 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Timer.stats | def stats(self):
""" -> :class:collections.OrderedDict of stats about the time intervals
"""
return OrderedDict([
("Intervals", len(self.array)),
("Mean", self.format_time(self.mean or 0)),
("Min", self.format_time(self.min or 0)),
("Median", self.... | python | def stats(self):
""" -> :class:collections.OrderedDict of stats about the time intervals
"""
return OrderedDict([
("Intervals", len(self.array)),
("Mean", self.format_time(self.mean or 0)),
("Min", self.format_time(self.min or 0)),
("Median", self.... | [
"def",
"stats",
"(",
"self",
")",
":",
"return",
"OrderedDict",
"(",
"[",
"(",
"\"Intervals\"",
",",
"len",
"(",
"self",
".",
"array",
")",
")",
",",
"(",
"\"Mean\"",
",",
"self",
".",
"format_time",
"(",
"self",
".",
"mean",
"or",
"0",
")",
")",
... | -> :class:collections.OrderedDict of stats about the time intervals | [
"-",
">",
":",
"class",
":",
"collections",
".",
"OrderedDict",
"of",
"stats",
"about",
"the",
"time",
"intervals"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2208-L2219 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Compare._pct_diff | def _pct_diff(self, best, other):
""" Calculates and colorizes the percent difference between @best
and @other
"""
return colorize("{}%".format(
round(((best-other)/best)*100, 2)).rjust(10), "red") | python | def _pct_diff(self, best, other):
""" Calculates and colorizes the percent difference between @best
and @other
"""
return colorize("{}%".format(
round(((best-other)/best)*100, 2)).rjust(10), "red") | [
"def",
"_pct_diff",
"(",
"self",
",",
"best",
",",
"other",
")",
":",
"return",
"colorize",
"(",
"\"{}%\"",
".",
"format",
"(",
"round",
"(",
"(",
"(",
"best",
"-",
"other",
")",
"/",
"best",
")",
"*",
"100",
",",
"2",
")",
")",
".",
"rjust",
"... | Calculates and colorizes the percent difference between @best
and @other | [
"Calculates",
"and",
"colorizes",
"the",
"percent",
"difference",
"between"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2367-L2372 | train |
jaredLunde/vital-tools | vital/debug/__init__.py | Compare.info | def info(self, verbose=None):
""" Prints and formats the results of the timing
@_print: #bool whether or not to print out to terminal
@verbose: #bool True if you'd like to print the individual timing
results in additions to the comparison results
"""
if se... | python | def info(self, verbose=None):
""" Prints and formats the results of the timing
@_print: #bool whether or not to print out to terminal
@verbose: #bool True if you'd like to print the individual timing
results in additions to the comparison results
"""
if se... | [
"def",
"info",
"(",
"self",
",",
"verbose",
"=",
"None",
")",
":",
"if",
"self",
".",
"name",
":",
"flag",
"(",
"bold",
"(",
"self",
".",
"name",
")",
")",
"flag",
"(",
"\"Results after {} intervals\"",
".",
"format",
"(",
"bold",
"(",
"self",
".",
... | Prints and formats the results of the timing
@_print: #bool whether or not to print out to terminal
@verbose: #bool True if you'd like to print the individual timing
results in additions to the comparison results | [
"Prints",
"and",
"formats",
"the",
"results",
"of",
"the",
"timing"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L2374-L2408 | train |
kajala/django-jutil | jutil/management/commands/bank_const_fi.py | fi_iban_load_map | def fi_iban_load_map(filename: str) -> dict:
"""
Loads Finnish monetary institution codes and BICs in CSV format.
Map which is based on 3 digits as in FIXX<3 digits>.
Can be used to map Finnish IBAN number to bank information.
Format: dict('<3 digits': (BIC, name), ...)
:param filename: CSV file... | python | def fi_iban_load_map(filename: str) -> dict:
"""
Loads Finnish monetary institution codes and BICs in CSV format.
Map which is based on 3 digits as in FIXX<3 digits>.
Can be used to map Finnish IBAN number to bank information.
Format: dict('<3 digits': (BIC, name), ...)
:param filename: CSV file... | [
"def",
"fi_iban_load_map",
"(",
"filename",
":",
"str",
")",
"->",
"dict",
":",
"out",
"=",
"{",
"}",
"with",
"open",
"(",
"filename",
",",
"'rt'",
")",
"as",
"fp",
":",
"lines",
"=",
"[",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"','",... | Loads Finnish monetary institution codes and BICs in CSV format.
Map which is based on 3 digits as in FIXX<3 digits>.
Can be used to map Finnish IBAN number to bank information.
Format: dict('<3 digits': (BIC, name), ...)
:param filename: CSV file name of the BIC definitions. Columns: National ID, BIC C... | [
"Loads",
"Finnish",
"monetary",
"institution",
"codes",
"and",
"BICs",
"in",
"CSV",
"format",
".",
"Map",
"which",
"is",
"based",
"on",
"3",
"digits",
"as",
"in",
"FIXX<3",
"digits",
">",
".",
"Can",
"be",
"used",
"to",
"map",
"Finnish",
"IBAN",
"number"... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/management/commands/bank_const_fi.py#L9-L30 | train |
jaredLunde/vital-tools | vital/cache/async_decorators.py | async_lru | def async_lru(size=100):
""" An LRU cache for asyncio coroutines in Python 3.5
..
@async_lru(1024)
async def slow_coroutine(*args, **kwargs):
return await some_other_slow_coroutine()
..
"""
cache = collections.OrderedDict()
def decorator(fn):
... | python | def async_lru(size=100):
""" An LRU cache for asyncio coroutines in Python 3.5
..
@async_lru(1024)
async def slow_coroutine(*args, **kwargs):
return await some_other_slow_coroutine()
..
"""
cache = collections.OrderedDict()
def decorator(fn):
... | [
"def",
"async_lru",
"(",
"size",
"=",
"100",
")",
":",
"cache",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"def",
"decorator",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"@",
"asyncio",
".",
"coroutine",
"def",
"memoizer",
"(",
"*",
... | An LRU cache for asyncio coroutines in Python 3.5
..
@async_lru(1024)
async def slow_coroutine(*args, **kwargs):
return await some_other_slow_coroutine()
.. | [
"An",
"LRU",
"cache",
"for",
"asyncio",
"coroutines",
"in",
"Python",
"3",
".",
"5",
".."
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/cache/async_decorators.py#L7-L31 | train |
kajala/django-jutil | jutil/dict.py | choices_label | def choices_label(choices: tuple, value) -> str:
"""
Iterates (value,label) list and returns label matching the choice
:param choices: [(choice1, label1), (choice2, label2), ...]
:param value: Value to find
:return: label or None
"""
for key, label in choices:
if key == value:
... | python | def choices_label(choices: tuple, value) -> str:
"""
Iterates (value,label) list and returns label matching the choice
:param choices: [(choice1, label1), (choice2, label2), ...]
:param value: Value to find
:return: label or None
"""
for key, label in choices:
if key == value:
... | [
"def",
"choices_label",
"(",
"choices",
":",
"tuple",
",",
"value",
")",
"->",
"str",
":",
"for",
"key",
",",
"label",
"in",
"choices",
":",
"if",
"key",
"==",
"value",
":",
"return",
"label",
"return",
"''"
] | Iterates (value,label) list and returns label matching the choice
:param choices: [(choice1, label1), (choice2, label2), ...]
:param value: Value to find
:return: label or None | [
"Iterates",
"(",
"value",
"label",
")",
"list",
"and",
"returns",
"label",
"matching",
"the",
"choice",
":",
"param",
"choices",
":",
"[",
"(",
"choice1",
"label1",
")",
"(",
"choice2",
"label2",
")",
"...",
"]",
":",
"param",
"value",
":",
"Value",
"t... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/dict.py#L13-L23 | train |
novopl/peltak | src/peltak/core/log.py | info | def info(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Print sys message to stdout.
System messages should inform about the flow of the script. This should
be a major milestones during the build.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-... | python | def info(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Print sys message to stdout.
System messages should inform about the flow of the script. This should
be a major milestones during the build.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-... | [
"def",
"info",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# type: (str, *Any, **Any) -> None",
"if",
"len",
"(",
"args",
")",
"or",
"len",
"(",
"kw",
")",
":",
"msg",
"=",
"msg",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
... | Print sys message to stdout.
System messages should inform about the flow of the script. This should
be a major milestones during the build. | [
"Print",
"sys",
"message",
"to",
"stdout",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/log.py#L28-L38 | train |
novopl/peltak | src/peltak/core/log.py | err | def err(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Per step status messages
Use this locally in a command definition to highlight more important
information.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-- <31>{}<0>'.format(msg)) | python | def err(msg, *args, **kw):
# type: (str, *Any, **Any) -> None
""" Per step status messages
Use this locally in a command definition to highlight more important
information.
"""
if len(args) or len(kw):
msg = msg.format(*args, **kw)
shell.cprint('-- <31>{}<0>'.format(msg)) | [
"def",
"err",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# type: (str, *Any, **Any) -> None",
"if",
"len",
"(",
"args",
")",
"or",
"len",
"(",
"kw",
")",
":",
"msg",
"=",
"msg",
".",
"format",
"(",
"*",
"args",
",",
"*",
"*",
... | Per step status messages
Use this locally in a command definition to highlight more important
information. | [
"Per",
"step",
"status",
"messages"
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/log.py#L41-L51 | train |
jaredLunde/vital-tools | vital/tools/strings.py | is_username | def is_username(string, minlen=1, maxlen=15):
""" Determines whether the @string pattern is username-like
@string: #str being tested
@minlen: minimum required username length
@maxlen: maximum username length
-> #bool
"""
if string:
string = string.strip()
ret... | python | def is_username(string, minlen=1, maxlen=15):
""" Determines whether the @string pattern is username-like
@string: #str being tested
@minlen: minimum required username length
@maxlen: maximum username length
-> #bool
"""
if string:
string = string.strip()
ret... | [
"def",
"is_username",
"(",
"string",
",",
"minlen",
"=",
"1",
",",
"maxlen",
"=",
"15",
")",
":",
"if",
"string",
":",
"string",
"=",
"string",
".",
"strip",
"(",
")",
"return",
"username_re",
".",
"match",
"(",
"string",
")",
"and",
"(",
"minlen",
... | Determines whether the @string pattern is username-like
@string: #str being tested
@minlen: minimum required username length
@maxlen: maximum username length
-> #bool | [
"Determines",
"whether",
"the",
"@string",
"pattern",
"is",
"username",
"-",
"like",
"@string",
":",
"#str",
"being",
"tested",
"@minlen",
":",
"minimum",
"required",
"username",
"length",
"@maxlen",
":",
"maximum",
"username",
"length"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L61-L72 | train |
jaredLunde/vital-tools | vital/tools/strings.py | bigint_to_string | def bigint_to_string(val):
""" Converts @val to a string if it is a big integer (|>2**53-1|)
@val: #int or #float
-> #str if @val is a big integer, otherwise @val
"""
if isinstance(val, _NUMBERS) and not abs(val) <= 2**53-1:
return str(val)
return val | python | def bigint_to_string(val):
""" Converts @val to a string if it is a big integer (|>2**53-1|)
@val: #int or #float
-> #str if @val is a big integer, otherwise @val
"""
if isinstance(val, _NUMBERS) and not abs(val) <= 2**53-1:
return str(val)
return val | [
"def",
"bigint_to_string",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"_NUMBERS",
")",
"and",
"not",
"abs",
"(",
"val",
")",
"<=",
"2",
"**",
"53",
"-",
"1",
":",
"return",
"str",
"(",
"val",
")",
"return",
"val"
] | Converts @val to a string if it is a big integer (|>2**53-1|)
@val: #int or #float
-> #str if @val is a big integer, otherwise @val | [
"Converts",
"@val",
"to",
"a",
"string",
"if",
"it",
"is",
"a",
"big",
"integer",
"(",
"|",
">",
"2",
"**",
"53",
"-",
"1|",
")"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L91-L100 | train |
jaredLunde/vital-tools | vital/tools/strings.py | rbigint_to_string | def rbigint_to_string(obj):
""" Recursively converts big integers (|>2**53-1|) to strings
@obj: Any python object
-> @obj, with any big integers converted to #str objects
"""
if isinstance(obj, (str, bytes)) or not obj:
# the input is the desired one, return as is
return ob... | python | def rbigint_to_string(obj):
""" Recursively converts big integers (|>2**53-1|) to strings
@obj: Any python object
-> @obj, with any big integers converted to #str objects
"""
if isinstance(obj, (str, bytes)) or not obj:
# the input is the desired one, return as is
return ob... | [
"def",
"rbigint_to_string",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"str",
",",
"bytes",
")",
")",
"or",
"not",
"obj",
":",
"# the input is the desired one, return as is",
"return",
"obj",
"elif",
"hasattr",
"(",
"obj",
",",
"'items'"... | Recursively converts big integers (|>2**53-1|) to strings
@obj: Any python object
-> @obj, with any big integers converted to #str objects | [
"Recursively",
"converts",
"big",
"integers",
"(",
"|",
">",
"2",
"**",
"53",
"-",
"1|",
")",
"to",
"strings"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L104-L127 | train |
jaredLunde/vital-tools | vital/tools/strings.py | remove_blank_lines | def remove_blank_lines(string):
""" Removes all blank lines in @string
-> #str without blank lines
"""
return "\n".join(line
for line in string.split("\n")
if len(line.strip())) | python | def remove_blank_lines(string):
""" Removes all blank lines in @string
-> #str without blank lines
"""
return "\n".join(line
for line in string.split("\n")
if len(line.strip())) | [
"def",
"remove_blank_lines",
"(",
"string",
")",
":",
"return",
"\"\\n\"",
".",
"join",
"(",
"line",
"for",
"line",
"in",
"string",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"len",
"(",
"line",
".",
"strip",
"(",
")",
")",
")"
] | Removes all blank lines in @string
-> #str without blank lines | [
"Removes",
"all",
"blank",
"lines",
"in",
"@string"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/strings.py#L214-L221 | train |
novopl/peltak | src/peltak_django/cli.py | _manage_cmd | def _manage_cmd(cmd, settings=None):
# type: () -> None
""" Run django ./manage.py command manually.
This function eliminates the need for having ``manage.py`` (reduces file
clutter).
"""
import sys
from os import environ
from peltak.core import conf
from peltak.core import context
... | python | def _manage_cmd(cmd, settings=None):
# type: () -> None
""" Run django ./manage.py command manually.
This function eliminates the need for having ``manage.py`` (reduces file
clutter).
"""
import sys
from os import environ
from peltak.core import conf
from peltak.core import context
... | [
"def",
"_manage_cmd",
"(",
"cmd",
",",
"settings",
"=",
"None",
")",
":",
"# type: () -> None",
"import",
"sys",
"from",
"os",
"import",
"environ",
"from",
"peltak",
".",
"core",
"import",
"conf",
"from",
"peltak",
".",
"core",
"import",
"context",
"from",
... | Run django ./manage.py command manually.
This function eliminates the need for having ``manage.py`` (reduces file
clutter). | [
"Run",
"django",
".",
"/",
"manage",
".",
"py",
"command",
"manually",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak_django/cli.py#L172-L196 | train |
novopl/peltak | src/peltak/core/git.py | current_branch | def current_branch():
# type: () -> BranchDetails
""" Return the BranchDetails for the current branch.
Return:
BranchDetails: The details of the current branch.
"""
cmd = 'git symbolic-ref --short HEAD'
branch_name = shell.run(
cmd,
capture=True,
never_pretend=Tr... | python | def current_branch():
# type: () -> BranchDetails
""" Return the BranchDetails for the current branch.
Return:
BranchDetails: The details of the current branch.
"""
cmd = 'git symbolic-ref --short HEAD'
branch_name = shell.run(
cmd,
capture=True,
never_pretend=Tr... | [
"def",
"current_branch",
"(",
")",
":",
"# type: () -> BranchDetails",
"cmd",
"=",
"'git symbolic-ref --short HEAD'",
"branch_name",
"=",
"shell",
".",
"run",
"(",
"cmd",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
... | Return the BranchDetails for the current branch.
Return:
BranchDetails: The details of the current branch. | [
"Return",
"the",
"BranchDetails",
"for",
"the",
"current",
"branch",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L181-L195 | train |
novopl/peltak | src/peltak/core/git.py | commit_branches | def commit_branches(sha1):
# type: (str) -> List[str]
""" Get the name of the branches that this commit belongs to. """
cmd = 'git branch --contains {}'.format(sha1)
return shell.run(
cmd,
capture=True,
never_pretend=True
).stdout.strip().split() | python | def commit_branches(sha1):
# type: (str) -> List[str]
""" Get the name of the branches that this commit belongs to. """
cmd = 'git branch --contains {}'.format(sha1)
return shell.run(
cmd,
capture=True,
never_pretend=True
).stdout.strip().split() | [
"def",
"commit_branches",
"(",
"sha1",
")",
":",
"# type: (str) -> List[str]",
"cmd",
"=",
"'git branch --contains {}'",
".",
"format",
"(",
"sha1",
")",
"return",
"shell",
".",
"run",
"(",
"cmd",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",... | Get the name of the branches that this commit belongs to. | [
"Get",
"the",
"name",
"of",
"the",
"branches",
"that",
"this",
"commit",
"belongs",
"to",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L226-L234 | train |
novopl/peltak | src/peltak/core/git.py | guess_base_branch | def guess_base_branch():
# type: (str) -> Optional[str, None]
""" Try to guess the base branch for the current branch.
Do not trust this guess. git makes it pretty much impossible to guess
the base branch reliably so this function implements few heuristics that
will work on most common use cases bu... | python | def guess_base_branch():
# type: (str) -> Optional[str, None]
""" Try to guess the base branch for the current branch.
Do not trust this guess. git makes it pretty much impossible to guess
the base branch reliably so this function implements few heuristics that
will work on most common use cases bu... | [
"def",
"guess_base_branch",
"(",
")",
":",
"# type: (str) -> Optional[str, None]",
"my_branch",
"=",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
".",
"name",
"curr",
"=",
"latest_commit",
"(",
")",
"if",
"len",
"(",
"curr",
".",
"branches",
")",
">",
... | Try to guess the base branch for the current branch.
Do not trust this guess. git makes it pretty much impossible to guess
the base branch reliably so this function implements few heuristics that
will work on most common use cases but anything a bit crazy will probably
trip this function.
Returns:... | [
"Try",
"to",
"guess",
"the",
"base",
"branch",
"for",
"the",
"current",
"branch",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L238-L291 | train |
novopl/peltak | src/peltak/core/git.py | commit_author | def commit_author(sha1=''):
# type: (str) -> Author
""" Return the author of the given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return the
sha1 for the current commit.
Returns:
Author: A named tuple ``(name, email)`` with t... | python | def commit_author(sha1=''):
# type: (str) -> Author
""" Return the author of the given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return the
sha1 for the current commit.
Returns:
Author: A named tuple ``(name, email)`` with t... | [
"def",
"commit_author",
"(",
"sha1",
"=",
"''",
")",
":",
"# type: (str) -> Author",
"with",
"conf",
".",
"within_proj_dir",
"(",
")",
":",
"cmd",
"=",
"'git show -s --format=\"%an||%ae\" {}'",
".",
"format",
"(",
"sha1",
")",
"result",
"=",
"shell",
".",
"run... | Return the author of the given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return the
sha1 for the current commit.
Returns:
Author: A named tuple ``(name, email)`` with the commit author details. | [
"Return",
"the",
"author",
"of",
"the",
"given",
"commit",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L295-L314 | train |
novopl/peltak | src/peltak/core/git.py | unstaged | def unstaged():
# type: () -> List[str]
""" Return a list of unstaged files in the project repository.
Returns:
list[str]: The list of files not tracked by project git repo.
"""
with conf.within_proj_dir():
status = shell.run(
'git status --porcelain',
captur... | python | def unstaged():
# type: () -> List[str]
""" Return a list of unstaged files in the project repository.
Returns:
list[str]: The list of files not tracked by project git repo.
"""
with conf.within_proj_dir():
status = shell.run(
'git status --porcelain',
captur... | [
"def",
"unstaged",
"(",
")",
":",
"# type: () -> List[str]",
"with",
"conf",
".",
"within_proj_dir",
"(",
")",
":",
"status",
"=",
"shell",
".",
"run",
"(",
"'git status --porcelain'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",... | Return a list of unstaged files in the project repository.
Returns:
list[str]: The list of files not tracked by project git repo. | [
"Return",
"a",
"list",
"of",
"unstaged",
"files",
"in",
"the",
"project",
"repository",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L341-L360 | train |
novopl/peltak | src/peltak/core/git.py | ignore | def ignore():
# type: () -> List[str]
""" Return a list of patterns in the project .gitignore
Returns:
list[str]: List of patterns set to be ignored by git.
"""
def parse_line(line): # pylint: disable=missing-docstring
# Decode if necessary
if not isinstance(line, string_... | python | def ignore():
# type: () -> List[str]
""" Return a list of patterns in the project .gitignore
Returns:
list[str]: List of patterns set to be ignored by git.
"""
def parse_line(line): # pylint: disable=missing-docstring
# Decode if necessary
if not isinstance(line, string_... | [
"def",
"ignore",
"(",
")",
":",
"# type: () -> List[str]",
"def",
"parse_line",
"(",
"line",
")",
":",
"# pylint: disable=missing-docstring",
"# Decode if necessary",
"if",
"not",
"isinstance",
"(",
"line",
",",
"string_types",
")",
":",
"line",
"=",
"line",
".",
... | Return a list of patterns in the project .gitignore
Returns:
list[str]: List of patterns set to be ignored by git. | [
"Return",
"a",
"list",
"of",
"patterns",
"in",
"the",
"project",
".",
"gitignore"
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L387-L420 | train |
novopl/peltak | src/peltak/core/git.py | branches | def branches():
# type: () -> List[str]
""" Return a list of branches in the current repo.
Returns:
list[str]: A list of branches in the current repo.
"""
out = shell.run(
'git branch',
capture=True,
never_pretend=True
).stdout.strip()
return [x.strip('* \t\n... | python | def branches():
# type: () -> List[str]
""" Return a list of branches in the current repo.
Returns:
list[str]: A list of branches in the current repo.
"""
out = shell.run(
'git branch',
capture=True,
never_pretend=True
).stdout.strip()
return [x.strip('* \t\n... | [
"def",
"branches",
"(",
")",
":",
"# type: () -> List[str]",
"out",
"=",
"shell",
".",
"run",
"(",
"'git branch'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
"return",
"[",
"x",
".",
"str... | Return a list of branches in the current repo.
Returns:
list[str]: A list of branches in the current repo. | [
"Return",
"a",
"list",
"of",
"branches",
"in",
"the",
"current",
"repo",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L424-L436 | train |
novopl/peltak | src/peltak/core/git.py | tag | def tag(name, message, author=None):
# type: (str, str, Author, bool) -> None
""" Tag the current commit.
Args:
name (str):
The tag name.
message (str):
The tag message. Same as ``-m`` parameter in ``git tag``.
author (Author):
The commit author. ... | python | def tag(name, message, author=None):
# type: (str, str, Author, bool) -> None
""" Tag the current commit.
Args:
name (str):
The tag name.
message (str):
The tag message. Same as ``-m`` parameter in ``git tag``.
author (Author):
The commit author. ... | [
"def",
"tag",
"(",
"name",
",",
"message",
",",
"author",
"=",
"None",
")",
":",
"# type: (str, str, Author, bool) -> None",
"cmd",
"=",
"(",
"'git -c \"user.name={author.name}\" -c \"user.email={author.email}\" '",
"'tag -a \"{name}\" -m \"{message}\"'",
")",
".",
"format",
... | Tag the current commit.
Args:
name (str):
The tag name.
message (str):
The tag message. Same as ``-m`` parameter in ``git tag``.
author (Author):
The commit author. Will default to the author of the commit.
pretend (bool):
If set to **... | [
"Tag",
"the",
"current",
"commit",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L439-L462 | train |
novopl/peltak | src/peltak/core/git.py | config | def config():
# type: () -> dict[str, Any]
""" Return the current git configuration.
Returns:
dict[str, Any]: The current git config taken from ``git config --list``.
"""
out = shell.run(
'git config --list',
capture=True,
never_pretend=True
).stdout.strip()
... | python | def config():
# type: () -> dict[str, Any]
""" Return the current git configuration.
Returns:
dict[str, Any]: The current git config taken from ``git config --list``.
"""
out = shell.run(
'git config --list',
capture=True,
never_pretend=True
).stdout.strip()
... | [
"def",
"config",
"(",
")",
":",
"# type: () -> dict[str, Any]",
"out",
"=",
"shell",
".",
"run",
"(",
"'git config --list'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
"result",
"=",
"{",
"... | Return the current git configuration.
Returns:
dict[str, Any]: The current git config taken from ``git config --list``. | [
"Return",
"the",
"current",
"git",
"configuration",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L466-L484 | train |
novopl/peltak | src/peltak/core/git.py | tags | def tags():
# type: () -> List[str]
""" Returns all tags in the repo.
Returns:
list[str]: List of all tags in the repo, sorted as versions.
All tags returned by this function will be parsed as if the contained
versions (using ``v:refname`` sorting).
"""
return shell.run(
'g... | python | def tags():
# type: () -> List[str]
""" Returns all tags in the repo.
Returns:
list[str]: List of all tags in the repo, sorted as versions.
All tags returned by this function will be parsed as if the contained
versions (using ``v:refname`` sorting).
"""
return shell.run(
'g... | [
"def",
"tags",
"(",
")",
":",
"# type: () -> List[str]",
"return",
"shell",
".",
"run",
"(",
"'git tag --sort=v:refname'",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
")",
".",
"stdout",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
"... | Returns all tags in the repo.
Returns:
list[str]: List of all tags in the repo, sorted as versions.
All tags returned by this function will be parsed as if the contained
versions (using ``v:refname`` sorting). | [
"Returns",
"all",
"tags",
"in",
"the",
"repo",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L488-L502 | train |
novopl/peltak | src/peltak/core/git.py | verify_branch | def verify_branch(branch_name):
# type: (str) -> bool
""" Verify if the given branch exists.
Args:
branch_name (str):
The name of the branch to check.
Returns:
bool: **True** if a branch with name *branch_name* exits, **False**
otherwise.
"""
try:
sh... | python | def verify_branch(branch_name):
# type: (str) -> bool
""" Verify if the given branch exists.
Args:
branch_name (str):
The name of the branch to check.
Returns:
bool: **True** if a branch with name *branch_name* exits, **False**
otherwise.
"""
try:
sh... | [
"def",
"verify_branch",
"(",
"branch_name",
")",
":",
"# type: (str) -> bool",
"try",
":",
"shell",
".",
"run",
"(",
"'git rev-parse --verify {}'",
".",
"format",
"(",
"branch_name",
")",
",",
"never_pretend",
"=",
"True",
")",
"return",
"True",
"except",
"IOErr... | Verify if the given branch exists.
Args:
branch_name (str):
The name of the branch to check.
Returns:
bool: **True** if a branch with name *branch_name* exits, **False**
otherwise. | [
"Verify",
"if",
"the",
"given",
"branch",
"exists",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L505-L524 | train |
novopl/peltak | src/peltak/core/git.py | protected_branches | def protected_branches():
# type: () -> list[str]
""" Return branches protected by deletion.
By default those are master and devel branches as configured in pelconf.
Returns:
list[str]: Names of important branches that should not be deleted.
"""
master = conf.get('git.master_branch', '... | python | def protected_branches():
# type: () -> list[str]
""" Return branches protected by deletion.
By default those are master and devel branches as configured in pelconf.
Returns:
list[str]: Names of important branches that should not be deleted.
"""
master = conf.get('git.master_branch', '... | [
"def",
"protected_branches",
"(",
")",
":",
"# type: () -> list[str]",
"master",
"=",
"conf",
".",
"get",
"(",
"'git.master_branch'",
",",
"'master'",
")",
"develop",
"=",
"conf",
".",
"get",
"(",
"'git.devel_branch'",
",",
"'develop'",
")",
"return",
"conf",
... | Return branches protected by deletion.
By default those are master and devel branches as configured in pelconf.
Returns:
list[str]: Names of important branches that should not be deleted. | [
"Return",
"branches",
"protected",
"by",
"deletion",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L528-L539 | train |
novopl/peltak | src/peltak/core/git.py | CommitDetails.branches | def branches(self):
# type: () -> List[str]
""" List of all branches this commit is a part of. """
if self._branches is None:
cmd = 'git branch --contains {}'.format(self.sha1)
out = shell.run(
cmd,
capture=True,
never_prete... | python | def branches(self):
# type: () -> List[str]
""" List of all branches this commit is a part of. """
if self._branches is None:
cmd = 'git branch --contains {}'.format(self.sha1)
out = shell.run(
cmd,
capture=True,
never_prete... | [
"def",
"branches",
"(",
"self",
")",
":",
"# type: () -> List[str]",
"if",
"self",
".",
"_branches",
"is",
"None",
":",
"cmd",
"=",
"'git branch --contains {}'",
".",
"format",
"(",
"self",
".",
"sha1",
")",
"out",
"=",
"shell",
".",
"run",
"(",
"cmd",
"... | List of all branches this commit is a part of. | [
"List",
"of",
"all",
"branches",
"this",
"commit",
"is",
"a",
"part",
"of",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L107-L119 | train |
novopl/peltak | src/peltak/core/git.py | CommitDetails.parents | def parents(self):
# type: () -> List[CommitDetails]
""" Parents of the this commit. """
if self._parents is None:
self._parents = [CommitDetails.get(x) for x in self.parents_sha1]
return self._parents | python | def parents(self):
# type: () -> List[CommitDetails]
""" Parents of the this commit. """
if self._parents is None:
self._parents = [CommitDetails.get(x) for x in self.parents_sha1]
return self._parents | [
"def",
"parents",
"(",
"self",
")",
":",
"# type: () -> List[CommitDetails]",
"if",
"self",
".",
"_parents",
"is",
"None",
":",
"self",
".",
"_parents",
"=",
"[",
"CommitDetails",
".",
"get",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"parents_sha1",
... | Parents of the this commit. | [
"Parents",
"of",
"the",
"this",
"commit",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L122-L128 | train |
novopl/peltak | src/peltak/core/git.py | CommitDetails.number | def number(self):
# type: () -> int
""" Return this commits number.
This is the same as the total number of commits in history up until
this commit.
This value can be useful in some CI scenarios as it allows to track
progress on any given branch (although there can be t... | python | def number(self):
# type: () -> int
""" Return this commits number.
This is the same as the total number of commits in history up until
this commit.
This value can be useful in some CI scenarios as it allows to track
progress on any given branch (although there can be t... | [
"def",
"number",
"(",
"self",
")",
":",
"# type: () -> int",
"cmd",
"=",
"'git log --oneline {}'",
".",
"format",
"(",
"self",
".",
"sha1",
")",
"out",
"=",
"shell",
".",
"run",
"(",
"cmd",
",",
"capture",
"=",
"True",
",",
"never_pretend",
"=",
"True",
... | Return this commits number.
This is the same as the total number of commits in history up until
this commit.
This value can be useful in some CI scenarios as it allows to track
progress on any given branch (although there can be two commits with the
same number existing on diff... | [
"Return",
"this",
"commits",
"number",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L131-L147 | train |
novopl/peltak | src/peltak/core/git.py | CommitDetails.get | def get(cls, sha1=''):
# type: (str) -> CommitDetails
""" Return details about a given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return
the details for the latest commit.
Returns:
CommitDetai... | python | def get(cls, sha1=''):
# type: (str) -> CommitDetails
""" Return details about a given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return
the details for the latest commit.
Returns:
CommitDetai... | [
"def",
"get",
"(",
"cls",
",",
"sha1",
"=",
"''",
")",
":",
"# type: (str) -> CommitDetails",
"with",
"conf",
".",
"within_proj_dir",
"(",
")",
":",
"cmd",
"=",
"'git show -s --format=\"%H||%an||%ae||%s||%b||%P\" {}'",
".",
"format",
"(",
"sha1",
")",
"result",
... | Return details about a given commit.
Args:
sha1 (str):
The sha1 of the commit to query. If not given, it will return
the details for the latest commit.
Returns:
CommitDetails: Commit details. You can use the instance of the
class to q... | [
"Return",
"details",
"about",
"a",
"given",
"commit",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/git.py#L150-L177 | train |
cons3rt/pycons3rt | pycons3rt/logify.py | main | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(Logify.get_name() + '.logify.main')
log.info('logger name is: %s', Logify.get_name())
log.debug('This is DEBUG')
log... | python | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(Logify.get_name() + '.logify.main')
log.info('logger name is: %s', Logify.get_name())
log.debug('This is DEBUG')
log... | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"Logify",
".",
"get_name",
"(",
")",
"+",
"'.logify.main'",
")",
"log",
".",
"info",
"(",
"'logger name is: %s'",
",",
"Logify",
".",
"get_name",
"(",
")",
")",
"log",
".",
"... | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/logify.py#L127-L140 | train |
cons3rt/pycons3rt | pycons3rt/logify.py | Logify.set_log_level | def set_log_level(cls, log_level):
"""Sets the log level for cons3rt assets
This method sets the logging level for cons3rt assets using
pycons3rt. The loglevel is read in from a deployment property
called loglevel and set appropriately.
:type log_level: str
:return: Tru... | python | def set_log_level(cls, log_level):
"""Sets the log level for cons3rt assets
This method sets the logging level for cons3rt assets using
pycons3rt. The loglevel is read in from a deployment property
called loglevel and set appropriately.
:type log_level: str
:return: Tru... | [
"def",
"set_log_level",
"(",
"cls",
",",
"log_level",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"cls",
".",
"cls_logger",
"+",
"'.set_log_level'",
")",
"log",
".",
"info",
"(",
"'Attempting to set the log level...'",
")",
"if",
"log_level",
"is",... | Sets the log level for cons3rt assets
This method sets the logging level for cons3rt assets using
pycons3rt. The loglevel is read in from a deployment property
called loglevel and set appropriately.
:type log_level: str
:return: True if log level was set, False otherwise. | [
"Sets",
"the",
"log",
"level",
"for",
"cons3rt",
"assets"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/logify.py#L83-L117 | train |
nathankw/pulsarpy | pulsarpy/elasticsearch_utils.py | Connection.get_record_by_name | def get_record_by_name(self, index, name):
"""
Searches for a single document in the given index on the 'name' field .
Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
Args:
index: `str`. The name of an Elasticsearch index (i.e. biosa... | python | def get_record_by_name(self, index, name):
"""
Searches for a single document in the given index on the 'name' field .
Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
Args:
index: `str`. The name of an Elasticsearch index (i.e. biosa... | [
"def",
"get_record_by_name",
"(",
"self",
",",
"index",
",",
"name",
")",
":",
"result",
"=",
"self",
".",
"ES",
".",
"search",
"(",
"index",
"=",
"index",
",",
"body",
"=",
"{",
"\"query\"",
":",
"{",
"\"match_phrase\"",
":",
"{",
"\"name\"",
":",
"... | Searches for a single document in the given index on the 'name' field .
Performs a case-insensitive search by utilizing Elasticsearch's `match_phrase` query.
Args:
index: `str`. The name of an Elasticsearch index (i.e. biosamples).
name: `str`. The value of a document's name... | [
"Searches",
"for",
"a",
"single",
"document",
"in",
"the",
"given",
"index",
"on",
"the",
"name",
"field",
".",
"Performs",
"a",
"case",
"-",
"insensitive",
"search",
"by",
"utilizing",
"Elasticsearch",
"s",
"match_phrase",
"query",
".",
"Args",
":",
"index"... | 359b040c0f2383b88c0b5548715fefd35f5f634c | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/elasticsearch_utils.py#L38-L77 | train |
jaredLunde/vital-tools | vital/tools/__init__.py | getattr_in | def getattr_in(obj, name):
""" Finds an in @obj via a period-delimited string @name.
@obj: (#object)
@name: (#str) |.|-separated keys to search @obj in
..
obj.deep.attr = 'deep value'
getattr_in(obj, 'obj.deep.attr')
..
|'deep value'|
"""
for p... | python | def getattr_in(obj, name):
""" Finds an in @obj via a period-delimited string @name.
@obj: (#object)
@name: (#str) |.|-separated keys to search @obj in
..
obj.deep.attr = 'deep value'
getattr_in(obj, 'obj.deep.attr')
..
|'deep value'|
"""
for p... | [
"def",
"getattr_in",
"(",
"obj",
",",
"name",
")",
":",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"obj",
"=",
"getattr",
"(",
"obj",
",",
"part",
")",
"return",
"obj"
] | Finds an in @obj via a period-delimited string @name.
@obj: (#object)
@name: (#str) |.|-separated keys to search @obj in
..
obj.deep.attr = 'deep value'
getattr_in(obj, 'obj.deep.attr')
..
|'deep value'| | [
"Finds",
"an",
"in"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L20-L32 | train |
jaredLunde/vital-tools | vital/tools/__init__.py | import_from | def import_from(name):
""" Imports a module, class or method from string and unwraps it
if wrapped by functools
@name: (#str) name of the python object
-> imported object
"""
obj = name
if isinstance(name, str) and len(name):
try:
obj = locate(name)
... | python | def import_from(name):
""" Imports a module, class or method from string and unwraps it
if wrapped by functools
@name: (#str) name of the python object
-> imported object
"""
obj = name
if isinstance(name, str) and len(name):
try:
obj = locate(name)
... | [
"def",
"import_from",
"(",
"name",
")",
":",
"obj",
"=",
"name",
"if",
"isinstance",
"(",
"name",
",",
"str",
")",
"and",
"len",
"(",
"name",
")",
":",
"try",
":",
"obj",
"=",
"locate",
"(",
"name",
")",
"assert",
"obj",
"is",
"not",
"None",
"exc... | Imports a module, class or method from string and unwraps it
if wrapped by functools
@name: (#str) name of the python object
-> imported object | [
"Imports",
"a",
"module",
"class",
"or",
"method",
"from",
"string",
"and",
"unwraps",
"it",
"if",
"wrapped",
"by",
"functools"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L35-L67 | train |
jaredLunde/vital-tools | vital/tools/__init__.py | unwrap_obj | def unwrap_obj(obj):
""" Gets the actual object from a decorated or wrapped function
@obj: (#object) the object to unwrap
"""
try:
obj = obj.fget
except (AttributeError, TypeError):
pass
try:
# Cached properties
if obj.func.__doc__ == obj.__doc__:
... | python | def unwrap_obj(obj):
""" Gets the actual object from a decorated or wrapped function
@obj: (#object) the object to unwrap
"""
try:
obj = obj.fget
except (AttributeError, TypeError):
pass
try:
# Cached properties
if obj.func.__doc__ == obj.__doc__:
... | [
"def",
"unwrap_obj",
"(",
"obj",
")",
":",
"try",
":",
"obj",
"=",
"obj",
".",
"fget",
"except",
"(",
"AttributeError",
",",
"TypeError",
")",
":",
"pass",
"try",
":",
"# Cached properties",
"if",
"obj",
".",
"func",
".",
"__doc__",
"==",
"obj",
".",
... | Gets the actual object from a decorated or wrapped function
@obj: (#object) the object to unwrap | [
"Gets",
"the",
"actual",
"object",
"from",
"a",
"decorated",
"or",
"wrapped",
"function"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/__init__.py#L70-L94 | train |
gpiantoni/bidso | bidso/utils.py | add_modality | def add_modality(output_path, modality):
"""Modality can be appended to the file name (such as 'bold') or use in the
folder (such as "func"). You should always use the specific modality ('bold').
This function converts it to the folder name.
"""
if modality is None:
return output_path
el... | python | def add_modality(output_path, modality):
"""Modality can be appended to the file name (such as 'bold') or use in the
folder (such as "func"). You should always use the specific modality ('bold').
This function converts it to the folder name.
"""
if modality is None:
return output_path
el... | [
"def",
"add_modality",
"(",
"output_path",
",",
"modality",
")",
":",
"if",
"modality",
"is",
"None",
":",
"return",
"output_path",
"else",
":",
"if",
"modality",
"in",
"(",
"'T1w'",
",",
"'T2star'",
",",
"'FLAIR'",
",",
"'PD'",
")",
":",
"modality",
"="... | Modality can be appended to the file name (such as 'bold') or use in the
folder (such as "func"). You should always use the specific modality ('bold').
This function converts it to the folder name. | [
"Modality",
"can",
"be",
"appended",
"to",
"the",
"file",
"name",
"(",
"such",
"as",
"bold",
")",
"or",
"use",
"in",
"the",
"folder",
"(",
"such",
"as",
"func",
")",
".",
"You",
"should",
"always",
"use",
"the",
"specific",
"modality",
"(",
"bold",
"... | af163b921ec4e3d70802de07f174de184491cfce | https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/utils.py#L92-L115 | train |
novopl/peltak | src/peltak/core/conf.py | load | def load():
# type: () -> None
""" Load configuration from file.
This will search the directory structure upwards to find the project root
(directory containing ``pelconf.py`` file). Once found it will import the
config file which should initialize all the configuration (using
`peltak.core.conf... | python | def load():
# type: () -> None
""" Load configuration from file.
This will search the directory structure upwards to find the project root
(directory containing ``pelconf.py`` file). Once found it will import the
config file which should initialize all the configuration (using
`peltak.core.conf... | [
"def",
"load",
"(",
")",
":",
"# type: () -> None",
"with",
"within_proj_dir",
"(",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"'pelconf.yaml'",
")",
":",
"load_yaml_config",
"(",
"'pelconf.yaml'",
")",
"if",
"os",
".",
"path",
".",
"exists",
... | Load configuration from file.
This will search the directory structure upwards to find the project root
(directory containing ``pelconf.py`` file). Once found it will import the
config file which should initialize all the configuration (using
`peltak.core.conf.init()` function).
You can also have ... | [
"Load",
"configuration",
"from",
"file",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L91-L109 | train |
novopl/peltak | src/peltak/core/conf.py | load_yaml_config | def load_yaml_config(conf_file):
# type: (str) -> None
""" Load a YAML configuration.
This will not update the configuration but replace it entirely.
Args:
conf_file (str):
Path to the YAML config. This function will not check the file name
or extension and will just cr... | python | def load_yaml_config(conf_file):
# type: (str) -> None
""" Load a YAML configuration.
This will not update the configuration but replace it entirely.
Args:
conf_file (str):
Path to the YAML config. This function will not check the file name
or extension and will just cr... | [
"def",
"load_yaml_config",
"(",
"conf_file",
")",
":",
"# type: (str) -> None",
"global",
"g_config",
"with",
"open",
"(",
"conf_file",
")",
"as",
"fp",
":",
"# Initialize config",
"g_config",
"=",
"util",
".",
"yaml_load",
"(",
"fp",
")",
"# Add src_dir to sys.pa... | Load a YAML configuration.
This will not update the configuration but replace it entirely.
Args:
conf_file (str):
Path to the YAML config. This function will not check the file name
or extension and will just crash if the given file does not exist or
is not a valid ... | [
"Load",
"a",
"YAML",
"configuration",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L112-L137 | train |
novopl/peltak | src/peltak/core/conf.py | load_py_config | def load_py_config(conf_file):
# type: (str) -> None
""" Import configuration from a python file.
This will just import the file into python. Sky is the limit. The file
has to deal with the configuration all by itself (i.e. call conf.init()).
You will also need to add your src directory to sys.path... | python | def load_py_config(conf_file):
# type: (str) -> None
""" Import configuration from a python file.
This will just import the file into python. Sky is the limit. The file
has to deal with the configuration all by itself (i.e. call conf.init()).
You will also need to add your src directory to sys.path... | [
"def",
"load_py_config",
"(",
"conf_file",
")",
":",
"# type: (str) -> None",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"5",
")",
":",
"from",
"importlib",
"import",
"util",
"spec",
"=",
"util",
".",
"spec_from_file_location",
"(",
"'pelconf'",
... | Import configuration from a python file.
This will just import the file into python. Sky is the limit. The file
has to deal with the configuration all by itself (i.e. call conf.init()).
You will also need to add your src directory to sys.paths if it's not the
current working directory. This is done aut... | [
"Import",
"configuration",
"from",
"a",
"python",
"file",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L140-L171 | train |
novopl/peltak | src/peltak/core/conf.py | load_template | def load_template(filename):
# type: (str) -> str
""" Load template from file.
The templates are part of the package and must be included as
``package_data`` in project ``setup.py``.
Args:
filename (str):
The template path. Relative to `peltak` package directory.
Returns:
... | python | def load_template(filename):
# type: (str) -> str
""" Load template from file.
The templates are part of the package and must be included as
``package_data`` in project ``setup.py``.
Args:
filename (str):
The template path. Relative to `peltak` package directory.
Returns:
... | [
"def",
"load_template",
"(",
"filename",
")",
":",
"# type: (str) -> str",
"template_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"PKG_DIR",
",",
"'templates'",
",",
"filename",
")",
"with",
"open",
"(",
"template_file",
")",
"as",
"fp",
":",
"return",
... | Load template from file.
The templates are part of the package and must be included as
``package_data`` in project ``setup.py``.
Args:
filename (str):
The template path. Relative to `peltak` package directory.
Returns:
str: The content of the chosen template. | [
"Load",
"template",
"from",
"file",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L174-L190 | train |
novopl/peltak | src/peltak/core/conf.py | proj_path | def proj_path(*path_parts):
# type: (str) -> str
""" Return absolute path to the repo dir (root project directory).
Args:
path (str):
The path relative to the project root (pelconf.yaml).
Returns:
str: The given path converted to an absolute path.
"""
path_parts = p... | python | def proj_path(*path_parts):
# type: (str) -> str
""" Return absolute path to the repo dir (root project directory).
Args:
path (str):
The path relative to the project root (pelconf.yaml).
Returns:
str: The given path converted to an absolute path.
"""
path_parts = p... | [
"def",
"proj_path",
"(",
"*",
"path_parts",
")",
":",
"# type: (str) -> str",
"path_parts",
"=",
"path_parts",
"or",
"[",
"'.'",
"]",
"# If path represented by path_parts is absolute, do not modify it.",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"path_parts",... | Return absolute path to the repo dir (root project directory).
Args:
path (str):
The path relative to the project root (pelconf.yaml).
Returns:
str: The given path converted to an absolute path. | [
"Return",
"absolute",
"path",
"to",
"the",
"repo",
"dir",
"(",
"root",
"project",
"directory",
")",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L204-L224 | train |
novopl/peltak | src/peltak/core/conf.py | within_proj_dir | def within_proj_dir(path='.'):
# type: (Optional[str]) -> str
""" Return an absolute path to the given project relative path.
:param path:
Project relative path that will be converted to the system wide absolute
path.
:return:
Absolute path.
"""
curr_dir = os.getcwd()
... | python | def within_proj_dir(path='.'):
# type: (Optional[str]) -> str
""" Return an absolute path to the given project relative path.
:param path:
Project relative path that will be converted to the system wide absolute
path.
:return:
Absolute path.
"""
curr_dir = os.getcwd()
... | [
"def",
"within_proj_dir",
"(",
"path",
"=",
"'.'",
")",
":",
"# type: (Optional[str]) -> str",
"curr_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"proj_path",
"(",
"path",
")",
")",
"yield",
"os",
".",
"chdir",
"(",
"curr_dir",
")"
... | Return an absolute path to the given project relative path.
:param path:
Project relative path that will be converted to the system wide absolute
path.
:return:
Absolute path. | [
"Return",
"an",
"absolute",
"path",
"to",
"the",
"given",
"project",
"relative",
"path",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L228-L244 | train |
novopl/peltak | src/peltak/core/conf.py | get | def get(name, *default):
# type: (str, Any) -> Any
""" Get config value with the given name and optional default.
Args:
name (str):
The name of the config value.
*default (Any):
If given and the key doesn't not exist, this will be returned
instead. If it'... | python | def get(name, *default):
# type: (str, Any) -> Any
""" Get config value with the given name and optional default.
Args:
name (str):
The name of the config value.
*default (Any):
If given and the key doesn't not exist, this will be returned
instead. If it'... | [
"def",
"get",
"(",
"name",
",",
"*",
"default",
")",
":",
"# type: (str, Any) -> Any",
"global",
"g_config",
"curr",
"=",
"g_config",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"if",
"part",
"in",
"curr",
":",
"curr",
"=",
"curr",... | Get config value with the given name and optional default.
Args:
name (str):
The name of the config value.
*default (Any):
If given and the key doesn't not exist, this will be returned
instead. If it's not given and the config value does not exist,
At... | [
"Get",
"config",
"value",
"with",
"the",
"given",
"name",
"and",
"optional",
"default",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L247-L280 | train |
novopl/peltak | src/peltak/core/conf.py | get_path | def get_path(name, *default):
# type: (str, Any) -> Any
""" Get config value as path relative to the project directory.
This allows easily defining the project configuration within the fabfile
as always relative to that fabfile.
Args:
name (str):
The name of the config value co... | python | def get_path(name, *default):
# type: (str, Any) -> Any
""" Get config value as path relative to the project directory.
This allows easily defining the project configuration within the fabfile
as always relative to that fabfile.
Args:
name (str):
The name of the config value co... | [
"def",
"get_path",
"(",
"name",
",",
"*",
"default",
")",
":",
"# type: (str, Any) -> Any",
"global",
"g_config",
"value",
"=",
"get",
"(",
"name",
",",
"*",
"default",
")",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"proj_path",
"(",
... | Get config value as path relative to the project directory.
This allows easily defining the project configuration within the fabfile
as always relative to that fabfile.
Args:
name (str):
The name of the config value containing the path.
*default (Any):
If given and ... | [
"Get",
"config",
"value",
"as",
"path",
"relative",
"to",
"the",
"project",
"directory",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L283-L313 | train |
novopl/peltak | src/peltak/core/conf.py | _find_proj_root | def _find_proj_root():
# type: () -> Optional[str]
""" Find the project path by going up the file tree.
This will look in the current directory and upwards for the pelconf file
(.yaml or .py)
"""
proj_files = frozenset(('pelconf.py', 'pelconf.yaml'))
curr = os.getcwd()
while curr.start... | python | def _find_proj_root():
# type: () -> Optional[str]
""" Find the project path by going up the file tree.
This will look in the current directory and upwards for the pelconf file
(.yaml or .py)
"""
proj_files = frozenset(('pelconf.py', 'pelconf.yaml'))
curr = os.getcwd()
while curr.start... | [
"def",
"_find_proj_root",
"(",
")",
":",
"# type: () -> Optional[str]",
"proj_files",
"=",
"frozenset",
"(",
"(",
"'pelconf.py'",
",",
"'pelconf.yaml'",
")",
")",
"curr",
"=",
"os",
".",
"getcwd",
"(",
")",
"while",
"curr",
".",
"startswith",
"(",
"'/'",
")"... | Find the project path by going up the file tree.
This will look in the current directory and upwards for the pelconf file
(.yaml or .py) | [
"Find",
"the",
"project",
"path",
"by",
"going",
"up",
"the",
"file",
"tree",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/conf.py#L317-L333 | train |
ktsstudio/tornkts | tornkts/modules/verification/verification_handler.py | VerificationHandler.verify | def verify(verified_entity, verification_key):
"""
Метод должен райзить ошибки
:param verified_entity: сущность
:param verification_key: ключ
:return:
"""
verification = get_object_or_none(Verification, verified_entity=verified_entity)
if verification is ... | python | def verify(verified_entity, verification_key):
"""
Метод должен райзить ошибки
:param verified_entity: сущность
:param verification_key: ключ
:return:
"""
verification = get_object_or_none(Verification, verified_entity=verified_entity)
if verification is ... | [
"def",
"verify",
"(",
"verified_entity",
",",
"verification_key",
")",
":",
"verification",
"=",
"get_object_or_none",
"(",
"Verification",
",",
"verified_entity",
"=",
"verified_entity",
")",
"if",
"verification",
"is",
"None",
":",
"raise",
"ServerError",
"(",
"... | Метод должен райзить ошибки
:param verified_entity: сущность
:param verification_key: ключ
:return: | [
"Метод",
"должен",
"райзить",
"ошибки",
":",
"param",
"verified_entity",
":",
"сущность",
":",
"param",
"verification_key",
":",
"ключ",
":",
"return",
":"
] | db47e4550426282960a7e4486dcc4399c8d52e02 | https://github.com/ktsstudio/tornkts/blob/db47e4550426282960a7e4486dcc4399c8d52e02/tornkts/modules/verification/verification_handler.py#L59-L74 | train |
kajala/django-jutil | jutil/xml.py | _xml_element_value | def _xml_element_value(el: Element, int_tags: list):
"""
Gets XML Element value.
:param el: Element
:param int_tags: List of tags that should be treated as ints
:return: value of the element (int/str)
"""
# None
if el.text is None:
return None
# int
try:
if el.tag... | python | def _xml_element_value(el: Element, int_tags: list):
"""
Gets XML Element value.
:param el: Element
:param int_tags: List of tags that should be treated as ints
:return: value of the element (int/str)
"""
# None
if el.text is None:
return None
# int
try:
if el.tag... | [
"def",
"_xml_element_value",
"(",
"el",
":",
"Element",
",",
"int_tags",
":",
"list",
")",
":",
"# None",
"if",
"el",
".",
"text",
"is",
"None",
":",
"return",
"None",
"# int",
"try",
":",
"if",
"el",
".",
"tag",
"in",
"int_tags",
":",
"return",
"int... | Gets XML Element value.
:param el: Element
:param int_tags: List of tags that should be treated as ints
:return: value of the element (int/str) | [
"Gets",
"XML",
"Element",
"value",
".",
":",
"param",
"el",
":",
"Element",
":",
"param",
"int_tags",
":",
"List",
"of",
"tags",
"that",
"should",
"be",
"treated",
"as",
"ints",
":",
"return",
":",
"value",
"of",
"the",
"element",
"(",
"int",
"/",
"s... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L6-L24 | train |
kajala/django-jutil | jutil/xml.py | _xml_tag_filter | def _xml_tag_filter(s: str, strip_namespaces: bool) -> str:
"""
Returns tag name and optionally strips namespaces.
:param el: Element
:param strip_namespaces: Strip namespace prefix
:return: str
"""
if strip_namespaces:
ns_end = s.find('}')
if ns_end != -1:
s = s[... | python | def _xml_tag_filter(s: str, strip_namespaces: bool) -> str:
"""
Returns tag name and optionally strips namespaces.
:param el: Element
:param strip_namespaces: Strip namespace prefix
:return: str
"""
if strip_namespaces:
ns_end = s.find('}')
if ns_end != -1:
s = s[... | [
"def",
"_xml_tag_filter",
"(",
"s",
":",
"str",
",",
"strip_namespaces",
":",
"bool",
")",
"->",
"str",
":",
"if",
"strip_namespaces",
":",
"ns_end",
"=",
"s",
".",
"find",
"(",
"'}'",
")",
"if",
"ns_end",
"!=",
"-",
"1",
":",
"s",
"=",
"s",
"[",
... | Returns tag name and optionally strips namespaces.
:param el: Element
:param strip_namespaces: Strip namespace prefix
:return: str | [
"Returns",
"tag",
"name",
"and",
"optionally",
"strips",
"namespaces",
".",
":",
"param",
"el",
":",
"Element",
":",
"param",
"strip_namespaces",
":",
"Strip",
"namespace",
"prefix",
":",
"return",
":",
"str"
] | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L27-L42 | train |
kajala/django-jutil | jutil/xml.py | xml_to_dict | def xml_to_dict(xml_bytes: bytes, tags: list=[], array_tags: list=[], int_tags: list=[],
strip_namespaces: bool=True, parse_attributes: bool=True,
value_key: str='@', attribute_prefix: str='@',
document_tag: bool=False) -> dict:
"""
Parses XML string to dict. In c... | python | def xml_to_dict(xml_bytes: bytes, tags: list=[], array_tags: list=[], int_tags: list=[],
strip_namespaces: bool=True, parse_attributes: bool=True,
value_key: str='@', attribute_prefix: str='@',
document_tag: bool=False) -> dict:
"""
Parses XML string to dict. In c... | [
"def",
"xml_to_dict",
"(",
"xml_bytes",
":",
"bytes",
",",
"tags",
":",
"list",
"=",
"[",
"]",
",",
"array_tags",
":",
"list",
"=",
"[",
"]",
",",
"int_tags",
":",
"list",
"=",
"[",
"]",
",",
"strip_namespaces",
":",
"bool",
"=",
"True",
",",
"pars... | Parses XML string to dict. In case of simple elements (no children, no attributes) value is stored as is.
For complex elements value is stored in key '@', attributes '@xxx' and children as sub-dicts.
Optionally strips namespaces.
For example:
<Doc version="1.2">
<A class="x">
... | [
"Parses",
"XML",
"string",
"to",
"dict",
".",
"In",
"case",
"of",
"simple",
"elements",
"(",
"no",
"children",
"no",
"attributes",
")",
"value",
"is",
"stored",
"as",
"is",
".",
"For",
"complex",
"elements",
"value",
"is",
"stored",
"in",
"key",
"@",
"... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L87-L148 | train |
kajala/django-jutil | jutil/xml.py | dict_to_element | def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element:
"""
Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For ex... | python | def dict_to_element(doc: dict, value_key: str='@', attribute_prefix: str='@') -> Element:
"""
Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For ex... | [
"def",
"dict_to_element",
"(",
"doc",
":",
"dict",
",",
"value_key",
":",
"str",
"=",
"'@'",
",",
"attribute_prefix",
":",
"str",
"=",
"'@'",
")",
"->",
"Element",
":",
"from",
"xml",
".",
"etree",
"import",
"ElementTree",
"as",
"ET",
"if",
"len",
"(",... | Generates XML Element from dict.
Generates complex elements by assuming element attributes are prefixed with '@', and value is stored to plain '@'
in case of complex element. Children are sub-dicts.
For example:
{
'Doc': {
'@version': '1.2',
'A': [{'@clas... | [
"Generates",
"XML",
"Element",
"from",
"dict",
".",
"Generates",
"complex",
"elements",
"by",
"assuming",
"element",
"attributes",
"are",
"prefixed",
"with",
"@",
"and",
"value",
"is",
"stored",
"to",
"plain",
"@",
"in",
"case",
"of",
"complex",
"element",
"... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/xml.py#L175-L218 | train |
jaredLunde/vital-tools | vital/cache/__init__.py | local_property | def local_property():
""" Property structure which maps within the :func:local() thread
(c)2014, Marcel Hellkamp
"""
ls = local()
def fget(self):
try:
return ls.var
except AttributeError:
raise RuntimeError("Request context not initialized.")
def fse... | python | def local_property():
""" Property structure which maps within the :func:local() thread
(c)2014, Marcel Hellkamp
"""
ls = local()
def fget(self):
try:
return ls.var
except AttributeError:
raise RuntimeError("Request context not initialized.")
def fse... | [
"def",
"local_property",
"(",
")",
":",
"ls",
"=",
"local",
"(",
")",
"def",
"fget",
"(",
"self",
")",
":",
"try",
":",
"return",
"ls",
".",
"var",
"except",
"AttributeError",
":",
"raise",
"RuntimeError",
"(",
"\"Request context not initialized.\"",
")",
... | Property structure which maps within the :func:local() thread
(c)2014, Marcel Hellkamp | [
"Property",
"structure",
"which",
"maps",
"within",
"the",
":",
"func",
":",
"local",
"()",
"thread",
"(",
"c",
")",
"2014",
"Marcel",
"Hellkamp"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/cache/__init__.py#L37-L55 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | download | def download(download_info):
"""Module method for downloading from S3
This public module method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:para... | python | def download(download_info):
"""Module method for downloading from S3
This public module method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:para... | [
"def",
"download",
"(",
"download_info",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.download'",
")",
"# Ensure the passed arg is a dict",
"if",
"not",
"isinstance",
"(",
"download_info",
",",
"dict",
")",
":",
"msg",
"=",
"'d... | Module method for downloading from S3
This public module method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:param download_info: (dict) Contains the... | [
"Module",
"method",
"for",
"downloading",
"from",
"S3"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L363-L467 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | find_bucket_keys | def find_bucket_keys(bucket_name, regex, region_name=None, aws_access_key_id=None, aws_secret_access_key=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an emp... | python | def find_bucket_keys(bucket_name, regex, region_name=None, aws_access_key_id=None, aws_secret_access_key=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an emp... | [
"def",
"find_bucket_keys",
"(",
"bucket_name",
",",
"regex",
",",
"region_name",
"=",
"None",
",",
"aws_access_key_id",
"=",
"None",
",",
"aws_secret_access_key",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.find_b... | Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: (str) Regular expression to use is the key search
:param bucket_name:... | [
"Finds",
"a",
"list",
"of",
"S3",
"keys",
"matching",
"the",
"passed",
"regex"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L470-L505 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | main | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
log.debug('This is DEBUG!')
log.info('This is INFO!')
log.warning('This is WARNING!')
log.... | python | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
log.debug('This is DEBUG!')
log.info('This is INFO!')
log.warning('This is WARNING!')
log.... | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.main'",
")",
"log",
".",
"debug",
"(",
"'This is DEBUG!'",
")",
"log",
".",
"info",
"(",
"'This is INFO!'",
")",
"log",
".",
"warning",
"(",
"'This is WARNI... | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L508-L537 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.validate_bucket | def validate_bucket(self):
"""Verify the specified bucket exists
This method validates that the bucket name passed in the S3Util
constructor actually exists.
:return: None
"""
log = logging.getLogger(self.cls_logger + '.validate_bucket')
log.info('Attempting to ... | python | def validate_bucket(self):
"""Verify the specified bucket exists
This method validates that the bucket name passed in the S3Util
constructor actually exists.
:return: None
"""
log = logging.getLogger(self.cls_logger + '.validate_bucket')
log.info('Attempting to ... | [
"def",
"validate_bucket",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.validate_bucket'",
")",
"log",
".",
"info",
"(",
"'Attempting to get bucket: {b}'",
".",
"format",
"(",
"b",
"=",
"self",
".",
... | Verify the specified bucket exists
This method validates that the bucket name passed in the S3Util
constructor actually exists.
:return: None | [
"Verify",
"the",
"specified",
"bucket",
"exists"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L85-L131 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.__download_from_s3 | def __download_from_s3(self, key, dest_dir):
"""Private method for downloading from S3
This private helper method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the spec... | python | def __download_from_s3(self, key, dest_dir):
"""Private method for downloading from S3
This private helper method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the spec... | [
"def",
"__download_from_s3",
"(",
"self",
",",
"key",
",",
"dest_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.__download_from_s3'",
")",
"filename",
"=",
"key",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
... | Private method for downloading from S3
This private helper method takes a key and the full path to
the destination directory, assumes that the args have been
validated by the public caller methods, and attempts to
download the specified key to the dest_dir.
:param key: (str) S3... | [
"Private",
"method",
"for",
"downloading",
"from",
"S3"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L133-L179 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.download_file_by_key | def download_file_by_key(self, key, dest_dir):
"""Downloads a file by key from the specified S3 bucket
This method takes the full 'key' as the arg, and attempts to
download the file to the specified dest_dir as the destination
directory. This method sets the downloaded filename to be th... | python | def download_file_by_key(self, key, dest_dir):
"""Downloads a file by key from the specified S3 bucket
This method takes the full 'key' as the arg, and attempts to
download the file to the specified dest_dir as the destination
directory. This method sets the downloaded filename to be th... | [
"def",
"download_file_by_key",
"(",
"self",
",",
"key",
",",
"dest_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.download_file_by_key'",
")",
"if",
"not",
"isinstance",
"(",
"key",
",",
"basestring",
")",
... | Downloads a file by key from the specified S3 bucket
This method takes the full 'key' as the arg, and attempts to
download the file to the specified dest_dir as the destination
directory. This method sets the downloaded filename to be the
same as it is on S3.
:param key: (str) ... | [
"Downloads",
"a",
"file",
"by",
"key",
"from",
"the",
"specified",
"S3",
"bucket"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L181-L208 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.download_file | def download_file(self, regex, dest_dir):
"""Downloads a file by regex from the specified S3 bucket
This method takes a regular expression as the arg, and attempts
to download the file to the specified dest_dir as the
destination directory. This method sets the downloaded filename
... | python | def download_file(self, regex, dest_dir):
"""Downloads a file by regex from the specified S3 bucket
This method takes a regular expression as the arg, and attempts
to download the file to the specified dest_dir as the
destination directory. This method sets the downloaded filename
... | [
"def",
"download_file",
"(",
"self",
",",
"regex",
",",
"dest_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.download_file'",
")",
"if",
"not",
"isinstance",
"(",
"regex",
",",
"basestring",
")",
":",
"lo... | Downloads a file by regex from the specified S3 bucket
This method takes a regular expression as the arg, and attempts
to download the file to the specified dest_dir as the
destination directory. This method sets the downloaded filename
to be the same as it is on S3.
:param reg... | [
"Downloads",
"a",
"file",
"by",
"regex",
"from",
"the",
"specified",
"S3",
"bucket"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L210-L238 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.find_key | def find_key(self, regex):
"""Attempts to find a single S3 key based on the passed regex
Given a regular expression, this method searches the S3 bucket
for a matching key, and returns it if exactly 1 key matches.
Otherwise, None is returned.
:param regex: (str) Regular expressi... | python | def find_key(self, regex):
"""Attempts to find a single S3 key based on the passed regex
Given a regular expression, this method searches the S3 bucket
for a matching key, and returns it if exactly 1 key matches.
Otherwise, None is returned.
:param regex: (str) Regular expressi... | [
"def",
"find_key",
"(",
"self",
",",
"regex",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.find_key'",
")",
"if",
"not",
"isinstance",
"(",
"regex",
",",
"basestring",
")",
":",
"log",
".",
"error",
"(",
... | Attempts to find a single S3 key based on the passed regex
Given a regular expression, this method searches the S3 bucket
for a matching key, and returns it if exactly 1 key matches.
Otherwise, None is returned.
:param regex: (str) Regular expression for an S3 key
:return: (str... | [
"Attempts",
"to",
"find",
"a",
"single",
"S3",
"key",
"based",
"on",
"the",
"passed",
"regex"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L240-L270 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.find_keys | def find_keys(self, regex, bucket_name=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: ... | python | def find_keys(self, regex, bucket_name=None):
"""Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: ... | [
"def",
"find_keys",
"(",
"self",
",",
"regex",
",",
"bucket_name",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.find_keys'",
")",
"matched_keys",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
... | Finds a list of S3 keys matching the passed regex
Given a regular expression, this method searches the S3 bucket
for matching keys, and returns an array of strings for matched
keys, an empty array if non are found.
:param regex: (str) Regular expression to use is the key search
... | [
"Finds",
"a",
"list",
"of",
"S3",
"keys",
"matching",
"the",
"passed",
"regex"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L272-L303 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.upload_file | def upload_file(self, filepath, key):
"""Uploads a file using the passed S3 key
This method uploads a file specified by the filepath to S3
using the provided S3 key.
:param filepath: (str) Full path to the file to be uploaded
:param key: (str) S3 key to be set for the upload
... | python | def upload_file(self, filepath, key):
"""Uploads a file using the passed S3 key
This method uploads a file specified by the filepath to S3
using the provided S3 key.
:param filepath: (str) Full path to the file to be uploaded
:param key: (str) S3 key to be set for the upload
... | [
"def",
"upload_file",
"(",
"self",
",",
"filepath",
",",
"key",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.upload_file'",
")",
"log",
".",
"info",
"(",
"'Attempting to upload file %s to S3 bucket %s as key %s...'",
... | Uploads a file using the passed S3 key
This method uploads a file specified by the filepath to S3
using the provided S3 key.
:param filepath: (str) Full path to the file to be uploaded
:param key: (str) S3 key to be set for the upload
:return: True if upload is successful, Fals... | [
"Uploads",
"a",
"file",
"using",
"the",
"passed",
"S3",
"key"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L305-L341 | train |
cons3rt/pycons3rt | pycons3rt/awsapi/s3util.py | S3Util.delete_key | def delete_key(self, key_to_delete):
"""Deletes the specified key
:param key_to_delete:
:return:
"""
log = logging.getLogger(self.cls_logger + '.delete_key')
log.info('Attempting to delete key: {k}'.format(k=key_to_delete))
try:
self.s3client.delete_... | python | def delete_key(self, key_to_delete):
"""Deletes the specified key
:param key_to_delete:
:return:
"""
log = logging.getLogger(self.cls_logger + '.delete_key')
log.info('Attempting to delete key: {k}'.format(k=key_to_delete))
try:
self.s3client.delete_... | [
"def",
"delete_key",
"(",
"self",
",",
"key_to_delete",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.delete_key'",
")",
"log",
".",
"info",
"(",
"'Attempting to delete key: {k}'",
".",
"format",
"(",
"k",
"=",
... | Deletes the specified key
:param key_to_delete:
:return: | [
"Deletes",
"the",
"specified",
"key"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/s3util.py#L343-L360 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | assert_branch_type | def assert_branch_type(branch_type):
# type: (str) -> None
""" Print error and exit if the current branch is not of a given type.
Args:
branch_type (str):
The branch type. This assumes the branch is in the '<type>/<title>`
format.
"""
branch = git.current_branch(refr... | python | def assert_branch_type(branch_type):
# type: (str) -> None
""" Print error and exit if the current branch is not of a given type.
Args:
branch_type (str):
The branch type. This assumes the branch is in the '<type>/<title>`
format.
"""
branch = git.current_branch(refr... | [
"def",
"assert_branch_type",
"(",
"branch_type",
")",
":",
"# type: (str) -> None",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"if",
"branch",
".",
"type",
"!=",
"branch_type",
":",
"if",
"context",
".",
"get",
"(",
"'pret... | Print error and exit if the current branch is not of a given type.
Args:
branch_type (str):
The branch type. This assumes the branch is in the '<type>/<title>`
format. | [
"Print",
"error",
"and",
"exit",
"if",
"the",
"current",
"branch",
"is",
"not",
"of",
"a",
"given",
"type",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L38-L58 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | assert_on_branch | def assert_on_branch(branch_name):
# type: (str) -> None
""" Print error and exit if *branch_name* is not the current branch.
Args:
branch_name (str):
The supposed name of the current branch.
"""
branch = git.current_branch(refresh=True)
if branch.name != branch_name:
... | python | def assert_on_branch(branch_name):
# type: (str) -> None
""" Print error and exit if *branch_name* is not the current branch.
Args:
branch_name (str):
The supposed name of the current branch.
"""
branch = git.current_branch(refresh=True)
if branch.name != branch_name:
... | [
"def",
"assert_on_branch",
"(",
"branch_name",
")",
":",
"# type: (str) -> None",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
"if",
"branch",
".",
"name",
"!=",
"branch_name",
":",
"if",
"context",
".",
"get",
"(",
"'preten... | Print error and exit if *branch_name* is not the current branch.
Args:
branch_name (str):
The supposed name of the current branch. | [
"Print",
"error",
"and",
"exit",
"if",
"*",
"branch_name",
"*",
"is",
"not",
"the",
"current",
"branch",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L61-L77 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | git_branch_delete | def git_branch_delete(branch_name):
# type: (str) -> None
""" Delete the given branch.
Args:
branch_name (str):
Name of the branch to delete.
"""
if branch_name not in git.protected_branches():
log.info("Deleting branch <33>{}", branch_name)
shell.run('git branch... | python | def git_branch_delete(branch_name):
# type: (str) -> None
""" Delete the given branch.
Args:
branch_name (str):
Name of the branch to delete.
"""
if branch_name not in git.protected_branches():
log.info("Deleting branch <33>{}", branch_name)
shell.run('git branch... | [
"def",
"git_branch_delete",
"(",
"branch_name",
")",
":",
"# type: (str) -> None",
"if",
"branch_name",
"not",
"in",
"git",
".",
"protected_branches",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"Deleting branch <33>{}\"",
",",
"branch_name",
")",
"shell",
".",
"r... | Delete the given branch.
Args:
branch_name (str):
Name of the branch to delete. | [
"Delete",
"the",
"given",
"branch",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L80-L90 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | git_branch_rename | def git_branch_rename(new_name):
# type: (str) -> None
""" Rename the current branch
Args:
new_name (str):
New name for the current branch.
"""
curr_name = git.current_branch(refresh=True).name
if curr_name not in git.protected_branches():
log.info("Renaming branch ... | python | def git_branch_rename(new_name):
# type: (str) -> None
""" Rename the current branch
Args:
new_name (str):
New name for the current branch.
"""
curr_name = git.current_branch(refresh=True).name
if curr_name not in git.protected_branches():
log.info("Renaming branch ... | [
"def",
"git_branch_rename",
"(",
"new_name",
")",
":",
"# type: (str) -> None",
"curr_name",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
"=",
"True",
")",
".",
"name",
"if",
"curr_name",
"not",
"in",
"git",
".",
"protected_branches",
"(",
")",
":",
"l... | Rename the current branch
Args:
new_name (str):
New name for the current branch. | [
"Rename",
"the",
"current",
"branch"
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L93-L107 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | git_checkout | def git_checkout(branch_name, create=False):
# type: (str, bool) -> None
""" Checkout or create a given branch
Args:
branch_name (str):
The name of the branch to checkout or create.
create (bool):
If set to **True** it will create the branch instead of checking it
... | python | def git_checkout(branch_name, create=False):
# type: (str, bool) -> None
""" Checkout or create a given branch
Args:
branch_name (str):
The name of the branch to checkout or create.
create (bool):
If set to **True** it will create the branch instead of checking it
... | [
"def",
"git_checkout",
"(",
"branch_name",
",",
"create",
"=",
"False",
")",
":",
"# type: (str, bool) -> None",
"log",
".",
"info",
"(",
"\"Checking out <33>{}\"",
".",
"format",
"(",
"branch_name",
")",
")",
"shell",
".",
"run",
"(",
"'git checkout {} {}'",
".... | Checkout or create a given branch
Args:
branch_name (str):
The name of the branch to checkout or create.
create (bool):
If set to **True** it will create the branch instead of checking it
out. | [
"Checkout",
"or",
"create",
"a",
"given",
"branch"
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L110-L122 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | git_merge | def git_merge(base, head, no_ff=False):
# type: (str, str, bool) -> None
""" Merge *head* into *base*.
Args:
base (str):
The base branch. *head* will be merged into this branch.
head (str):
The branch that will be merged into *base*.
no_ff (bool):
... | python | def git_merge(base, head, no_ff=False):
# type: (str, str, bool) -> None
""" Merge *head* into *base*.
Args:
base (str):
The base branch. *head* will be merged into this branch.
head (str):
The branch that will be merged into *base*.
no_ff (bool):
... | [
"def",
"git_merge",
"(",
"base",
",",
"head",
",",
"no_ff",
"=",
"False",
")",
":",
"# type: (str, str, bool) -> None",
"pretend",
"=",
"context",
".",
"get",
"(",
"'pretend'",
",",
"False",
")",
"branch",
"=",
"git",
".",
"current_branch",
"(",
"refresh",
... | Merge *head* into *base*.
Args:
base (str):
The base branch. *head* will be merged into this branch.
head (str):
The branch that will be merged into *base*.
no_ff (bool):
If set to **True** it will force git to create merge commit. If set
to *... | [
"Merge",
"*",
"head",
"*",
"into",
"*",
"base",
"*",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L137-L168 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | get_base_branch | def get_base_branch():
# type: () -> str
""" Return the base branch for the current branch.
This function will first try to guess the base branch and if it can't it
will let the user choose the branch from the list of all local branches.
Returns:
str: The name of the branch the current bra... | python | def get_base_branch():
# type: () -> str
""" Return the base branch for the current branch.
This function will first try to guess the base branch and if it can't it
will let the user choose the branch from the list of all local branches.
Returns:
str: The name of the branch the current bra... | [
"def",
"get_base_branch",
"(",
")",
":",
"# type: () -> str",
"base_branch",
"=",
"git",
".",
"guess_base_branch",
"(",
")",
"if",
"base_branch",
"is",
"None",
":",
"log",
".",
"info",
"(",
"\"Can't guess the base branch, you have to pick one yourself:\"",
")",
"base_... | Return the base branch for the current branch.
This function will first try to guess the base branch and if it can't it
will let the user choose the branch from the list of all local branches.
Returns:
str: The name of the branch the current branch is based on. | [
"Return",
"the",
"base",
"branch",
"for",
"the",
"current",
"branch",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L178-L194 | train |
novopl/peltak | src/peltak/extra/gitflow/logic/common.py | choose_branch | def choose_branch(exclude=None):
# type: (List[str]) -> str
""" Show the user a menu to pick a branch from the existing ones.
Args:
exclude (list[str]):
List of branch names to exclude from the menu. By default it will
exclude master and develop branches. To show all branche... | python | def choose_branch(exclude=None):
# type: (List[str]) -> str
""" Show the user a menu to pick a branch from the existing ones.
Args:
exclude (list[str]):
List of branch names to exclude from the menu. By default it will
exclude master and develop branches. To show all branche... | [
"def",
"choose_branch",
"(",
"exclude",
"=",
"None",
")",
":",
"# type: (List[str]) -> str",
"if",
"exclude",
"is",
"None",
":",
"master",
"=",
"conf",
".",
"get",
"(",
"'git.master_branch'",
",",
"'master'",
")",
"develop",
"=",
"conf",
".",
"get",
"(",
"... | Show the user a menu to pick a branch from the existing ones.
Args:
exclude (list[str]):
List of branch names to exclude from the menu. By default it will
exclude master and develop branches. To show all branches pass an
empty array here.
Returns:
str: The n... | [
"Show",
"the",
"user",
"a",
"menu",
"to",
"pick",
"a",
"branch",
"from",
"the",
"existing",
"ones",
"."
] | b627acc019e3665875fe76cdca0a14773b69beaa | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/logic/common.py#L197-L234 | train |
Varkal/chuda | chuda/decorators.py | autorun | def autorun():
'''
Call the run method of the decorated class if the current file is the main file
'''
def wrapper(cls):
import inspect
if inspect.getmodule(cls).__name__ == "__main__":
cls().run()
return cls
return wrapper | python | def autorun():
'''
Call the run method of the decorated class if the current file is the main file
'''
def wrapper(cls):
import inspect
if inspect.getmodule(cls).__name__ == "__main__":
cls().run()
return cls
return wrapper | [
"def",
"autorun",
"(",
")",
":",
"def",
"wrapper",
"(",
"cls",
")",
":",
"import",
"inspect",
"if",
"inspect",
".",
"getmodule",
"(",
"cls",
")",
".",
"__name__",
"==",
"\"__main__\"",
":",
"cls",
"(",
")",
".",
"run",
"(",
")",
"return",
"cls",
"r... | Call the run method of the decorated class if the current file is the main file | [
"Call",
"the",
"run",
"method",
"of",
"the",
"decorated",
"class",
"if",
"the",
"current",
"file",
"is",
"the",
"main",
"file"
] | 0d93b716dede35231c21be97bcc19a656655983f | https://github.com/Varkal/chuda/blob/0d93b716dede35231c21be97bcc19a656655983f/chuda/decorators.py#L1-L12 | train |
jaredLunde/vital-tools | vital/tools/lists.py | unique_list | def unique_list(seq):
""" Removes duplicate elements from given @seq
@seq: a #list or sequence-like object
-> #list
"""
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))] | python | def unique_list(seq):
""" Removes duplicate elements from given @seq
@seq: a #list or sequence-like object
-> #list
"""
seen = set()
seen_add = seen.add
return [x for x in seq if not (x in seen or seen_add(x))] | [
"def",
"unique_list",
"(",
"seq",
")",
":",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"return",
"[",
"x",
"for",
"x",
"in",
"seq",
"if",
"not",
"(",
"x",
"in",
"seen",
"or",
"seen_add",
"(",
"x",
")",
")",
"]"
] | Removes duplicate elements from given @seq
@seq: a #list or sequence-like object
-> #list | [
"Removes",
"duplicate",
"elements",
"from",
"given",
"@seq"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/lists.py#L17-L26 | train |
jaredLunde/vital-tools | vital/tools/lists.py | flatten | def flatten(*seqs):
""" Flattens a sequence e.g. |[(1, 2), (3, (4, 5))] -> [1, 2, 3, 4, 5]|
@seq: #tuple, #list or :class:UserList
-> yields an iterator
..
l = [(1, 2), (3, 4)]
for x in flatten(l):
print(x)
..
"""
for seq in seqs:
... | python | def flatten(*seqs):
""" Flattens a sequence e.g. |[(1, 2), (3, (4, 5))] -> [1, 2, 3, 4, 5]|
@seq: #tuple, #list or :class:UserList
-> yields an iterator
..
l = [(1, 2), (3, 4)]
for x in flatten(l):
print(x)
..
"""
for seq in seqs:
... | [
"def",
"flatten",
"(",
"*",
"seqs",
")",
":",
"for",
"seq",
"in",
"seqs",
":",
"for",
"item",
"in",
"seq",
":",
"if",
"isinstance",
"(",
"item",
",",
"(",
"tuple",
",",
"list",
",",
"UserList",
")",
")",
":",
"for",
"subitem",
"in",
"flatten",
"(... | Flattens a sequence e.g. |[(1, 2), (3, (4, 5))] -> [1, 2, 3, 4, 5]|
@seq: #tuple, #list or :class:UserList
-> yields an iterator
..
l = [(1, 2), (3, 4)]
for x in flatten(l):
print(x)
.. | [
"Flattens",
"a",
"sequence",
"e",
".",
"g",
".",
"|",
"[",
"(",
"1",
"2",
")",
"(",
"3",
"(",
"4",
"5",
"))",
"]",
"-",
">",
"[",
"1",
"2",
"3",
"4",
"5",
"]",
"|"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/lists.py#L59-L78 | train |
jaredLunde/vital-tools | vital/tools/lists.py | randrange | def randrange(seq):
""" Yields random values from @seq until @seq is empty """
seq = seq.copy()
choose = rng().choice
remove = seq.remove
for x in range(len(seq)):
y = choose(seq)
remove(y)
yield y | python | def randrange(seq):
""" Yields random values from @seq until @seq is empty """
seq = seq.copy()
choose = rng().choice
remove = seq.remove
for x in range(len(seq)):
y = choose(seq)
remove(y)
yield y | [
"def",
"randrange",
"(",
"seq",
")",
":",
"seq",
"=",
"seq",
".",
"copy",
"(",
")",
"choose",
"=",
"rng",
"(",
")",
".",
"choice",
"remove",
"=",
"seq",
".",
"remove",
"for",
"x",
"in",
"range",
"(",
"len",
"(",
"seq",
")",
")",
":",
"y",
"="... | Yields random values from @seq until @seq is empty | [
"Yields",
"random",
"values",
"from"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/lists.py#L91-L99 | train |
Vital-Fernandez/dazer | bin/lib/ssp_functions/ssp_Hector_Fit3D_tools.py | linear_least_squares | def linear_least_squares(a, b, residuals=False):
"""
Return the least-squares solution to a linear matrix equation.
Solves the equation `a x = b` by computing a vector `x` that
minimizes the Euclidean 2-norm `|| b - a x ||^2`. The equation may
be under-, well-, or over- determined (i.e., the number... | python | def linear_least_squares(a, b, residuals=False):
"""
Return the least-squares solution to a linear matrix equation.
Solves the equation `a x = b` by computing a vector `x` that
minimizes the Euclidean 2-norm `|| b - a x ||^2`. The equation may
be under-, well-, or over- determined (i.e., the number... | [
"def",
"linear_least_squares",
"(",
"a",
",",
"b",
",",
"residuals",
"=",
"False",
")",
":",
"# Copyright (c) 2013 Alexandre Drouin. All rights reserved.",
"# From https://gist.github.com/aldro61/5889795",
"from",
"warnings",
"import",
"warn",
"# from scipy.linalg.fblas impo... | Return the least-squares solution to a linear matrix equation.
Solves the equation `a x = b` by computing a vector `x` that
minimizes the Euclidean 2-norm `|| b - a x ||^2`. The equation may
be under-, well-, or over- determined (i.e., the number of
linearly independent rows of `a` can be less than, eq... | [
"Return",
"the",
"least",
"-",
"squares",
"solution",
"to",
"a",
"linear",
"matrix",
"equation",
".",
"Solves",
"the",
"equation",
"a",
"x",
"=",
"b",
"by",
"computing",
"a",
"vector",
"x",
"that",
"minimizes",
"the",
"Euclidean",
"2",
"-",
"norm",
"||",... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/ssp_functions/ssp_Hector_Fit3D_tools.py#L14-L55 | train |
cons3rt/pycons3rt | pycons3rt/aliasip.py | validate_ip_address | def validate_ip_address(ip_address):
"""Validate the ip_address
:param ip_address: (str) IP address
:return: (bool) True if the ip_address is valid
"""
# Validate the IP address
log = logging.getLogger(mod_logger + '.validate_ip_address')
if not isinstance(ip_address, basestring):
l... | python | def validate_ip_address(ip_address):
"""Validate the ip_address
:param ip_address: (str) IP address
:return: (bool) True if the ip_address is valid
"""
# Validate the IP address
log = logging.getLogger(mod_logger + '.validate_ip_address')
if not isinstance(ip_address, basestring):
l... | [
"def",
"validate_ip_address",
"(",
"ip_address",
")",
":",
"# Validate the IP address",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.validate_ip_address'",
")",
"if",
"not",
"isinstance",
"(",
"ip_address",
",",
"basestring",
")",
":",
"log"... | Validate the ip_address
:param ip_address: (str) IP address
:return: (bool) True if the ip_address is valid | [
"Validate",
"the",
"ip_address"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/aliasip.py#L32-L61 | train |
cons3rt/pycons3rt | pycons3rt/aliasip.py | ip_addr | def ip_addr():
"""Uses the ip addr command to enumerate IP addresses by device
:return: (dict) Containing device: ip_address
"""
log = logging.getLogger(mod_logger + '.ip_addr')
log.debug('Running the ip addr command...')
ip_addr_output = {}
command = ['ip', 'addr']
try:
ip_add... | python | def ip_addr():
"""Uses the ip addr command to enumerate IP addresses by device
:return: (dict) Containing device: ip_address
"""
log = logging.getLogger(mod_logger + '.ip_addr')
log.debug('Running the ip addr command...')
ip_addr_output = {}
command = ['ip', 'addr']
try:
ip_add... | [
"def",
"ip_addr",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.ip_addr'",
")",
"log",
".",
"debug",
"(",
"'Running the ip addr command...'",
")",
"ip_addr_output",
"=",
"{",
"}",
"command",
"=",
"[",
"'ip'",
",",
"'add... | Uses the ip addr command to enumerate IP addresses by device
:return: (dict) Containing device: ip_address | [
"Uses",
"the",
"ip",
"addr",
"command",
"to",
"enumerate",
"IP",
"addresses",
"by",
"device"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/aliasip.py#L64-L103 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.