partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | eval_step.nvim_io_recover | calls `map` to shift the recover execution to flat_map_nvim_io | ribosome/nvim/io/compute.py | def nvim_io_recover(self, io: NvimIORecover[A]) -> NvimIO[B]:
'''calls `map` to shift the recover execution to flat_map_nvim_io
'''
return eval_step(self.vim)(io.map(lambda a: a)) | def nvim_io_recover(self, io: NvimIORecover[A]) -> NvimIO[B]:
'''calls `map` to shift the recover execution to flat_map_nvim_io
'''
return eval_step(self.vim)(io.map(lambda a: a)) | [
"calls",
"map",
"to",
"shift",
"the",
"recover",
"execution",
"to",
"flat_map_nvim_io"
] | tek/ribosome | python | https://github.com/tek/ribosome/blob/b2ce9e118faa46d93506cbbb5f27ecfbd4e8a1cc/ribosome/nvim/io/compute.py#L242-L245 | [
"def",
"nvim_io_recover",
"(",
"self",
",",
"io",
":",
"NvimIORecover",
"[",
"A",
"]",
")",
"->",
"NvimIO",
"[",
"B",
"]",
":",
"return",
"eval_step",
"(",
"self",
".",
"vim",
")",
"(",
"io",
".",
"map",
"(",
"lambda",
"a",
":",
"a",
")",
")"
] | b2ce9e118faa46d93506cbbb5f27ecfbd4e8a1cc |
test | read_codeml_output | Read codeml file. | pyasr/read.py | def read_codeml_output(
filename,
df,
altall_cutoff=0.2,
):
"""Read codeml file.
"""
# Read paml output.
with open(filename, 'r') as f:
data = f.read()
# Rip all trees out of the codeml output.
regex = re.compile('\([()\w\:. ,]+;')
trees = regex.findall(data)
anc... | def read_codeml_output(
filename,
df,
altall_cutoff=0.2,
):
"""Read codeml file.
"""
# Read paml output.
with open(filename, 'r') as f:
data = f.read()
# Rip all trees out of the codeml output.
regex = re.compile('\([()\w\:. ,]+;')
trees = regex.findall(data)
anc... | [
"Read",
"codeml",
"file",
"."
] | Zsailer/pyasr | python | https://github.com/Zsailer/pyasr/blob/f9a05912ae2409a4cb2d8bac878bb5230c8824b4/pyasr/read.py#L6-L123 | [
"def",
"read_codeml_output",
"(",
"filename",
",",
"df",
",",
"altall_cutoff",
"=",
"0.2",
",",
")",
":",
"# Read paml output.",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
"# Rip all trees o... | f9a05912ae2409a4cb2d8bac878bb5230c8824b4 |
test | ugettext | Always return a stripped string, localized if possible | tower/__init__.py | def ugettext(message, context=None):
"""Always return a stripped string, localized if possible"""
stripped = strip_whitespace(message)
message = add_context(context, stripped) if context else stripped
ret = django_ugettext(message)
# If the context isn't found, we need to return the string withou... | def ugettext(message, context=None):
"""Always return a stripped string, localized if possible"""
stripped = strip_whitespace(message)
message = add_context(context, stripped) if context else stripped
ret = django_ugettext(message)
# If the context isn't found, we need to return the string withou... | [
"Always",
"return",
"a",
"stripped",
"string",
"localized",
"if",
"possible"
] | clouserw/tower | python | https://github.com/clouserw/tower/blob/e2ac254f7dac887952441592f7772af7bb25cc7b/tower/__init__.py#L22-L31 | [
"def",
"ugettext",
"(",
"message",
",",
"context",
"=",
"None",
")",
":",
"stripped",
"=",
"strip_whitespace",
"(",
"message",
")",
"message",
"=",
"add_context",
"(",
"context",
",",
"stripped",
")",
"if",
"context",
"else",
"stripped",
"ret",
"=",
"djang... | e2ac254f7dac887952441592f7772af7bb25cc7b |
test | ungettext | Always return a stripped string, localized if possible | tower/__init__.py | def ungettext(singular, plural, number, context=None):
"""Always return a stripped string, localized if possible"""
singular_stripped = strip_whitespace(singular)
plural_stripped = strip_whitespace(plural)
if context:
singular = add_context(context, singular_stripped)
plural = add_conte... | def ungettext(singular, plural, number, context=None):
"""Always return a stripped string, localized if possible"""
singular_stripped = strip_whitespace(singular)
plural_stripped = strip_whitespace(plural)
if context:
singular = add_context(context, singular_stripped)
plural = add_conte... | [
"Always",
"return",
"a",
"stripped",
"string",
"localized",
"if",
"possible"
] | clouserw/tower | python | https://github.com/clouserw/tower/blob/e2ac254f7dac887952441592f7772af7bb25cc7b/tower/__init__.py#L34-L53 | [
"def",
"ungettext",
"(",
"singular",
",",
"plural",
",",
"number",
",",
"context",
"=",
"None",
")",
":",
"singular_stripped",
"=",
"strip_whitespace",
"(",
"singular",
")",
"plural_stripped",
"=",
"strip_whitespace",
"(",
"plural",
")",
"if",
"context",
":",
... | e2ac254f7dac887952441592f7772af7bb25cc7b |
test | install_jinja_translations | Install our gettext and ngettext functions into Jinja2's environment. | tower/__init__.py | def install_jinja_translations():
"""
Install our gettext and ngettext functions into Jinja2's environment.
"""
class Translation(object):
"""
We pass this object to jinja so it can find our gettext implementation.
If we pass the GNUTranslation object directly, it won't have our
... | def install_jinja_translations():
"""
Install our gettext and ngettext functions into Jinja2's environment.
"""
class Translation(object):
"""
We pass this object to jinja so it can find our gettext implementation.
If we pass the GNUTranslation object directly, it won't have our
... | [
"Install",
"our",
"gettext",
"and",
"ngettext",
"functions",
"into",
"Jinja2",
"s",
"environment",
"."
] | clouserw/tower | python | https://github.com/clouserw/tower/blob/e2ac254f7dac887952441592f7772af7bb25cc7b/tower/__init__.py#L76-L90 | [
"def",
"install_jinja_translations",
"(",
")",
":",
"class",
"Translation",
"(",
"object",
")",
":",
"\"\"\"\n We pass this object to jinja so it can find our gettext implementation.\n If we pass the GNUTranslation object directly, it won't have our\n context and whitespac... | e2ac254f7dac887952441592f7772af7bb25cc7b |
test | activate | Override django's utils.translation.activate(). Django forces files
to be named django.mo (http://code.djangoproject.com/ticket/6376). Since
that's dumb and we want to be able to load different files depending on
what part of the site the user is in, we'll make our own function here. | tower/__init__.py | def activate(locale):
"""
Override django's utils.translation.activate(). Django forces files
to be named django.mo (http://code.djangoproject.com/ticket/6376). Since
that's dumb and we want to be able to load different files depending on
what part of the site the user is in, we'll make our own fu... | def activate(locale):
"""
Override django's utils.translation.activate(). Django forces files
to be named django.mo (http://code.djangoproject.com/ticket/6376). Since
that's dumb and we want to be able to load different files depending on
what part of the site the user is in, we'll make our own fu... | [
"Override",
"django",
"s",
"utils",
".",
"translation",
".",
"activate",
"()",
".",
"Django",
"forces",
"files",
"to",
"be",
"named",
"django",
".",
"mo",
"(",
"http",
":",
"//",
"code",
".",
"djangoproject",
".",
"com",
"/",
"ticket",
"/",
"6376",
")"... | clouserw/tower | python | https://github.com/clouserw/tower/blob/e2ac254f7dac887952441592f7772af7bb25cc7b/tower/__init__.py#L93-L107 | [
"def",
"activate",
"(",
"locale",
")",
":",
"if",
"INSTALL_JINJA_TRANSLATIONS",
":",
"install_jinja_translations",
"(",
")",
"if",
"django",
".",
"VERSION",
">=",
"(",
"1",
",",
"3",
")",
":",
"django_trans",
".",
"_active",
".",
"value",
"=",
"_activate",
... | e2ac254f7dac887952441592f7772af7bb25cc7b |
test | tweak_message | We piggyback on jinja2's babel_extract() (really, Babel's extract_*
functions) but they don't support some things we need so this function will
tweak the message. Specifically:
1) We strip whitespace from the msgid. Jinja2 will only strip
whitespace from the ends of a string so linebreaks... | tower/__init__.py | def tweak_message(message):
"""We piggyback on jinja2's babel_extract() (really, Babel's extract_*
functions) but they don't support some things we need so this function will
tweak the message. Specifically:
1) We strip whitespace from the msgid. Jinja2 will only strip
whitespace from... | def tweak_message(message):
"""We piggyback on jinja2's babel_extract() (really, Babel's extract_*
functions) but they don't support some things we need so this function will
tweak the message. Specifically:
1) We strip whitespace from the msgid. Jinja2 will only strip
whitespace from... | [
"We",
"piggyback",
"on",
"jinja2",
"s",
"babel_extract",
"()",
"(",
"really",
"Babel",
"s",
"extract_",
"*",
"functions",
")",
"but",
"they",
"don",
"t",
"support",
"some",
"things",
"we",
"need",
"so",
"this",
"function",
"will",
"tweak",
"the",
"message"... | clouserw/tower | python | https://github.com/clouserw/tower/blob/e2ac254f7dac887952441592f7772af7bb25cc7b/tower/__init__.py#L169-L198 | [
"def",
"tweak_message",
"(",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"basestring",
")",
":",
"message",
"=",
"strip_whitespace",
"(",
"message",
")",
"elif",
"isinstance",
"(",
"message",
",",
"tuple",
")",
":",
"# A tuple of 2 has contex... | e2ac254f7dac887952441592f7772af7bb25cc7b |
test | exclusive_ns | this is the central unsafe function, using a lock and updating the state in `guard` in-place. | ribosome/rpc/comm.py | def exclusive_ns(guard: StateGuard[A], desc: str, thunk: Callable[..., NS[A, B]], *a: Any) -> Do:
'''this is the central unsafe function, using a lock and updating the state in `guard` in-place.
'''
yield guard.acquire()
log.debug2(lambda: f'exclusive: {desc}')
state, response = yield N.ensure_failu... | def exclusive_ns(guard: StateGuard[A], desc: str, thunk: Callable[..., NS[A, B]], *a: Any) -> Do:
'''this is the central unsafe function, using a lock and updating the state in `guard` in-place.
'''
yield guard.acquire()
log.debug2(lambda: f'exclusive: {desc}')
state, response = yield N.ensure_failu... | [
"this",
"is",
"the",
"central",
"unsafe",
"function",
"using",
"a",
"lock",
"and",
"updating",
"the",
"state",
"in",
"guard",
"in",
"-",
"place",
"."
] | tek/ribosome | python | https://github.com/tek/ribosome/blob/b2ce9e118faa46d93506cbbb5f27ecfbd4e8a1cc/ribosome/rpc/comm.py#L105-L114 | [
"def",
"exclusive_ns",
"(",
"guard",
":",
"StateGuard",
"[",
"A",
"]",
",",
"desc",
":",
"str",
",",
"thunk",
":",
"Callable",
"[",
"...",
",",
"NS",
"[",
"A",
",",
"B",
"]",
"]",
",",
"*",
"a",
":",
"Any",
")",
"->",
"Do",
":",
"yield",
"gua... | b2ce9e118faa46d93506cbbb5f27ecfbd4e8a1cc |
test | _percent | Calculate a percentage. | memcache_admin/views.py | def _percent(data, part, total):
"""
Calculate a percentage.
"""
try:
return round(100 * float(data[part]) / float(data[total]), 1)
except ZeroDivisionError:
return 0 | def _percent(data, part, total):
"""
Calculate a percentage.
"""
try:
return round(100 * float(data[part]) / float(data[total]), 1)
except ZeroDivisionError:
return 0 | [
"Calculate",
"a",
"percentage",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L25-L32 | [
"def",
"_percent",
"(",
"data",
",",
"part",
",",
"total",
")",
":",
"try",
":",
"return",
"round",
"(",
"100",
"*",
"float",
"(",
"data",
"[",
"part",
"]",
")",
"/",
"float",
"(",
"data",
"[",
"total",
"]",
")",
",",
"1",
")",
"except",
"ZeroD... | 330db10139ccf04c6137255e23115482b0c89aec |
test | _get_cache_stats | Get stats info. | memcache_admin/views.py | def _get_cache_stats(server_name=None):
"""
Get stats info.
"""
server_info = {}
for svr in mc_client.get_stats():
svr_info = svr[0].split(' ')
svr_name = svr_info[0]
svr_stats = svr[1]
svr_stats['bytes_percent'] = _percent(svr_stats, 'bytes', 'limit_maxbytes')
... | def _get_cache_stats(server_name=None):
"""
Get stats info.
"""
server_info = {}
for svr in mc_client.get_stats():
svr_info = svr[0].split(' ')
svr_name = svr_info[0]
svr_stats = svr[1]
svr_stats['bytes_percent'] = _percent(svr_stats, 'bytes', 'limit_maxbytes')
... | [
"Get",
"stats",
"info",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L35-L50 | [
"def",
"_get_cache_stats",
"(",
"server_name",
"=",
"None",
")",
":",
"server_info",
"=",
"{",
"}",
"for",
"svr",
"in",
"mc_client",
".",
"get_stats",
"(",
")",
":",
"svr_info",
"=",
"svr",
"[",
"0",
"]",
".",
"split",
"(",
"' '",
")",
"svr_name",
"=... | 330db10139ccf04c6137255e23115482b0c89aec |
test | _get_cache_slabs | Get slabs info. | memcache_admin/views.py | def _get_cache_slabs(server_name=None):
"""
Get slabs info.
"""
server_info = {}
for svr in mc_client.get_slabs():
svr_info = svr[0].split(' ')
svr_name = svr_info[0]
if server_name and server_name == svr_name:
return svr[1]
server_info[svr_name] = svr[1]
... | def _get_cache_slabs(server_name=None):
"""
Get slabs info.
"""
server_info = {}
for svr in mc_client.get_slabs():
svr_info = svr[0].split(' ')
svr_name = svr_info[0]
if server_name and server_name == svr_name:
return svr[1]
server_info[svr_name] = svr[1]
... | [
"Get",
"slabs",
"info",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L53-L64 | [
"def",
"_get_cache_slabs",
"(",
"server_name",
"=",
"None",
")",
":",
"server_info",
"=",
"{",
"}",
"for",
"svr",
"in",
"mc_client",
".",
"get_slabs",
"(",
")",
":",
"svr_info",
"=",
"svr",
"[",
"0",
"]",
".",
"split",
"(",
"' '",
")",
"svr_name",
"=... | 330db10139ccf04c6137255e23115482b0c89aec |
test | _context_data | Add admin global context, for compatibility with Django 1.7 | memcache_admin/views.py | def _context_data(data, request=None):
"""
Add admin global context, for compatibility with Django 1.7
"""
try:
return dict(site.each_context(request).items() + data.items())
except AttributeError:
return data | def _context_data(data, request=None):
"""
Add admin global context, for compatibility with Django 1.7
"""
try:
return dict(site.each_context(request).items() + data.items())
except AttributeError:
return data | [
"Add",
"admin",
"global",
"context",
"for",
"compatibility",
"with",
"Django",
"1",
".",
"7"
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L67-L74 | [
"def",
"_context_data",
"(",
"data",
",",
"request",
"=",
"None",
")",
":",
"try",
":",
"return",
"dict",
"(",
"site",
".",
"each_context",
"(",
"request",
")",
".",
"items",
"(",
")",
"+",
"data",
".",
"items",
"(",
")",
")",
"except",
"AttributeErr... | 330db10139ccf04c6137255e23115482b0c89aec |
test | server_status | Return the status of all servers. | memcache_admin/views.py | def server_status(request):
"""
Return the status of all servers.
"""
data = {
'cache_stats': _get_cache_stats(),
'can_get_slabs': hasattr(mc_client, 'get_slabs'),
}
return render_to_response('memcache_admin/server_status.html', data, RequestContext(request)) | def server_status(request):
"""
Return the status of all servers.
"""
data = {
'cache_stats': _get_cache_stats(),
'can_get_slabs': hasattr(mc_client, 'get_slabs'),
}
return render_to_response('memcache_admin/server_status.html', data, RequestContext(request)) | [
"Return",
"the",
"status",
"of",
"all",
"servers",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L77-L85 | [
"def",
"server_status",
"(",
"request",
")",
":",
"data",
"=",
"{",
"'cache_stats'",
":",
"_get_cache_stats",
"(",
")",
",",
"'can_get_slabs'",
":",
"hasattr",
"(",
"mc_client",
",",
"'get_slabs'",
")",
",",
"}",
"return",
"render_to_response",
"(",
"'memcache... | 330db10139ccf04c6137255e23115482b0c89aec |
test | dashboard | Show the dashboard. | memcache_admin/views.py | def dashboard(request):
"""
Show the dashboard.
"""
# mc_client will be a dict if memcached is not configured
if not isinstance(mc_client, dict):
cache_stats = _get_cache_stats()
else:
cache_stats = None
if cache_stats:
data = _context_data({
'title': _('M... | def dashboard(request):
"""
Show the dashboard.
"""
# mc_client will be a dict if memcached is not configured
if not isinstance(mc_client, dict):
cache_stats = _get_cache_stats()
else:
cache_stats = None
if cache_stats:
data = _context_data({
'title': _('M... | [
"Show",
"the",
"dashboard",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L88-L113 | [
"def",
"dashboard",
"(",
"request",
")",
":",
"# mc_client will be a dict if memcached is not configured",
"if",
"not",
"isinstance",
"(",
"mc_client",
",",
"dict",
")",
":",
"cache_stats",
"=",
"_get_cache_stats",
"(",
")",
"else",
":",
"cache_stats",
"=",
"None",
... | 330db10139ccf04c6137255e23115482b0c89aec |
test | stats | Show server statistics. | memcache_admin/views.py | def stats(request, server_name):
"""
Show server statistics.
"""
server_name = server_name.strip('/')
data = _context_data({
'title': _('Memcache Statistics for %s') % server_name,
'cache_stats': _get_cache_stats(server_name),
},
request)
return render_to_response('me... | def stats(request, server_name):
"""
Show server statistics.
"""
server_name = server_name.strip('/')
data = _context_data({
'title': _('Memcache Statistics for %s') % server_name,
'cache_stats': _get_cache_stats(server_name),
},
request)
return render_to_response('me... | [
"Show",
"server",
"statistics",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L116-L126 | [
"def",
"stats",
"(",
"request",
",",
"server_name",
")",
":",
"server_name",
"=",
"server_name",
".",
"strip",
"(",
"'/'",
")",
"data",
"=",
"_context_data",
"(",
"{",
"'title'",
":",
"_",
"(",
"'Memcache Statistics for %s'",
")",
"%",
"server_name",
",",
... | 330db10139ccf04c6137255e23115482b0c89aec |
test | slabs | Show server slabs. | memcache_admin/views.py | def slabs(request, server_name):
"""
Show server slabs.
"""
data = _context_data({
'title': _('Memcache Slabs for %s') % server_name,
'cache_slabs': _get_cache_slabs(server_name),
},
request)
return render_to_response('memcache_admin/slabs.html', data, RequestContext(requ... | def slabs(request, server_name):
"""
Show server slabs.
"""
data = _context_data({
'title': _('Memcache Slabs for %s') % server_name,
'cache_slabs': _get_cache_slabs(server_name),
},
request)
return render_to_response('memcache_admin/slabs.html', data, RequestContext(requ... | [
"Show",
"server",
"slabs",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/views.py#L129-L138 | [
"def",
"slabs",
"(",
"request",
",",
"server_name",
")",
":",
"data",
"=",
"_context_data",
"(",
"{",
"'title'",
":",
"_",
"(",
"'Memcache Slabs for %s'",
")",
"%",
"server_name",
",",
"'cache_slabs'",
":",
"_get_cache_slabs",
"(",
"server_name",
")",
",",
"... | 330db10139ccf04c6137255e23115482b0c89aec |
test | human_bytes | Convert a byte value into a human-readable format. | memcache_admin/templatetags/memcache_admin.py | def human_bytes(value):
"""
Convert a byte value into a human-readable format.
"""
value = float(value)
if value >= 1073741824:
gigabytes = value / 1073741824
size = '%.2f GB' % gigabytes
elif value >= 1048576:
megabytes = value / 1048576
size = '%.2f MB' % megaby... | def human_bytes(value):
"""
Convert a byte value into a human-readable format.
"""
value = float(value)
if value >= 1073741824:
gigabytes = value / 1073741824
size = '%.2f GB' % gigabytes
elif value >= 1048576:
megabytes = value / 1048576
size = '%.2f MB' % megaby... | [
"Convert",
"a",
"byte",
"value",
"into",
"a",
"human",
"-",
"readable",
"format",
"."
] | ianare/django-memcache-admin | python | https://github.com/ianare/django-memcache-admin/blob/330db10139ccf04c6137255e23115482b0c89aec/memcache_admin/templatetags/memcache_admin.py#L13-L29 | [
"def",
"human_bytes",
"(",
"value",
")",
":",
"value",
"=",
"float",
"(",
"value",
")",
"if",
"value",
">=",
"1073741824",
":",
"gigabytes",
"=",
"value",
"/",
"1073741824",
"size",
"=",
"'%.2f GB'",
"%",
"gigabytes",
"elif",
"value",
">=",
"1048576",
":... | 330db10139ccf04c6137255e23115482b0c89aec |
test | Environment.find_config | Find a config in our children so we can fill in variables in our other
children with its data. | scruffy/env.py | def find_config(self, children):
"""
Find a config in our children so we can fill in variables in our other
children with its data.
"""
named_config = None
found_config = None
# first see if we got a kwarg named 'config', as this guy is special
if 'config... | def find_config(self, children):
"""
Find a config in our children so we can fill in variables in our other
children with its data.
"""
named_config = None
found_config = None
# first see if we got a kwarg named 'config', as this guy is special
if 'config... | [
"Find",
"a",
"config",
"in",
"our",
"children",
"so",
"we",
"can",
"fill",
"in",
"variables",
"in",
"our",
"other",
"children",
"with",
"its",
"data",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/env.py#L61-L99 | [
"def",
"find_config",
"(",
"self",
",",
"children",
")",
":",
"named_config",
"=",
"None",
"found_config",
"=",
"None",
"# first see if we got a kwarg named 'config', as this guy is special",
"if",
"'config'",
"in",
"children",
":",
"if",
"type",
"(",
"children",
"[",... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Environment.add | Add objects to the environment. | scruffy/env.py | def add(self, **kwargs):
"""
Add objects to the environment.
"""
for key in kwargs:
if type(kwargs[key]) == str:
self._children[key] = Directory(kwargs[key])
else:
self._children[key] = kwargs[key]
self._children[key]._e... | def add(self, **kwargs):
"""
Add objects to the environment.
"""
for key in kwargs:
if type(kwargs[key]) == str:
self._children[key] = Directory(kwargs[key])
else:
self._children[key] = kwargs[key]
self._children[key]._e... | [
"Add",
"objects",
"to",
"the",
"environment",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/env.py#L101-L112 | [
"def",
"add",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
"in",
"kwargs",
":",
"if",
"type",
"(",
"kwargs",
"[",
"key",
"]",
")",
"==",
"str",
":",
"self",
".",
"_children",
"[",
"key",
"]",
"=",
"Directory",
"(",
"kwargs",
"[... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | File.apply_config | Replace any config tokens in the file's path with values from the config. | scruffy/file.py | def apply_config(self, applicator):
"""
Replace any config tokens in the file's path with values from the config.
"""
if type(self._fpath) == str:
self._fpath = applicator.apply(self._fpath) | def apply_config(self, applicator):
"""
Replace any config tokens in the file's path with values from the config.
"""
if type(self._fpath) == str:
self._fpath = applicator.apply(self._fpath) | [
"Replace",
"any",
"config",
"tokens",
"in",
"the",
"file",
"s",
"path",
"with",
"values",
"from",
"the",
"config",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L45-L50 | [
"def",
"apply_config",
"(",
"self",
",",
"applicator",
")",
":",
"if",
"type",
"(",
"self",
".",
"_fpath",
")",
"==",
"str",
":",
"self",
".",
"_fpath",
"=",
"applicator",
".",
"apply",
"(",
"self",
".",
"_fpath",
")"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | File.path | Get the path to the file relative to its parent. | scruffy/file.py | def path(self):
"""
Get the path to the file relative to its parent.
"""
if self._parent:
return os.path.join(self._parent.path, self._fpath)
else:
return self._fpath | def path(self):
"""
Get the path to the file relative to its parent.
"""
if self._parent:
return os.path.join(self._parent.path, self._fpath)
else:
return self._fpath | [
"Get",
"the",
"path",
"to",
"the",
"file",
"relative",
"to",
"its",
"parent",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L84-L91 | [
"def",
"path",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parent",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_parent",
".",
"path",
",",
"self",
".",
"_fpath",
")",
"else",
":",
"return",
"self",
".",
"_fpath"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | File.read | Read and return the contents of the file. | scruffy/file.py | def read(self):
"""
Read and return the contents of the file.
"""
with open(self.path) as f:
d = f.read()
return d | def read(self):
"""
Read and return the contents of the file.
"""
with open(self.path) as f:
d = f.read()
return d | [
"Read",
"and",
"return",
"the",
"contents",
"of",
"the",
"file",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L121-L127 | [
"def",
"read",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
")",
"as",
"f",
":",
"d",
"=",
"f",
".",
"read",
"(",
")",
"return",
"d"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | File.write | Write data to the file.
`data` is the data to write
`mode` is the mode argument to pass to `open()` | scruffy/file.py | def write(self, data, mode='w'):
"""
Write data to the file.
`data` is the data to write
`mode` is the mode argument to pass to `open()`
"""
with open(self.path, mode) as f:
f.write(data) | def write(self, data, mode='w'):
"""
Write data to the file.
`data` is the data to write
`mode` is the mode argument to pass to `open()`
"""
with open(self.path, mode) as f:
f.write(data) | [
"Write",
"data",
"to",
"the",
"file",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L129-L137 | [
"def",
"write",
"(",
"self",
",",
"data",
",",
"mode",
"=",
"'w'",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"mode",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"data",
")"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | LogFile.configure | Configure the Python logging module for this file. | scruffy/file.py | def configure(self):
"""
Configure the Python logging module for this file.
"""
# build a file handler for this file
handler = logging.FileHandler(self.path, delay=True)
# if we got a format string, create a formatter with it
if self._format:
handler.... | def configure(self):
"""
Configure the Python logging module for this file.
"""
# build a file handler for this file
handler = logging.FileHandler(self.path, delay=True)
# if we got a format string, create a formatter with it
if self._format:
handler.... | [
"Configure",
"the",
"Python",
"logging",
"module",
"for",
"this",
"file",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L162-L189 | [
"def",
"configure",
"(",
"self",
")",
":",
"# build a file handler for this file",
"handler",
"=",
"logging",
".",
"FileHandler",
"(",
"self",
".",
"path",
",",
"delay",
"=",
"True",
")",
"# if we got a format string, create a formatter with it",
"if",
"self",
".",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | LockFile.create | Create the file.
If the file already exists an exception will be raised | scruffy/file.py | def create(self):
"""
Create the file.
If the file already exists an exception will be raised
"""
if not os.path.exists(self.path):
open(self.path, 'a').close()
else:
raise Exception("File exists: {}".format(self.path)) | def create(self):
"""
Create the file.
If the file already exists an exception will be raised
"""
if not os.path.exists(self.path):
open(self.path, 'a').close()
else:
raise Exception("File exists: {}".format(self.path)) | [
"Create",
"the",
"file",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L201-L210 | [
"def",
"create",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"open",
"(",
"self",
".",
"path",
",",
"'a'",
")",
".",
"close",
"(",
")",
"else",
":",
"raise",
"Exception",
"(",
"\"Fil... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.apply_config | Replace any config tokens with values from the config. | scruffy/file.py | def apply_config(self, applicator):
"""
Replace any config tokens with values from the config.
"""
if type(self._path) == str:
self._path = applicator.apply(self._path)
for key in self._children:
self._children[key].apply_config(applicator) | def apply_config(self, applicator):
"""
Replace any config tokens with values from the config.
"""
if type(self._path) == str:
self._path = applicator.apply(self._path)
for key in self._children:
self._children[key].apply_config(applicator) | [
"Replace",
"any",
"config",
"tokens",
"with",
"values",
"from",
"the",
"config",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L288-L296 | [
"def",
"apply_config",
"(",
"self",
",",
"applicator",
")",
":",
"if",
"type",
"(",
"self",
".",
"_path",
")",
"==",
"str",
":",
"self",
".",
"_path",
"=",
"applicator",
".",
"apply",
"(",
"self",
".",
"_path",
")",
"for",
"key",
"in",
"self",
".",... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.path | Return the path to this directory. | scruffy/file.py | def path(self):
"""
Return the path to this directory.
"""
p = ''
if self._parent and self._parent.path:
p = os.path.join(p, self._parent.path)
if self._base:
p = os.path.join(p, self._base)
if self._path:
p = os.path.join(p, s... | def path(self):
"""
Return the path to this directory.
"""
p = ''
if self._parent and self._parent.path:
p = os.path.join(p, self._parent.path)
if self._base:
p = os.path.join(p, self._base)
if self._path:
p = os.path.join(p, s... | [
"Return",
"the",
"path",
"to",
"this",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L299-L312 | [
"def",
"path",
"(",
"self",
")",
":",
"p",
"=",
"''",
"if",
"self",
".",
"_parent",
"and",
"self",
".",
"_parent",
".",
"path",
":",
"p",
"=",
"os",
".",
"path",
".",
"join",
"(",
"p",
",",
"self",
".",
"_parent",
".",
"path",
")",
"if",
"sel... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.remove | Remove the directory. | scruffy/file.py | def remove(self, recursive=True, ignore_error=True):
"""
Remove the directory.
"""
try:
if recursive or self._cleanup == 'recursive':
shutil.rmtree(self.path)
else:
os.rmdir(self.path)
except Exception as e:
if n... | def remove(self, recursive=True, ignore_error=True):
"""
Remove the directory.
"""
try:
if recursive or self._cleanup == 'recursive':
shutil.rmtree(self.path)
else:
os.rmdir(self.path)
except Exception as e:
if n... | [
"Remove",
"the",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L323-L334 | [
"def",
"remove",
"(",
"self",
",",
"recursive",
"=",
"True",
",",
"ignore_error",
"=",
"True",
")",
":",
"try",
":",
"if",
"recursive",
"or",
"self",
".",
"_cleanup",
"==",
"'recursive'",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"path",
")",
"... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.prepare | Prepare the Directory for use in an Environment.
This will create the directory if the create flag is set. | scruffy/file.py | def prepare(self):
"""
Prepare the Directory for use in an Environment.
This will create the directory if the create flag is set.
"""
if self._create:
self.create()
for k in self._children:
self._children[k]._env = self._env
self._chil... | def prepare(self):
"""
Prepare the Directory for use in an Environment.
This will create the directory if the create flag is set.
"""
if self._create:
self.create()
for k in self._children:
self._children[k]._env = self._env
self._chil... | [
"Prepare",
"the",
"Directory",
"for",
"use",
"in",
"an",
"Environment",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L336-L346 | [
"def",
"prepare",
"(",
"self",
")",
":",
"if",
"self",
".",
"_create",
":",
"self",
".",
"create",
"(",
")",
"for",
"k",
"in",
"self",
".",
"_children",
":",
"self",
".",
"_children",
"[",
"k",
"]",
".",
"_env",
"=",
"self",
".",
"_env",
"self",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.cleanup | Clean up children and remove the directory.
Directory will only be removed if the cleanup flag is set. | scruffy/file.py | def cleanup(self):
"""
Clean up children and remove the directory.
Directory will only be removed if the cleanup flag is set.
"""
for k in self._children:
self._children[k].cleanup()
if self._cleanup:
self.remove(True) | def cleanup(self):
"""
Clean up children and remove the directory.
Directory will only be removed if the cleanup flag is set.
"""
for k in self._children:
self._children[k].cleanup()
if self._cleanup:
self.remove(True) | [
"Clean",
"up",
"children",
"and",
"remove",
"the",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L348-L358 | [
"def",
"cleanup",
"(",
"self",
")",
":",
"for",
"k",
"in",
"self",
".",
"_children",
":",
"self",
".",
"_children",
"[",
"k",
"]",
".",
"cleanup",
"(",
")",
"if",
"self",
".",
"_cleanup",
":",
"self",
".",
"remove",
"(",
"True",
")"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.path_to | Find the path to something inside this directory. | scruffy/file.py | def path_to(self, path):
"""
Find the path to something inside this directory.
"""
return os.path.join(self.path, str(path)) | def path_to(self, path):
"""
Find the path to something inside this directory.
"""
return os.path.join(self.path, str(path)) | [
"Find",
"the",
"path",
"to",
"something",
"inside",
"this",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L360-L364 | [
"def",
"path_to",
"(",
"self",
",",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"str",
"(",
"path",
")",
")"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.list | List the contents of the directory. | scruffy/file.py | def list(self):
"""
List the contents of the directory.
"""
return [File(f, parent=self) for f in os.listdir(self.path)] | def list(self):
"""
List the contents of the directory.
"""
return [File(f, parent=self) for f in os.listdir(self.path)] | [
"List",
"the",
"contents",
"of",
"the",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L373-L377 | [
"def",
"list",
"(",
"self",
")",
":",
"return",
"[",
"File",
"(",
"f",
",",
"parent",
"=",
"self",
")",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"path",
")",
"]"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.write | Write to a file in the directory. | scruffy/file.py | def write(self, filename, data, mode='w'):
"""
Write to a file in the directory.
"""
with open(self.path_to(str(filename)), mode) as f:
f.write(data) | def write(self, filename, data, mode='w'):
"""
Write to a file in the directory.
"""
with open(self.path_to(str(filename)), mode) as f:
f.write(data) | [
"Write",
"to",
"a",
"file",
"in",
"the",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L379-L384 | [
"def",
"write",
"(",
"self",
",",
"filename",
",",
"data",
",",
"mode",
"=",
"'w'",
")",
":",
"with",
"open",
"(",
"self",
".",
"path_to",
"(",
"str",
"(",
"filename",
")",
")",
",",
"mode",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"data",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.read | Read a file from the directory. | scruffy/file.py | def read(self, filename):
"""
Read a file from the directory.
"""
with open(self.path_to(str(filename))) as f:
d = f.read()
return d | def read(self, filename):
"""
Read a file from the directory.
"""
with open(self.path_to(str(filename))) as f:
d = f.read()
return d | [
"Read",
"a",
"file",
"from",
"the",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L386-L392 | [
"def",
"read",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"self",
".",
"path_to",
"(",
"str",
"(",
"filename",
")",
")",
")",
"as",
"f",
":",
"d",
"=",
"f",
".",
"read",
"(",
")",
"return",
"d"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | Directory.add | Add objects to the directory. | scruffy/file.py | def add(self, *args, **kwargs):
"""
Add objects to the directory.
"""
for key in kwargs:
if isinstance(kwargs[key], str):
self._children[key] = File(kwargs[key])
else:
self._children[key] = kwargs[key]
self._children[key... | def add(self, *args, **kwargs):
"""
Add objects to the directory.
"""
for key in kwargs:
if isinstance(kwargs[key], str):
self._children[key] = File(kwargs[key])
else:
self._children[key] = kwargs[key]
self._children[key... | [
"Add",
"objects",
"to",
"the",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L394-L425 | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
"in",
"kwargs",
":",
"if",
"isinstance",
"(",
"kwargs",
"[",
"key",
"]",
",",
"str",
")",
":",
"self",
".",
"_children",
"[",
"key",
"]",
"=",
"File",... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | State.save | Save the state to a file. | scruffy/state.py | def save(self):
"""
Save the state to a file.
"""
with open(self.path, 'w') as f:
f.write(yaml.dump(dict(self.d))) | def save(self):
"""
Save the state to a file.
"""
with open(self.path, 'w') as f:
f.write(yaml.dump(dict(self.d))) | [
"Save",
"the",
"state",
"to",
"a",
"file",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/state.py#L54-L59 | [
"def",
"save",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"yaml",
".",
"dump",
"(",
"dict",
"(",
"self",
".",
"d",
")",
")",
")"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | State.load | Load a saved state file. | scruffy/state.py | def load(self):
"""
Load a saved state file.
"""
if os.path.exists(self.path):
with open(self.path, 'r') as f:
self.d = yaml.safe_load(f.read().replace('\t', ' '*4)) | def load(self):
"""
Load a saved state file.
"""
if os.path.exists(self.path):
with open(self.path, 'r') as f:
self.d = yaml.safe_load(f.read().replace('\t', ' '*4)) | [
"Load",
"a",
"saved",
"state",
"file",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/state.py#L61-L67 | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"self",
".",
"d",
"=",
"yaml",
".",
"safe_load",
"(",... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | State.cleanup | Clean up the saved state. | scruffy/state.py | def cleanup(self):
"""
Clean up the saved state.
"""
if os.path.exists(self.path):
os.remove(self.path) | def cleanup(self):
"""
Clean up the saved state.
"""
if os.path.exists(self.path):
os.remove(self.path) | [
"Clean",
"up",
"the",
"saved",
"state",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/state.py#L69-L74 | [
"def",
"cleanup",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"path",
")"
] | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | PluginManager.load_plugins | Loads plugins from the specified directory.
`directory` is the full path to a directory containing python modules
which each contain a subclass of the Plugin class.
There is no criteria for a valid plugin at this level - any python
module found in the directory will be loaded. Only mod... | scruffy/plugin.py | def load_plugins(self, directory):
"""
Loads plugins from the specified directory.
`directory` is the full path to a directory containing python modules
which each contain a subclass of the Plugin class.
There is no criteria for a valid plugin at this level - any python
... | def load_plugins(self, directory):
"""
Loads plugins from the specified directory.
`directory` is the full path to a directory containing python modules
which each contain a subclass of the Plugin class.
There is no criteria for a valid plugin at this level - any python
... | [
"Loads",
"plugins",
"from",
"the",
"specified",
"directory",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/plugin.py#L38-L65 | [
"def",
"load_plugins",
"(",
"self",
",",
"directory",
")",
":",
"# walk directory",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"# path to file",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"filena... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | update_dict | Recursively merge values from a nested dictionary into another nested
dictionary.
For example:
>>> target = {
... 'thing': 123,
... 'thang': {
... 'a': 1,
... 'b': 2
... }
... }
>>> source = {
... 'thang': {
... 'a': 666,
... ... | scruffy/config.py | def update_dict(target, source):
"""
Recursively merge values from a nested dictionary into another nested
dictionary.
For example:
>>> target = {
... 'thing': 123,
... 'thang': {
... 'a': 1,
... 'b': 2
... }
... }
>>> source = {
... ... | def update_dict(target, source):
"""
Recursively merge values from a nested dictionary into another nested
dictionary.
For example:
>>> target = {
... 'thing': 123,
... 'thang': {
... 'a': 1,
... 'b': 2
... }
... }
>>> source = {
... ... | [
"Recursively",
"merge",
"values",
"from",
"a",
"nested",
"dictionary",
"into",
"another",
"nested",
"dictionary",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L382-L417 | [
"def",
"update_dict",
"(",
"target",
",",
"source",
")",
":",
"for",
"k",
",",
"v",
"in",
"source",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
"and",
"k",
"in",
"target",
"and",
"isinstance",
"(",
"source",
"[",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | ConfigNode._child | Return a ConfigNode object representing a child node with the specified
relative path. | scruffy/config.py | def _child(self, path):
"""
Return a ConfigNode object representing a child node with the specified
relative path.
"""
if self._path:
path = '{}.{}'.format(self._path, path)
return ConfigNode(root=self._root, path=path) | def _child(self, path):
"""
Return a ConfigNode object representing a child node with the specified
relative path.
"""
if self._path:
path = '{}.{}'.format(self._path, path)
return ConfigNode(root=self._root, path=path) | [
"Return",
"a",
"ConfigNode",
"object",
"representing",
"a",
"child",
"node",
"with",
"the",
"specified",
"relative",
"path",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L114-L121 | [
"def",
"_child",
"(",
"self",
",",
"path",
")",
":",
"if",
"self",
".",
"_path",
":",
"path",
"=",
"'{}.{}'",
".",
"format",
"(",
"self",
".",
"_path",
",",
"path",
")",
"return",
"ConfigNode",
"(",
"root",
"=",
"self",
".",
"_root",
",",
"path",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | ConfigNode._resolve_path | Returns a tuple of a reference to the last container in the path, and
the last component in the key path.
For example, with a self._value like this:
{
'thing': {
'another': {
'some_leaf': 5,
'one_more': {
... | scruffy/config.py | def _resolve_path(self, create=False):
"""
Returns a tuple of a reference to the last container in the path, and
the last component in the key path.
For example, with a self._value like this:
{
'thing': {
'another': {
'some_leaf':... | def _resolve_path(self, create=False):
"""
Returns a tuple of a reference to the last container in the path, and
the last component in the key path.
For example, with a self._value like this:
{
'thing': {
'another': {
'some_leaf':... | [
"Returns",
"a",
"tuple",
"of",
"a",
"reference",
"to",
"the",
"last",
"container",
"in",
"the",
"path",
"and",
"the",
"last",
"component",
"in",
"the",
"key",
"path",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L123-L185 | [
"def",
"_resolve_path",
"(",
"self",
",",
"create",
"=",
"False",
")",
":",
"# Split up the key path",
"if",
"type",
"(",
"self",
".",
"_path",
")",
"==",
"str",
":",
"key_path",
"=",
"self",
".",
"_path",
".",
"split",
"(",
"'.'",
")",
"else",
":",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | ConfigNode._get_value | Get the value represented by this node. | scruffy/config.py | def _get_value(self):
"""
Get the value represented by this node.
"""
if self._path:
try:
container, last = self._resolve_path()
return container[last]
except KeyError:
return None
except IndexError:
... | def _get_value(self):
"""
Get the value represented by this node.
"""
if self._path:
try:
container, last = self._resolve_path()
return container[last]
except KeyError:
return None
except IndexError:
... | [
"Get",
"the",
"value",
"represented",
"by",
"this",
"node",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L187-L200 | [
"def",
"_get_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_path",
":",
"try",
":",
"container",
",",
"last",
"=",
"self",
".",
"_resolve_path",
"(",
")",
"return",
"container",
"[",
"last",
"]",
"except",
"KeyError",
":",
"return",
"None",
"excep... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | ConfigNode.update | Update the configuration with new data.
This can be passed either or both `data` and `options`.
`options` is a dict of keypath/value pairs like this (similar to
CherryPy's config mechanism:
>>> c.update(options={
... 'server.port': 8080,
... 'server... | scruffy/config.py | def update(self, data={}, options={}):
"""
Update the configuration with new data.
This can be passed either or both `data` and `options`.
`options` is a dict of keypath/value pairs like this (similar to
CherryPy's config mechanism:
>>> c.update(options={
... | def update(self, data={}, options={}):
"""
Update the configuration with new data.
This can be passed either or both `data` and `options`.
`options` is a dict of keypath/value pairs like this (similar to
CherryPy's config mechanism:
>>> c.update(options={
... | [
"Update",
"the",
"configuration",
"with",
"new",
"data",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L202-L236 | [
"def",
"update",
"(",
"self",
",",
"data",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
")",
":",
"# Handle an update with a set of options like CherryPy does",
"for",
"key",
"in",
"options",
":",
"self",
"[",
"key",
"]",
"=",
"options",
"[",
"key",
"]",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | ConfigFile.load | Load the config and defaults from files. | scruffy/config.py | def load(self, reload=False):
"""
Load the config and defaults from files.
"""
if reload or not self._loaded:
# load defaults
if self._defaults_file and type(self._defaults_file) == str:
self._defaults_file = File(self._defaults_file, parent=self._... | def load(self, reload=False):
"""
Load the config and defaults from files.
"""
if reload or not self._loaded:
# load defaults
if self._defaults_file and type(self._defaults_file) == str:
self._defaults_file = File(self._defaults_file, parent=self._... | [
"Load",
"the",
"config",
"and",
"defaults",
"from",
"files",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L292-L320 | [
"def",
"load",
"(",
"self",
",",
"reload",
"=",
"False",
")",
":",
"if",
"reload",
"or",
"not",
"self",
".",
"_loaded",
":",
"# load defaults",
"if",
"self",
".",
"_defaults_file",
"and",
"type",
"(",
"self",
".",
"_defaults_file",
")",
"==",
"str",
":... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | ConfigApplicator.apply_to_str | Apply the config to a string. | scruffy/config.py | def apply_to_str(self, obj):
"""
Apply the config to a string.
"""
toks = re.split('({config:|})', obj)
newtoks = []
try:
while len(toks):
tok = toks.pop(0)
if tok == '{config:':
# pop the config variable, lo... | def apply_to_str(self, obj):
"""
Apply the config to a string.
"""
toks = re.split('({config:|})', obj)
newtoks = []
try:
while len(toks):
tok = toks.pop(0)
if tok == '{config:':
# pop the config variable, lo... | [
"Apply",
"the",
"config",
"to",
"a",
"string",
"."
] | snare/scruffy | python | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/config.py#L349-L379 | [
"def",
"apply_to_str",
"(",
"self",
",",
"obj",
")",
":",
"toks",
"=",
"re",
".",
"split",
"(",
"'({config:|})'",
",",
"obj",
")",
"newtoks",
"=",
"[",
"]",
"try",
":",
"while",
"len",
"(",
"toks",
")",
":",
"tok",
"=",
"toks",
".",
"pop",
"(",
... | 0fedc08cfdb6db927ff93c09f25f24ce5a04c541 |
test | validate_twilio_signature | View decorator to validate requests from Twilio per http://www.twilio.com/docs/security. | rtwilio/views.py | def validate_twilio_signature(func=None, backend_name='twilio-backend'):
"""View decorator to validate requests from Twilio per http://www.twilio.com/docs/security."""
def _dec(view_func):
@functools.wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwarg... | def validate_twilio_signature(func=None, backend_name='twilio-backend'):
"""View decorator to validate requests from Twilio per http://www.twilio.com/docs/security."""
def _dec(view_func):
@functools.wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwarg... | [
"View",
"decorator",
"to",
"validate",
"requests",
"from",
"Twilio",
"per",
"http",
":",
"//",
"www",
".",
"twilio",
".",
"com",
"/",
"docs",
"/",
"security",
"."
] | caktus/rapidsms-twilio | python | https://github.com/caktus/rapidsms-twilio/blob/77ab913cc12d00c3afe5252dc6345903bee9a483/rtwilio/views.py#L20-L44 | [
"def",
"validate_twilio_signature",
"(",
"func",
"=",
"None",
",",
"backend_name",
"=",
"'twilio-backend'",
")",
":",
"def",
"_dec",
"(",
"view_func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"... | 77ab913cc12d00c3afe5252dc6345903bee9a483 |
test | build_callback_url | Build Twilio callback url for confirming message delivery status
:type message: OutgoingSMS | src/utils.py | def build_callback_url(request, urlname, message):
"""
Build Twilio callback url for confirming message delivery status
:type message: OutgoingSMS
"""
location = reverse(urlname, kwargs={"pk": message.pk})
callback_domain = getattr(settings, "TWILIO_CALLBACK_DOMAIN", None)
if callback_doma... | def build_callback_url(request, urlname, message):
"""
Build Twilio callback url for confirming message delivery status
:type message: OutgoingSMS
"""
location = reverse(urlname, kwargs={"pk": message.pk})
callback_domain = getattr(settings, "TWILIO_CALLBACK_DOMAIN", None)
if callback_doma... | [
"Build",
"Twilio",
"callback",
"url",
"for",
"confirming",
"message",
"delivery",
"status"
] | nigma/django-twilio-sms | python | https://github.com/nigma/django-twilio-sms/blob/386999c3da545e001cb8977c78b67408e33aba11/src/utils.py#L19-L42 | [
"def",
"build_callback_url",
"(",
"request",
",",
"urlname",
",",
"message",
")",
":",
"location",
"=",
"reverse",
"(",
"urlname",
",",
"kwargs",
"=",
"{",
"\"pk\"",
":",
"message",
".",
"pk",
"}",
")",
"callback_domain",
"=",
"getattr",
"(",
"settings",
... | 386999c3da545e001cb8977c78b67408e33aba11 |
test | send_sms | Create :class:`OutgoingSMS` object and send SMS using Twilio. | src/utils.py | def send_sms(request, to_number, body, callback_urlname="sms_status_callback"):
"""
Create :class:`OutgoingSMS` object and send SMS using Twilio.
"""
client = TwilioRestClient(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
from_number = settings.TWILIO_PHONE_NUMBER
message = OutgoingS... | def send_sms(request, to_number, body, callback_urlname="sms_status_callback"):
"""
Create :class:`OutgoingSMS` object and send SMS using Twilio.
"""
client = TwilioRestClient(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
from_number = settings.TWILIO_PHONE_NUMBER
message = OutgoingS... | [
"Create",
":",
"class",
":",
"OutgoingSMS",
"object",
"and",
"send",
"SMS",
"using",
"Twilio",
"."
] | nigma/django-twilio-sms | python | https://github.com/nigma/django-twilio-sms/blob/386999c3da545e001cb8977c78b67408e33aba11/src/utils.py#L45-L88 | [
"def",
"send_sms",
"(",
"request",
",",
"to_number",
",",
"body",
",",
"callback_urlname",
"=",
"\"sms_status_callback\"",
")",
":",
"client",
"=",
"TwilioRestClient",
"(",
"settings",
".",
"TWILIO_ACCOUNT_SID",
",",
"settings",
".",
"TWILIO_AUTH_TOKEN",
")",
"fro... | 386999c3da545e001cb8977c78b67408e33aba11 |
test | main | \b
Examples:
$ moo README.md # live preview README.md
$ moo -e *.md # export all markdown files
$ moo --no-css -e README.md # export README.md without CSS
$ cat README.md | moo -e - | less # export STDIN to STDOUT | moo/__init__.py | def main(port, export, css, files):
"""
\b
Examples:
$ moo README.md # live preview README.md
$ moo -e *.md # export all markdown files
$ moo --no-css -e README.md # export README.md without CSS
$ cat README.md | moo -e - | less # export ST... | def main(port, export, css, files):
"""
\b
Examples:
$ moo README.md # live preview README.md
$ moo -e *.md # export all markdown files
$ moo --no-css -e README.md # export README.md without CSS
$ cat README.md | moo -e - | less # export ST... | [
"\\",
"b",
"Examples",
":",
"$",
"moo",
"README",
".",
"md",
"#",
"live",
"preview",
"README",
".",
"md",
"$",
"moo",
"-",
"e",
"*",
".",
"md",
"#",
"export",
"all",
"markdown",
"files",
"$",
"moo",
"--",
"no",
"-",
"css",
"-",
"e",
"README",
"... | pyrocat101/moo | python | https://github.com/pyrocat101/moo/blob/39e86d4ecb329309260bc30876c77aa3a7a2cfb1/moo/__init__.py#L209-L229 | [
"def",
"main",
"(",
"port",
",",
"export",
",",
"css",
",",
"files",
")",
":",
"options",
"=",
"{",
"'css'",
":",
"css",
",",
"'port'",
":",
"port",
"}",
"try",
":",
"if",
"not",
"export",
":",
"if",
"len",
"(",
"files",
")",
"!=",
"1",
":",
... | 39e86d4ecb329309260bc30876c77aa3a7a2cfb1 |
test | SocketConnection.process_input | Called when socket is read-ready | examples/rpc-server.py | def process_input(self):
"""Called when socket is read-ready"""
try:
pyngus.read_socket_input(self.connection, self.socket)
except Exception as e:
LOG.error("Exception on socket read: %s", str(e))
self.connection.close_input()
self.connection.close... | def process_input(self):
"""Called when socket is read-ready"""
try:
pyngus.read_socket_input(self.connection, self.socket)
except Exception as e:
LOG.error("Exception on socket read: %s", str(e))
self.connection.close_input()
self.connection.close... | [
"Called",
"when",
"socket",
"is",
"read",
"-",
"ready"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-server.py#L92-L100 | [
"def",
"process_input",
"(",
"self",
")",
":",
"try",
":",
"pyngus",
".",
"read_socket_input",
"(",
"self",
".",
"connection",
",",
"self",
".",
"socket",
")",
"except",
"Exception",
"as",
"e",
":",
"LOG",
".",
"error",
"(",
"\"Exception on socket read: %s\"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | SocketConnection.send_output | Called when socket is write-ready | examples/rpc-server.py | def send_output(self):
"""Called when socket is write-ready"""
try:
pyngus.write_socket_output(self.connection,
self.socket)
except Exception as e:
LOG.error("Exception on socket write: %s", str(e))
self.connection.close_... | def send_output(self):
"""Called when socket is write-ready"""
try:
pyngus.write_socket_output(self.connection,
self.socket)
except Exception as e:
LOG.error("Exception on socket write: %s", str(e))
self.connection.close_... | [
"Called",
"when",
"socket",
"is",
"write",
"-",
"ready"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-server.py#L102-L111 | [
"def",
"send_output",
"(",
"self",
")",
":",
"try",
":",
"pyngus",
".",
"write_socket_output",
"(",
"self",
".",
"connection",
",",
"self",
".",
"socket",
")",
"except",
"Exception",
"as",
"e",
":",
"LOG",
".",
"error",
"(",
"\"Exception on socket write: %s\... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | MyConnection.process | Do connection-based processing (I/O and timers) | examples/rpc-client.py | def process(self):
""" Do connection-based processing (I/O and timers) """
readfd = []
writefd = []
if self.connection.needs_input > 0:
readfd = [self.socket]
if self.connection.has_output > 0:
writefd = [self.socket]
timeout = None
deadli... | def process(self):
""" Do connection-based processing (I/O and timers) """
readfd = []
writefd = []
if self.connection.needs_input > 0:
readfd = [self.socket]
if self.connection.has_output > 0:
writefd = [self.socket]
timeout = None
deadli... | [
"Do",
"connection",
"-",
"based",
"processing",
"(",
"I",
"/",
"O",
"and",
"timers",
")"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-client.py#L73-L112 | [
"def",
"process",
"(",
"self",
")",
":",
"readfd",
"=",
"[",
"]",
"writefd",
"=",
"[",
"]",
"if",
"self",
".",
"connection",
".",
"needs_input",
">",
"0",
":",
"readfd",
"=",
"[",
"self",
".",
"socket",
"]",
"if",
"self",
".",
"connection",
".",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | MyConnection.create_caller | Caller factory | examples/rpc-client.py | def create_caller(self, method_map, source_addr, target_addr,
receiver_properties, sender_properties):
""" Caller factory
"""
if self.caller:
self.caller.destroy()
self.caller = MyCaller(method_map, self, source_addr, target_addr,
... | def create_caller(self, method_map, source_addr, target_addr,
receiver_properties, sender_properties):
""" Caller factory
"""
if self.caller:
self.caller.destroy()
self.caller = MyCaller(method_map, self, source_addr, target_addr,
... | [
"Caller",
"factory"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-client.py#L127-L135 | [
"def",
"create_caller",
"(",
"self",
",",
"method_map",
",",
"source_addr",
",",
"target_addr",
",",
"receiver_properties",
",",
"sender_properties",
")",
":",
"if",
"self",
".",
"caller",
":",
"self",
".",
"caller",
".",
"destroy",
"(",
")",
"self",
".",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | MyCaller._send_request | Send a message containing the RPC method call | examples/rpc-client.py | def _send_request(self):
"""Send a message containing the RPC method call
"""
msg = Message()
msg.subject = "An RPC call!"
msg.address = self._to
msg.reply_to = self._reply_to
msg.body = self._method
msg.correlation_id = 5 # whatever...
print("se... | def _send_request(self):
"""Send a message containing the RPC method call
"""
msg = Message()
msg.subject = "An RPC call!"
msg.address = self._to
msg.reply_to = self._reply_to
msg.body = self._method
msg.correlation_id = 5 # whatever...
print("se... | [
"Send",
"a",
"message",
"containing",
"the",
"RPC",
"method",
"call"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/rpc-client.py#L245-L258 | [
"def",
"_send_request",
"(",
"self",
")",
":",
"msg",
"=",
"Message",
"(",
")",
"msg",
".",
"subject",
"=",
"\"An RPC call!\"",
"msg",
".",
"address",
"=",
"self",
".",
"_to",
"msg",
".",
"reply_to",
"=",
"self",
".",
"_reply_to",
"msg",
".",
"body",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | read_socket_input | Read from the network layer and processes all data read. Can
support both blocking and non-blocking sockets.
Returns the number of input bytes processed, or EOS if input processing
is done. Any exceptions raised by the socket are re-raised. | pyngus/sockets.py | def read_socket_input(connection, socket_obj):
"""Read from the network layer and processes all data read. Can
support both blocking and non-blocking sockets.
Returns the number of input bytes processed, or EOS if input processing
is done. Any exceptions raised by the socket are re-raised.
"""
... | def read_socket_input(connection, socket_obj):
"""Read from the network layer and processes all data read. Can
support both blocking and non-blocking sockets.
Returns the number of input bytes processed, or EOS if input processing
is done. Any exceptions raised by the socket are re-raised.
"""
... | [
"Read",
"from",
"the",
"network",
"layer",
"and",
"processes",
"all",
"data",
"read",
".",
"Can",
"support",
"both",
"blocking",
"and",
"non",
"-",
"blocking",
"sockets",
".",
"Returns",
"the",
"number",
"of",
"input",
"bytes",
"processed",
"or",
"EOS",
"i... | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/sockets.py#L35-L73 | [
"def",
"read_socket_input",
"(",
"connection",
",",
"socket_obj",
")",
":",
"count",
"=",
"connection",
".",
"needs_input",
"if",
"count",
"<=",
"0",
":",
"return",
"count",
"# 0 or EOS",
"while",
"True",
":",
"try",
":",
"sock_data",
"=",
"socket_obj",
".",... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | write_socket_output | Write data to the network layer. Can support both blocking and
non-blocking sockets.
Returns the number of output bytes sent, or EOS if output processing
is done. Any exceptions raised by the socket are re-raised. | pyngus/sockets.py | def write_socket_output(connection, socket_obj):
"""Write data to the network layer. Can support both blocking and
non-blocking sockets.
Returns the number of output bytes sent, or EOS if output processing
is done. Any exceptions raised by the socket are re-raised.
"""
count = connection.has_o... | def write_socket_output(connection, socket_obj):
"""Write data to the network layer. Can support both blocking and
non-blocking sockets.
Returns the number of output bytes sent, or EOS if output processing
is done. Any exceptions raised by the socket are re-raised.
"""
count = connection.has_o... | [
"Write",
"data",
"to",
"the",
"network",
"layer",
".",
"Can",
"support",
"both",
"blocking",
"and",
"non",
"-",
"blocking",
"sockets",
".",
"Returns",
"the",
"number",
"of",
"output",
"bytes",
"sent",
"or",
"EOS",
"if",
"output",
"processing",
"is",
"done"... | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/sockets.py#L76-L119 | [
"def",
"write_socket_output",
"(",
"connection",
",",
"socket_obj",
")",
":",
"count",
"=",
"connection",
".",
"has_output",
"if",
"count",
"<=",
"0",
":",
"return",
"count",
"# 0 or EOS",
"data",
"=",
"connection",
".",
"output_data",
"(",
")",
"if",
"not",... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _not_reentrant | Decorator that prevents callbacks from calling into link methods that
are not reentrant | pyngus/link.py | def _not_reentrant(func):
"""Decorator that prevents callbacks from calling into link methods that
are not reentrant """
def wrap(*args, **kws):
link = args[0]
if link._callback_lock.in_callback:
m = "Link %s cannot be invoked from a callback!" % func
raise RuntimeErr... | def _not_reentrant(func):
"""Decorator that prevents callbacks from calling into link methods that
are not reentrant """
def wrap(*args, **kws):
link = args[0]
if link._callback_lock.in_callback:
m = "Link %s cannot be invoked from a callback!" % func
raise RuntimeErr... | [
"Decorator",
"that",
"prevents",
"callbacks",
"from",
"calling",
"into",
"link",
"methods",
"that",
"are",
"not",
"reentrant"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L71-L80 | [
"def",
"_not_reentrant",
"(",
"func",
")",
":",
"def",
"wrap",
"(",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"link",
"=",
"args",
"[",
"0",
"]",
"if",
"link",
".",
"_callback_lock",
".",
"in_callback",
":",
"m",
"=",
"\"Link %s cannot be invoked fr... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _get_remote_settle_modes | Return a map containing the settle modes as provided by the remote.
Skip any default value. | pyngus/link.py | def _get_remote_settle_modes(pn_link):
"""Return a map containing the settle modes as provided by the remote.
Skip any default value.
"""
modes = {}
snd = pn_link.remote_snd_settle_mode
if snd == proton.Link.SND_UNSETTLED:
modes['snd-settle-mode'] = 'unsettled'
elif snd == proton.Lin... | def _get_remote_settle_modes(pn_link):
"""Return a map containing the settle modes as provided by the remote.
Skip any default value.
"""
modes = {}
snd = pn_link.remote_snd_settle_mode
if snd == proton.Link.SND_UNSETTLED:
modes['snd-settle-mode'] = 'unsettled'
elif snd == proton.Lin... | [
"Return",
"a",
"map",
"containing",
"the",
"settle",
"modes",
"as",
"provided",
"by",
"the",
"remote",
".",
"Skip",
"any",
"default",
"value",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L342-L354 | [
"def",
"_get_remote_settle_modes",
"(",
"pn_link",
")",
":",
"modes",
"=",
"{",
"}",
"snd",
"=",
"pn_link",
".",
"remote_snd_settle_mode",
"if",
"snd",
"==",
"proton",
".",
"Link",
".",
"SND_UNSETTLED",
":",
"modes",
"[",
"'snd-settle-mode'",
"]",
"=",
"'uns... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _Link.configure | Assign addresses, properties, etc. | pyngus/link.py | def configure(self, target_address, source_address, handler, properties):
"""Assign addresses, properties, etc."""
self._handler = handler
self._properties = properties
dynamic_props = None
if properties:
dynamic_props = properties.get("dynamic-node-properties")
... | def configure(self, target_address, source_address, handler, properties):
"""Assign addresses, properties, etc."""
self._handler = handler
self._properties = properties
dynamic_props = None
if properties:
dynamic_props = properties.get("dynamic-node-properties")
... | [
"Assign",
"addresses",
"properties",
"etc",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L99-L135 | [
"def",
"configure",
"(",
"self",
",",
"target_address",
",",
"source_address",
",",
"handler",
",",
"properties",
")",
":",
"self",
".",
"_handler",
"=",
"handler",
"self",
".",
"_properties",
"=",
"properties",
"dynamic_props",
"=",
"None",
"if",
"properties"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _Link.source_address | Return the authorative source of the link. | pyngus/link.py | def source_address(self):
"""Return the authorative source of the link."""
# If link is a sender, source is determined by the local
# value, else use the remote.
if self._pn_link.is_sender:
return self._pn_link.source.address
else:
return self._pn_link.rem... | def source_address(self):
"""Return the authorative source of the link."""
# If link is a sender, source is determined by the local
# value, else use the remote.
if self._pn_link.is_sender:
return self._pn_link.source.address
else:
return self._pn_link.rem... | [
"Return",
"the",
"authorative",
"source",
"of",
"the",
"link",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L161-L168 | [
"def",
"source_address",
"(",
"self",
")",
":",
"# If link is a sender, source is determined by the local",
"# value, else use the remote.",
"if",
"self",
".",
"_pn_link",
".",
"is_sender",
":",
"return",
"self",
".",
"_pn_link",
".",
"source",
".",
"address",
"else",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _Link.target_address | Return the authorative target of the link. | pyngus/link.py | def target_address(self):
"""Return the authorative target of the link."""
# If link is a receiver, target is determined by the local
# value, else use the remote.
if self._pn_link.is_receiver:
return self._pn_link.target.address
else:
return self._pn_link... | def target_address(self):
"""Return the authorative target of the link."""
# If link is a receiver, target is determined by the local
# value, else use the remote.
if self._pn_link.is_receiver:
return self._pn_link.target.address
else:
return self._pn_link... | [
"Return",
"the",
"authorative",
"target",
"of",
"the",
"link",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L171-L178 | [
"def",
"target_address",
"(",
"self",
")",
":",
"# If link is a receiver, target is determined by the local",
"# value, else use the remote.",
"if",
"self",
".",
"_pn_link",
".",
"is_receiver",
":",
"return",
"self",
".",
"_pn_link",
".",
"target",
".",
"address",
"else... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _Link._session_closed | Remote has closed the session used by this link. | pyngus/link.py | def _session_closed(self):
"""Remote has closed the session used by this link."""
# if link not already closed:
if self._endpoint_state & proton.Endpoint.REMOTE_ACTIVE:
# simulate close received
self._process_remote_state()
elif self._endpoint_state & proton.Endpo... | def _session_closed(self):
"""Remote has closed the session used by this link."""
# if link not already closed:
if self._endpoint_state & proton.Endpoint.REMOTE_ACTIVE:
# simulate close received
self._process_remote_state()
elif self._endpoint_state & proton.Endpo... | [
"Remote",
"has",
"closed",
"the",
"session",
"used",
"by",
"this",
"link",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L230-L239 | [
"def",
"_session_closed",
"(",
"self",
")",
":",
"# if link not already closed:",
"if",
"self",
".",
"_endpoint_state",
"&",
"proton",
".",
"Endpoint",
".",
"REMOTE_ACTIVE",
":",
"# simulate close received",
"self",
".",
"_process_remote_state",
"(",
")",
"elif",
"s... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | SenderLink.reject | See Link Reject, AMQP1.0 spec. | pyngus/link.py | def reject(self, pn_condition=None):
"""See Link Reject, AMQP1.0 spec."""
self._pn_link.source.type = proton.Terminus.UNSPECIFIED
super(SenderLink, self).reject(pn_condition) | def reject(self, pn_condition=None):
"""See Link Reject, AMQP1.0 spec."""
self._pn_link.source.type = proton.Terminus.UNSPECIFIED
super(SenderLink, self).reject(pn_condition) | [
"See",
"Link",
"Reject",
"AMQP1",
".",
"0",
"spec",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L463-L466 | [
"def",
"reject",
"(",
"self",
",",
"pn_condition",
"=",
"None",
")",
":",
"self",
".",
"_pn_link",
".",
"source",
".",
"type",
"=",
"proton",
".",
"Terminus",
".",
"UNSPECIFIED",
"super",
"(",
"SenderLink",
",",
"self",
")",
".",
"reject",
"(",
"pn_con... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | SenderLink._process_delivery | Check if the delivery can be processed. | pyngus/link.py | def _process_delivery(self, pn_delivery):
"""Check if the delivery can be processed."""
if pn_delivery.tag in self._send_requests:
if pn_delivery.settled or pn_delivery.remote_state:
# remote has reached a 'terminal state'
outcome = pn_delivery.remote_state
... | def _process_delivery(self, pn_delivery):
"""Check if the delivery can be processed."""
if pn_delivery.tag in self._send_requests:
if pn_delivery.settled or pn_delivery.remote_state:
# remote has reached a 'terminal state'
outcome = pn_delivery.remote_state
... | [
"Check",
"if",
"the",
"delivery",
"can",
"be",
"processed",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L474-L505 | [
"def",
"_process_delivery",
"(",
"self",
",",
"pn_delivery",
")",
":",
"if",
"pn_delivery",
".",
"tag",
"in",
"self",
".",
"_send_requests",
":",
"if",
"pn_delivery",
".",
"settled",
"or",
"pn_delivery",
".",
"remote_state",
":",
"# remote has reached a 'terminal ... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | ReceiverLink.reject | See Link Reject, AMQP1.0 spec. | pyngus/link.py | def reject(self, pn_condition=None):
"""See Link Reject, AMQP1.0 spec."""
self._pn_link.target.type = proton.Terminus.UNSPECIFIED
super(ReceiverLink, self).reject(pn_condition) | def reject(self, pn_condition=None):
"""See Link Reject, AMQP1.0 spec."""
self._pn_link.target.type = proton.Terminus.UNSPECIFIED
super(ReceiverLink, self).reject(pn_condition) | [
"See",
"Link",
"Reject",
"AMQP1",
".",
"0",
"spec",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L674-L677 | [
"def",
"reject",
"(",
"self",
",",
"pn_condition",
"=",
"None",
")",
":",
"self",
".",
"_pn_link",
".",
"target",
".",
"type",
"=",
"proton",
".",
"Terminus",
".",
"UNSPECIFIED",
"super",
"(",
"ReceiverLink",
",",
"self",
")",
".",
"reject",
"(",
"pn_c... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | ReceiverLink._process_delivery | Check if the delivery can be processed. | pyngus/link.py | def _process_delivery(self, pn_delivery):
"""Check if the delivery can be processed."""
if pn_delivery.readable and not pn_delivery.partial:
data = self._pn_link.recv(pn_delivery.pending)
msg = proton.Message()
msg.decode(data)
self._pn_link.advance()
... | def _process_delivery(self, pn_delivery):
"""Check if the delivery can be processed."""
if pn_delivery.readable and not pn_delivery.partial:
data = self._pn_link.recv(pn_delivery.pending)
msg = proton.Message()
msg.decode(data)
self._pn_link.advance()
... | [
"Check",
"if",
"the",
"delivery",
"can",
"be",
"processed",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L685-L701 | [
"def",
"_process_delivery",
"(",
"self",
",",
"pn_delivery",
")",
":",
"if",
"pn_delivery",
".",
"readable",
"and",
"not",
"pn_delivery",
".",
"partial",
":",
"data",
"=",
"self",
".",
"_pn_link",
".",
"recv",
"(",
"pn_delivery",
".",
"pending",
")",
"msg"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _SessionProxy.new_sender | Create a new sender link. | pyngus/link.py | def new_sender(self, name):
"""Create a new sender link."""
pn_link = self._pn_session.sender(name)
return self.request_sender(pn_link) | def new_sender(self, name):
"""Create a new sender link."""
pn_link = self._pn_session.sender(name)
return self.request_sender(pn_link) | [
"Create",
"a",
"new",
"sender",
"link",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L780-L783 | [
"def",
"new_sender",
"(",
"self",
",",
"name",
")",
":",
"pn_link",
"=",
"self",
".",
"_pn_session",
".",
"sender",
"(",
"name",
")",
"return",
"self",
".",
"request_sender",
"(",
"pn_link",
")"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _SessionProxy.request_sender | Create link from request for a sender. | pyngus/link.py | def request_sender(self, pn_link):
"""Create link from request for a sender."""
sl = SenderLink(self._connection, pn_link)
self._links.add(sl)
return sl | def request_sender(self, pn_link):
"""Create link from request for a sender."""
sl = SenderLink(self._connection, pn_link)
self._links.add(sl)
return sl | [
"Create",
"link",
"from",
"request",
"for",
"a",
"sender",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L785-L789 | [
"def",
"request_sender",
"(",
"self",
",",
"pn_link",
")",
":",
"sl",
"=",
"SenderLink",
"(",
"self",
".",
"_connection",
",",
"pn_link",
")",
"self",
".",
"_links",
".",
"add",
"(",
"sl",
")",
"return",
"sl"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _SessionProxy.new_receiver | Create a new receiver link. | pyngus/link.py | def new_receiver(self, name):
"""Create a new receiver link."""
pn_link = self._pn_session.receiver(name)
return self.request_receiver(pn_link) | def new_receiver(self, name):
"""Create a new receiver link."""
pn_link = self._pn_session.receiver(name)
return self.request_receiver(pn_link) | [
"Create",
"a",
"new",
"receiver",
"link",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L791-L794 | [
"def",
"new_receiver",
"(",
"self",
",",
"name",
")",
":",
"pn_link",
"=",
"self",
".",
"_pn_session",
".",
"receiver",
"(",
"name",
")",
"return",
"self",
".",
"request_receiver",
"(",
"pn_link",
")"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _SessionProxy.request_receiver | Create link from request for a receiver. | pyngus/link.py | def request_receiver(self, pn_link):
"""Create link from request for a receiver."""
rl = ReceiverLink(self._connection, pn_link)
self._links.add(rl)
return rl | def request_receiver(self, pn_link):
"""Create link from request for a receiver."""
rl = ReceiverLink(self._connection, pn_link)
self._links.add(rl)
return rl | [
"Create",
"link",
"from",
"request",
"for",
"a",
"receiver",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L796-L800 | [
"def",
"request_receiver",
"(",
"self",
",",
"pn_link",
")",
":",
"rl",
"=",
"ReceiverLink",
"(",
"self",
".",
"_connection",
",",
"pn_link",
")",
"self",
".",
"_links",
".",
"add",
"(",
"rl",
")",
"return",
"rl"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _SessionProxy.link_destroyed | Link has been destroyed. | pyngus/link.py | def link_destroyed(self, link):
"""Link has been destroyed."""
self._links.discard(link)
if not self._links:
# no more links
LOG.debug("destroying unneeded session")
self._pn_session.close()
self._pn_session.free()
self._pn_session = No... | def link_destroyed(self, link):
"""Link has been destroyed."""
self._links.discard(link)
if not self._links:
# no more links
LOG.debug("destroying unneeded session")
self._pn_session.close()
self._pn_session.free()
self._pn_session = No... | [
"Link",
"has",
"been",
"destroyed",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L802-L811 | [
"def",
"link_destroyed",
"(",
"self",
",",
"link",
")",
":",
"self",
".",
"_links",
".",
"discard",
"(",
"link",
")",
"if",
"not",
"self",
".",
"_links",
":",
"# no more links",
"LOG",
".",
"debug",
"(",
"\"destroying unneeded session\"",
")",
"self",
".",... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | _SessionProxy._ep_need_close | Peer has closed its end of the session. | pyngus/link.py | def _ep_need_close(self):
"""Peer has closed its end of the session."""
LOG.debug("Session %s close requested - closing...",
self._name)
links = self._links.copy() # may modify _links
for link in links:
link._session_closed() | def _ep_need_close(self):
"""Peer has closed its end of the session."""
LOG.debug("Session %s close requested - closing...",
self._name)
links = self._links.copy() # may modify _links
for link in links:
link._session_closed() | [
"Peer",
"has",
"closed",
"its",
"end",
"of",
"the",
"session",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/link.py#L878-L884 | [
"def",
"_ep_need_close",
"(",
"self",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Session %s close requested - closing...\"",
",",
"self",
".",
"_name",
")",
"links",
"=",
"self",
".",
"_links",
".",
"copy",
"(",
")",
"# may modify _links",
"for",
"link",
"in",
"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Endpoint._process_endpoint_event | Called when the Proton Engine generates an endpoint state change
event. | pyngus/endpoint.py | def _process_endpoint_event(self, event):
"""Called when the Proton Engine generates an endpoint state change
event.
"""
state_fsm = Endpoint._FSM[self._state]
entry = state_fsm.get(event)
if not entry:
# protocol error: invalid event for current state
... | def _process_endpoint_event(self, event):
"""Called when the Proton Engine generates an endpoint state change
event.
"""
state_fsm = Endpoint._FSM[self._state]
entry = state_fsm.get(event)
if not entry:
# protocol error: invalid event for current state
... | [
"Called",
"when",
"the",
"Proton",
"Engine",
"generates",
"an",
"endpoint",
"state",
"change",
"event",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/endpoint.py#L117-L134 | [
"def",
"_process_endpoint_event",
"(",
"self",
",",
"event",
")",
":",
"state_fsm",
"=",
"Endpoint",
".",
"_FSM",
"[",
"self",
".",
"_state",
"]",
"entry",
"=",
"state_fsm",
".",
"get",
"(",
"event",
")",
"if",
"not",
"entry",
":",
"# protocol error: inval... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | HighlightExtension.extendMarkdown | Modifies inline patterns. | MarkdownHighlight/highlight.py | def extendMarkdown(self, md, md_globals):
"""Modifies inline patterns."""
mark_tag = SimpleTagPattern(MARK_RE, 'mark')
md.inlinePatterns.add('mark', mark_tag, '_begin') | def extendMarkdown(self, md, md_globals):
"""Modifies inline patterns."""
mark_tag = SimpleTagPattern(MARK_RE, 'mark')
md.inlinePatterns.add('mark', mark_tag, '_begin') | [
"Modifies",
"inline",
"patterns",
"."
] | ribalba/markdown.highlight | python | https://github.com/ribalba/markdown.highlight/blob/f220f3366dc5c42a3c303565cf7f297fce89098a/MarkdownHighlight/highlight.py#L15-L18 | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"mark_tag",
"=",
"SimpleTagPattern",
"(",
"MARK_RE",
",",
"'mark'",
")",
"md",
".",
"inlinePatterns",
".",
"add",
"(",
"'mark'",
",",
"mark_tag",
",",
"'_begin'",
")"
] | f220f3366dc5c42a3c303565cf7f297fce89098a |
test | ReceiverEventHandler.receiver_remote_closed | Peer has closed its end of the link. | examples/recv.py | def receiver_remote_closed(self, receiver_link, pn_condition):
"""Peer has closed its end of the link."""
LOG.debug("receiver_remote_closed condition=%s", pn_condition)
receiver_link.close()
self.done = True | def receiver_remote_closed(self, receiver_link, pn_condition):
"""Peer has closed its end of the link."""
LOG.debug("receiver_remote_closed condition=%s", pn_condition)
receiver_link.close()
self.done = True | [
"Peer",
"has",
"closed",
"its",
"end",
"of",
"the",
"link",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/recv.py#L54-L58 | [
"def",
"receiver_remote_closed",
"(",
"self",
",",
"receiver_link",
",",
"pn_condition",
")",
":",
"LOG",
".",
"debug",
"(",
"\"receiver_remote_closed condition=%s\"",
",",
"pn_condition",
")",
"receiver_link",
".",
"close",
"(",
")",
"self",
".",
"done",
"=",
"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | ReceiverEventHandler.receiver_failed | Protocol error occurred. | examples/recv.py | def receiver_failed(self, receiver_link, error):
"""Protocol error occurred."""
LOG.warn("receiver_failed error=%s", error)
receiver_link.close()
self.done = True | def receiver_failed(self, receiver_link, error):
"""Protocol error occurred."""
LOG.warn("receiver_failed error=%s", error)
receiver_link.close()
self.done = True | [
"Protocol",
"error",
"occurred",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/recv.py#L60-L64 | [
"def",
"receiver_failed",
"(",
"self",
",",
"receiver_link",
",",
"error",
")",
":",
"LOG",
".",
"warn",
"(",
"\"receiver_failed error=%s\"",
",",
"error",
")",
"receiver_link",
".",
"close",
"(",
")",
"self",
".",
"done",
"=",
"True"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | get_host_port | Parse the hostname and port out of the server_address. | examples/utils.py | def get_host_port(server_address):
"""Parse the hostname and port out of the server_address."""
regex = re.compile(r"^amqp://([a-zA-Z0-9.]+)(:([\d]+))?$")
x = regex.match(server_address)
if not x:
raise Exception("Bad address syntax: %s" % server_address)
matches = x.groups()
host = matc... | def get_host_port(server_address):
"""Parse the hostname and port out of the server_address."""
regex = re.compile(r"^amqp://([a-zA-Z0-9.]+)(:([\d]+))?$")
x = regex.match(server_address)
if not x:
raise Exception("Bad address syntax: %s" % server_address)
matches = x.groups()
host = matc... | [
"Parse",
"the",
"hostname",
"and",
"port",
"out",
"of",
"the",
"server_address",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/utils.py#L33-L42 | [
"def",
"get_host_port",
"(",
"server_address",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"^amqp://([a-zA-Z0-9.]+)(:([\\d]+))?$\"",
")",
"x",
"=",
"regex",
".",
"match",
"(",
"server_address",
")",
"if",
"not",
"x",
":",
"raise",
"Exception",
"(",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | connect_socket | Create a TCP connection to the server. | examples/utils.py | def connect_socket(host, port, blocking=True):
"""Create a TCP connection to the server."""
addr = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM)
if not addr:
raise Exception("Could not translate address '%s:%s'"
% (host, str(port)))
my_socket = socket... | def connect_socket(host, port, blocking=True):
"""Create a TCP connection to the server."""
addr = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM)
if not addr:
raise Exception("Could not translate address '%s:%s'"
% (host, str(port)))
my_socket = socket... | [
"Create",
"a",
"TCP",
"connection",
"to",
"the",
"server",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/utils.py#L45-L59 | [
"def",
"connect_socket",
"(",
"host",
",",
"port",
",",
"blocking",
"=",
"True",
")",
":",
"addr",
"=",
"socket",
".",
"getaddrinfo",
"(",
"host",
",",
"port",
",",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"if",
"not",
"addr",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | server_socket | Create a TCP listening socket for a server. | examples/utils.py | def server_socket(host, port, backlog=10):
"""Create a TCP listening socket for a server."""
addr = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM)
if not addr:
raise Exception("Could not translate address '%s:%s'"
% (host, str(port)))
my_socket = socke... | def server_socket(host, port, backlog=10):
"""Create a TCP listening socket for a server."""
addr = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM)
if not addr:
raise Exception("Could not translate address '%s:%s'"
% (host, str(port)))
my_socket = socke... | [
"Create",
"a",
"TCP",
"listening",
"socket",
"for",
"a",
"server",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/utils.py#L62-L76 | [
"def",
"server_socket",
"(",
"host",
",",
"port",
",",
"backlog",
"=",
"10",
")",
":",
"addr",
"=",
"socket",
".",
"getaddrinfo",
"(",
"host",
",",
"port",
",",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"if",
"not",
"addr",
":... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | process_connection | Handle I/O and Timers on a single Connection. | examples/utils.py | def process_connection(connection, my_socket):
"""Handle I/O and Timers on a single Connection."""
if connection.closed:
return False
work = False
readfd = []
writefd = []
if connection.needs_input > 0:
readfd = [my_socket]
work = True
if connection.has_output > 0:
... | def process_connection(connection, my_socket):
"""Handle I/O and Timers on a single Connection."""
if connection.closed:
return False
work = False
readfd = []
writefd = []
if connection.needs_input > 0:
readfd = [my_socket]
work = True
if connection.has_output > 0:
... | [
"Handle",
"I",
"/",
"O",
"and",
"Timers",
"on",
"a",
"single",
"Connection",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/examples/utils.py#L79-L127 | [
"def",
"process_connection",
"(",
"connection",
",",
"my_socket",
")",
":",
"if",
"connection",
".",
"closed",
":",
"return",
"False",
"work",
"=",
"False",
"readfd",
"=",
"[",
"]",
"writefd",
"=",
"[",
"]",
"if",
"connection",
".",
"needs_input",
">",
"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Container.need_processing | A utility to help determine which connections need
processing. Returns a triple of lists containing those connections that
0) need to read from the network, 1) need to write to the network, 2)
waiting for pending timers to expire. The timer list is sorted with
the connection next expiri... | pyngus/container.py | def need_processing(self):
"""A utility to help determine which connections need
processing. Returns a triple of lists containing those connections that
0) need to read from the network, 1) need to write to the network, 2)
waiting for pending timers to expire. The timer list is sorted w... | def need_processing(self):
"""A utility to help determine which connections need
processing. Returns a triple of lists containing those connections that
0) need to read from the network, 1) need to write to the network, 2)
waiting for pending timers to expire. The timer list is sorted w... | [
"A",
"utility",
"to",
"help",
"determine",
"which",
"connections",
"need",
"processing",
".",
"Returns",
"a",
"triple",
"of",
"lists",
"containing",
"those",
"connections",
"that",
"0",
")",
"need",
"to",
"read",
"from",
"the",
"network",
"1",
")",
"need",
... | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/container.py#L53-L75 | [
"def",
"need_processing",
"(",
"self",
")",
":",
"readers",
"=",
"[",
"]",
"writers",
"=",
"[",
"]",
"timer_heap",
"=",
"[",
"]",
"for",
"c",
"in",
"iter",
"(",
"self",
".",
"_connections",
".",
"values",
"(",
")",
")",
":",
"if",
"c",
".",
"need... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection._not_reentrant | Decorator that prevents callbacks from calling into methods that are
not reentrant | pyngus/connection.py | def _not_reentrant(func):
"""Decorator that prevents callbacks from calling into methods that are
not reentrant
"""
def wrap(self, *args, **kws):
if self._callback_lock and self._callback_lock.in_callback:
m = "Connection %s cannot be invoked from a callback!"... | def _not_reentrant(func):
"""Decorator that prevents callbacks from calling into methods that are
not reentrant
"""
def wrap(self, *args, **kws):
if self._callback_lock and self._callback_lock.in_callback:
m = "Connection %s cannot be invoked from a callback!"... | [
"Decorator",
"that",
"prevents",
"callbacks",
"from",
"calling",
"into",
"methods",
"that",
"are",
"not",
"reentrant"
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L122-L131 | [
"def",
"_not_reentrant",
"(",
"func",
")",
":",
"def",
"wrap",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kws",
")",
":",
"if",
"self",
".",
"_callback_lock",
"and",
"self",
".",
"_callback_lock",
".",
"in_callback",
":",
"m",
"=",
"\"Connection %s... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection.process | Perform connection state processing. | pyngus/connection.py | def process(self, now):
"""Perform connection state processing."""
if self._pn_connection is None:
LOG.error("Connection.process() called on destroyed connection!")
return 0
# do nothing until the connection has been opened
if self._pn_connection.state & proton.E... | def process(self, now):
"""Perform connection state processing."""
if self._pn_connection is None:
LOG.error("Connection.process() called on destroyed connection!")
return 0
# do nothing until the connection has been opened
if self._pn_connection.state & proton.E... | [
"Perform",
"connection",
"state",
"processing",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L461-L533 | [
"def",
"process",
"(",
"self",
",",
"now",
")",
":",
"if",
"self",
".",
"_pn_connection",
"is",
"None",
":",
"LOG",
".",
"error",
"(",
"\"Connection.process() called on destroyed connection!\"",
")",
"return",
"0",
"# do nothing until the connection has been opened",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection.output_data | Get a buffer of data that needs to be written to the network. | pyngus/connection.py | def output_data(self):
"""Get a buffer of data that needs to be written to the network.
"""
c = self.has_output
if c <= 0:
return None
try:
buf = self._pn_transport.peek(c)
except Exception as e:
self._connection_failed(str(e))
... | def output_data(self):
"""Get a buffer of data that needs to be written to the network.
"""
c = self.has_output
if c <= 0:
return None
try:
buf = self._pn_transport.peek(c)
except Exception as e:
self._connection_failed(str(e))
... | [
"Get",
"a",
"buffer",
"of",
"data",
"that",
"needs",
"to",
"be",
"written",
"to",
"the",
"network",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L609-L620 | [
"def",
"output_data",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"has_output",
"if",
"c",
"<=",
"0",
":",
"return",
"None",
"try",
":",
"buf",
"=",
"self",
".",
"_pn_transport",
".",
"peek",
"(",
"c",
")",
"except",
"Exception",
"as",
"e",
":",
... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection.create_sender | Factory method for Sender links. | pyngus/connection.py | def create_sender(self, source_address, target_address=None,
event_handler=None, name=None, properties=None):
"""Factory method for Sender links."""
ident = name or str(source_address)
if ident in self._sender_links:
raise KeyError("Sender %s already exists!" % ... | def create_sender(self, source_address, target_address=None,
event_handler=None, name=None, properties=None):
"""Factory method for Sender links."""
ident = name or str(source_address)
if ident in self._sender_links:
raise KeyError("Sender %s already exists!" % ... | [
"Factory",
"method",
"for",
"Sender",
"links",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L642-L654 | [
"def",
"create_sender",
"(",
"self",
",",
"source_address",
",",
"target_address",
"=",
"None",
",",
"event_handler",
"=",
"None",
",",
"name",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"ident",
"=",
"name",
"or",
"str",
"(",
"source_address",... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection.reject_sender | Rejects the SenderLink, and destroys the handle. | pyngus/connection.py | def reject_sender(self, link_handle, pn_condition=None):
"""Rejects the SenderLink, and destroys the handle."""
link = self._sender_links.get(link_handle)
if not link:
raise Exception("Invalid link_handle: %s" % link_handle)
link.reject(pn_condition)
# note: normally,... | def reject_sender(self, link_handle, pn_condition=None):
"""Rejects the SenderLink, and destroys the handle."""
link = self._sender_links.get(link_handle)
if not link:
raise Exception("Invalid link_handle: %s" % link_handle)
link.reject(pn_condition)
# note: normally,... | [
"Rejects",
"the",
"SenderLink",
"and",
"destroys",
"the",
"handle",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L670-L679 | [
"def",
"reject_sender",
"(",
"self",
",",
"link_handle",
",",
"pn_condition",
"=",
"None",
")",
":",
"link",
"=",
"self",
".",
"_sender_links",
".",
"get",
"(",
"link_handle",
")",
"if",
"not",
"link",
":",
"raise",
"Exception",
"(",
"\"Invalid link_handle: ... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection.create_receiver | Factory method for creating Receive links. | pyngus/connection.py | def create_receiver(self, target_address, source_address=None,
event_handler=None, name=None, properties=None):
"""Factory method for creating Receive links."""
ident = name or str(target_address)
if ident in self._receiver_links:
raise KeyError("Receiver %s a... | def create_receiver(self, target_address, source_address=None,
event_handler=None, name=None, properties=None):
"""Factory method for creating Receive links."""
ident = name or str(target_address)
if ident in self._receiver_links:
raise KeyError("Receiver %s a... | [
"Factory",
"method",
"for",
"creating",
"Receive",
"links",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L681-L693 | [
"def",
"create_receiver",
"(",
"self",
",",
"target_address",
",",
"source_address",
"=",
"None",
",",
"event_handler",
"=",
"None",
",",
"name",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"ident",
"=",
"name",
"or",
"str",
"(",
"target_address... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection._connection_failed | Clean up after connection failure detected. | pyngus/connection.py | def _connection_failed(self, error="Error not specified!"):
"""Clean up after connection failure detected."""
if not self._error:
LOG.error("Connection failed: %s", str(error))
self._error = error | def _connection_failed(self, error="Error not specified!"):
"""Clean up after connection failure detected."""
if not self._error:
LOG.error("Connection failed: %s", str(error))
self._error = error | [
"Clean",
"up",
"after",
"connection",
"failure",
"detected",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L731-L735 | [
"def",
"_connection_failed",
"(",
"self",
",",
"error",
"=",
"\"Error not specified!\"",
")",
":",
"if",
"not",
"self",
".",
"_error",
":",
"LOG",
".",
"error",
"(",
"\"Connection failed: %s\"",
",",
"str",
"(",
"error",
")",
")",
"self",
".",
"_error",
"=... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection._ep_active | Both ends of the Endpoint have become active. | pyngus/connection.py | def _ep_active(self):
"""Both ends of the Endpoint have become active."""
LOG.debug("Connection is up")
if self._handler:
with self._callback_lock:
self._handler.connection_active(self) | def _ep_active(self):
"""Both ends of the Endpoint have become active."""
LOG.debug("Connection is up")
if self._handler:
with self._callback_lock:
self._handler.connection_active(self) | [
"Both",
"ends",
"of",
"the",
"Endpoint",
"have",
"become",
"active",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L856-L861 | [
"def",
"_ep_active",
"(",
"self",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Connection is up\"",
")",
"if",
"self",
".",
"_handler",
":",
"with",
"self",
".",
"_callback_lock",
":",
"self",
".",
"_handler",
".",
"connection_active",
"(",
"self",
")"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection._ep_need_close | The remote has closed its end of the endpoint. | pyngus/connection.py | def _ep_need_close(self):
"""The remote has closed its end of the endpoint."""
LOG.debug("Connection remotely closed")
if self._handler:
cond = self._pn_connection.remote_condition
with self._callback_lock:
self._handler.connection_remote_closed(self, cond... | def _ep_need_close(self):
"""The remote has closed its end of the endpoint."""
LOG.debug("Connection remotely closed")
if self._handler:
cond = self._pn_connection.remote_condition
with self._callback_lock:
self._handler.connection_remote_closed(self, cond... | [
"The",
"remote",
"has",
"closed",
"its",
"end",
"of",
"the",
"endpoint",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L863-L869 | [
"def",
"_ep_need_close",
"(",
"self",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Connection remotely closed\"",
")",
"if",
"self",
".",
"_handler",
":",
"cond",
"=",
"self",
".",
"_pn_connection",
".",
"remote_condition",
"with",
"self",
".",
"_callback_lock",
":"... | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | Connection._ep_error | The endpoint state machine failed due to protocol error. | pyngus/connection.py | def _ep_error(self, error):
"""The endpoint state machine failed due to protocol error."""
super(Connection, self)._ep_error(error)
self._connection_failed("Protocol error occurred.") | def _ep_error(self, error):
"""The endpoint state machine failed due to protocol error."""
super(Connection, self)._ep_error(error)
self._connection_failed("Protocol error occurred.") | [
"The",
"endpoint",
"state",
"machine",
"failed",
"due",
"to",
"protocol",
"error",
"."
] | kgiusti/pyngus | python | https://github.com/kgiusti/pyngus/blob/5392392046989f1bb84ba938c30e4d48311075f1/pyngus/connection.py#L871-L874 | [
"def",
"_ep_error",
"(",
"self",
",",
"error",
")",
":",
"super",
"(",
"Connection",
",",
"self",
")",
".",
"_ep_error",
"(",
"error",
")",
"self",
".",
"_connection_failed",
"(",
"\"Protocol error occurred.\"",
")"
] | 5392392046989f1bb84ba938c30e4d48311075f1 |
test | twilio_view | This decorator provides several helpful shortcuts for writing Twilio
views.
- It ensures that only requests from Twilio are passed through. This
helps protect you from forged requests.
- It ensures your view is exempt from CSRF checks via Django's
@csrf_exempt decorator. This i... | src/decorators.py | def twilio_view(f):
"""This decorator provides several helpful shortcuts for writing Twilio
views.
- It ensures that only requests from Twilio are passed through. This
helps protect you from forged requests.
- It ensures your view is exempt from CSRF checks via Django's
@cs... | def twilio_view(f):
"""This decorator provides several helpful shortcuts for writing Twilio
views.
- It ensures that only requests from Twilio are passed through. This
helps protect you from forged requests.
- It ensures your view is exempt from CSRF checks via Django's
@cs... | [
"This",
"decorator",
"provides",
"several",
"helpful",
"shortcuts",
"for",
"writing",
"Twilio",
"views",
"."
] | nigma/django-twilio-sms | python | https://github.com/nigma/django-twilio-sms/blob/386999c3da545e001cb8977c78b67408e33aba11/src/decorators.py#L23-L103 | [
"def",
"twilio_view",
"(",
"f",
")",
":",
"@",
"csrf_exempt",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorator",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Attempt to gather all required information to allow us to check the",
"# incomi... | 386999c3da545e001cb8977c78b67408e33aba11 |
test | PDFColor._is_equal | Equality test | pypdflite/pdfobjects/pdfcolor.py | def _is_equal(self, test_color):
"""Equality test"""
if test_color is None:
ans = False
elif test_color.color_type != self.color_type:
ans = False
elif self.name is not None and self.name == test_color.name:
ans = True
elif (self.red ==... | def _is_equal(self, test_color):
"""Equality test"""
if test_color is None:
ans = False
elif test_color.color_type != self.color_type:
ans = False
elif self.name is not None and self.name == test_color.name:
ans = True
elif (self.red ==... | [
"Equality",
"test"
] | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/pdfobjects/pdfcolor.py#L59-L73 | [
"def",
"_is_equal",
"(",
"self",
",",
"test_color",
")",
":",
"if",
"test_color",
"is",
"None",
":",
"ans",
"=",
"False",
"elif",
"test_color",
".",
"color_type",
"!=",
"self",
".",
"color_type",
":",
"ans",
"=",
"False",
"elif",
"self",
".",
"name",
"... | ac2501f30d6619eae9dea5644717575ca9263d0a |
test | PDFColor._get_color_string | Adobe output string for defining colors | pypdflite/pdfobjects/pdfcolor.py | def _get_color_string(self):
"""Adobe output string for defining colors"""
s = ''
if self.color_type == 'd':
if self.name is "black":
s = '%.3f G' % 0
else:
s = '%.3f %.3f %.3f RG' % (
self.red / 255.0, self.gree... | def _get_color_string(self):
"""Adobe output string for defining colors"""
s = ''
if self.color_type == 'd':
if self.name is "black":
s = '%.3f G' % 0
else:
s = '%.3f %.3f %.3f RG' % (
self.red / 255.0, self.gree... | [
"Adobe",
"output",
"string",
"for",
"defining",
"colors"
] | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/pdfobjects/pdfcolor.py#L75-L90 | [
"def",
"_get_color_string",
"(",
"self",
")",
":",
"s",
"=",
"''",
"if",
"self",
".",
"color_type",
"==",
"'d'",
":",
"if",
"self",
".",
"name",
"is",
"\"black\"",
":",
"s",
"=",
"'%.3f G'",
"%",
"0",
"else",
":",
"s",
"=",
"'%.3f %.3f %.3f RG'",
"%"... | ac2501f30d6619eae9dea5644717575ca9263d0a |
test | PDFTTFont._set_font | Select a font; size given in points | pypdflite/pdfobjects/pdfttfonts.py | def _set_font(self, family=None, style=None, size=None):
"""Select a font; size given in points"""
if style is not None:
if 'B' in style:
family += '_bold'
if 'I' in style:
family += '_italic'
self._set_family(family)
self._get_dif... | def _set_font(self, family=None, style=None, size=None):
"""Select a font; size given in points"""
if style is not None:
if 'B' in style:
family += '_bold'
if 'I' in style:
family += '_italic'
self._set_family(family)
self._get_dif... | [
"Select",
"a",
"font",
";",
"size",
"given",
"in",
"points"
] | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/pdfobjects/pdfttfonts.py#L50-L63 | [
"def",
"_set_font",
"(",
"self",
",",
"family",
"=",
"None",
",",
"style",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"if",
"style",
"is",
"not",
"None",
":",
"if",
"'B'",
"in",
"style",
":",
"family",
"+=",
"'_bold'",
"if",
"'I'",
"in",
"s... | ac2501f30d6619eae9dea5644717575ca9263d0a |
test | PDFTTFont._string_width | Get width of a string in the current font | pypdflite/pdfobjects/pdfttfonts.py | def _string_width(self, s):
"""Get width of a string in the current font"""
s = str(s)
w = 0
for char in s:
char = ord(char)
w += self.character_widths[char]
return w * self.font_size / 1000.0 | def _string_width(self, s):
"""Get width of a string in the current font"""
s = str(s)
w = 0
for char in s:
char = ord(char)
w += self.character_widths[char]
return w * self.font_size / 1000.0 | [
"Get",
"width",
"of",
"a",
"string",
"in",
"the",
"current",
"font"
] | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/pdfobjects/pdfttfonts.py#L90-L97 | [
"def",
"_string_width",
"(",
"self",
",",
"s",
")",
":",
"s",
"=",
"str",
"(",
"s",
")",
"w",
"=",
"0",
"for",
"char",
"in",
"s",
":",
"char",
"=",
"ord",
"(",
"char",
")",
"w",
"+=",
"self",
".",
"character_widths",
"[",
"char",
"]",
"return",... | ac2501f30d6619eae9dea5644717575ca9263d0a |
test | FontLoader.get_ttf | Given a search path, find file with requested extension | pypdflite/font_loader.py | def get_ttf(self):
""" Given a search path, find file with requested extension """
font_dict = {}
families = []
rootdirlist = string.split(self.search_path, os.pathsep)
#for rootdir in rootdirlist:
# rootdir = os.path.expanduser(rootdir)
for dirName, subdirLis... | def get_ttf(self):
""" Given a search path, find file with requested extension """
font_dict = {}
families = []
rootdirlist = string.split(self.search_path, os.pathsep)
#for rootdir in rootdirlist:
# rootdir = os.path.expanduser(rootdir)
for dirName, subdirLis... | [
"Given",
"a",
"search",
"path",
"find",
"file",
"with",
"requested",
"extension"
] | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/font_loader.py#L30-L68 | [
"def",
"get_ttf",
"(",
"self",
")",
":",
"font_dict",
"=",
"{",
"}",
"families",
"=",
"[",
"]",
"rootdirlist",
"=",
"string",
".",
"split",
"(",
"self",
".",
"search_path",
",",
"os",
".",
"pathsep",
")",
"#for rootdir in rootdirlist:",
"# rootdir = os.pa... | ac2501f30d6619eae9dea5644717575ca9263d0a |
test | _Session._set_compression | May be used to compress PDF files. Code is more readable
for testing and inspection if not compressed. Requires a boolean. | pypdflite/session.py | def _set_compression(self, value):
""" May be used to compress PDF files. Code is more readable
for testing and inspection if not compressed. Requires a boolean. """
if isinstance(value, bool):
self.compression = value
else:
raise Exception(
... | def _set_compression(self, value):
""" May be used to compress PDF files. Code is more readable
for testing and inspection if not compressed. Requires a boolean. """
if isinstance(value, bool):
self.compression = value
else:
raise Exception(
... | [
"May",
"be",
"used",
"to",
"compress",
"PDF",
"files",
".",
"Code",
"is",
"more",
"readable",
"for",
"testing",
"and",
"inspection",
"if",
"not",
"compressed",
".",
"Requires",
"a",
"boolean",
"."
] | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/session.py#L43-L50 | [
"def",
"_set_compression",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"self",
".",
"compression",
"=",
"value",
"else",
":",
"raise",
"Exception",
"(",
"TypeError",
",",
"\"%s is not a valid option for compres... | ac2501f30d6619eae9dea5644717575ca9263d0a |
test | _Session._create_placeholder_objects | PDF objects #1 through #3 are typically saved for the
Zeroth, Catalog, and Pages Objects. This program will save
the numbers, but outputs the individual Page and Content objects
first. The actual Catalog and Pages objects are calculated after. | pypdflite/session.py | def _create_placeholder_objects(self):
""" PDF objects #1 through #3 are typically saved for the
Zeroth, Catalog, and Pages Objects. This program will save
the numbers, but outputs the individual Page and Content objects
first. The actual Catalog and Pages objects are cal... | def _create_placeholder_objects(self):
""" PDF objects #1 through #3 are typically saved for the
Zeroth, Catalog, and Pages Objects. This program will save
the numbers, but outputs the individual Page and Content objects
first. The actual Catalog and Pages objects are cal... | [
"PDF",
"objects",
"#1",
"through",
"#3",
"are",
"typically",
"saved",
"for",
"the",
"Zeroth",
"Catalog",
"and",
"Pages",
"Objects",
".",
"This",
"program",
"will",
"save",
"the",
"numbers",
"but",
"outputs",
"the",
"individual",
"Page",
"and",
"Content",
"ob... | katerina7479/pypdflite | python | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/session.py#L53-L62 | [
"def",
"_create_placeholder_objects",
"(",
"self",
")",
":",
"self",
".",
"objects",
".",
"append",
"(",
"\"Zeroth\"",
")",
"self",
".",
"objects",
".",
"append",
"(",
"\"Catalog\"",
")",
"self",
".",
"objects",
".",
"append",
"(",
"\"Pages\"",
")"
] | ac2501f30d6619eae9dea5644717575ca9263d0a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.