id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
242,300 | edeposit/edeposit.amqp.ltp | src/edeposit/amqp/ltp/info_composer.py | compose_info | def compose_info(root_dir, files, hash_fn, aleph_record, urn_nbn=None):
"""
Compose `info` XML file.
Info example::
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<info>
<created>2014-07-31T10:58:53</created>
<metadataversion>1.0</metadataversion>
... | python | def compose_info(root_dir, files, hash_fn, aleph_record, urn_nbn=None):
"""
Compose `info` XML file.
Info example::
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<info>
<created>2014-07-31T10:58:53</created>
<metadataversion>1.0</metadataversion>
... | [
"def",
"compose_info",
"(",
"root_dir",
",",
"files",
",",
"hash_fn",
",",
"aleph_record",
",",
"urn_nbn",
"=",
"None",
")",
":",
"# compute hash for hashfile",
"with",
"open",
"(",
"hash_fn",
")",
"as",
"f",
":",
"hash_file_md5",
"=",
"hashlib",
".",
"md5",... | Compose `info` XML file.
Info example::
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<info>
<created>2014-07-31T10:58:53</created>
<metadataversion>1.0</metadataversion>
<packageid>c88f5a50-7b34-11e2-b930-005056827e51</packageid>
<mainmet... | [
"Compose",
"info",
"XML",
"file",
"."
] | df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e | https://github.com/edeposit/edeposit.amqp.ltp/blob/df9ac7ec6cbdbeaaeed438ca66df75ea967b6d8e/src/edeposit/amqp/ltp/info_composer.py#L81-L210 |
242,301 | 1and1/infrascope | src/infrascope/cli.py | run | def run(argv=None):
"""Main CLI entry point."""
cli = InfrascopeCLI()
return cli.run(sys.argv[1:] if argv is None else argv) | python | def run(argv=None):
"""Main CLI entry point."""
cli = InfrascopeCLI()
return cli.run(sys.argv[1:] if argv is None else argv) | [
"def",
"run",
"(",
"argv",
"=",
"None",
")",
":",
"cli",
"=",
"InfrascopeCLI",
"(",
")",
"return",
"cli",
".",
"run",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"if",
"argv",
"is",
"None",
"else",
"argv",
")"
] | Main CLI entry point. | [
"Main",
"CLI",
"entry",
"point",
"."
] | d7e291917e618a0a3cd6d5bfc20c6b5defd7550c | https://github.com/1and1/infrascope/blob/d7e291917e618a0a3cd6d5bfc20c6b5defd7550c/src/infrascope/cli.py#L58-L61 |
242,302 | donovan-duplessis/pwnurl | pwnurl/app.py | create_app | def create_app(configobj=ProdConfig):
""" Create and configure Flask Application """
app = Flask(__name__)
app.config.from_object(configobj)
configure_blueprints(app)
configure_extensions(app)
configure_callbacks(app)
configure_filters(app)
configure_error_handlers(app)
return app | python | def create_app(configobj=ProdConfig):
""" Create and configure Flask Application """
app = Flask(__name__)
app.config.from_object(configobj)
configure_blueprints(app)
configure_extensions(app)
configure_callbacks(app)
configure_filters(app)
configure_error_handlers(app)
return app | [
"def",
"create_app",
"(",
"configobj",
"=",
"ProdConfig",
")",
":",
"app",
"=",
"Flask",
"(",
"__name__",
")",
"app",
".",
"config",
".",
"from_object",
"(",
"configobj",
")",
"configure_blueprints",
"(",
"app",
")",
"configure_extensions",
"(",
"app",
")",
... | Create and configure Flask Application | [
"Create",
"and",
"configure",
"Flask",
"Application"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L21-L31 |
242,303 | donovan-duplessis/pwnurl | pwnurl/app.py | configure_extensions | def configure_extensions(app):
""" Configure application extensions """
db.init_app(app)
app.wsgi_app = ProxyFix(app.wsgi_app)
assets.init_app(app)
for asset in bundles:
for (name, bundle) in asset.iteritems():
assets.register(name, bundle)
login_manager.login_view = 'fro... | python | def configure_extensions(app):
""" Configure application extensions """
db.init_app(app)
app.wsgi_app = ProxyFix(app.wsgi_app)
assets.init_app(app)
for asset in bundles:
for (name, bundle) in asset.iteritems():
assets.register(name, bundle)
login_manager.login_view = 'fro... | [
"def",
"configure_extensions",
"(",
"app",
")",
":",
"db",
".",
"init_app",
"(",
"app",
")",
"app",
".",
"wsgi_app",
"=",
"ProxyFix",
"(",
"app",
".",
"wsgi_app",
")",
"assets",
".",
"init_app",
"(",
"app",
")",
"for",
"asset",
"in",
"bundles",
":",
... | Configure application extensions | [
"Configure",
"application",
"extensions"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L48-L71 |
242,304 | donovan-duplessis/pwnurl | pwnurl/app.py | configure_callbacks | def configure_callbacks(app):
""" Configure application callbacks """
@app.before_request
def before_request():
""" Retrieve menu configuration before every request (this will return
cached version if possible, else reload from database. """
from flask import session
#... | python | def configure_callbacks(app):
""" Configure application callbacks """
@app.before_request
def before_request():
""" Retrieve menu configuration before every request (this will return
cached version if possible, else reload from database. """
from flask import session
#... | [
"def",
"configure_callbacks",
"(",
"app",
")",
":",
"@",
"app",
".",
"before_request",
"def",
"before_request",
"(",
")",
":",
"\"\"\" Retrieve menu configuration before every request (this will return\n cached version if possible, else reload from database. \"\"\"",
"from... | Configure application callbacks | [
"Configure",
"application",
"callbacks"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L74-L86 |
242,305 | donovan-duplessis/pwnurl | pwnurl/app.py | configure_error_handlers | def configure_error_handlers(app):
""" Configure application error handlers """
def render_error(error):
return (render_template('errors/%s.html' % error.code,
title=error_messages[error.code], code=error.code), error.code)
for (errcode, title) in error_messages.iteritems():
... | python | def configure_error_handlers(app):
""" Configure application error handlers """
def render_error(error):
return (render_template('errors/%s.html' % error.code,
title=error_messages[error.code], code=error.code), error.code)
for (errcode, title) in error_messages.iteritems():
... | [
"def",
"configure_error_handlers",
"(",
"app",
")",
":",
"def",
"render_error",
"(",
"error",
")",
":",
"return",
"(",
"render_template",
"(",
"'errors/%s.html'",
"%",
"error",
".",
"code",
",",
"title",
"=",
"error_messages",
"[",
"error",
".",
"code",
"]",... | Configure application error handlers | [
"Configure",
"application",
"error",
"handlers"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/app.py#L89-L97 |
242,306 | krinj/k-util | k_util/logger.py | Logger._strip_colors | def _strip_colors(self, message: str) -> str:
""" Remove all of the color tags from this message. """
for c in self.COLORS:
message = message.replace(c, "")
return message | python | def _strip_colors(self, message: str) -> str:
""" Remove all of the color tags from this message. """
for c in self.COLORS:
message = message.replace(c, "")
return message | [
"def",
"_strip_colors",
"(",
"self",
",",
"message",
":",
"str",
")",
"->",
"str",
":",
"for",
"c",
"in",
"self",
".",
"COLORS",
":",
"message",
"=",
"message",
".",
"replace",
"(",
"c",
",",
"\"\"",
")",
"return",
"message"
] | Remove all of the color tags from this message. | [
"Remove",
"all",
"of",
"the",
"color",
"tags",
"from",
"this",
"message",
"."
] | b118826b1d6f49ca4e1ca7327d5b171db332ac23 | https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/logger.py#L305-L309 |
242,307 | 50onRed/smr | smr/shared.py | add_str | def add_str(window, line_num, str):
""" attempt to draw str on screen and ignore errors if they occur """
try:
window.addstr(line_num, 0, str)
except curses.error:
pass | python | def add_str(window, line_num, str):
""" attempt to draw str on screen and ignore errors if they occur """
try:
window.addstr(line_num, 0, str)
except curses.error:
pass | [
"def",
"add_str",
"(",
"window",
",",
"line_num",
",",
"str",
")",
":",
"try",
":",
"window",
".",
"addstr",
"(",
"line_num",
",",
"0",
",",
"str",
")",
"except",
"curses",
".",
"error",
":",
"pass"
] | attempt to draw str on screen and ignore errors if they occur | [
"attempt",
"to",
"draw",
"str",
"on",
"screen",
"and",
"ignore",
"errors",
"if",
"they",
"occur"
] | 999b33d86b6a900d7c4aadf03cf4a661acba9f1b | https://github.com/50onRed/smr/blob/999b33d86b6a900d7c4aadf03cf4a661acba9f1b/smr/shared.py#L39-L44 |
242,308 | 50onRed/smr | smr/shared.py | write_file_to_descriptor | def write_file_to_descriptor(input_queue, descriptor):
"""
get item from input_queue and write it to descriptor
returns True if and only if it was successfully written
"""
try:
file_name = input_queue.get(timeout=2)
descriptor.write("{}\n".format(file_name))
descriptor.flush(... | python | def write_file_to_descriptor(input_queue, descriptor):
"""
get item from input_queue and write it to descriptor
returns True if and only if it was successfully written
"""
try:
file_name = input_queue.get(timeout=2)
descriptor.write("{}\n".format(file_name))
descriptor.flush(... | [
"def",
"write_file_to_descriptor",
"(",
"input_queue",
",",
"descriptor",
")",
":",
"try",
":",
"file_name",
"=",
"input_queue",
".",
"get",
"(",
"timeout",
"=",
"2",
")",
"descriptor",
".",
"write",
"(",
"\"{}\\n\"",
".",
"format",
"(",
"file_name",
")",
... | get item from input_queue and write it to descriptor
returns True if and only if it was successfully written | [
"get",
"item",
"from",
"input_queue",
"and",
"write",
"it",
"to",
"descriptor",
"returns",
"True",
"if",
"and",
"only",
"if",
"it",
"was",
"successfully",
"written"
] | 999b33d86b6a900d7c4aadf03cf4a661acba9f1b | https://github.com/50onRed/smr/blob/999b33d86b6a900d7c4aadf03cf4a661acba9f1b/smr/shared.py#L63-L79 |
242,309 | jeffrimko/Auxly | lib/auxly/listy.py | smooth | def smooth(l):
"""Yields a generator which smooths all elements as if the given list
was of depth 1.
**Examples**:
::
list(auxly.listy.smooth([1,[2,[3,[4]]]]))
# [1, 2, 3, 4]
"""
if type(l) in [list, tuple]:
for i in l:
for j in smooth(i):
yie... | python | def smooth(l):
"""Yields a generator which smooths all elements as if the given list
was of depth 1.
**Examples**:
::
list(auxly.listy.smooth([1,[2,[3,[4]]]]))
# [1, 2, 3, 4]
"""
if type(l) in [list, tuple]:
for i in l:
for j in smooth(i):
yie... | [
"def",
"smooth",
"(",
"l",
")",
":",
"if",
"type",
"(",
"l",
")",
"in",
"[",
"list",
",",
"tuple",
"]",
":",
"for",
"i",
"in",
"l",
":",
"for",
"j",
"in",
"smooth",
"(",
"i",
")",
":",
"yield",
"j",
"else",
":",
"yield",
"l"
] | Yields a generator which smooths all elements as if the given list
was of depth 1.
**Examples**:
::
list(auxly.listy.smooth([1,[2,[3,[4]]]]))
# [1, 2, 3, 4] | [
"Yields",
"a",
"generator",
"which",
"smooths",
"all",
"elements",
"as",
"if",
"the",
"given",
"list",
"was",
"of",
"depth",
"1",
"."
] | 5aae876bcb6ca117c81d904f9455764cdc78cd48 | https://github.com/jeffrimko/Auxly/blob/5aae876bcb6ca117c81d904f9455764cdc78cd48/lib/auxly/listy.py#L21-L35 |
242,310 | CivicSpleen/ckcache | ckcache/s3.py | S3Cache.s3path | def s3path(self, rel_path):
"""Return the path as an S3 schema"""
import urlparse
path = self.path(rel_path, public_url=True)
parts = list(urlparse.urlparse(path))
parts[0] = 's3'
parts[1] = self.bucket_name
return urlparse.urlunparse(parts) | python | def s3path(self, rel_path):
"""Return the path as an S3 schema"""
import urlparse
path = self.path(rel_path, public_url=True)
parts = list(urlparse.urlparse(path))
parts[0] = 's3'
parts[1] = self.bucket_name
return urlparse.urlunparse(parts) | [
"def",
"s3path",
"(",
"self",
",",
"rel_path",
")",
":",
"import",
"urlparse",
"path",
"=",
"self",
".",
"path",
"(",
"rel_path",
",",
"public_url",
"=",
"True",
")",
"parts",
"=",
"list",
"(",
"urlparse",
".",
"urlparse",
"(",
"path",
")",
")",
"par... | Return the path as an S3 schema | [
"Return",
"the",
"path",
"as",
"an",
"S3",
"schema"
] | 0c699b6ba97ff164e9702504f0e1643dd4cd39e1 | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/s3.py#L153-L164 |
242,311 | CivicSpleen/ckcache | ckcache/s3.py | S3Cache.get_stream | def get_stream(self, rel_path, cb=None, return_meta=False):
"""Return the object as a stream"""
from boto.s3.key import Key
from boto.exception import S3ResponseError
import StringIO
from . import MetadataFlo
b = StringIO.StringIO()
try:
k = self._ge... | python | def get_stream(self, rel_path, cb=None, return_meta=False):
"""Return the object as a stream"""
from boto.s3.key import Key
from boto.exception import S3ResponseError
import StringIO
from . import MetadataFlo
b = StringIO.StringIO()
try:
k = self._ge... | [
"def",
"get_stream",
"(",
"self",
",",
"rel_path",
",",
"cb",
"=",
"None",
",",
"return_meta",
"=",
"False",
")",
":",
"from",
"boto",
".",
"s3",
".",
"key",
"import",
"Key",
"from",
"boto",
".",
"exception",
"import",
"S3ResponseError",
"import",
"Strin... | Return the object as a stream | [
"Return",
"the",
"object",
"as",
"a",
"stream"
] | 0c699b6ba97ff164e9702504f0e1643dd4cd39e1 | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/s3.py#L187-L218 |
242,312 | CivicSpleen/ckcache | ckcache/s3.py | S3Cache.list | def list(self, path=None, with_metadata=False, include_partitions=False):
'''Get a list of all of bundle files in the cache. Does not return partition files'''
import json
sub_path = self.prefix + '/' + path.strip('/') if path else self.prefix
l = {}
for e in self.bucket.list(... | python | def list(self, path=None, with_metadata=False, include_partitions=False):
'''Get a list of all of bundle files in the cache. Does not return partition files'''
import json
sub_path = self.prefix + '/' + path.strip('/') if path else self.prefix
l = {}
for e in self.bucket.list(... | [
"def",
"list",
"(",
"self",
",",
"path",
"=",
"None",
",",
"with_metadata",
"=",
"False",
",",
"include_partitions",
"=",
"False",
")",
":",
"import",
"json",
"sub_path",
"=",
"self",
".",
"prefix",
"+",
"'/'",
"+",
"path",
".",
"strip",
"(",
"'/'",
... | Get a list of all of bundle files in the cache. Does not return partition files | [
"Get",
"a",
"list",
"of",
"all",
"of",
"bundle",
"files",
"in",
"the",
"cache",
".",
"Does",
"not",
"return",
"partition",
"files"
] | 0c699b6ba97ff164e9702504f0e1643dd4cd39e1 | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/s3.py#L440-L470 |
242,313 | klmitch/tendril | tendril/connection.py | Tendril._send_streamify | def _send_streamify(self, frame):
"""
Helper method to streamify a frame.
"""
# Get the state and framer
state = self._send_framer_state
framer = self._send_framer
# Reset the state as needed
state._reset(framer)
# Now pass the frame through str... | python | def _send_streamify(self, frame):
"""
Helper method to streamify a frame.
"""
# Get the state and framer
state = self._send_framer_state
framer = self._send_framer
# Reset the state as needed
state._reset(framer)
# Now pass the frame through str... | [
"def",
"_send_streamify",
"(",
"self",
",",
"frame",
")",
":",
"# Get the state and framer",
"state",
"=",
"self",
".",
"_send_framer_state",
"framer",
"=",
"self",
".",
"_send_framer",
"# Reset the state as needed",
"state",
".",
"_reset",
"(",
"framer",
")",
"# ... | Helper method to streamify a frame. | [
"Helper",
"method",
"to",
"streamify",
"a",
"frame",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L102-L115 |
242,314 | klmitch/tendril | tendril/connection.py | Tendril._recv_frameify | def _recv_frameify(self, data):
"""
Helper method to frameify a stream.
"""
# Get the state and framer
state = self._recv_framer_state
framer = None
# Grab off as many frames as we can
frameify = None
while True:
# Check if we need to... | python | def _recv_frameify(self, data):
"""
Helper method to frameify a stream.
"""
# Get the state and framer
state = self._recv_framer_state
framer = None
# Grab off as many frames as we can
frameify = None
while True:
# Check if we need to... | [
"def",
"_recv_frameify",
"(",
"self",
",",
"data",
")",
":",
"# Get the state and framer",
"state",
"=",
"self",
".",
"_recv_framer_state",
"framer",
"=",
"None",
"# Grab off as many frames as we can",
"frameify",
"=",
"None",
"while",
"True",
":",
"# Check if we need... | Helper method to frameify a stream. | [
"Helper",
"method",
"to",
"frameify",
"a",
"stream",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L117-L153 |
242,315 | klmitch/tendril | tendril/connection.py | Tendril.closed | def closed(self, error=None):
"""
Notify the application that the connection has been closed.
:param error: The exception which has caused the connection to
be closed. If the connection has been closed
due to an EOF, pass ``None``.
"""
... | python | def closed(self, error=None):
"""
Notify the application that the connection has been closed.
:param error: The exception which has caused the connection to
be closed. If the connection has been closed
due to an EOF, pass ``None``.
"""
... | [
"def",
"closed",
"(",
"self",
",",
"error",
"=",
"None",
")",
":",
"if",
"self",
".",
"_application",
":",
"try",
":",
"self",
".",
"_application",
".",
"closed",
"(",
"error",
")",
"except",
"Exception",
":",
"# Ignore exceptions from the notification",
"pa... | Notify the application that the connection has been closed.
:param error: The exception which has caused the connection to
be closed. If the connection has been closed
due to an EOF, pass ``None``. | [
"Notify",
"the",
"application",
"that",
"the",
"connection",
"has",
"been",
"closed",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L169-L183 |
242,316 | klmitch/tendril | tendril/connection.py | Tendril.send_framer | def send_framer(self, value):
"""
Set the framer in use for the sending side of the connection.
The framer state will be reset next time the framer is used.
"""
if not isinstance(value, framers.Framer):
raise ValueError("framer must be an instance of tendril.Framer")... | python | def send_framer(self, value):
"""
Set the framer in use for the sending side of the connection.
The framer state will be reset next time the framer is used.
"""
if not isinstance(value, framers.Framer):
raise ValueError("framer must be an instance of tendril.Framer")... | [
"def",
"send_framer",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"framers",
".",
"Framer",
")",
":",
"raise",
"ValueError",
"(",
"\"framer must be an instance of tendril.Framer\"",
")",
"self",
".",
"_send_framer",
"=",
... | Set the framer in use for the sending side of the connection.
The framer state will be reset next time the framer is used. | [
"Set",
"the",
"framer",
"in",
"use",
"for",
"the",
"sending",
"side",
"of",
"the",
"connection",
".",
"The",
"framer",
"state",
"will",
"be",
"reset",
"next",
"time",
"the",
"framer",
"is",
"used",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L203-L212 |
242,317 | klmitch/tendril | tendril/connection.py | Tendril.recv_framer | def recv_framer(self, value):
"""
Set the framer in use for the receiving side of the
connection. The framer state will be reset next time the
framer is used.
"""
if not isinstance(value, framers.Framer):
raise ValueError("framer must be an instance of tendr... | python | def recv_framer(self, value):
"""
Set the framer in use for the receiving side of the
connection. The framer state will be reset next time the
framer is used.
"""
if not isinstance(value, framers.Framer):
raise ValueError("framer must be an instance of tendr... | [
"def",
"recv_framer",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"framers",
".",
"Framer",
")",
":",
"raise",
"ValueError",
"(",
"\"framer must be an instance of tendril.Framer\"",
")",
"self",
".",
"_recv_framer",
"=",
... | Set the framer in use for the receiving side of the
connection. The framer state will be reset next time the
framer is used. | [
"Set",
"the",
"framer",
"in",
"use",
"for",
"the",
"receiving",
"side",
"of",
"the",
"connection",
".",
"The",
"framer",
"state",
"will",
"be",
"reset",
"next",
"time",
"the",
"framer",
"is",
"used",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L243-L253 |
242,318 | klmitch/tendril | tendril/connection.py | Tendril.framers | def framers(self, value):
"""
Set the framers in use for the connection. The framer states
will be reset next time their respective framer is used.
"""
# Handle sequence values
if isinstance(value, collections.Sequence):
if len(value) != 2:
r... | python | def framers(self, value):
"""
Set the framers in use for the connection. The framer states
will be reset next time their respective framer is used.
"""
# Handle sequence values
if isinstance(value, collections.Sequence):
if len(value) != 2:
r... | [
"def",
"framers",
"(",
"self",
",",
"value",
")",
":",
"# Handle sequence values",
"if",
"isinstance",
"(",
"value",
",",
"collections",
".",
"Sequence",
")",
":",
"if",
"len",
"(",
"value",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'need exactly 2... | Set the framers in use for the connection. The framer states
will be reset next time their respective framer is used. | [
"Set",
"the",
"framers",
"in",
"use",
"for",
"the",
"connection",
".",
"The",
"framer",
"states",
"will",
"be",
"reset",
"next",
"time",
"their",
"respective",
"framer",
"is",
"used",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L283-L307 |
242,319 | klmitch/tendril | tendril/connection.py | Tendril.framers | def framers(self):
"""
Reset the framers in use for the connection to be a
tendril.IdentityFramer. The framer states will be reset next
time their respective framer is used.
"""
f = self.default_framer()
self._send_framer = f
self._recv_framer = f | python | def framers(self):
"""
Reset the framers in use for the connection to be a
tendril.IdentityFramer. The framer states will be reset next
time their respective framer is used.
"""
f = self.default_framer()
self._send_framer = f
self._recv_framer = f | [
"def",
"framers",
"(",
"self",
")",
":",
"f",
"=",
"self",
".",
"default_framer",
"(",
")",
"self",
".",
"_send_framer",
"=",
"f",
"self",
".",
"_recv_framer",
"=",
"f"
] | Reset the framers in use for the connection to be a
tendril.IdentityFramer. The framer states will be reset next
time their respective framer is used. | [
"Reset",
"the",
"framers",
"in",
"use",
"for",
"the",
"connection",
"to",
"be",
"a",
"tendril",
".",
"IdentityFramer",
".",
"The",
"framer",
"states",
"will",
"be",
"reset",
"next",
"time",
"their",
"respective",
"framer",
"is",
"used",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L310-L319 |
242,320 | klmitch/tendril | tendril/connection.py | Tendril.application | def application(self, value):
"""Update the application."""
# Always allow None
if value is None:
self._application = None
return
# Check that the state is valid
if not isinstance(value, application.Application):
raise ValueError("application... | python | def application(self, value):
"""Update the application."""
# Always allow None
if value is None:
self._application = None
return
# Check that the state is valid
if not isinstance(value, application.Application):
raise ValueError("application... | [
"def",
"application",
"(",
"self",
",",
"value",
")",
":",
"# Always allow None",
"if",
"value",
"is",
"None",
":",
"self",
".",
"_application",
"=",
"None",
"return",
"# Check that the state is valid",
"if",
"not",
"isinstance",
"(",
"value",
",",
"application"... | Update the application. | [
"Update",
"the",
"application",
"."
] | 207102c83e88f8f1fa7ba605ef0aab2ae9078b36 | https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/connection.py#L337-L350 |
242,321 | pop/pageup | pageup/pageup.py | build | def build():
"""
Builds pages given template.jinja, style.css, and content.rst
produces index.html.
"""
test_files()
with open('content.rst') as f:
content = publish_parts(f.read(), writer_name='html')
title = content['title']
body = content['html_body'].replace('\n',' '... | python | def build():
"""
Builds pages given template.jinja, style.css, and content.rst
produces index.html.
"""
test_files()
with open('content.rst') as f:
content = publish_parts(f.read(), writer_name='html')
title = content['title']
body = content['html_body'].replace('\n',' '... | [
"def",
"build",
"(",
")",
":",
"test_files",
"(",
")",
"with",
"open",
"(",
"'content.rst'",
")",
"as",
"f",
":",
"content",
"=",
"publish_parts",
"(",
"f",
".",
"read",
"(",
")",
",",
"writer_name",
"=",
"'html'",
")",
"title",
"=",
"content",
"[",
... | Builds pages given template.jinja, style.css, and content.rst
produces index.html. | [
"Builds",
"pages",
"given",
"template",
".",
"jinja",
"style",
".",
"css",
"and",
"content",
".",
"rst",
"produces",
"index",
".",
"html",
"."
] | e78471d50517e1779e6e2a5ea961f2a2def7e5e8 | https://github.com/pop/pageup/blob/e78471d50517e1779e6e2a5ea961f2a2def7e5e8/pageup/pageup.py#L34-L53 |
242,322 | pop/pageup | pageup/pageup.py | init | def init(directory=None):
"""
Initializes a new site in the `directory`
Current working dir if directory is None.
"""
if directory is not None and not path.exists(directory):
makedirs(directory)
else:
print('%s already exists, populating with template files' % (directory))
... | python | def init(directory=None):
"""
Initializes a new site in the `directory`
Current working dir if directory is None.
"""
if directory is not None and not path.exists(directory):
makedirs(directory)
else:
print('%s already exists, populating with template files' % (directory))
... | [
"def",
"init",
"(",
"directory",
"=",
"None",
")",
":",
"if",
"directory",
"is",
"not",
"None",
"and",
"not",
"path",
".",
"exists",
"(",
"directory",
")",
":",
"makedirs",
"(",
"directory",
")",
"else",
":",
"print",
"(",
"'%s already exists, populating w... | Initializes a new site in the `directory`
Current working dir if directory is None. | [
"Initializes",
"a",
"new",
"site",
"in",
"the",
"directory",
"Current",
"working",
"dir",
"if",
"directory",
"is",
"None",
"."
] | e78471d50517e1779e6e2a5ea961f2a2def7e5e8 | https://github.com/pop/pageup/blob/e78471d50517e1779e6e2a5ea961f2a2def7e5e8/pageup/pageup.py#L56-L75 |
242,323 | defnull/contexter | contexter.py | ExitStack.callback | def callback(self, callback, *args, **kwds):
""" Registers an arbitrary callback and arguments.
Cannot suppress exceptions.
"""
return self << _CloseDummy(callback, args, kwds) | python | def callback(self, callback, *args, **kwds):
""" Registers an arbitrary callback and arguments.
Cannot suppress exceptions.
"""
return self << _CloseDummy(callback, args, kwds) | [
"def",
"callback",
"(",
"self",
",",
"callback",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
"<<",
"_CloseDummy",
"(",
"callback",
",",
"args",
",",
"kwds",
")"
] | Registers an arbitrary callback and arguments.
Cannot suppress exceptions. | [
"Registers",
"an",
"arbitrary",
"callback",
"and",
"arguments",
"."
] | 12113375bd748f40a8a26e59847dbe291b957c0d | https://github.com/defnull/contexter/blob/12113375bd748f40a8a26e59847dbe291b957c0d/contexter.py#L151-L156 |
242,324 | defnull/contexter | contexter.py | ExitStack.pop_all | def pop_all(self):
""" Preserve the context stack by transferring it to a new instance """
ret = ExitStack()
ret._context_stack.append(self._context_stack.pop())
self._context_stack.append([]) | python | def pop_all(self):
""" Preserve the context stack by transferring it to a new instance """
ret = ExitStack()
ret._context_stack.append(self._context_stack.pop())
self._context_stack.append([]) | [
"def",
"pop_all",
"(",
"self",
")",
":",
"ret",
"=",
"ExitStack",
"(",
")",
"ret",
".",
"_context_stack",
".",
"append",
"(",
"self",
".",
"_context_stack",
".",
"pop",
"(",
")",
")",
"self",
".",
"_context_stack",
".",
"append",
"(",
"[",
"]",
")"
] | Preserve the context stack by transferring it to a new instance | [
"Preserve",
"the",
"context",
"stack",
"by",
"transferring",
"it",
"to",
"a",
"new",
"instance"
] | 12113375bd748f40a8a26e59847dbe291b957c0d | https://github.com/defnull/contexter/blob/12113375bd748f40a8a26e59847dbe291b957c0d/contexter.py#L158-L162 |
242,325 | briancappello/flask-sqlalchemy-bundle | flask_sqlalchemy_bundle/base_model.py | BaseModel.update | def update(self, **kwargs):
"""Update fields on the model.
:param kwargs: The model attribute values to update the model with.
"""
self.validate(**kwargs)
for attr, value in kwargs.items():
setattr(self, attr, value)
return self | python | def update(self, **kwargs):
"""Update fields on the model.
:param kwargs: The model attribute values to update the model with.
"""
self.validate(**kwargs)
for attr, value in kwargs.items():
setattr(self, attr, value)
return self | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"validate",
"(",
"*",
"*",
"kwargs",
")",
"for",
"attr",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"attr",
",",
"value",
... | Update fields on the model.
:param kwargs: The model attribute values to update the model with. | [
"Update",
"fields",
"on",
"the",
"model",
"."
] | 8150896787907ef0001839b5a6ef303edccb9b6c | https://github.com/briancappello/flask-sqlalchemy-bundle/blob/8150896787907ef0001839b5a6ef303edccb9b6c/flask_sqlalchemy_bundle/base_model.py#L76-L84 |
242,326 | briancappello/flask-sqlalchemy-bundle | flask_sqlalchemy_bundle/base_model.py | BaseModel.validate | def validate(cls, partial=True, **kwargs):
"""
Validate kwargs before setting attributes on the model
"""
data = kwargs
if not partial:
data = dict(**kwargs, **{col.name: None for col in cls.__table__.c
if col.name not in kwargs})
... | python | def validate(cls, partial=True, **kwargs):
"""
Validate kwargs before setting attributes on the model
"""
data = kwargs
if not partial:
data = dict(**kwargs, **{col.name: None for col in cls.__table__.c
if col.name not in kwargs})
... | [
"def",
"validate",
"(",
"cls",
",",
"partial",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
"if",
"not",
"partial",
":",
"data",
"=",
"dict",
"(",
"*",
"*",
"kwargs",
",",
"*",
"*",
"{",
"col",
".",
"name",
":",
"None"... | Validate kwargs before setting attributes on the model | [
"Validate",
"kwargs",
"before",
"setting",
"attributes",
"on",
"the",
"model"
] | 8150896787907ef0001839b5a6ef303edccb9b6c | https://github.com/briancappello/flask-sqlalchemy-bundle/blob/8150896787907ef0001839b5a6ef303edccb9b6c/flask_sqlalchemy_bundle/base_model.py#L87-L107 |
242,327 | racker/torment | torment/fixtures/__init__.py | of | def of(fixture_classes: Iterable[type], context: Union[None, 'torment.TestContext'] = None) -> Iterable['torment.fixtures.Fixture']:
'''Obtain all Fixture objects of the provided classes.
**Parameters**
:``fixture_classes``: classes inheriting from ``torment.fixtures.Fixture``
:``context``: a ... | python | def of(fixture_classes: Iterable[type], context: Union[None, 'torment.TestContext'] = None) -> Iterable['torment.fixtures.Fixture']:
'''Obtain all Fixture objects of the provided classes.
**Parameters**
:``fixture_classes``: classes inheriting from ``torment.fixtures.Fixture``
:``context``: a ... | [
"def",
"of",
"(",
"fixture_classes",
":",
"Iterable",
"[",
"type",
"]",
",",
"context",
":",
"Union",
"[",
"None",
",",
"'torment.TestContext'",
"]",
"=",
"None",
")",
"->",
"Iterable",
"[",
"'torment.fixtures.Fixture'",
"]",
":",
"classes",
"=",
"list",
"... | Obtain all Fixture objects of the provided classes.
**Parameters**
:``fixture_classes``: classes inheriting from ``torment.fixtures.Fixture``
:``context``: a ``torment.TestContext`` to initialize Fixtures with
**Return Value(s)**
Instantiated ``torment.fixtures.Fixture`` objects for each... | [
"Obtain",
"all",
"Fixture",
"objects",
"of",
"the",
"provided",
"classes",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L293-L320 |
242,328 | racker/torment | torment/fixtures/__init__.py | register | def register(namespace, base_classes: Tuple[type], properties: Dict[str, Any]) -> None:
'''Register a Fixture class in namespace with the given properties.
Creates a Fixture class (not object) and inserts it into the provided
namespace. The properties is a dict but allows functions to reference other
... | python | def register(namespace, base_classes: Tuple[type], properties: Dict[str, Any]) -> None:
'''Register a Fixture class in namespace with the given properties.
Creates a Fixture class (not object) and inserts it into the provided
namespace. The properties is a dict but allows functions to reference other
... | [
"def",
"register",
"(",
"namespace",
",",
"base_classes",
":",
"Tuple",
"[",
"type",
"]",
",",
"properties",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"# ensure we have a clean copy of the data",
"# and won't stomp on re-uses elsewhere in",
... | Register a Fixture class in namespace with the given properties.
Creates a Fixture class (not object) and inserts it into the provided
namespace. The properties is a dict but allows functions to reference other
properties and acts like a small DSL (domain specific language). This is
really just a dec... | [
"Register",
"a",
"Fixture",
"class",
"in",
"namespace",
"with",
"the",
"given",
"properties",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L323-L438 |
242,329 | racker/torment | torment/fixtures/__init__.py | _prepare_mock | def _prepare_mock(context: 'torment.contexts.TestContext', symbol: str, return_value = None, side_effect = None) -> None:
'''Sets return value or side effect of symbol's mock in context.
.. seealso:: :py:func:`_find_mocker`
**Parameters**
:``context``: the search context
:``symbol``: ... | python | def _prepare_mock(context: 'torment.contexts.TestContext', symbol: str, return_value = None, side_effect = None) -> None:
'''Sets return value or side effect of symbol's mock in context.
.. seealso:: :py:func:`_find_mocker`
**Parameters**
:``context``: the search context
:``symbol``: ... | [
"def",
"_prepare_mock",
"(",
"context",
":",
"'torment.contexts.TestContext'",
",",
"symbol",
":",
"str",
",",
"return_value",
"=",
"None",
",",
"side_effect",
"=",
"None",
")",
"->",
"None",
":",
"methods",
"=",
"symbol",
".",
"split",
"(",
"'.'",
")",
"i... | Sets return value or side effect of symbol's mock in context.
.. seealso:: :py:func:`_find_mocker`
**Parameters**
:``context``: the search context
:``symbol``: the symbol to be located
:``return_value``: pass through to mock ``return_value``
:``side_effect``: pass through to m... | [
"Sets",
"return",
"value",
"or",
"side",
"effect",
"of",
"symbol",
"s",
"mock",
"in",
"context",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L441-L482 |
242,330 | racker/torment | torment/fixtures/__init__.py | _find_mocker | def _find_mocker(symbol: str, context: 'torment.contexts.TestContext') -> Callable[[], bool]:
'''Find method within the context that mocks symbol.
Given a symbol (i.e. ``tornado.httpclient.AsyncHTTPClient.fetch``), find
the shortest ``mock_`` method that resembles the symbol. Resembles means
the lowerc... | python | def _find_mocker(symbol: str, context: 'torment.contexts.TestContext') -> Callable[[], bool]:
'''Find method within the context that mocks symbol.
Given a symbol (i.e. ``tornado.httpclient.AsyncHTTPClient.fetch``), find
the shortest ``mock_`` method that resembles the symbol. Resembles means
the lowerc... | [
"def",
"_find_mocker",
"(",
"symbol",
":",
"str",
",",
"context",
":",
"'torment.contexts.TestContext'",
")",
"->",
"Callable",
"[",
"[",
"]",
",",
"bool",
"]",
":",
"components",
"=",
"[",
"]",
"method",
"=",
"None",
"for",
"component",
"in",
"symbol",
... | Find method within the context that mocks symbol.
Given a symbol (i.e. ``tornado.httpclient.AsyncHTTPClient.fetch``), find
the shortest ``mock_`` method that resembles the symbol. Resembles means
the lowercased and periods replaced with underscores.
If no match is found, a dummy function (only returns... | [
"Find",
"method",
"within",
"the",
"context",
"that",
"mocks",
"symbol",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L485-L534 |
242,331 | racker/torment | torment/fixtures/__init__.py | _resolve_functions | def _resolve_functions(functions: Dict[str, Callable[[Any], Any]], fixture: Fixture) -> None:
'''Apply functions and collect values as properties on fixture.
Call functions and apply their values as properteis on fixture.
Functions will continue to get applied until no more functions resolve.
All unres... | python | def _resolve_functions(functions: Dict[str, Callable[[Any], Any]], fixture: Fixture) -> None:
'''Apply functions and collect values as properties on fixture.
Call functions and apply their values as properteis on fixture.
Functions will continue to get applied until no more functions resolve.
All unres... | [
"def",
"_resolve_functions",
"(",
"functions",
":",
"Dict",
"[",
"str",
",",
"Callable",
"[",
"[",
"Any",
"]",
",",
"Any",
"]",
"]",
",",
"fixture",
":",
"Fixture",
")",
"->",
"None",
":",
"exc_info",
"=",
"last_function",
"=",
"None",
"function_count",
... | Apply functions and collect values as properties on fixture.
Call functions and apply their values as properteis on fixture.
Functions will continue to get applied until no more functions resolve.
All unresolved functions are logged and the last exception to have
occurred is also logged. This function... | [
"Apply",
"functions",
"and",
"collect",
"values",
"as",
"properties",
"on",
"fixture",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L537-L579 |
242,332 | racker/torment | torment/fixtures/__init__.py | _unique_class_name | def _unique_class_name(namespace: Dict[str, Any], uuid: uuid.UUID) -> str:
'''Generate unique to namespace name for a class using uuid.
**Parameters**
:``namespace``: the namespace to verify uniqueness against
:``uuid``: the "unique" portion of the name
**Return Value(s)**
A unique stri... | python | def _unique_class_name(namespace: Dict[str, Any], uuid: uuid.UUID) -> str:
'''Generate unique to namespace name for a class using uuid.
**Parameters**
:``namespace``: the namespace to verify uniqueness against
:``uuid``: the "unique" portion of the name
**Return Value(s)**
A unique stri... | [
"def",
"_unique_class_name",
"(",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"uuid",
":",
"uuid",
".",
"UUID",
")",
"->",
"str",
":",
"count",
"=",
"0",
"name",
"=",
"original_name",
"=",
"'f_'",
"+",
"uuid",
".",
"hex",
"while",
"... | Generate unique to namespace name for a class using uuid.
**Parameters**
:``namespace``: the namespace to verify uniqueness against
:``uuid``: the "unique" portion of the name
**Return Value(s)**
A unique string (in namespace) using uuid. | [
"Generate",
"unique",
"to",
"namespace",
"name",
"for",
"a",
"class",
"using",
"uuid",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L582-L603 |
242,333 | racker/torment | torment/fixtures/__init__.py | ErrorFixture.run | def run(self) -> None:
'''Calls sibling with exception expectation.'''
with self.context.assertRaises(self.error.__class__) as error:
super().run()
self.exception = error.exception | python | def run(self) -> None:
'''Calls sibling with exception expectation.'''
with self.context.assertRaises(self.error.__class__) as error:
super().run()
self.exception = error.exception | [
"def",
"run",
"(",
"self",
")",
"->",
"None",
":",
"with",
"self",
".",
"context",
".",
"assertRaises",
"(",
"self",
".",
"error",
".",
"__class__",
")",
"as",
"error",
":",
"super",
"(",
")",
".",
"run",
"(",
")",
"self",
".",
"exception",
"=",
... | Calls sibling with exception expectation. | [
"Calls",
"sibling",
"with",
"exception",
"expectation",
"."
] | bd5d2f978324bf9b7360edfae76d853b226c63e1 | https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/fixtures/__init__.py#L283-L289 |
242,334 | jalanb/pysyte | pysyte/getch.py | cache_keys | def cache_keys(keys):
"""Allow debugging via PyCharm"""
d = known_keys()
known_names = dict(zip(d.values(), d.keys()))
for k in keys:
i = (ord(k),) if len(k) == 1 else known_names[k]
_key_cache.insert(0, i) | python | def cache_keys(keys):
"""Allow debugging via PyCharm"""
d = known_keys()
known_names = dict(zip(d.values(), d.keys()))
for k in keys:
i = (ord(k),) if len(k) == 1 else known_names[k]
_key_cache.insert(0, i) | [
"def",
"cache_keys",
"(",
"keys",
")",
":",
"d",
"=",
"known_keys",
"(",
")",
"known_names",
"=",
"dict",
"(",
"zip",
"(",
"d",
".",
"values",
"(",
")",
",",
"d",
".",
"keys",
"(",
")",
")",
")",
"for",
"k",
"in",
"keys",
":",
"i",
"=",
"(",
... | Allow debugging via PyCharm | [
"Allow",
"debugging",
"via",
"PyCharm"
] | 4e278101943d1ceb1a6bcaf6ddc72052ecf13114 | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/getch.py#L92-L98 |
242,335 | jalanb/pysyte | pysyte/getch.py | _get_keycodes | def _get_keycodes():
"""Read keypress giving a tuple of key codes
A 'key code' is the ordinal value of characters read
For example, pressing 'A' will give (65,)
"""
try:
return _key_cache.pop()
except IndexError:
pass
result = []
terminators = 'ABCDFHPQRS~'
with Ter... | python | def _get_keycodes():
"""Read keypress giving a tuple of key codes
A 'key code' is the ordinal value of characters read
For example, pressing 'A' will give (65,)
"""
try:
return _key_cache.pop()
except IndexError:
pass
result = []
terminators = 'ABCDFHPQRS~'
with Ter... | [
"def",
"_get_keycodes",
"(",
")",
":",
"try",
":",
"return",
"_key_cache",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"pass",
"result",
"=",
"[",
"]",
"terminators",
"=",
"'ABCDFHPQRS~'",
"with",
"TerminalContext",
"(",
")",
":",
"code",
"=",
"ge... | Read keypress giving a tuple of key codes
A 'key code' is the ordinal value of characters read
For example, pressing 'A' will give (65,) | [
"Read",
"keypress",
"giving",
"a",
"tuple",
"of",
"key",
"codes"
] | 4e278101943d1ceb1a6bcaf6ddc72052ecf13114 | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/getch.py#L101-L131 |
242,336 | jalanb/pysyte | pysyte/getch.py | get_key | def get_key():
"""Get a key from the keyboard as a string
A 'key' will be a single char, or the name of an extended key
"""
character_name = chr
codes = _get_keycodes()
if len(codes) == 1:
code = codes[0]
if code >= 32:
return character_name(code)
return cont... | python | def get_key():
"""Get a key from the keyboard as a string
A 'key' will be a single char, or the name of an extended key
"""
character_name = chr
codes = _get_keycodes()
if len(codes) == 1:
code = codes[0]
if code >= 32:
return character_name(code)
return cont... | [
"def",
"get_key",
"(",
")",
":",
"character_name",
"=",
"chr",
"codes",
"=",
"_get_keycodes",
"(",
")",
"if",
"len",
"(",
"codes",
")",
"==",
"1",
":",
"code",
"=",
"codes",
"[",
"0",
"]",
"if",
"code",
">=",
"32",
":",
"return",
"character_name",
... | Get a key from the keyboard as a string
A 'key' will be a single char, or the name of an extended key | [
"Get",
"a",
"key",
"from",
"the",
"keyboard",
"as",
"a",
"string"
] | 4e278101943d1ceb1a6bcaf6ddc72052ecf13114 | https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/getch.py#L155-L167 |
242,337 | unitedstack/steth | stetho/agent/api.py | AgentApi.check_ports_on_br | def check_ports_on_br(self, bridge='br-ex', ports=['eth3']):
"""Check ports exist on bridge.
ovs-vsctl list-ports bridge
"""
LOG.info("RPC: check_ports_on_br bridge: %s, ports: %s" %
(bridge, ports))
cmd = ['ovs-vsctl', 'list-ports', bridge]
stdcode, std... | python | def check_ports_on_br(self, bridge='br-ex', ports=['eth3']):
"""Check ports exist on bridge.
ovs-vsctl list-ports bridge
"""
LOG.info("RPC: check_ports_on_br bridge: %s, ports: %s" %
(bridge, ports))
cmd = ['ovs-vsctl', 'list-ports', bridge]
stdcode, std... | [
"def",
"check_ports_on_br",
"(",
"self",
",",
"bridge",
"=",
"'br-ex'",
",",
"ports",
"=",
"[",
"'eth3'",
"]",
")",
":",
"LOG",
".",
"info",
"(",
"\"RPC: check_ports_on_br bridge: %s, ports: %s\"",
"%",
"(",
"bridge",
",",
"ports",
")",
")",
"cmd",
"=",
"[... | Check ports exist on bridge.
ovs-vsctl list-ports bridge | [
"Check",
"ports",
"exist",
"on",
"bridge",
"."
] | 955884ceebf3bdc474c93cc5cf555e67d16458f1 | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L27-L48 |
242,338 | unitedstack/steth | stetho/agent/api.py | AgentApi.ping | def ping(self, ips, boardcast=False,
count=2, timeout=2, interface=None):
"""Ping host or broadcast.
ping host -c 2 -W 2
"""
cmd = ['ping', '-c', str(count), '-W', str(timeout)]
True if not interface else cmd.extend(['-I', interface])
True if not boardcast e... | python | def ping(self, ips, boardcast=False,
count=2, timeout=2, interface=None):
"""Ping host or broadcast.
ping host -c 2 -W 2
"""
cmd = ['ping', '-c', str(count), '-W', str(timeout)]
True if not interface else cmd.extend(['-I', interface])
True if not boardcast e... | [
"def",
"ping",
"(",
"self",
",",
"ips",
",",
"boardcast",
"=",
"False",
",",
"count",
"=",
"2",
",",
"timeout",
"=",
"2",
",",
"interface",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'ping'",
",",
"'-c'",
",",
"str",
"(",
"count",
")",
",",
"'-W'... | Ping host or broadcast.
ping host -c 2 -W 2 | [
"Ping",
"host",
"or",
"broadcast",
"."
] | 955884ceebf3bdc474c93cc5cf555e67d16458f1 | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L50-L72 |
242,339 | unitedstack/steth | stetho/agent/api.py | AgentApi.add_vlan_to_interface | def add_vlan_to_interface(self, interface, vlan_id):
"""Add vlan interface.
ip link add link eth0 name eth0.10 type vlan id 10
"""
subif = '%s.%s' % (interface, vlan_id)
vlan_id = '%s' % vlan_id
cmd = ['ip', 'link', 'add', 'link', interface, 'name',
subif,... | python | def add_vlan_to_interface(self, interface, vlan_id):
"""Add vlan interface.
ip link add link eth0 name eth0.10 type vlan id 10
"""
subif = '%s.%s' % (interface, vlan_id)
vlan_id = '%s' % vlan_id
cmd = ['ip', 'link', 'add', 'link', interface, 'name',
subif,... | [
"def",
"add_vlan_to_interface",
"(",
"self",
",",
"interface",
",",
"vlan_id",
")",
":",
"subif",
"=",
"'%s.%s'",
"%",
"(",
"interface",
",",
"vlan_id",
")",
"vlan_id",
"=",
"'%s'",
"%",
"vlan_id",
"cmd",
"=",
"[",
"'ip'",
",",
"'link'",
",",
"'add'",
... | Add vlan interface.
ip link add link eth0 name eth0.10 type vlan id 10 | [
"Add",
"vlan",
"interface",
"."
] | 955884ceebf3bdc474c93cc5cf555e67d16458f1 | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L74-L88 |
242,340 | unitedstack/steth | stetho/agent/api.py | AgentApi.get_interface | def get_interface(self, interface='eth0'):
"""Interface info.
ifconfig interface
"""
LOG.info("RPC: get_interface interfae: %s" % interface)
code, message, data = agent_utils.get_interface(interface)
return agent_utils.make_response(code, message, data) | python | def get_interface(self, interface='eth0'):
"""Interface info.
ifconfig interface
"""
LOG.info("RPC: get_interface interfae: %s" % interface)
code, message, data = agent_utils.get_interface(interface)
return agent_utils.make_response(code, message, data) | [
"def",
"get_interface",
"(",
"self",
",",
"interface",
"=",
"'eth0'",
")",
":",
"LOG",
".",
"info",
"(",
"\"RPC: get_interface interfae: %s\"",
"%",
"interface",
")",
"code",
",",
"message",
",",
"data",
"=",
"agent_utils",
".",
"get_interface",
"(",
"interfac... | Interface info.
ifconfig interface | [
"Interface",
"info",
"."
] | 955884ceebf3bdc474c93cc5cf555e67d16458f1 | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L90-L97 |
242,341 | unitedstack/steth | stetho/agent/api.py | AgentApi.setup_link | def setup_link(self, interface, cidr):
"""Setup a link.
ip addr add dev interface
ip link set dev interface up
"""
# clear old ipaddr in interface
cmd = ['ip', 'addr', 'flush', 'dev', interface]
agent_utils.execute(cmd, root=True)
ip = IPNetwork(cidr)
... | python | def setup_link(self, interface, cidr):
"""Setup a link.
ip addr add dev interface
ip link set dev interface up
"""
# clear old ipaddr in interface
cmd = ['ip', 'addr', 'flush', 'dev', interface]
agent_utils.execute(cmd, root=True)
ip = IPNetwork(cidr)
... | [
"def",
"setup_link",
"(",
"self",
",",
"interface",
",",
"cidr",
")",
":",
"# clear old ipaddr in interface",
"cmd",
"=",
"[",
"'ip'",
",",
"'addr'",
",",
"'flush'",
",",
"'dev'",
",",
"interface",
"]",
"agent_utils",
".",
"execute",
"(",
"cmd",
",",
"root... | Setup a link.
ip addr add dev interface
ip link set dev interface up | [
"Setup",
"a",
"link",
"."
] | 955884ceebf3bdc474c93cc5cf555e67d16458f1 | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L99-L119 |
242,342 | unitedstack/steth | stetho/agent/api.py | AgentApi.setup_iperf_server | def setup_iperf_server(self, protocol='TCP', port=5001, window=None):
"""iperf -s
"""
iperf = iperf_driver.IPerfDriver()
try:
data = iperf.start_server(protocol='TCP', port=5001, window=None)
return agent_utils.make_response(code=0, data=data)
except:
... | python | def setup_iperf_server(self, protocol='TCP', port=5001, window=None):
"""iperf -s
"""
iperf = iperf_driver.IPerfDriver()
try:
data = iperf.start_server(protocol='TCP', port=5001, window=None)
return agent_utils.make_response(code=0, data=data)
except:
... | [
"def",
"setup_iperf_server",
"(",
"self",
",",
"protocol",
"=",
"'TCP'",
",",
"port",
"=",
"5001",
",",
"window",
"=",
"None",
")",
":",
"iperf",
"=",
"iperf_driver",
".",
"IPerfDriver",
"(",
")",
"try",
":",
"data",
"=",
"iperf",
".",
"start_server",
... | iperf -s | [
"iperf",
"-",
"s"
] | 955884ceebf3bdc474c93cc5cf555e67d16458f1 | https://github.com/unitedstack/steth/blob/955884ceebf3bdc474c93cc5cf555e67d16458f1/stetho/agent/api.py#L132-L141 |
242,343 | DecBayComp/RWA-python | rwa/generic.py | isreference | def isreference(a):
"""
Tell whether a variable is an object reference.
Due to garbage collection, some objects happen to get the id of a distinct variable.
As a consequence, linking is not ready yet and `isreference` returns ``False``.
"""
return False
return id(a) != id(copy.copy(a))
... | python | def isreference(a):
"""
Tell whether a variable is an object reference.
Due to garbage collection, some objects happen to get the id of a distinct variable.
As a consequence, linking is not ready yet and `isreference` returns ``False``.
"""
return False
return id(a) != id(copy.copy(a))
... | [
"def",
"isreference",
"(",
"a",
")",
":",
"return",
"False",
"return",
"id",
"(",
"a",
")",
"!=",
"id",
"(",
"copy",
".",
"copy",
"(",
"a",
")",
")",
"check",
"=",
"(",
"'__dict__'",
",",
"'__slots__'",
")",
"for",
"attr",
"in",
"check",
":",
"tr... | Tell whether a variable is an object reference.
Due to garbage collection, some objects happen to get the id of a distinct variable.
As a consequence, linking is not ready yet and `isreference` returns ``False``. | [
"Tell",
"whether",
"a",
"variable",
"is",
"an",
"object",
"reference",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L24-L43 |
242,344 | DecBayComp/RWA-python | rwa/generic.py | lookup_type | def lookup_type(storable_type):
"""
Look for the Python type that corresponds to a storable type name.
"""
if storable_type.startswith('Python'):
_, module_name = storable_type.split('.', 1)
else:
module_name = storable_type
#type_name, module_name = \
names = [ _name[::-1] f... | python | def lookup_type(storable_type):
"""
Look for the Python type that corresponds to a storable type name.
"""
if storable_type.startswith('Python'):
_, module_name = storable_type.split('.', 1)
else:
module_name = storable_type
#type_name, module_name = \
names = [ _name[::-1] f... | [
"def",
"lookup_type",
"(",
"storable_type",
")",
":",
"if",
"storable_type",
".",
"startswith",
"(",
"'Python'",
")",
":",
"_",
",",
"module_name",
"=",
"storable_type",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"else",
":",
"module_name",
"=",
"storable_ty... | Look for the Python type that corresponds to a storable type name. | [
"Look",
"for",
"the",
"Python",
"type",
"that",
"corresponds",
"to",
"a",
"storable",
"type",
"name",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L46-L66 |
242,345 | DecBayComp/RWA-python | rwa/generic.py | poke | def poke(exposes):
"""
Default serializer factory.
Arguments:
exposes (iterable): attributes to serialized.
Returns:
callable: serializer (`poke` routine).
"""
def _poke(store, objname, obj, container, visited=None, _stack=None):
try:
sub_container = store... | python | def poke(exposes):
"""
Default serializer factory.
Arguments:
exposes (iterable): attributes to serialized.
Returns:
callable: serializer (`poke` routine).
"""
def _poke(store, objname, obj, container, visited=None, _stack=None):
try:
sub_container = store... | [
"def",
"poke",
"(",
"exposes",
")",
":",
"def",
"_poke",
"(",
"store",
",",
"objname",
",",
"obj",
",",
"container",
",",
"visited",
"=",
"None",
",",
"_stack",
"=",
"None",
")",
":",
"try",
":",
"sub_container",
"=",
"store",
".",
"newContainer",
"(... | Default serializer factory.
Arguments:
exposes (iterable): attributes to serialized.
Returns:
callable: serializer (`poke` routine). | [
"Default",
"serializer",
"factory",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L466-L494 |
242,346 | DecBayComp/RWA-python | rwa/generic.py | poke_assoc | def poke_assoc(store, objname, assoc, container, visited=None, _stack=None):
"""
Serialize association lists.
"""
try:
sub_container = store.newContainer(objname, assoc, container)
except (SystemExit, KeyboardInterrupt):
raise
except:
raise ValueError('generic poke not su... | python | def poke_assoc(store, objname, assoc, container, visited=None, _stack=None):
"""
Serialize association lists.
"""
try:
sub_container = store.newContainer(objname, assoc, container)
except (SystemExit, KeyboardInterrupt):
raise
except:
raise ValueError('generic poke not su... | [
"def",
"poke_assoc",
"(",
"store",
",",
"objname",
",",
"assoc",
",",
"container",
",",
"visited",
"=",
"None",
",",
"_stack",
"=",
"None",
")",
":",
"try",
":",
"sub_container",
"=",
"store",
".",
"newContainer",
"(",
"objname",
",",
"assoc",
",",
"co... | Serialize association lists. | [
"Serialize",
"association",
"lists",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L496-L532 |
242,347 | DecBayComp/RWA-python | rwa/generic.py | default_peek | def default_peek(python_type, exposes):
"""
Autoserializer factory.
Works best in Python 3.
Arguments:
python_type (type): type constructor.
exposes (iterable): sequence of attributes.
Returns:
callable: deserializer (`peek` routine).
"""
with_args = False
... | python | def default_peek(python_type, exposes):
"""
Autoserializer factory.
Works best in Python 3.
Arguments:
python_type (type): type constructor.
exposes (iterable): sequence of attributes.
Returns:
callable: deserializer (`peek` routine).
"""
with_args = False
... | [
"def",
"default_peek",
"(",
"python_type",
",",
"exposes",
")",
":",
"with_args",
"=",
"False",
"make",
"=",
"python_type",
"try",
":",
"make",
"(",
")",
"except",
"(",
"SystemExit",
",",
"KeyboardInterrupt",
")",
":",
"raise",
"except",
":",
"make",
"=",
... | Autoserializer factory.
Works best in Python 3.
Arguments:
python_type (type): type constructor.
exposes (iterable): sequence of attributes.
Returns:
callable: deserializer (`peek` routine). | [
"Autoserializer",
"factory",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L536-L604 |
242,348 | DecBayComp/RWA-python | rwa/generic.py | unsafe_peek | def unsafe_peek(init):
"""
Deserialize all the attributes available in the container and pass them in the same order
as they come in the container.
This is a factory function; returns the actual `peek` routine.
Arguments:
init: type constructor.
Returns:
callable: deserializ... | python | def unsafe_peek(init):
"""
Deserialize all the attributes available in the container and pass them in the same order
as they come in the container.
This is a factory function; returns the actual `peek` routine.
Arguments:
init: type constructor.
Returns:
callable: deserializ... | [
"def",
"unsafe_peek",
"(",
"init",
")",
":",
"def",
"peek",
"(",
"store",
",",
"container",
",",
"_stack",
"=",
"None",
")",
":",
"return",
"init",
"(",
"*",
"[",
"store",
".",
"peek",
"(",
"attr",
",",
"container",
",",
"_stack",
"=",
"_stack",
")... | Deserialize all the attributes available in the container and pass them in the same order
as they come in the container.
This is a factory function; returns the actual `peek` routine.
Arguments:
init: type constructor.
Returns:
callable: deserializer (`peek` routine). | [
"Deserialize",
"all",
"the",
"attributes",
"available",
"in",
"the",
"container",
"and",
"pass",
"them",
"in",
"the",
"same",
"order",
"as",
"they",
"come",
"in",
"the",
"container",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L606-L624 |
242,349 | DecBayComp/RWA-python | rwa/generic.py | peek_with_kwargs | def peek_with_kwargs(init, args=[]):
"""
Make datatypes passing keyworded arguments to the constructor.
This is a factory function; returns the actual `peek` routine.
Arguments:
init (callable): type constructor.
args (iterable): arguments NOT to be keyworded; order does matter.
... | python | def peek_with_kwargs(init, args=[]):
"""
Make datatypes passing keyworded arguments to the constructor.
This is a factory function; returns the actual `peek` routine.
Arguments:
init (callable): type constructor.
args (iterable): arguments NOT to be keyworded; order does matter.
... | [
"def",
"peek_with_kwargs",
"(",
"init",
",",
"args",
"=",
"[",
"]",
")",
":",
"def",
"peek",
"(",
"store",
",",
"container",
",",
"_stack",
"=",
"None",
")",
":",
"return",
"init",
"(",
"*",
"[",
"store",
".",
"peek",
"(",
"attr",
",",
"container",... | Make datatypes passing keyworded arguments to the constructor.
This is a factory function; returns the actual `peek` routine.
Arguments:
init (callable): type constructor.
args (iterable): arguments NOT to be keyworded; order does matter.
Returns:
callable: deserializer (`peek`... | [
"Make",
"datatypes",
"passing",
"keyworded",
"arguments",
"to",
"the",
"constructor",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L626-L650 |
242,350 | DecBayComp/RWA-python | rwa/generic.py | peek | def peek(init, exposes, debug=False):
"""
Default deserializer factory.
Arguments:
init (callable): type constructor.
exposes (iterable): attributes to be peeked and passed to `init`.
Returns:
callable: deserializer (`peek` routine).
"""
def _peek(store, container, _... | python | def peek(init, exposes, debug=False):
"""
Default deserializer factory.
Arguments:
init (callable): type constructor.
exposes (iterable): attributes to be peeked and passed to `init`.
Returns:
callable: deserializer (`peek` routine).
"""
def _peek(store, container, _... | [
"def",
"peek",
"(",
"init",
",",
"exposes",
",",
"debug",
"=",
"False",
")",
":",
"def",
"_peek",
"(",
"store",
",",
"container",
",",
"_stack",
"=",
"None",
")",
":",
"args",
"=",
"[",
"store",
".",
"peek",
"(",
"objname",
",",
"container",
",",
... | Default deserializer factory.
Arguments:
init (callable): type constructor.
exposes (iterable): attributes to be peeked and passed to `init`.
Returns:
callable: deserializer (`peek` routine). | [
"Default",
"deserializer",
"factory",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L655-L675 |
242,351 | DecBayComp/RWA-python | rwa/generic.py | peek_assoc | def peek_assoc(store, container, _stack=None):
"""
Deserialize association lists.
"""
assoc = []
try:
if store.getRecordAttr('key', container) == 'escaped':
for i in container:
assoc.append(store.peek(i, container, _stack=_stack))
else:
for i i... | python | def peek_assoc(store, container, _stack=None):
"""
Deserialize association lists.
"""
assoc = []
try:
if store.getRecordAttr('key', container) == 'escaped':
for i in container:
assoc.append(store.peek(i, container, _stack=_stack))
else:
for i i... | [
"def",
"peek_assoc",
"(",
"store",
",",
"container",
",",
"_stack",
"=",
"None",
")",
":",
"assoc",
"=",
"[",
"]",
"try",
":",
"if",
"store",
".",
"getRecordAttr",
"(",
"'key'",
",",
"container",
")",
"==",
"'escaped'",
":",
"for",
"i",
"in",
"contai... | Deserialize association lists. | [
"Deserialize",
"association",
"lists",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L677-L697 |
242,352 | DecBayComp/RWA-python | rwa/generic.py | most_exposes | def most_exposes(python_type):
"""
Core engine for the automatic generation of storable instances.
Finds the attributes exposed by the objects of a given type.
Mostly Python3-only.
Does not handle types which `__new__` method requires extra arguments either.
Arguments:
python_type (t... | python | def most_exposes(python_type):
"""
Core engine for the automatic generation of storable instances.
Finds the attributes exposed by the objects of a given type.
Mostly Python3-only.
Does not handle types which `__new__` method requires extra arguments either.
Arguments:
python_type (t... | [
"def",
"most_exposes",
"(",
"python_type",
")",
":",
"_exposes",
"=",
"set",
"(",
")",
"try",
":",
"# list all standard class attributes and methods:",
"do_not_expose",
"=",
"set",
"(",
"python_type",
".",
"__dir__",
"(",
"object",
")",
"+",
"[",
"'__slots__'",
... | Core engine for the automatic generation of storable instances.
Finds the attributes exposed by the objects of a given type.
Mostly Python3-only.
Does not handle types which `__new__` method requires extra arguments either.
Arguments:
python_type (type): object type.
Returns:
l... | [
"Core",
"engine",
"for",
"the",
"automatic",
"generation",
"of",
"storable",
"instances",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L703-L766 |
242,353 | DecBayComp/RWA-python | rwa/generic.py | default_storable | def default_storable(python_type, exposes=None, version=None, storable_type=None, peek=default_peek):
"""
Default mechanics for building the storable instance for a type.
Arguments:
python_type (type): type.
exposes (iterable): attributes exposed by the type.
version (tuple): ver... | python | def default_storable(python_type, exposes=None, version=None, storable_type=None, peek=default_peek):
"""
Default mechanics for building the storable instance for a type.
Arguments:
python_type (type): type.
exposes (iterable): attributes exposed by the type.
version (tuple): ver... | [
"def",
"default_storable",
"(",
"python_type",
",",
"exposes",
"=",
"None",
",",
"version",
"=",
"None",
",",
"storable_type",
"=",
"None",
",",
"peek",
"=",
"default_peek",
")",
":",
"if",
"not",
"exposes",
":",
"for",
"extension",
"in",
"expose_extensions"... | Default mechanics for building the storable instance for a type.
Arguments:
python_type (type): type.
exposes (iterable): attributes exposed by the type.
version (tuple): version number.
storable_type (str): universal string identifier for the type.
peek (callable): pee... | [
"Default",
"mechanics",
"for",
"building",
"the",
"storable",
"instance",
"for",
"a",
"type",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L779-L815 |
242,354 | DecBayComp/RWA-python | rwa/generic.py | not_storable | def not_storable(_type):
"""
Helper for tagging unserializable types.
Arguments:
_type (type): type to be ignored.
Returns:
Storable: storable instance that does not poke.
"""
return Storable(_type, handlers=StorableHandler(poke=fake_poke, peek=fail_peek(_type))) | python | def not_storable(_type):
"""
Helper for tagging unserializable types.
Arguments:
_type (type): type to be ignored.
Returns:
Storable: storable instance that does not poke.
"""
return Storable(_type, handlers=StorableHandler(poke=fake_poke, peek=fail_peek(_type))) | [
"def",
"not_storable",
"(",
"_type",
")",
":",
"return",
"Storable",
"(",
"_type",
",",
"handlers",
"=",
"StorableHandler",
"(",
"poke",
"=",
"fake_poke",
",",
"peek",
"=",
"fail_peek",
"(",
"_type",
")",
")",
")"
] | Helper for tagging unserializable types.
Arguments:
_type (type): type to be ignored.
Returns:
Storable: storable instance that does not poke. | [
"Helper",
"for",
"tagging",
"unserializable",
"types",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L883-L896 |
242,355 | DecBayComp/RWA-python | rwa/generic.py | force_auto | def force_auto(service, _type):
"""
Helper for forcing autoserialization of a datatype with already registered explicit
storable instance.
Arguments:
service (StorableService): active storable service.
_type (type): type to be autoserialized.
**Not tested**
"""
storable =... | python | def force_auto(service, _type):
"""
Helper for forcing autoserialization of a datatype with already registered explicit
storable instance.
Arguments:
service (StorableService): active storable service.
_type (type): type to be autoserialized.
**Not tested**
"""
storable =... | [
"def",
"force_auto",
"(",
"service",
",",
"_type",
")",
":",
"storable",
"=",
"service",
".",
"byPythonType",
"(",
"_type",
",",
"istype",
"=",
"True",
")",
"version",
"=",
"max",
"(",
"handler",
".",
"version",
"[",
"0",
"]",
"for",
"handler",
"in",
... | Helper for forcing autoserialization of a datatype with already registered explicit
storable instance.
Arguments:
service (StorableService): active storable service.
_type (type): type to be autoserialized.
**Not tested** | [
"Helper",
"for",
"forcing",
"autoserialization",
"of",
"a",
"datatype",
"with",
"already",
"registered",
"explicit",
"storable",
"instance",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L900-L916 |
242,356 | DecBayComp/RWA-python | rwa/generic.py | poke_native | def poke_native(getstate):
"""
Serializer factory for types which state can be natively serialized.
Arguments:
getstate (callable): takes an object and returns the object's state
to be passed to `pokeNative`.
Returns:
callable: serializer (`poke` routine).
"""
de... | python | def poke_native(getstate):
"""
Serializer factory for types which state can be natively serialized.
Arguments:
getstate (callable): takes an object and returns the object's state
to be passed to `pokeNative`.
Returns:
callable: serializer (`poke` routine).
"""
de... | [
"def",
"poke_native",
"(",
"getstate",
")",
":",
"def",
"poke",
"(",
"service",
",",
"objname",
",",
"obj",
",",
"container",
",",
"visited",
"=",
"None",
",",
"_stack",
"=",
"None",
")",
":",
"service",
".",
"pokeNative",
"(",
"objname",
",",
"getstat... | Serializer factory for types which state can be natively serialized.
Arguments:
getstate (callable): takes an object and returns the object's state
to be passed to `pokeNative`.
Returns:
callable: serializer (`poke` routine). | [
"Serializer",
"factory",
"for",
"types",
"which",
"state",
"can",
"be",
"natively",
"serialized",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L940-L956 |
242,357 | DecBayComp/RWA-python | rwa/generic.py | peek_native | def peek_native(make):
"""
Deserializer factory for types which state can be natively serialized.
Arguments:
make (callable): type constructor.
Returns:
callable: deserializer (`peek` routine)
"""
def peek(service, container, _stack=None):
return make(service.peekNat... | python | def peek_native(make):
"""
Deserializer factory for types which state can be natively serialized.
Arguments:
make (callable): type constructor.
Returns:
callable: deserializer (`peek` routine)
"""
def peek(service, container, _stack=None):
return make(service.peekNat... | [
"def",
"peek_native",
"(",
"make",
")",
":",
"def",
"peek",
"(",
"service",
",",
"container",
",",
"_stack",
"=",
"None",
")",
":",
"return",
"make",
"(",
"service",
".",
"peekNative",
"(",
"container",
")",
")",
"return",
"peek"
] | Deserializer factory for types which state can be natively serialized.
Arguments:
make (callable): type constructor.
Returns:
callable: deserializer (`peek` routine) | [
"Deserializer",
"factory",
"for",
"types",
"which",
"state",
"can",
"be",
"natively",
"serialized",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L958-L973 |
242,358 | DecBayComp/RWA-python | rwa/generic.py | handler | def handler(init, exposes, version=None):
"""
Simple handler with default `peek` and `poke` procedures.
Arguments:
init (callable): type constructor.
exposes (iterable): attributes to be (de-)serialized.
version (tuple): version number.
Returns:
StorableHandler: sto... | python | def handler(init, exposes, version=None):
"""
Simple handler with default `peek` and `poke` procedures.
Arguments:
init (callable): type constructor.
exposes (iterable): attributes to be (de-)serialized.
version (tuple): version number.
Returns:
StorableHandler: sto... | [
"def",
"handler",
"(",
"init",
",",
"exposes",
",",
"version",
"=",
"None",
")",
":",
"return",
"StorableHandler",
"(",
"poke",
"=",
"poke",
"(",
"exposes",
")",
",",
"peek",
"=",
"peek",
"(",
"init",
",",
"exposes",
")",
",",
"version",
"=",
"versio... | Simple handler with default `peek` and `poke` procedures.
Arguments:
init (callable): type constructor.
exposes (iterable): attributes to be (de-)serialized.
version (tuple): version number.
Returns:
StorableHandler: storable handler. | [
"Simple",
"handler",
"with",
"default",
"peek",
"and",
"poke",
"procedures",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L981-L997 |
242,359 | DecBayComp/RWA-python | rwa/generic.py | namedtuple_storable | def namedtuple_storable(namedtuple, *args, **kwargs):
"""
Storable factory for named tuples.
"""
return default_storable(namedtuple, namedtuple._fields, *args, **kwargs) | python | def namedtuple_storable(namedtuple, *args, **kwargs):
"""
Storable factory for named tuples.
"""
return default_storable(namedtuple, namedtuple._fields, *args, **kwargs) | [
"def",
"namedtuple_storable",
"(",
"namedtuple",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"default_storable",
"(",
"namedtuple",
",",
"namedtuple",
".",
"_fields",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Storable factory for named tuples. | [
"Storable",
"factory",
"for",
"named",
"tuples",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L1000-L1004 |
242,360 | DecBayComp/RWA-python | rwa/generic.py | GenericStore.pokeVisited | def pokeVisited(self, objname, obj, record, existing, visited=None, _stack=None, **kwargs):
"""
Serialize an already serialized object.
If the underlying store supports linking, this is the place where to make links.
The default implementation delegates to :meth:`pokeStorable` or :meth... | python | def pokeVisited(self, objname, obj, record, existing, visited=None, _stack=None, **kwargs):
"""
Serialize an already serialized object.
If the underlying store supports linking, this is the place where to make links.
The default implementation delegates to :meth:`pokeStorable` or :meth... | [
"def",
"pokeVisited",
"(",
"self",
",",
"objname",
",",
"obj",
",",
"record",
",",
"existing",
",",
"visited",
"=",
"None",
",",
"_stack",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"hasPythonType",
"(",
"obj",
")",
":",
"st... | Serialize an already serialized object.
If the underlying store supports linking, this is the place where to make links.
The default implementation delegates to :meth:`pokeStorable` or :meth:`pokeNative`.
Arguments:
objname (any): record reference.
obj (any): object ... | [
"Serialize",
"an",
"already",
"serialized",
"object",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L276-L309 |
242,361 | DecBayComp/RWA-python | rwa/generic.py | GenericStore.defaultStorable | def defaultStorable(self, python_type=None, storable_type=None, version=None, **kwargs):
"""
Generate a default storable instance.
Arguments:
python_type (type): Python type of the object.
storable_type (str): storable type name.
version (tuple): version n... | python | def defaultStorable(self, python_type=None, storable_type=None, version=None, **kwargs):
"""
Generate a default storable instance.
Arguments:
python_type (type): Python type of the object.
storable_type (str): storable type name.
version (tuple): version n... | [
"def",
"defaultStorable",
"(",
"self",
",",
"python_type",
"=",
"None",
",",
"storable_type",
"=",
"None",
",",
"version",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"python_type",
"is",
"None",
":",
"python_type",
"=",
"lookup_type",
"(",
"st... | Generate a default storable instance.
Arguments:
python_type (type): Python type of the object.
storable_type (str): storable type name.
version (tuple): version number of the storable handler.
Returns:
StorableHandler: storable instance.
Ex... | [
"Generate",
"a",
"default",
"storable",
"instance",
"."
] | 734a52e15a0e8c244d84d74acf3fd64721074732 | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L438-L462 |
242,362 | zeromake/aiko | aiko/request.py | RequestParameters.get | def get(self, name: str, default: Any = None) -> Any:
"""Return the first value, either the default or actual"""
return super().get(name, [default])[0] | python | def get(self, name: str, default: Any = None) -> Any:
"""Return the first value, either the default or actual"""
return super().get(name, [default])[0] | [
"def",
"get",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"None",
")",
"->",
"Any",
":",
"return",
"super",
"(",
")",
".",
"get",
"(",
"name",
",",
"[",
"default",
"]",
")",
"[",
"0",
"]"
] | Return the first value, either the default or actual | [
"Return",
"the",
"first",
"value",
"either",
"the",
"default",
"or",
"actual"
] | 53b246fa88652466a9e38ac3d1a99a6198195b0f | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/request.py#L31-L33 |
242,363 | zeromake/aiko | aiko/request.py | RequestParameters.getlist | def getlist(self, name: str, default: Any = None) -> List[Any]:
"""Return the entire list"""
return super().get(name, default) | python | def getlist(self, name: str, default: Any = None) -> List[Any]:
"""Return the entire list"""
return super().get(name, default) | [
"def",
"getlist",
"(",
"self",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"None",
")",
"->",
"List",
"[",
"Any",
"]",
":",
"return",
"super",
"(",
")",
".",
"get",
"(",
"name",
",",
"default",
")"
] | Return the entire list | [
"Return",
"the",
"entire",
"list"
] | 53b246fa88652466a9e38ac3d1a99a6198195b0f | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/request.py#L35-L37 |
242,364 | mrstephenneal/dirutility | dirutility/walk/filter.py | PathFilters.validate | def validate(self, path):
"""Run path against filter sets and return True if all pass"""
# Exclude hidden files and folders with '.' prefix
if os.path.basename(path).startswith('.'):
return False
# Check that current path level is more than min path and less than max path
... | python | def validate(self, path):
"""Run path against filter sets and return True if all pass"""
# Exclude hidden files and folders with '.' prefix
if os.path.basename(path).startswith('.'):
return False
# Check that current path level is more than min path and less than max path
... | [
"def",
"validate",
"(",
"self",
",",
"path",
")",
":",
"# Exclude hidden files and folders with '.' prefix",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
".",
"startswith",
"(",
"'.'",
")",
":",
"return",
"False",
"# Check that current path level is... | Run path against filter sets and return True if all pass | [
"Run",
"path",
"against",
"filter",
"sets",
"and",
"return",
"True",
"if",
"all",
"pass"
] | 339378659e2d7e09c53acfc51c5df745bb0cd517 | https://github.com/mrstephenneal/dirutility/blob/339378659e2d7e09c53acfc51c5df745bb0cd517/dirutility/walk/filter.py#L49-L74 |
242,365 | emin63/eyap | eyap/__init__.py | Make.comment_thread | def comment_thread(cls, backend, *args, **kwargs):
"""Create a comment thread for the desired backend.
:arg backend: String name of backend (e.g., 'file',
'github', 'redis', etc.).
:arg *args, **kwargs: Arguments to be passed to contructor
... | python | def comment_thread(cls, backend, *args, **kwargs):
"""Create a comment thread for the desired backend.
:arg backend: String name of backend (e.g., 'file',
'github', 'redis', etc.).
:arg *args, **kwargs: Arguments to be passed to contructor
... | [
"def",
"comment_thread",
"(",
"cls",
",",
"backend",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ct_cls",
"=",
"cls",
".",
"_known_backends",
".",
"get",
"(",
"backend",
")",
"if",
"not",
"ct_cls",
":",
"return",
"None",
"return",
"ct_cls",
... | Create a comment thread for the desired backend.
:arg backend: String name of backend (e.g., 'file',
'github', 'redis', etc.).
:arg *args, **kwargs: Arguments to be passed to contructor
for that backend.
~-~-~-~-~-~-~-~-~-~... | [
"Create",
"a",
"comment",
"thread",
"for",
"the",
"desired",
"backend",
"."
] | a610761973b478ca0e864e970be05ce29d5994a5 | https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/__init__.py#L123-L145 |
242,366 | political-memory/django-representatives-votes | representatives_votes/contrib/francedata/import_dossiers.py | find_dossier | def find_dossier(data):
'''
Find dossier with reference matching either 'ref_an' or 'ref_sen',
create it if not found. Ensure its reference is 'ref_an' if both fields
are present.
'''
changed = False
dossier = None
reffield = None
for field in [k for k in ('ref_an', 'ref_sen') if ... | python | def find_dossier(data):
'''
Find dossier with reference matching either 'ref_an' or 'ref_sen',
create it if not found. Ensure its reference is 'ref_an' if both fields
are present.
'''
changed = False
dossier = None
reffield = None
for field in [k for k in ('ref_an', 'ref_sen') if ... | [
"def",
"find_dossier",
"(",
"data",
")",
":",
"changed",
"=",
"False",
"dossier",
"=",
"None",
"reffield",
"=",
"None",
"for",
"field",
"in",
"[",
"k",
"for",
"k",
"in",
"(",
"'ref_an'",
",",
"'ref_sen'",
")",
"if",
"k",
"in",
"data",
"]",
":",
"tr... | Find dossier with reference matching either 'ref_an' or 'ref_sen',
create it if not found. Ensure its reference is 'ref_an' if both fields
are present. | [
"Find",
"dossier",
"with",
"reference",
"matching",
"either",
"ref_an",
"or",
"ref_sen",
"create",
"it",
"if",
"not",
"found",
".",
"Ensure",
"its",
"reference",
"is",
"ref_an",
"if",
"both",
"fields",
"are",
"present",
"."
] | 97f9f29deefec05f18e51f6c38270b791b921bac | https://github.com/political-memory/django-representatives-votes/blob/97f9f29deefec05f18e51f6c38270b791b921bac/representatives_votes/contrib/francedata/import_dossiers.py#L36-L66 |
242,367 | donovan-duplessis/pwnurl | pwnurl/models/base.py | BaseModel.saveform | def saveform(cls, form):
""" Create and save form model data to database """
columns = dict()
for name, field in cls.form_fields.iteritems():
columns[name] = getattr(form, field).data
instance = cls(**columns)
return instance.save() | python | def saveform(cls, form):
""" Create and save form model data to database """
columns = dict()
for name, field in cls.form_fields.iteritems():
columns[name] = getattr(form, field).data
instance = cls(**columns)
return instance.save() | [
"def",
"saveform",
"(",
"cls",
",",
"form",
")",
":",
"columns",
"=",
"dict",
"(",
")",
"for",
"name",
",",
"field",
"in",
"cls",
".",
"form_fields",
".",
"iteritems",
"(",
")",
":",
"columns",
"[",
"name",
"]",
"=",
"getattr",
"(",
"form",
",",
... | Create and save form model data to database | [
"Create",
"and",
"save",
"form",
"model",
"data",
"to",
"database"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L28-L35 |
242,368 | donovan-duplessis/pwnurl | pwnurl/models/base.py | BaseModel.get_by_id | def get_by_id(cls, id):
""" Get model by identifier """
if any((isinstance(id, basestring) and id.isdigit(), isinstance(id,
(int, float)))):
return cls.query.get(int(id))
return None | python | def get_by_id(cls, id):
""" Get model by identifier """
if any((isinstance(id, basestring) and id.isdigit(), isinstance(id,
(int, float)))):
return cls.query.get(int(id))
return None | [
"def",
"get_by_id",
"(",
"cls",
",",
"id",
")",
":",
"if",
"any",
"(",
"(",
"isinstance",
"(",
"id",
",",
"basestring",
")",
"and",
"id",
".",
"isdigit",
"(",
")",
",",
"isinstance",
"(",
"id",
",",
"(",
"int",
",",
"float",
")",
")",
")",
")",... | Get model by identifier | [
"Get",
"model",
"by",
"identifier"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L38-L44 |
242,369 | donovan-duplessis/pwnurl | pwnurl/models/base.py | BaseModel.update | def update(self, commit=True, **kwargs):
""" Update model attributes and save to database """
for (attr, value) in kwargs.iteritems():
setattr(self, attr, value)
return commit and self.save() or self | python | def update(self, commit=True, **kwargs):
""" Update model attributes and save to database """
for (attr, value) in kwargs.iteritems():
setattr(self, attr, value)
return commit and self.save() or self | [
"def",
"update",
"(",
"self",
",",
"commit",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"(",
"attr",
",",
"value",
")",
"in",
"kwargs",
".",
"iteritems",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"attr",
",",
"value",
")",
"return",... | Update model attributes and save to database | [
"Update",
"model",
"attributes",
"and",
"save",
"to",
"database"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L53-L58 |
242,370 | donovan-duplessis/pwnurl | pwnurl/models/base.py | BaseModel.save | def save(self, commit=True):
""" Save model to database """
db.session.add(self)
if commit:
db.session.commit()
return self | python | def save(self, commit=True):
""" Save model to database """
db.session.add(self)
if commit:
db.session.commit()
return self | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"db",
".",
"session",
".",
"add",
"(",
"self",
")",
"if",
"commit",
":",
"db",
".",
"session",
".",
"commit",
"(",
")",
"return",
"self"
] | Save model to database | [
"Save",
"model",
"to",
"database"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L60-L66 |
242,371 | donovan-duplessis/pwnurl | pwnurl/models/base.py | BaseModel.delete | def delete(self, commit=True):
""" Delete model from database """
db.session.delete(self)
return commit and db.session.commit() | python | def delete(self, commit=True):
""" Delete model from database """
db.session.delete(self)
return commit and db.session.commit() | [
"def",
"delete",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"db",
".",
"session",
".",
"delete",
"(",
"self",
")",
"return",
"commit",
"and",
"db",
".",
"session",
".",
"commit",
"(",
")"
] | Delete model from database | [
"Delete",
"model",
"from",
"database"
] | a13e27694f738228d186ea437b4d15ef5a925a87 | https://github.com/donovan-duplessis/pwnurl/blob/a13e27694f738228d186ea437b4d15ef5a925a87/pwnurl/models/base.py#L68-L72 |
242,372 | jpablo128/simplystatic | simplystatic/s2site.py | verify_dir_structure | def verify_dir_structure(full_path):
'''Check if given directory to see if it is usable by s2.
Checks that all required directories exist under the given
directory, and also checks that they are writable.
'''
if full_path == None:
return False
r = True
for d2c in PREDEFINED_DIR_NA... | python | def verify_dir_structure(full_path):
'''Check if given directory to see if it is usable by s2.
Checks that all required directories exist under the given
directory, and also checks that they are writable.
'''
if full_path == None:
return False
r = True
for d2c in PREDEFINED_DIR_NA... | [
"def",
"verify_dir_structure",
"(",
"full_path",
")",
":",
"if",
"full_path",
"==",
"None",
":",
"return",
"False",
"r",
"=",
"True",
"for",
"d2c",
"in",
"PREDEFINED_DIR_NAMES",
":",
"#if d2c == \"s2\":",
"# d2c = \".s2\"",
"cp2c",
"=",
"os",
".",
"path",
"... | Check if given directory to see if it is usable by s2.
Checks that all required directories exist under the given
directory, and also checks that they are writable. | [
"Check",
"if",
"given",
"directory",
"to",
"see",
"if",
"it",
"is",
"usable",
"by",
"s2",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L32-L53 |
242,373 | jpablo128/simplystatic | simplystatic/s2site.py | dir_param_valid | def dir_param_valid(d):
'''True if d is a string and it's an existing directory.'''
r = True
if not isinstance(d, str) :
r = False
raise TypeError
if not os.path.isdir(d):
r = False
raise ValueError
return r | python | def dir_param_valid(d):
'''True if d is a string and it's an existing directory.'''
r = True
if not isinstance(d, str) :
r = False
raise TypeError
if not os.path.isdir(d):
r = False
raise ValueError
return r | [
"def",
"dir_param_valid",
"(",
"d",
")",
":",
"r",
"=",
"True",
"if",
"not",
"isinstance",
"(",
"d",
",",
"str",
")",
":",
"r",
"=",
"False",
"raise",
"TypeError",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"d",
")",
":",
"r",
"=",
"Fal... | True if d is a string and it's an existing directory. | [
"True",
"if",
"d",
"is",
"a",
"string",
"and",
"it",
"s",
"an",
"existing",
"directory",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L55-L64 |
242,374 | jpablo128/simplystatic | simplystatic/s2site.py | dir_empty | def dir_empty(d):
'''Return True if given directory is empty, false otherwise.'''
flist = glob.glob(os.path.join(d,'*'))
return (len(flist) == 0) | python | def dir_empty(d):
'''Return True if given directory is empty, false otherwise.'''
flist = glob.glob(os.path.join(d,'*'))
return (len(flist) == 0) | [
"def",
"dir_empty",
"(",
"d",
")",
":",
"flist",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"'*'",
")",
")",
"return",
"(",
"len",
"(",
"flist",
")",
"==",
"0",
")"
] | Return True if given directory is empty, false otherwise. | [
"Return",
"True",
"if",
"given",
"directory",
"is",
"empty",
"false",
"otherwise",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L66-L69 |
242,375 | jpablo128/simplystatic | simplystatic/s2site.py | is_base_dir | def is_base_dir(d):
'''True if the dir is valid and it contains a dir called s2'''
if not dir_param_valid(d): # pragma: no cover
raise
else:
mfn = os.path.join(d,'s2') #marker name. it must be a directory.
return os.path.isdir(mfn) | python | def is_base_dir(d):
'''True if the dir is valid and it contains a dir called s2'''
if not dir_param_valid(d): # pragma: no cover
raise
else:
mfn = os.path.join(d,'s2') #marker name. it must be a directory.
return os.path.isdir(mfn) | [
"def",
"is_base_dir",
"(",
"d",
")",
":",
"if",
"not",
"dir_param_valid",
"(",
"d",
")",
":",
"# pragma: no cover",
"raise",
"else",
":",
"mfn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"'s2'",
")",
"#marker name. it must be a directory.",
"retu... | True if the dir is valid and it contains a dir called s2 | [
"True",
"if",
"the",
"dir",
"is",
"valid",
"and",
"it",
"contains",
"a",
"dir",
"called",
"s2"
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L71-L77 |
242,376 | jpablo128/simplystatic | simplystatic/s2site.py | discover_base_dir | def discover_base_dir(start_dir):
'''Return start_dir or the parent dir that has the s2 marker.
Starting from the specified directory, and going up the parent
chain, check each directory to see if it's a base_dir (contains
the "marker" directory *s2*) and return it. Otherwise, return
the start_dir.... | python | def discover_base_dir(start_dir):
'''Return start_dir or the parent dir that has the s2 marker.
Starting from the specified directory, and going up the parent
chain, check each directory to see if it's a base_dir (contains
the "marker" directory *s2*) and return it. Otherwise, return
the start_dir.... | [
"def",
"discover_base_dir",
"(",
"start_dir",
")",
":",
"if",
"is_base_dir",
"(",
"start_dir",
")",
":",
"return",
"start_dir",
"pcl",
"=",
"start_dir",
".",
"split",
"(",
"'/'",
")",
"#path component list",
"found_base_dir",
"=",
"None",
"for",
"i",
"in",
"... | Return start_dir or the parent dir that has the s2 marker.
Starting from the specified directory, and going up the parent
chain, check each directory to see if it's a base_dir (contains
the "marker" directory *s2*) and return it. Otherwise, return
the start_dir. | [
"Return",
"start_dir",
"or",
"the",
"parent",
"dir",
"that",
"has",
"the",
"s2",
"marker",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L79-L99 |
242,377 | jpablo128/simplystatic | simplystatic/s2site.py | package_data_location | def package_data_location():
'''Get the locations of themes distributed with this package.
Just finds if there are templates, and returns a dictionary with
the corresponding values.
'''
pkg_dir = os.path.split(__file__)[0]
pkg_data_dir = os.path.join(pkg_dir,'data')
return pkg_data_dir | python | def package_data_location():
'''Get the locations of themes distributed with this package.
Just finds if there are templates, and returns a dictionary with
the corresponding values.
'''
pkg_dir = os.path.split(__file__)[0]
pkg_data_dir = os.path.join(pkg_dir,'data')
return pkg_data_dir | [
"def",
"package_data_location",
"(",
")",
":",
"pkg_dir",
"=",
"os",
".",
"path",
".",
"split",
"(",
"__file__",
")",
"[",
"0",
"]",
"pkg_data_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pkg_dir",
",",
"'data'",
")",
"return",
"pkg_data_dir"
] | Get the locations of themes distributed with this package.
Just finds if there are templates, and returns a dictionary with
the corresponding values. | [
"Get",
"the",
"locations",
"of",
"themes",
"distributed",
"with",
"this",
"package",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L107-L116 |
242,378 | jpablo128/simplystatic | simplystatic/s2site.py | Site._set_directories | def _set_directories(self):
'''Initialize variables based on evidence about the directories.'''
if self._dirs['initial'] == None:
self._dirs['base'] = discover_base_dir(self._dirs['run'])
else:
self._dirs['base'] = discover_base_dir(self._dirs['initial'])
# no... | python | def _set_directories(self):
'''Initialize variables based on evidence about the directories.'''
if self._dirs['initial'] == None:
self._dirs['base'] = discover_base_dir(self._dirs['run'])
else:
self._dirs['base'] = discover_base_dir(self._dirs['initial'])
# no... | [
"def",
"_set_directories",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirs",
"[",
"'initial'",
"]",
"==",
"None",
":",
"self",
".",
"_dirs",
"[",
"'base'",
"]",
"=",
"discover_base_dir",
"(",
"self",
".",
"_dirs",
"[",
"'run'",
"]",
")",
"else",
":"... | Initialize variables based on evidence about the directories. | [
"Initialize",
"variables",
"based",
"on",
"evidence",
"about",
"the",
"directories",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L207-L220 |
242,379 | jpablo128/simplystatic | simplystatic/s2site.py | Site._update_dirs_on_base | def _update_dirs_on_base(self):
'''Fill up the names of dirs based on the contents of 'base'.'''
if self._dirs['base'] != None:
for d in self._predefined_dir_names:
dstr = d
#if d == "s2":
# dstr = '.'+d
self._dirs[d] = os.pa... | python | def _update_dirs_on_base(self):
'''Fill up the names of dirs based on the contents of 'base'.'''
if self._dirs['base'] != None:
for d in self._predefined_dir_names:
dstr = d
#if d == "s2":
# dstr = '.'+d
self._dirs[d] = os.pa... | [
"def",
"_update_dirs_on_base",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirs",
"[",
"'base'",
"]",
"!=",
"None",
":",
"for",
"d",
"in",
"self",
".",
"_predefined_dir_names",
":",
"dstr",
"=",
"d",
"#if d == \"s2\":",
"# dstr = '.'+d",
"self",
".",
"_... | Fill up the names of dirs based on the contents of 'base'. | [
"Fill",
"up",
"the",
"names",
"of",
"dirs",
"based",
"on",
"the",
"contents",
"of",
"base",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L222-L229 |
242,380 | jpablo128/simplystatic | simplystatic/s2site.py | Site.init_structure | def init_structure(self):
'''Initialize a directory to serve as a Simply Static site.
Initialization is done on the base_dir (base_dir is set upon
__init__, so it has a value when this method is called), and it
is only performed if base_dir is empty and it is writeable.
This op... | python | def init_structure(self):
'''Initialize a directory to serve as a Simply Static site.
Initialization is done on the base_dir (base_dir is set upon
__init__, so it has a value when this method is called), and it
is only performed if base_dir is empty and it is writeable.
This op... | [
"def",
"init_structure",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirs",
"[",
"'base'",
"]",
"!=",
"None",
":",
"# pragma: no cover ",
"#there's a base here or up the chain",
"raise",
"ValueError",
"#cannot initialize",
"else",
":",
"if",
"self",
".",
"_dirs",
... | Initialize a directory to serve as a Simply Static site.
Initialization is done on the base_dir (base_dir is set upon
__init__, so it has a value when this method is called), and it
is only performed if base_dir is empty and it is writeable.
This operation creates the directories, copi... | [
"Initialize",
"a",
"directory",
"to",
"serve",
"as",
"a",
"Simply",
"Static",
"site",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L236-L275 |
242,381 | jpablo128/simplystatic | simplystatic/s2site.py | Site.random_page | def random_page(self, title=None, content=None,
creation_date=None, tags=None):
'''Generate random page, write it and return the corresponding \
object.'''
if title == None:
title = util.random_title()
if content == None:
content = util.random_md_page... | python | def random_page(self, title=None, content=None,
creation_date=None, tags=None):
'''Generate random page, write it and return the corresponding \
object.'''
if title == None:
title = util.random_title()
if content == None:
content = util.random_md_page... | [
"def",
"random_page",
"(",
"self",
",",
"title",
"=",
"None",
",",
"content",
"=",
"None",
",",
"creation_date",
"=",
"None",
",",
"tags",
"=",
"None",
")",
":",
"if",
"title",
"==",
"None",
":",
"title",
"=",
"util",
".",
"random_title",
"(",
")",
... | Generate random page, write it and return the corresponding \
object. | [
"Generate",
"random",
"page",
"write",
"it",
"and",
"return",
"the",
"corresponding",
"\\",
"object",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L474-L495 |
242,382 | jpablo128/simplystatic | simplystatic/s2site.py | Site.page_exists_on_disk | def page_exists_on_disk(self, slug):
'''Return true if post directory and post file both exist.'''
r = False
page_dir = os.path.join(self.dirs['source'], slug)
page_file_name = os.path.join(page_dir, slug + '.md')
if os.path.isdir(page_dir):
if os.path.isfile(page_fi... | python | def page_exists_on_disk(self, slug):
'''Return true if post directory and post file both exist.'''
r = False
page_dir = os.path.join(self.dirs['source'], slug)
page_file_name = os.path.join(page_dir, slug + '.md')
if os.path.isdir(page_dir):
if os.path.isfile(page_fi... | [
"def",
"page_exists_on_disk",
"(",
"self",
",",
"slug",
")",
":",
"r",
"=",
"False",
"page_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dirs",
"[",
"'source'",
"]",
",",
"slug",
")",
"page_file_name",
"=",
"os",
".",
"path",
".",
"... | Return true if post directory and post file both exist. | [
"Return",
"true",
"if",
"post",
"directory",
"and",
"post",
"file",
"both",
"exist",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L497-L506 |
242,383 | jpablo128/simplystatic | simplystatic/s2site.py | Site.rename_page | def rename_page(self, old_slug, new_title):
'''Load the page corresponding to the slug, and rename it.'''
#load page
p = s2page.Page(self, old_slug, isslug=True)
p.rename(new_title) | python | def rename_page(self, old_slug, new_title):
'''Load the page corresponding to the slug, and rename it.'''
#load page
p = s2page.Page(self, old_slug, isslug=True)
p.rename(new_title) | [
"def",
"rename_page",
"(",
"self",
",",
"old_slug",
",",
"new_title",
")",
":",
"#load page",
"p",
"=",
"s2page",
".",
"Page",
"(",
"self",
",",
"old_slug",
",",
"isslug",
"=",
"True",
")",
"p",
".",
"rename",
"(",
"new_title",
")"
] | Load the page corresponding to the slug, and rename it. | [
"Load",
"the",
"page",
"corresponding",
"to",
"the",
"slug",
"and",
"rename",
"it",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L508-L512 |
242,384 | jpablo128/simplystatic | simplystatic/s2site.py | Site._wipe_www_page | def _wipe_www_page(self, slug):
'''Remove all data in www about the page identified by slug.'''
wd = os.path.join(self._dirs['www'], slug)
if os.path.isdir(wd): # pragma: no cover
shutil.rmtree(wd) | python | def _wipe_www_page(self, slug):
'''Remove all data in www about the page identified by slug.'''
wd = os.path.join(self._dirs['www'], slug)
if os.path.isdir(wd): # pragma: no cover
shutil.rmtree(wd) | [
"def",
"_wipe_www_page",
"(",
"self",
",",
"slug",
")",
":",
"wd",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_dirs",
"[",
"'www'",
"]",
",",
"slug",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"wd",
")",
":",
"# pragma: no cove... | Remove all data in www about the page identified by slug. | [
"Remove",
"all",
"data",
"in",
"www",
"about",
"the",
"page",
"identified",
"by",
"slug",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L524-L528 |
242,385 | jpablo128/simplystatic | simplystatic/s2site.py | Site._pages_to_generate | def _pages_to_generate(self):
'''Return list of slugs that correspond to pages to generate.'''
# right now it gets all the files. In theory, It should only
# get what's changed... but the program is not doing that yet.
all_pages = self.get_page_names()
# keep only those whose st... | python | def _pages_to_generate(self):
'''Return list of slugs that correspond to pages to generate.'''
# right now it gets all the files. In theory, It should only
# get what's changed... but the program is not doing that yet.
all_pages = self.get_page_names()
# keep only those whose st... | [
"def",
"_pages_to_generate",
"(",
"self",
")",
":",
"# right now it gets all the files. In theory, It should only",
"# get what's changed... but the program is not doing that yet.",
"all_pages",
"=",
"self",
".",
"get_page_names",
"(",
")",
"# keep only those whose status is published"... | Return list of slugs that correspond to pages to generate. | [
"Return",
"list",
"of",
"slugs",
"that",
"correspond",
"to",
"pages",
"to",
"generate",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L530-L546 |
242,386 | jpablo128/simplystatic | simplystatic/s2site.py | Site._create_default_config | def _create_default_config(self):
'''Create and write to disk a default site config file.'''
# maybe I should read the default config from somewhere in the package?
cfg = { 'site_title': '',
'site_subtitle': '',
'default_author': '',
'site_url': ''... | python | def _create_default_config(self):
'''Create and write to disk a default site config file.'''
# maybe I should read the default config from somewhere in the package?
cfg = { 'site_title': '',
'site_subtitle': '',
'default_author': '',
'site_url': ''... | [
"def",
"_create_default_config",
"(",
"self",
")",
":",
"# maybe I should read the default config from somewhere in the package?",
"cfg",
"=",
"{",
"'site_title'",
":",
"''",
",",
"'site_subtitle'",
":",
"''",
",",
"'default_author'",
":",
"''",
",",
"'site_url'",
":",
... | Create and write to disk a default site config file. | [
"Create",
"and",
"write",
"to",
"disk",
"a",
"default",
"site",
"config",
"file",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L548-L565 |
242,387 | jpablo128/simplystatic | simplystatic/s2site.py | Site._read_site_config | def _read_site_config(self):
'''Read and return the site config, as a dictionary.'''
file_name = os.path.join(self._dirs['s2'],'config.yml')
if os.path.isfile(file_name):
f = open(file_name,'r')
cfg = yaml.load(f.read())
f.close()
else:
cfg... | python | def _read_site_config(self):
'''Read and return the site config, as a dictionary.'''
file_name = os.path.join(self._dirs['s2'],'config.yml')
if os.path.isfile(file_name):
f = open(file_name,'r')
cfg = yaml.load(f.read())
f.close()
else:
cfg... | [
"def",
"_read_site_config",
"(",
"self",
")",
":",
"file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_dirs",
"[",
"'s2'",
"]",
",",
"'config.yml'",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"file_name",
")",
":",
"f",
"="... | Read and return the site config, as a dictionary. | [
"Read",
"and",
"return",
"the",
"site",
"config",
"as",
"a",
"dictionary",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/s2site.py#L567-L576 |
242,388 | OiNutter/lean | lean/__init__.py | Lean.register | def register(template_class,*extensions):
''' Register a template for a given extension or range of extensions '''
for ext in extensions:
ext = normalize(ext)
if not Lean.template_mappings.has_key(ext):
Lean.template_mappings[ext] = []
Lean.template_mappings[ext].insert(0,template_class)
Lean.templ... | python | def register(template_class,*extensions):
''' Register a template for a given extension or range of extensions '''
for ext in extensions:
ext = normalize(ext)
if not Lean.template_mappings.has_key(ext):
Lean.template_mappings[ext] = []
Lean.template_mappings[ext].insert(0,template_class)
Lean.templ... | [
"def",
"register",
"(",
"template_class",
",",
"*",
"extensions",
")",
":",
"for",
"ext",
"in",
"extensions",
":",
"ext",
"=",
"normalize",
"(",
"ext",
")",
"if",
"not",
"Lean",
".",
"template_mappings",
".",
"has_key",
"(",
"ext",
")",
":",
"Lean",
".... | Register a template for a given extension or range of extensions | [
"Register",
"a",
"template",
"for",
"a",
"given",
"extension",
"or",
"range",
"of",
"extensions"
] | 5d251f923acd44265ed401de14a9ead6752c543f | https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/__init__.py#L10-L18 |
242,389 | OiNutter/lean | lean/__init__.py | Lean.is_registered | def is_registered(ext):
''' Returns true when a template exists on an exact match of the provided file extension '''
return Lean.template_mappings.has_key(ext.lower()) and len(Lean.template_mappings[ext]) | python | def is_registered(ext):
''' Returns true when a template exists on an exact match of the provided file extension '''
return Lean.template_mappings.has_key(ext.lower()) and len(Lean.template_mappings[ext]) | [
"def",
"is_registered",
"(",
"ext",
")",
":",
"return",
"Lean",
".",
"template_mappings",
".",
"has_key",
"(",
"ext",
".",
"lower",
"(",
")",
")",
"and",
"len",
"(",
"Lean",
".",
"template_mappings",
"[",
"ext",
"]",
")"
] | Returns true when a template exists on an exact match of the provided file extension | [
"Returns",
"true",
"when",
"a",
"template",
"exists",
"on",
"an",
"exact",
"match",
"of",
"the",
"provided",
"file",
"extension"
] | 5d251f923acd44265ed401de14a9ead6752c543f | https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/__init__.py#L44-L46 |
242,390 | OiNutter/lean | lean/__init__.py | Lean.load | def load(file,line=None,options={},block=None):
''' Create a new template for the given file using the file's extension
to determine the the template mapping.
'''
template_class = Lean.get_template(file)
if template_class:
return template_class(file,line,options,block)
else:
rai... | python | def load(file,line=None,options={},block=None):
''' Create a new template for the given file using the file's extension
to determine the the template mapping.
'''
template_class = Lean.get_template(file)
if template_class:
return template_class(file,line,options,block)
else:
rai... | [
"def",
"load",
"(",
"file",
",",
"line",
"=",
"None",
",",
"options",
"=",
"{",
"}",
",",
"block",
"=",
"None",
")",
":",
"template_class",
"=",
"Lean",
".",
"get_template",
"(",
"file",
")",
"if",
"template_class",
":",
"return",
"template_class",
"("... | Create a new template for the given file using the file's extension
to determine the the template mapping. | [
"Create",
"a",
"new",
"template",
"for",
"the",
"given",
"file",
"using",
"the",
"file",
"s",
"extension",
"to",
"determine",
"the",
"the",
"template",
"mapping",
"."
] | 5d251f923acd44265ed401de14a9ead6752c543f | https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/__init__.py#L49-L58 |
242,391 | OiNutter/lean | lean/__init__.py | Lean.get_template | def get_template(file):
''' Lookup a template class for the given filename or file
extension. Return nil when no implementation is found.
'''
pattern = str(file).lower()
while len(pattern) and not Lean.is_registered(pattern):
pattern = os.path.basename(pattern)
pattern = re.sub(r'^[... | python | def get_template(file):
''' Lookup a template class for the given filename or file
extension. Return nil when no implementation is found.
'''
pattern = str(file).lower()
while len(pattern) and not Lean.is_registered(pattern):
pattern = os.path.basename(pattern)
pattern = re.sub(r'^[... | [
"def",
"get_template",
"(",
"file",
")",
":",
"pattern",
"=",
"str",
"(",
"file",
")",
".",
"lower",
"(",
")",
"while",
"len",
"(",
"pattern",
")",
"and",
"not",
"Lean",
".",
"is_registered",
"(",
"pattern",
")",
":",
"pattern",
"=",
"os",
".",
"pa... | Lookup a template class for the given filename or file
extension. Return nil when no implementation is found. | [
"Lookup",
"a",
"template",
"class",
"for",
"the",
"given",
"filename",
"or",
"file",
"extension",
".",
"Return",
"nil",
"when",
"no",
"implementation",
"is",
"found",
"."
] | 5d251f923acd44265ed401de14a9ead6752c543f | https://github.com/OiNutter/lean/blob/5d251f923acd44265ed401de14a9ead6752c543f/lean/__init__.py#L61-L103 |
242,392 | steenzout/python-sphinx | steenzout/sphinx/cli.py | generate | def generate(organization, package, destination):
"""Generates the Sphinx configuration and Makefile.
Args:
organization (str): the organization name.
package (str): the package to be documented.
destination (str): the destination directory.
"""
gen = ResourceGenerator(organizat... | python | def generate(organization, package, destination):
"""Generates the Sphinx configuration and Makefile.
Args:
organization (str): the organization name.
package (str): the package to be documented.
destination (str): the destination directory.
"""
gen = ResourceGenerator(organizat... | [
"def",
"generate",
"(",
"organization",
",",
"package",
",",
"destination",
")",
":",
"gen",
"=",
"ResourceGenerator",
"(",
"organization",
",",
"package",
")",
"tmp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"mode",
"=",
"'w+t'",
",",
"delete",
"=",... | Generates the Sphinx configuration and Makefile.
Args:
organization (str): the organization name.
package (str): the package to be documented.
destination (str): the destination directory. | [
"Generates",
"the",
"Sphinx",
"configuration",
"and",
"Makefile",
"."
] | b9767195fba74540c385fdf5f94cc4a24bc5e46d | https://github.com/steenzout/python-sphinx/blob/b9767195fba74540c385fdf5f94cc4a24bc5e46d/steenzout/sphinx/cli.py#L33-L57 |
242,393 | elifesciences/elife-article | elifearticle/article.py | Article.get_self_uri | def get_self_uri(self, content_type):
"return the first self uri with the content_type"
try:
return [self_uri for self_uri in self.self_uri_list
if self_uri.content_type == content_type][0]
except IndexError:
return None | python | def get_self_uri(self, content_type):
"return the first self uri with the content_type"
try:
return [self_uri for self_uri in self.self_uri_list
if self_uri.content_type == content_type][0]
except IndexError:
return None | [
"def",
"get_self_uri",
"(",
"self",
",",
"content_type",
")",
":",
"try",
":",
"return",
"[",
"self_uri",
"for",
"self_uri",
"in",
"self",
".",
"self_uri_list",
"if",
"self_uri",
".",
"content_type",
"==",
"content_type",
"]",
"[",
"0",
"]",
"except",
"Ind... | return the first self uri with the content_type | [
"return",
"the",
"first",
"self",
"uri",
"with",
"the",
"content_type"
] | 99710c213cd81fe6fd1e5c150d6e20efe2d1e33b | https://github.com/elifesciences/elife-article/blob/99710c213cd81fe6fd1e5c150d6e20efe2d1e33b/elifearticle/article.py#L145-L151 |
242,394 | elifesciences/elife-article | elifearticle/article.py | Article.pretty | def pretty(self):
"sort values and format output for viewing and comparing in test scenarios"
pretty_obj = OrderedDict()
for key, value in sorted(iteritems(self.__dict__)):
if value is None:
pretty_obj[key] = None
elif is_str_or_unicode(value):
... | python | def pretty(self):
"sort values and format output for viewing and comparing in test scenarios"
pretty_obj = OrderedDict()
for key, value in sorted(iteritems(self.__dict__)):
if value is None:
pretty_obj[key] = None
elif is_str_or_unicode(value):
... | [
"def",
"pretty",
"(",
"self",
")",
":",
"pretty_obj",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"iteritems",
"(",
"self",
".",
"__dict__",
")",
")",
":",
"if",
"value",
"is",
"None",
":",
"pretty_obj",
"[",
"key",... | sort values and format output for viewing and comparing in test scenarios | [
"sort",
"values",
"and",
"format",
"output",
"for",
"viewing",
"and",
"comparing",
"in",
"test",
"scenarios"
] | 99710c213cd81fe6fd1e5c150d6e20efe2d1e33b | https://github.com/elifesciences/elife-article/blob/99710c213cd81fe6fd1e5c150d6e20efe2d1e33b/elifearticle/article.py#L153-L167 |
242,395 | biocore/mustached-octo-ironman | moi/__init__.py | _support_directory | def _support_directory():
"""Get the path of the support_files directory"""
from os.path import join, dirname, abspath
return join(dirname(abspath(__file__)), 'support_files') | python | def _support_directory():
"""Get the path of the support_files directory"""
from os.path import join, dirname, abspath
return join(dirname(abspath(__file__)), 'support_files') | [
"def",
"_support_directory",
"(",
")",
":",
"from",
"os",
".",
"path",
"import",
"join",
",",
"dirname",
",",
"abspath",
"return",
"join",
"(",
"dirname",
"(",
"abspath",
"(",
"__file__",
")",
")",
",",
"'support_files'",
")"
] | Get the path of the support_files directory | [
"Get",
"the",
"path",
"of",
"the",
"support_files",
"directory"
] | 54128d8fdff327e1b7ffd9bb77bf38c3df9526d7 | https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/__init__.py#L21-L24 |
242,396 | EnigmaBridge/client.py | ebclient/eb_create_uo.py | CreateUO.create_uo | def create_uo(self, configuration=None, tpl=None, keys=None, obj_type=None):
"""
Create a new UserObject from the given template.
:param configuration: EB configuration to use
:param tpl: CreateUserObject template, contain misc settings
:param keys: dictionary of keys, create_u... | python | def create_uo(self, configuration=None, tpl=None, keys=None, obj_type=None):
"""
Create a new UserObject from the given template.
:param configuration: EB configuration to use
:param tpl: CreateUserObject template, contain misc settings
:param keys: dictionary of keys, create_u... | [
"def",
"create_uo",
"(",
"self",
",",
"configuration",
"=",
"None",
",",
"tpl",
"=",
"None",
",",
"keys",
"=",
"None",
",",
"obj_type",
"=",
"None",
")",
":",
"if",
"configuration",
"is",
"not",
"None",
":",
"self",
".",
"configuration",
"=",
"configur... | Create a new UserObject from the given template.
:param configuration: EB configuration to use
:param tpl: CreateUserObject template, contain misc settings
:param keys: dictionary of keys, create_uo.KeyTypes. Communication keys, application key (if applicable).
:param obj_type: optiona... | [
"Create",
"a",
"new",
"UserObject",
"from",
"the",
"given",
"template",
"."
] | 0fafe3902da394da88e9f960751d695ca65bbabd | https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_create_uo.py#L36-L84 |
242,397 | EnigmaBridge/client.py | ebclient/eb_create_uo.py | CreateUO.set_type | def set_type(spec, obj_type):
"""
Updates type integer in the cerate UO specification.
Type has to already have generations flags set correctly.
Generation field is set accordingly.
:param spec:
:param obj_type:
:return:
"""
if spec is None:
... | python | def set_type(spec, obj_type):
"""
Updates type integer in the cerate UO specification.
Type has to already have generations flags set correctly.
Generation field is set accordingly.
:param spec:
:param obj_type:
:return:
"""
if spec is None:
... | [
"def",
"set_type",
"(",
"spec",
",",
"obj_type",
")",
":",
"if",
"spec",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Spec cannot be None'",
")",
"if",
"TemplateFields",
".",
"generation",
"not",
"in",
"spec",
":",
"spec",
"[",
"TemplateFields",
".",
"... | Updates type integer in the cerate UO specification.
Type has to already have generations flags set correctly.
Generation field is set accordingly.
:param spec:
:param obj_type:
:return: | [
"Updates",
"type",
"integer",
"in",
"the",
"cerate",
"UO",
"specification",
".",
"Type",
"has",
"to",
"already",
"have",
"generations",
"flags",
"set",
"correctly",
".",
"Generation",
"field",
"is",
"set",
"accordingly",
"."
] | 0fafe3902da394da88e9f960751d695ca65bbabd | https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_create_uo.py#L165-L185 |
242,398 | EnigmaBridge/client.py | ebclient/eb_create_uo.py | CreateUO.get_uo_type | def get_uo_type(obj_type, comm_keys_provided=True, app_keys_provided=True):
"""
Constructs UO type from the operation and keys provided, clears bits set ib obj_type before
unless None is specified to the given parameters.
:param obj_type:
:param comm_keys_provided:
:para... | python | def get_uo_type(obj_type, comm_keys_provided=True, app_keys_provided=True):
"""
Constructs UO type from the operation and keys provided, clears bits set ib obj_type before
unless None is specified to the given parameters.
:param obj_type:
:param comm_keys_provided:
:para... | [
"def",
"get_uo_type",
"(",
"obj_type",
",",
"comm_keys_provided",
"=",
"True",
",",
"app_keys_provided",
"=",
"True",
")",
":",
"if",
"comm_keys_provided",
"is",
"not",
"None",
"and",
"comm_keys_provided",
"==",
"False",
":",
"obj_type",
"&=",
"~",
"(",
"int",... | Constructs UO type from the operation and keys provided, clears bits set ib obj_type before
unless None is specified to the given parameters.
:param obj_type:
:param comm_keys_provided:
:param app_keys_provided:
:return: | [
"Constructs",
"UO",
"type",
"from",
"the",
"operation",
"and",
"keys",
"provided",
"clears",
"bits",
"set",
"ib",
"obj_type",
"before",
"unless",
"None",
"is",
"specified",
"to",
"the",
"given",
"parameters",
"."
] | 0fafe3902da394da88e9f960751d695ca65bbabd | https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_create_uo.py#L188-L208 |
242,399 | EnigmaBridge/client.py | ebclient/eb_create_uo.py | CreateUO.template_request | def template_request(configuration, spec):
"""
Calls the get template request
:param configuration:
:param spec:
:return:
"""
# Template request, nonce will be regenerated.
req = CreateUO.get_template_request(configuration, spec)
# Do the request... | python | def template_request(configuration, spec):
"""
Calls the get template request
:param configuration:
:param spec:
:return:
"""
# Template request, nonce will be regenerated.
req = CreateUO.get_template_request(configuration, spec)
# Do the request... | [
"def",
"template_request",
"(",
"configuration",
",",
"spec",
")",
":",
"# Template request, nonce will be regenerated.",
"req",
"=",
"CreateUO",
".",
"get_template_request",
"(",
"configuration",
",",
"spec",
")",
"# Do the request with retry.",
"caller",
"=",
"RequestCa... | Calls the get template request
:param configuration:
:param spec:
:return: | [
"Calls",
"the",
"get",
"template",
"request"
] | 0fafe3902da394da88e9f960751d695ca65bbabd | https://github.com/EnigmaBridge/client.py/blob/0fafe3902da394da88e9f960751d695ca65bbabd/ebclient/eb_create_uo.py#L237-L251 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.