repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
dslackw/slpkg | slpkg/pkg/build.py | BuildPackage._delete_sbo_tar_gz | def _delete_sbo_tar_gz(self):
"""Delete slackbuild tar.gz file after untar
"""
if not self.auto and os.path.isfile(self.meta.build_path + self.script):
os.remove(self.meta.build_path + self.script) | python | def _delete_sbo_tar_gz(self):
"""Delete slackbuild tar.gz file after untar
"""
if not self.auto and os.path.isfile(self.meta.build_path + self.script):
os.remove(self.meta.build_path + self.script) | [
"def",
"_delete_sbo_tar_gz",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"auto",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"meta",
".",
"build_path",
"+",
"self",
".",
"script",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",... | Delete slackbuild tar.gz file after untar | [
"Delete",
"slackbuild",
"tar",
".",
"gz",
"file",
"after",
"untar"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/pkg/build.py#L146-L150 | train | 60,400 |
dslackw/slpkg | slpkg/pkg/build.py | BuildPackage._delete_dir | def _delete_dir(self):
"""Delete old folder if exists before start build
"""
if not self.auto and os.path.isdir(self.meta.build_path + self.prgnam):
shutil.rmtree(self.meta.build_path + self.prgnam) | python | def _delete_dir(self):
"""Delete old folder if exists before start build
"""
if not self.auto and os.path.isdir(self.meta.build_path + self.prgnam):
shutil.rmtree(self.meta.build_path + self.prgnam) | [
"def",
"_delete_dir",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"auto",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"meta",
".",
"build_path",
"+",
"self",
".",
"prgnam",
")",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"... | Delete old folder if exists before start build | [
"Delete",
"old",
"folder",
"if",
"exists",
"before",
"start",
"build"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/pkg/build.py#L152-L156 | train | 60,401 |
dslackw/slpkg | slpkg/blacklist.py | BlackList.listed | def listed(self):
"""Print blacklist packages
"""
print("\nPackages in the blacklist:\n")
for black in self.get_black():
if black:
print("{0}{1}{2}".format(self.meta.color["GREEN"], black,
self.meta.color["ENDC"]))
... | python | def listed(self):
"""Print blacklist packages
"""
print("\nPackages in the blacklist:\n")
for black in self.get_black():
if black:
print("{0}{1}{2}".format(self.meta.color["GREEN"], black,
self.meta.color["ENDC"]))
... | [
"def",
"listed",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nPackages in the blacklist:\\n\"",
")",
"for",
"black",
"in",
"self",
".",
"get_black",
"(",
")",
":",
"if",
"black",
":",
"print",
"(",
"\"{0}{1}{2}\"",
".",
"format",
"(",
"self",
".",
"meta",
... | Print blacklist packages | [
"Print",
"blacklist",
"packages"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/blacklist.py#L53-L63 | train | 60,402 |
dslackw/slpkg | slpkg/blacklist.py | BlackList.add | def add(self, pkgs):
"""Add blacklist packages if not exist
"""
blacklist = self.get_black()
pkgs = set(pkgs)
print("\nAdd packages in the blacklist:\n")
with open(self.blackfile, "a") as black_conf:
for pkg in pkgs:
if pkg not in blacklist:
... | python | def add(self, pkgs):
"""Add blacklist packages if not exist
"""
blacklist = self.get_black()
pkgs = set(pkgs)
print("\nAdd packages in the blacklist:\n")
with open(self.blackfile, "a") as black_conf:
for pkg in pkgs:
if pkg not in blacklist:
... | [
"def",
"add",
"(",
"self",
",",
"pkgs",
")",
":",
"blacklist",
"=",
"self",
".",
"get_black",
"(",
")",
"pkgs",
"=",
"set",
"(",
"pkgs",
")",
"print",
"(",
"\"\\nAdd packages in the blacklist:\\n\"",
")",
"with",
"open",
"(",
"self",
".",
"blackfile",
",... | Add blacklist packages if not exist | [
"Add",
"blacklist",
"packages",
"if",
"not",
"exist"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/blacklist.py#L65-L80 | train | 60,403 |
dslackw/slpkg | slpkg/blacklist.py | BlackList.remove | def remove(self, pkgs):
"""Remove packages from blacklist
"""
print("\nRemove packages from the blacklist:\n")
with open(self.blackfile, "w") as remove:
for line in self.black_conf.splitlines():
if line not in pkgs:
remove.write(line + "\n"... | python | def remove(self, pkgs):
"""Remove packages from blacklist
"""
print("\nRemove packages from the blacklist:\n")
with open(self.blackfile, "w") as remove:
for line in self.black_conf.splitlines():
if line not in pkgs:
remove.write(line + "\n"... | [
"def",
"remove",
"(",
"self",
",",
"pkgs",
")",
":",
"print",
"(",
"\"\\nRemove packages from the blacklist:\\n\"",
")",
"with",
"open",
"(",
"self",
".",
"blackfile",
",",
"\"w\"",
")",
"as",
"remove",
":",
"for",
"line",
"in",
"self",
".",
"black_conf",
... | Remove packages from blacklist | [
"Remove",
"packages",
"from",
"blacklist"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/blacklist.py#L82-L96 | train | 60,404 |
dslackw/slpkg | slpkg/blacklist.py | BlackList.packages | def packages(self, pkgs, repo):
"""Return packages in blacklist or by repository
"""
self.black = []
for bl in self.get_black():
pr = bl.split(":")
for pkg in pkgs:
self.__priority(pr, repo, pkg)
self.__blackpkg(bl, repo, pkg)
... | python | def packages(self, pkgs, repo):
"""Return packages in blacklist or by repository
"""
self.black = []
for bl in self.get_black():
pr = bl.split(":")
for pkg in pkgs:
self.__priority(pr, repo, pkg)
self.__blackpkg(bl, repo, pkg)
... | [
"def",
"packages",
"(",
"self",
",",
"pkgs",
",",
"repo",
")",
":",
"self",
".",
"black",
"=",
"[",
"]",
"for",
"bl",
"in",
"self",
".",
"get_black",
"(",
")",
":",
"pr",
"=",
"bl",
".",
"split",
"(",
"\":\"",
")",
"for",
"pkg",
"in",
"pkgs",
... | Return packages in blacklist or by repository | [
"Return",
"packages",
"in",
"blacklist",
"or",
"by",
"repository"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/blacklist.py#L98-L107 | train | 60,405 |
dslackw/slpkg | slpkg/blacklist.py | BlackList.__priority | def __priority(self, pr, repo, pkg):
"""Add packages in blacklist by priority
"""
if (pr[0] == repo and pr[1].startswith("*") and
pr[1].endswith("*")):
if pr[1][1:-1] in pkg:
self.black.append(self.__add(repo, pkg))
elif pr[0] == repo and pr[1]... | python | def __priority(self, pr, repo, pkg):
"""Add packages in blacklist by priority
"""
if (pr[0] == repo and pr[1].startswith("*") and
pr[1].endswith("*")):
if pr[1][1:-1] in pkg:
self.black.append(self.__add(repo, pkg))
elif pr[0] == repo and pr[1]... | [
"def",
"__priority",
"(",
"self",
",",
"pr",
",",
"repo",
",",
"pkg",
")",
":",
"if",
"(",
"pr",
"[",
"0",
"]",
"==",
"repo",
"and",
"pr",
"[",
"1",
"]",
".",
"startswith",
"(",
"\"*\"",
")",
"and",
"pr",
"[",
"1",
"]",
".",
"endswith",
"(",
... | Add packages in blacklist by priority | [
"Add",
"packages",
"in",
"blacklist",
"by",
"priority"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/blacklist.py#L117-L131 | train | 60,406 |
dslackw/slpkg | slpkg/blacklist.py | BlackList.__blackpkg | def __blackpkg(self, bl, repo, pkg):
"""Add packages in blacklist
"""
if bl.startswith("*") and bl.endswith("*"):
if bl[1:-1] in pkg:
self.black.append(self.__add(repo, pkg))
elif bl.endswith("*"):
if pkg.startswith(bl[:-1]):
self.b... | python | def __blackpkg(self, bl, repo, pkg):
"""Add packages in blacklist
"""
if bl.startswith("*") and bl.endswith("*"):
if bl[1:-1] in pkg:
self.black.append(self.__add(repo, pkg))
elif bl.endswith("*"):
if pkg.startswith(bl[:-1]):
self.b... | [
"def",
"__blackpkg",
"(",
"self",
",",
"bl",
",",
"repo",
",",
"pkg",
")",
":",
"if",
"bl",
".",
"startswith",
"(",
"\"*\"",
")",
"and",
"bl",
".",
"endswith",
"(",
"\"*\"",
")",
":",
"if",
"bl",
"[",
"1",
":",
"-",
"1",
"]",
"in",
"pkg",
":"... | Add packages in blacklist | [
"Add",
"packages",
"in",
"blacklist"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/blacklist.py#L133-L146 | train | 60,407 |
dslackw/slpkg | slpkg/desc.py | PkgDesc.view | def view(self):
"""Print package description by repository
"""
print("") # new line at start
description, count = "", 0
if self.repo == "sbo":
description = SBoGrep(self.name).description()
else:
PACKAGES_TXT = Utils().read_file(self.lib)
... | python | def view(self):
"""Print package description by repository
"""
print("") # new line at start
description, count = "", 0
if self.repo == "sbo":
description = SBoGrep(self.name).description()
else:
PACKAGES_TXT = Utils().read_file(self.lib)
... | [
"def",
"view",
"(",
"self",
")",
":",
"print",
"(",
"\"\"",
")",
"# new line at start",
"description",
",",
"count",
"=",
"\"\"",
",",
"0",
"if",
"self",
".",
"repo",
"==",
"\"sbo\"",
":",
"description",
"=",
"SBoGrep",
"(",
"self",
".",
"name",
")",
... | Print package description by repository | [
"Print",
"package",
"description",
"by",
"repository"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/desc.py#L56-L78 | train | 60,408 |
dslackw/slpkg | slpkg/downloader.py | Download.start | def start(self):
"""Download files using wget or other downloader.
Optional curl, aria2c and httpie
"""
dwn_count = 1
self._directory_prefix()
for dwn in self.url:
# get file name from url and fix passing char '+'
self.file_name = dwn.split("/")[-1... | python | def start(self):
"""Download files using wget or other downloader.
Optional curl, aria2c and httpie
"""
dwn_count = 1
self._directory_prefix()
for dwn in self.url:
# get file name from url and fix passing char '+'
self.file_name = dwn.split("/")[-1... | [
"def",
"start",
"(",
"self",
")",
":",
"dwn_count",
"=",
"1",
"self",
".",
"_directory_prefix",
"(",
")",
"for",
"dwn",
"in",
"self",
".",
"url",
":",
"# get file name from url and fix passing char '+'",
"self",
".",
"file_name",
"=",
"dwn",
".",
"split",
"(... | Download files using wget or other downloader.
Optional curl, aria2c and httpie | [
"Download",
"files",
"using",
"wget",
"or",
"other",
"downloader",
".",
"Optional",
"curl",
"aria2c",
"and",
"httpie"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/downloader.py#L49-L83 | train | 60,409 |
dslackw/slpkg | slpkg/downloader.py | Download._make_tarfile | def _make_tarfile(self, output_filename, source_dir):
"""Create .tar.gz file
"""
with tarfile.open(output_filename, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir)) | python | def _make_tarfile(self, output_filename, source_dir):
"""Create .tar.gz file
"""
with tarfile.open(output_filename, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir)) | [
"def",
"_make_tarfile",
"(",
"self",
",",
"output_filename",
",",
"source_dir",
")",
":",
"with",
"tarfile",
".",
"open",
"(",
"output_filename",
",",
"\"w:gz\"",
")",
"as",
"tar",
":",
"tar",
".",
"add",
"(",
"source_dir",
",",
"arcname",
"=",
"os",
"."... | Create .tar.gz file | [
"Create",
".",
"tar",
".",
"gz",
"file"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/downloader.py#L85-L89 | train | 60,410 |
dslackw/slpkg | slpkg/downloader.py | Download._directory_prefix | def _directory_prefix(self):
"""Downloader options for specific directory
"""
if self.downder == "wget":
self.dir_prefix = "--directory-prefix="
elif self.downder == "aria2c":
self.dir_prefix = "--dir=" | python | def _directory_prefix(self):
"""Downloader options for specific directory
"""
if self.downder == "wget":
self.dir_prefix = "--directory-prefix="
elif self.downder == "aria2c":
self.dir_prefix = "--dir=" | [
"def",
"_directory_prefix",
"(",
"self",
")",
":",
"if",
"self",
".",
"downder",
"==",
"\"wget\"",
":",
"self",
".",
"dir_prefix",
"=",
"\"--directory-prefix=\"",
"elif",
"self",
".",
"downder",
"==",
"\"aria2c\"",
":",
"self",
".",
"dir_prefix",
"=",
"\"--d... | Downloader options for specific directory | [
"Downloader",
"options",
"for",
"specific",
"directory"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/downloader.py#L91-L97 | train | 60,411 |
dslackw/slpkg | slpkg/downloader.py | Download._check_if_downloaded | def _check_if_downloaded(self):
"""Check if file downloaded
"""
if not os.path.isfile(self.path + self.file_name):
print("")
self.msg.template(78)
print("| Download '{0}' file [ {1}FAILED{2} ]".format(
self.file_name, self.meta.color["RED"],
... | python | def _check_if_downloaded(self):
"""Check if file downloaded
"""
if not os.path.isfile(self.path + self.file_name):
print("")
self.msg.template(78)
print("| Download '{0}' file [ {1}FAILED{2} ]".format(
self.file_name, self.meta.color["RED"],
... | [
"def",
"_check_if_downloaded",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"path",
"+",
"self",
".",
"file_name",
")",
":",
"print",
"(",
"\"\"",
")",
"self",
".",
"msg",
".",
"template",
"(",
"78",
")",
... | Check if file downloaded | [
"Check",
"if",
"file",
"downloaded"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/downloader.py#L99-L111 | train | 60,412 |
dslackw/slpkg | slpkg/downloader.py | Download._check_certificate | def _check_certificate(self):
"""Check for certificates options for wget
"""
if (self.file_name.startswith("jdk-") and self.repo == "sbo" and
self.downder == "wget"):
certificate = (' --no-check-certificate --header="Cookie: '
'oraclelicense... | python | def _check_certificate(self):
"""Check for certificates options for wget
"""
if (self.file_name.startswith("jdk-") and self.repo == "sbo" and
self.downder == "wget"):
certificate = (' --no-check-certificate --header="Cookie: '
'oraclelicense... | [
"def",
"_check_certificate",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"file_name",
".",
"startswith",
"(",
"\"jdk-\"",
")",
"and",
"self",
".",
"repo",
"==",
"\"sbo\"",
"and",
"self",
".",
"downder",
"==",
"\"wget\"",
")",
":",
"certificate",
"=",
... | Check for certificates options for wget | [
"Check",
"for",
"certificates",
"options",
"for",
"wget"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/downloader.py#L113-L127 | train | 60,413 |
dslackw/slpkg | slpkg/sbo/slack_find.py | slack_package | def slack_package(prgnam):
"""Return maximum binary Slackware package from output directory
"""
binaries, cache, binary = [], "0", ""
for pkg in find_package(prgnam, _meta_.output):
if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"):
binaries.append(pkg)
for bins in binaries... | python | def slack_package(prgnam):
"""Return maximum binary Slackware package from output directory
"""
binaries, cache, binary = [], "0", ""
for pkg in find_package(prgnam, _meta_.output):
if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"):
binaries.append(pkg)
for bins in binaries... | [
"def",
"slack_package",
"(",
"prgnam",
")",
":",
"binaries",
",",
"cache",
",",
"binary",
"=",
"[",
"]",
",",
"\"0\"",
",",
"\"\"",
"for",
"pkg",
"in",
"find_package",
"(",
"prgnam",
",",
"_meta_",
".",
"output",
")",
":",
"if",
"pkg",
".",
"startswi... | Return maximum binary Slackware package from output directory | [
"Return",
"maximum",
"binary",
"Slackware",
"package",
"from",
"output",
"directory"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slack_find.py#L33-L47 | train | 60,414 |
dslackw/slpkg | slpkg/file_size.py | FileSize.server | def server(self):
"""Returns the size of remote files
"""
try:
tar = urllib2.urlopen(self.registry)
meta = tar.info()
return int(meta.getheaders("Content-Length")[0])
except (urllib2.URLError, IndexError):
return " " | python | def server(self):
"""Returns the size of remote files
"""
try:
tar = urllib2.urlopen(self.registry)
meta = tar.info()
return int(meta.getheaders("Content-Length")[0])
except (urllib2.URLError, IndexError):
return " " | [
"def",
"server",
"(",
"self",
")",
":",
"try",
":",
"tar",
"=",
"urllib2",
".",
"urlopen",
"(",
"self",
".",
"registry",
")",
"meta",
"=",
"tar",
".",
"info",
"(",
")",
"return",
"int",
"(",
"meta",
".",
"getheaders",
"(",
"\"Content-Length\"",
")",
... | Returns the size of remote files | [
"Returns",
"the",
"size",
"of",
"remote",
"files"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/file_size.py#L35-L43 | train | 60,415 |
dslackw/slpkg | slpkg/sizes.py | units | def units(comp_sum, uncomp_sum):
"""Calculate package size
"""
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
comp_unit = uncomp_unit = "Mb"
if compressed > 1024:
compressed = round((compressed / 1024), 2)
c... | python | def units(comp_sum, uncomp_sum):
"""Calculate package size
"""
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
comp_unit = uncomp_unit = "Mb"
if compressed > 1024:
compressed = round((compressed / 1024), 2)
c... | [
"def",
"units",
"(",
"comp_sum",
",",
"uncomp_sum",
")",
":",
"compressed",
"=",
"round",
"(",
"(",
"sum",
"(",
"map",
"(",
"float",
",",
"comp_sum",
")",
")",
"/",
"1024",
")",
",",
"2",
")",
"uncompressed",
"=",
"round",
"(",
"(",
"sum",
"(",
"... | Calculate package size | [
"Calculate",
"package",
"size"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sizes.py#L25-L43 | train | 60,416 |
dslackw/slpkg | slpkg/toolbar.py | status | def status(sec):
"""Toolbar progressive status
"""
if _meta_.prg_bar in ["on", "ON"]:
syms = ["|", "/", "-", "\\"]
for sym in syms:
sys.stdout.write("\b{0}{1}{2}".format(_meta_.color["GREY"], sym,
_meta_.color["ENDC"]))
... | python | def status(sec):
"""Toolbar progressive status
"""
if _meta_.prg_bar in ["on", "ON"]:
syms = ["|", "/", "-", "\\"]
for sym in syms:
sys.stdout.write("\b{0}{1}{2}".format(_meta_.color["GREY"], sym,
_meta_.color["ENDC"]))
... | [
"def",
"status",
"(",
"sec",
")",
":",
"if",
"_meta_",
".",
"prg_bar",
"in",
"[",
"\"on\"",
",",
"\"ON\"",
"]",
":",
"syms",
"=",
"[",
"\"|\"",
",",
"\"/\"",
",",
"\"-\"",
",",
"\"\\\\\"",
"]",
"for",
"sym",
"in",
"syms",
":",
"sys",
".",
"stdout... | Toolbar progressive status | [
"Toolbar",
"progressive",
"status"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/toolbar.py#L31-L40 | train | 60,417 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.continue_to_install | def continue_to_install(self):
"""Continue to install ?
"""
if (self.count_uni > 0 or self.count_upg > 0 or
"--download-only" in self.flag or "--rebuild" in self.flag):
if self.master_packages and self.msg.answer() in ["y", "Y"]:
installs, upgraded = s... | python | def continue_to_install(self):
"""Continue to install ?
"""
if (self.count_uni > 0 or self.count_upg > 0 or
"--download-only" in self.flag or "--rebuild" in self.flag):
if self.master_packages and self.msg.answer() in ["y", "Y"]:
installs, upgraded = s... | [
"def",
"continue_to_install",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"count_uni",
">",
"0",
"or",
"self",
".",
"count_upg",
">",
"0",
"or",
"\"--download-only\"",
"in",
"self",
".",
"flag",
"or",
"\"--rebuild\"",
"in",
"self",
".",
"flag",
")",
... | Continue to install ? | [
"Continue",
"to",
"install",
"?"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L188-L199 | train | 60,418 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.clear_masters | def clear_masters(self):
"""Clear master slackbuilds if already exist in dependencies
or if added to install two or more times
"""
self.master_packages = Utils().remove_dbs(self.master_packages)
for mas in self.master_packages:
if mas in self.dependencies:
... | python | def clear_masters(self):
"""Clear master slackbuilds if already exist in dependencies
or if added to install two or more times
"""
self.master_packages = Utils().remove_dbs(self.master_packages)
for mas in self.master_packages:
if mas in self.dependencies:
... | [
"def",
"clear_masters",
"(",
"self",
")",
":",
"self",
".",
"master_packages",
"=",
"Utils",
"(",
")",
".",
"remove_dbs",
"(",
"self",
".",
"master_packages",
")",
"for",
"mas",
"in",
"self",
".",
"master_packages",
":",
"if",
"mas",
"in",
"self",
".",
... | Clear master slackbuilds if already exist in dependencies
or if added to install two or more times | [
"Clear",
"master",
"slackbuilds",
"if",
"already",
"exist",
"in",
"dependencies",
"or",
"if",
"added",
"to",
"install",
"two",
"or",
"more",
"times"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L207-L214 | train | 60,419 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.matching | def matching(self):
"""Return found matching SBo packages
"""
for sbo in self.package_not_found:
for pkg in self.data:
if sbo in pkg and pkg not in self.blacklist:
self.package_found.append(pkg) | python | def matching(self):
"""Return found matching SBo packages
"""
for sbo in self.package_not_found:
for pkg in self.data:
if sbo in pkg and pkg not in self.blacklist:
self.package_found.append(pkg) | [
"def",
"matching",
"(",
"self",
")",
":",
"for",
"sbo",
"in",
"self",
".",
"package_not_found",
":",
"for",
"pkg",
"in",
"self",
".",
"data",
":",
"if",
"sbo",
"in",
"pkg",
"and",
"pkg",
"not",
"in",
"self",
".",
"blacklist",
":",
"self",
".",
"pac... | Return found matching SBo packages | [
"Return",
"found",
"matching",
"SBo",
"packages"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L216-L222 | train | 60,420 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.sbo_version_source | def sbo_version_source(self, slackbuilds):
"""Create sbo name with version
"""
sbo_versions, sources = [], []
for sbo in slackbuilds:
status(0.02)
sbo_ver = "{0}-{1}".format(sbo, SBoGrep(sbo).version())
sbo_versions.append(sbo_ver)
sources.... | python | def sbo_version_source(self, slackbuilds):
"""Create sbo name with version
"""
sbo_versions, sources = [], []
for sbo in slackbuilds:
status(0.02)
sbo_ver = "{0}-{1}".format(sbo, SBoGrep(sbo).version())
sbo_versions.append(sbo_ver)
sources.... | [
"def",
"sbo_version_source",
"(",
"self",
",",
"slackbuilds",
")",
":",
"sbo_versions",
",",
"sources",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"sbo",
"in",
"slackbuilds",
":",
"status",
"(",
"0.02",
")",
"sbo_ver",
"=",
"\"{0}-{1}\"",
".",
"format",
"(",
... | Create sbo name with version | [
"Create",
"sbo",
"name",
"with",
"version"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L224-L233 | train | 60,421 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.one_for_all | def one_for_all(self, deps):
"""Because there are dependencies that depend on other
dependencies are created lists into other lists.
Thus creating this loop create one-dimensional list and
remove double packages from dependencies.
"""
requires, dependencies = [], []
... | python | def one_for_all(self, deps):
"""Because there are dependencies that depend on other
dependencies are created lists into other lists.
Thus creating this loop create one-dimensional list and
remove double packages from dependencies.
"""
requires, dependencies = [], []
... | [
"def",
"one_for_all",
"(",
"self",
",",
"deps",
")",
":",
"requires",
",",
"dependencies",
"=",
"[",
"]",
",",
"[",
"]",
"deps",
".",
"reverse",
"(",
")",
"# Inverting the list brings the",
"# dependencies in order to be installed.",
"requires",
"=",
"Utils",
"(... | Because there are dependencies that depend on other
dependencies are created lists into other lists.
Thus creating this loop create one-dimensional list and
remove double packages from dependencies. | [
"Because",
"there",
"are",
"dependencies",
"that",
"depend",
"on",
"other",
"dependencies",
"are",
"created",
"lists",
"into",
"other",
"lists",
".",
"Thus",
"creating",
"this",
"loop",
"create",
"one",
"-",
"dimensional",
"list",
"and",
"remove",
"double",
"p... | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L235-L247 | train | 60,422 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.tag | def tag(self, sbo):
"""Tag with color green if package already installed,
color yellow for packages to upgrade and color red
if not installed.
"""
# split sbo name with version and get name
sbo_name = "-".join(sbo.split("-")[:-1])
find = GetFromInstalled(sbo_name)... | python | def tag(self, sbo):
"""Tag with color green if package already installed,
color yellow for packages to upgrade and color red
if not installed.
"""
# split sbo name with version and get name
sbo_name = "-".join(sbo.split("-")[:-1])
find = GetFromInstalled(sbo_name)... | [
"def",
"tag",
"(",
"self",
",",
"sbo",
")",
":",
"# split sbo name with version and get name",
"sbo_name",
"=",
"\"-\"",
".",
"join",
"(",
"sbo",
".",
"split",
"(",
"\"-\"",
")",
"[",
":",
"-",
"1",
"]",
")",
"find",
"=",
"GetFromInstalled",
"(",
"sbo_na... | Tag with color green if package already installed,
color yellow for packages to upgrade and color red
if not installed. | [
"Tag",
"with",
"color",
"green",
"if",
"package",
"already",
"installed",
"color",
"yellow",
"for",
"packages",
"to",
"upgrade",
"and",
"color",
"red",
"if",
"not",
"installed",
"."
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L277-L296 | train | 60,423 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.select_arch | def select_arch(self, src):
"""Looks if sources unsupported or untested
from arch else select arch.
"""
arch = self.arch
for item in self.unst:
if item in src:
arch = item
return arch | python | def select_arch(self, src):
"""Looks if sources unsupported or untested
from arch else select arch.
"""
arch = self.arch
for item in self.unst:
if item in src:
arch = item
return arch | [
"def",
"select_arch",
"(",
"self",
",",
"src",
")",
":",
"arch",
"=",
"self",
".",
"arch",
"for",
"item",
"in",
"self",
".",
"unst",
":",
"if",
"item",
"in",
"src",
":",
"arch",
"=",
"item",
"return",
"arch"
] | Looks if sources unsupported or untested
from arch else select arch. | [
"Looks",
"if",
"sources",
"unsupported",
"or",
"untested",
"from",
"arch",
"else",
"select",
"arch",
"."
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L298-L306 | train | 60,424 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.filenames | def filenames(self, sources):
"""Return filenames from sources links
"""
filename = []
for src in sources:
filename.append(src.split("/")[-1])
return filename | python | def filenames(self, sources):
"""Return filenames from sources links
"""
filename = []
for src in sources:
filename.append(src.split("/")[-1])
return filename | [
"def",
"filenames",
"(",
"self",
",",
"sources",
")",
":",
"filename",
"=",
"[",
"]",
"for",
"src",
"in",
"sources",
":",
"filename",
".",
"append",
"(",
"src",
".",
"split",
"(",
"\"/\"",
")",
"[",
"-",
"1",
"]",
")",
"return",
"filename"
] | Return filenames from sources links | [
"Return",
"filenames",
"from",
"sources",
"links"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L308-L314 | train | 60,425 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.not_downgrade | def not_downgrade(self, prgnam):
"""Don't downgrade packages if sbo version is lower than
installed"""
name = "-".join(prgnam.split("-")[:-1])
sbo_ver = prgnam.split("-")[-1]
ins_ver = GetFromInstalled(name).version()[1:]
if not ins_ver:
ins_ver = "0"
... | python | def not_downgrade(self, prgnam):
"""Don't downgrade packages if sbo version is lower than
installed"""
name = "-".join(prgnam.split("-")[:-1])
sbo_ver = prgnam.split("-")[-1]
ins_ver = GetFromInstalled(name).version()[1:]
if not ins_ver:
ins_ver = "0"
... | [
"def",
"not_downgrade",
"(",
"self",
",",
"prgnam",
")",
":",
"name",
"=",
"\"-\"",
".",
"join",
"(",
"prgnam",
".",
"split",
"(",
"\"-\"",
")",
"[",
":",
"-",
"1",
"]",
")",
"sbo_ver",
"=",
"prgnam",
".",
"split",
"(",
"\"-\"",
")",
"[",
"-",
... | Don't downgrade packages if sbo version is lower than
installed | [
"Don",
"t",
"downgrade",
"packages",
"if",
"sbo",
"version",
"is",
"lower",
"than",
"installed"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L377-L390 | train | 60,426 |
dslackw/slpkg | slpkg/sbo/slackbuild.py | SBoInstall.sbosrcarsh | def sbosrcarsh(self, prgnam, sbo_link, src_link):
"""Alternative repository for sbo sources"""
sources = []
name = "-".join(prgnam.split("-")[:-1])
category = "{0}/{1}/".format(sbo_link.split("/")[-2], name)
for link in src_link:
source = link.split("/")[-1]
... | python | def sbosrcarsh(self, prgnam, sbo_link, src_link):
"""Alternative repository for sbo sources"""
sources = []
name = "-".join(prgnam.split("-")[:-1])
category = "{0}/{1}/".format(sbo_link.split("/")[-2], name)
for link in src_link:
source = link.split("/")[-1]
... | [
"def",
"sbosrcarsh",
"(",
"self",
",",
"prgnam",
",",
"sbo_link",
",",
"src_link",
")",
":",
"sources",
"=",
"[",
"]",
"name",
"=",
"\"-\"",
".",
"join",
"(",
"prgnam",
".",
"split",
"(",
"\"-\"",
")",
"[",
":",
"-",
"1",
"]",
")",
"category",
"=... | Alternative repository for sbo sources | [
"Alternative",
"repository",
"for",
"sbo",
"sources"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/slackbuild.py#L392-L401 | train | 60,427 |
dslackw/slpkg | slpkg/version.py | prog_version | def prog_version():
"""Print version, license and email
"""
print("Version : {0}\n"
"Licence : {1}\n"
"Email : {2}\n"
"Maintainer: {3}".format(_meta_.__version__,
_meta_.__license__,
_meta_.__email__,... | python | def prog_version():
"""Print version, license and email
"""
print("Version : {0}\n"
"Licence : {1}\n"
"Email : {2}\n"
"Maintainer: {3}".format(_meta_.__version__,
_meta_.__license__,
_meta_.__email__,... | [
"def",
"prog_version",
"(",
")",
":",
"print",
"(",
"\"Version : {0}\\n\"",
"\"Licence : {1}\\n\"",
"\"Email : {2}\\n\"",
"\"Maintainer: {3}\"",
".",
"format",
"(",
"_meta_",
".",
"__version__",
",",
"_meta_",
".",
"__license__",
",",
"_meta_",
".",
"__email__... | Print version, license and email | [
"Print",
"version",
"license",
"and",
"email"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/version.py#L28-L37 | train | 60,428 |
dslackw/slpkg | slpkg/messages.py | Msg.pkg_not_found | def pkg_not_found(self, bol, pkg, message, eol):
"""Print message when package not found
"""
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol)) | python | def pkg_not_found(self, bol, pkg, message, eol):
"""Print message when package not found
"""
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol)) | [
"def",
"pkg_not_found",
"(",
"self",
",",
"bol",
",",
"pkg",
",",
"message",
",",
"eol",
")",
":",
"print",
"(",
"\"{0}No such package {1}: {2}{3}\"",
".",
"format",
"(",
"bol",
",",
"pkg",
",",
"message",
",",
"eol",
")",
")"
] | Print message when package not found | [
"Print",
"message",
"when",
"package",
"not",
"found"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/messages.py#L37-L40 | train | 60,429 |
dslackw/slpkg | slpkg/messages.py | Msg.build_FAILED | def build_FAILED(self, prgnam):
"""Print error message if build failed
"""
self.template(78)
print("| Some error on the package {0} [ {1}FAILED{2} ]".format(
prgnam, self.meta.color["RED"], self.meta.color["ENDC"]))
self.template(78)
print("| See the log file ... | python | def build_FAILED(self, prgnam):
"""Print error message if build failed
"""
self.template(78)
print("| Some error on the package {0} [ {1}FAILED{2} ]".format(
prgnam, self.meta.color["RED"], self.meta.color["ENDC"]))
self.template(78)
print("| See the log file ... | [
"def",
"build_FAILED",
"(",
"self",
",",
"prgnam",
")",
":",
"self",
".",
"template",
"(",
"78",
")",
"print",
"(",
"\"| Some error on the package {0} [ {1}FAILED{2} ]\"",
".",
"format",
"(",
"prgnam",
",",
"self",
".",
"meta",
".",
"color",
"[",
"\"RED\"",
... | Print error message if build failed | [
"Print",
"error",
"message",
"if",
"build",
"failed"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/messages.py#L52-L63 | train | 60,430 |
dslackw/slpkg | slpkg/messages.py | Msg.security_pkg | def security_pkg(self, pkg):
"""Warning message for some special reasons
"""
print("")
self.template(78)
print("| {0}{1}*** WARNING ***{2}").format(
" " * 27, self.meta.color["RED"], self.meta.color["ENDC"])
self.template(78)
print("| Before proceed wi... | python | def security_pkg(self, pkg):
"""Warning message for some special reasons
"""
print("")
self.template(78)
print("| {0}{1}*** WARNING ***{2}").format(
" " * 27, self.meta.color["RED"], self.meta.color["ENDC"])
self.template(78)
print("| Before proceed wi... | [
"def",
"security_pkg",
"(",
"self",
",",
"pkg",
")",
":",
"print",
"(",
"\"\"",
")",
"self",
".",
"template",
"(",
"78",
")",
"print",
"(",
"\"| {0}{1}*** WARNING ***{2}\"",
")",
".",
"format",
"(",
"\" \"",
"*",
"27",
",",
"self",
".",
"meta",
".",
... | Warning message for some special reasons | [
"Warning",
"message",
"for",
"some",
"special",
"reasons"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/messages.py#L134-L146 | train | 60,431 |
dslackw/slpkg | slpkg/messages.py | Msg.reference | def reference(self, install, upgrade):
"""Reference list with packages installed
and upgraded
"""
self.template(78)
print("| Total {0} {1} installed and {2} {3} upgraded".format(
len(install), self.pkg(len(install)),
len(upgrade), self.pkg(len(upgrade))))
... | python | def reference(self, install, upgrade):
"""Reference list with packages installed
and upgraded
"""
self.template(78)
print("| Total {0} {1} installed and {2} {3} upgraded".format(
len(install), self.pkg(len(install)),
len(upgrade), self.pkg(len(upgrade))))
... | [
"def",
"reference",
"(",
"self",
",",
"install",
",",
"upgrade",
")",
":",
"self",
".",
"template",
"(",
"78",
")",
"print",
"(",
"\"| Total {0} {1} installed and {2} {3} upgraded\"",
".",
"format",
"(",
"len",
"(",
"install",
")",
",",
"self",
".",
"pkg",
... | Reference list with packages installed
and upgraded | [
"Reference",
"list",
"with",
"packages",
"installed",
"and",
"upgraded"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/messages.py#L148-L163 | train | 60,432 |
dslackw/slpkg | slpkg/messages.py | Msg.matching | def matching(self, packages):
"""Message for matching packages
"""
print("\nNot found package with the name [ {0}{1}{2} ]. "
"Matching packages:\nNOTE: Not dependenc"
"ies are resolved\n".format(self.meta.color["CYAN"],
"".joi... | python | def matching(self, packages):
"""Message for matching packages
"""
print("\nNot found package with the name [ {0}{1}{2} ]. "
"Matching packages:\nNOTE: Not dependenc"
"ies are resolved\n".format(self.meta.color["CYAN"],
"".joi... | [
"def",
"matching",
"(",
"self",
",",
"packages",
")",
":",
"print",
"(",
"\"\\nNot found package with the name [ {0}{1}{2} ]. \"",
"\"Matching packages:\\nNOTE: Not dependenc\"",
"\"ies are resolved\\n\"",
".",
"format",
"(",
"self",
".",
"meta",
".",
"color",
"[",
"\"CYA... | Message for matching packages | [
"Message",
"for",
"matching",
"packages"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/messages.py#L165-L172 | train | 60,433 |
dslackw/slpkg | slpkg/slack/mirrors.py | mirrors | def mirrors(name, location):
"""
Select Slackware official mirror packages
based architecture and version.
"""
rel = _meta_.slack_rel
ver = slack_ver()
repo = Repo().slack()
if _meta_.arch == "x86_64":
if rel == "stable":
http = repo + "slackware64-{0}/{1}{2}".format(... | python | def mirrors(name, location):
"""
Select Slackware official mirror packages
based architecture and version.
"""
rel = _meta_.slack_rel
ver = slack_ver()
repo = Repo().slack()
if _meta_.arch == "x86_64":
if rel == "stable":
http = repo + "slackware64-{0}/{1}{2}".format(... | [
"def",
"mirrors",
"(",
"name",
",",
"location",
")",
":",
"rel",
"=",
"_meta_",
".",
"slack_rel",
"ver",
"=",
"slack_ver",
"(",
")",
"repo",
"=",
"Repo",
"(",
")",
".",
"slack",
"(",
")",
"if",
"_meta_",
".",
"arch",
"==",
"\"x86_64\"",
":",
"if",
... | Select Slackware official mirror packages
based architecture and version. | [
"Select",
"Slackware",
"official",
"mirror",
"packages",
"based",
"architecture",
"and",
"version",
"."
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/slack/mirrors.py#L31-L54 | train | 60,434 |
dslackw/slpkg | slpkg/auto_pkg.py | Auto.select | def select(self):
"""Select Slackware command
"""
print("\nDetected Slackware binary package for installation:\n")
for pkg in self.packages:
print(" " + pkg.split("/")[-1])
print("")
self.msg.template(78)
print("| Choose a Slackware command:")
... | python | def select(self):
"""Select Slackware command
"""
print("\nDetected Slackware binary package for installation:\n")
for pkg in self.packages:
print(" " + pkg.split("/")[-1])
print("")
self.msg.template(78)
print("| Choose a Slackware command:")
... | [
"def",
"select",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nDetected Slackware binary package for installation:\\n\"",
")",
"for",
"pkg",
"in",
"self",
".",
"packages",
":",
"print",
"(",
"\" \"",
"+",
"pkg",
".",
"split",
"(",
"\"/\"",
")",
"[",
"-",
"1",
... | Select Slackware command | [
"Select",
"Slackware",
"command"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/auto_pkg.py#L46-L72 | train | 60,435 |
dslackw/slpkg | slpkg/auto_pkg.py | Auto.execute | def execute(self):
"""Execute Slackware command
"""
if self.choice in self.commands.keys():
if self.choice == "i":
PackageManager(self.packages).install("")
elif self.choice in ["u", "r"]:
PackageManager(self.packages).upgrade(
... | python | def execute(self):
"""Execute Slackware command
"""
if self.choice in self.commands.keys():
if self.choice == "i":
PackageManager(self.packages).install("")
elif self.choice in ["u", "r"]:
PackageManager(self.packages).upgrade(
... | [
"def",
"execute",
"(",
"self",
")",
":",
"if",
"self",
".",
"choice",
"in",
"self",
".",
"commands",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"choice",
"==",
"\"i\"",
":",
"PackageManager",
"(",
"self",
".",
"packages",
")",
".",
"install",
"... | Execute Slackware command | [
"Execute",
"Slackware",
"command"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/auto_pkg.py#L74-L82 | train | 60,436 |
dslackw/slpkg | slpkg/repoenable.py | RepoEnable.read_enabled | def read_enabled(self):
"""Read enable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if (line and self.tag_line and not line.startswith("#") and
self.tag ... | python | def read_enabled(self):
"""Read enable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if (line and self.tag_line and not line.startswith("#") and
self.tag ... | [
"def",
"read_enabled",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"conf",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"if",
"self",
".",
"tag",
"in",
"line",
":",
"self",
".",
"tag_line",
"=",
"Tr... | Read enable repositories | [
"Read",
"enable",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L76-L86 | train | 60,437 |
dslackw/slpkg | slpkg/repoenable.py | RepoEnable.read_disabled | def read_disabled(self):
"""Read disable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if self.tag_line and line.startswith("#"):
line = "".join(line.split("#... | python | def read_disabled(self):
"""Read disable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if self.tag_line and line.startswith("#"):
line = "".join(line.split("#... | [
"def",
"read_disabled",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"conf",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"if",
"self",
".",
"tag",
"in",
"line",
":",
"self",
".",
"tag_line",
"=",
"T... | Read disable repositories | [
"Read",
"disable",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L88-L98 | train | 60,438 |
dslackw/slpkg | slpkg/repoenable.py | RepoEnable.update_repos | def update_repos(self):
"""Update repositories.conf file with enabled or disabled
repositories
"""
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
for line in self.conf.splitlines():
l... | python | def update_repos(self):
"""Update repositories.conf file with enabled or disabled
repositories
"""
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
for line in self.conf.splitlines():
l... | [
"def",
"update_repos",
"(",
"self",
")",
":",
"with",
"open",
"(",
"\"{0}{1}\"",
".",
"format",
"(",
"self",
".",
"meta",
".",
"conf_path",
",",
"self",
".",
"repositories_conf",
")",
",",
"\"w\"",
")",
"as",
"new_conf",
":",
"for",
"line",
"in",
"self... | Update repositories.conf file with enabled or disabled
repositories | [
"Update",
"repositories",
".",
"conf",
"file",
"with",
"enabled",
"or",
"disabled",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L100-L121 | train | 60,439 |
dslackw/slpkg | slpkg/repoenable.py | RepoEnable.reference | def reference(self):
"""Reference enable repositories
"""
total_enabled = ", ".join(self.selected)
if len(total_enabled) < 1:
total_enabled = ("{0}Are you crazy? This is a package "
"manager for packages :p{1}".format(
... | python | def reference(self):
"""Reference enable repositories
"""
total_enabled = ", ".join(self.selected)
if len(total_enabled) < 1:
total_enabled = ("{0}Are you crazy? This is a package "
"manager for packages :p{1}".format(
... | [
"def",
"reference",
"(",
"self",
")",
":",
"total_enabled",
"=",
"\", \"",
".",
"join",
"(",
"self",
".",
"selected",
")",
"if",
"len",
"(",
"total_enabled",
")",
"<",
"1",
":",
"total_enabled",
"=",
"(",
"\"{0}Are you crazy? This is a package \"",
"\"manager ... | Reference enable repositories | [
"Reference",
"enable",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L128-L144 | train | 60,440 |
dslackw/slpkg | slpkg/sbo/search.py | sbo_search_pkg | def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
return url
"""
repo = Repo().default_repository()["sbo"]
sbo_url = "{0}{1}/".format(repo, slack_ver())
SLACKBUILDS_TXT = Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLA... | python | def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
return url
"""
repo = Repo().default_repository()["sbo"]
sbo_url = "{0}{1}/".format(repo, slack_ver())
SLACKBUILDS_TXT = Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLA... | [
"def",
"sbo_search_pkg",
"(",
"name",
")",
":",
"repo",
"=",
"Repo",
"(",
")",
".",
"default_repository",
"(",
")",
"[",
"\"sbo\"",
"]",
"sbo_url",
"=",
"\"{0}{1}/\"",
".",
"format",
"(",
"repo",
",",
"slack_ver",
"(",
")",
")",
"SLACKBUILDS_TXT",
"=",
... | Search for package path from SLACKBUILDS.TXT file and
return url | [
"Search",
"for",
"package",
"path",
"from",
"SLACKBUILDS",
".",
"TXT",
"file",
"and",
"return",
"url"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/search.py#L32-L45 | train | 60,441 |
jsommers/switchyard | examples/exercises/router/myrouter.py | Router.router_main | def router_main(self):
'''
Main method for router; we stay in a loop in this method, receiving
packets until the end of time.
'''
while True:
gotpkt = True
try:
timestamp,dev,pkt = self.net.recv_packet(timeout=1.0)
except No... | python | def router_main(self):
'''
Main method for router; we stay in a loop in this method, receiving
packets until the end of time.
'''
while True:
gotpkt = True
try:
timestamp,dev,pkt = self.net.recv_packet(timeout=1.0)
except No... | [
"def",
"router_main",
"(",
"self",
")",
":",
"while",
"True",
":",
"gotpkt",
"=",
"True",
"try",
":",
"timestamp",
",",
"dev",
",",
"pkt",
"=",
"self",
".",
"net",
".",
"recv_packet",
"(",
"timeout",
"=",
"1.0",
")",
"except",
"NoPackets",
":",
"log_... | Main method for router; we stay in a loop in this method, receiving
packets until the end of time. | [
"Main",
"method",
"for",
"router",
";",
"we",
"stay",
"in",
"a",
"loop",
"in",
"this",
"method",
"receiving",
"packets",
"until",
"the",
"end",
"of",
"time",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/examples/exercises/router/myrouter.py#L18-L35 | train | 60,442 |
bronto/javasphinx | javasphinx/apidoc.py | find_source_files | def find_source_files(input_path, excludes):
""" Get a list of filenames for all Java source files within the given
directory.
"""
java_files = []
input_path = os.path.normpath(os.path.abspath(input_path))
for dirpath, dirnames, filenames in os.walk(input_path):
if is_excluded(dirpat... | python | def find_source_files(input_path, excludes):
""" Get a list of filenames for all Java source files within the given
directory.
"""
java_files = []
input_path = os.path.normpath(os.path.abspath(input_path))
for dirpath, dirnames, filenames in os.walk(input_path):
if is_excluded(dirpat... | [
"def",
"find_source_files",
"(",
"input_path",
",",
"excludes",
")",
":",
"java_files",
"=",
"[",
"]",
"input_path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"input_path",
")",
")",
"for",
"dirpath",
",",
"d... | Get a list of filenames for all Java source files within the given
directory. | [
"Get",
"a",
"list",
"of",
"filenames",
"for",
"all",
"Java",
"source",
"files",
"within",
"the",
"given",
"directory",
"."
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/apidoc.py#L43-L62 | train | 60,443 |
jsommers/switchyard | switchyard/lib/packet/ipv4.py | IPOptionList.from_bytes | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
IPOption objects.
'''
ipopts = IPOptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optcopied = opttype >> 7 # high order 1 bit
... | python | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
IPOption objects.
'''
ipopts = IPOptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optcopied = opttype >> 7 # high order 1 bit
... | [
"def",
"from_bytes",
"(",
"rawbytes",
")",
":",
"ipopts",
"=",
"IPOptionList",
"(",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"rawbytes",
")",
":",
"opttype",
"=",
"rawbytes",
"[",
"i",
"]",
"optcopied",
"=",
"opttype",
">>",
"7",
"# high or... | Takes a byte string as a parameter and returns a list of
IPOption objects. | [
"Takes",
"a",
"byte",
"string",
"as",
"a",
"parameter",
"and",
"returns",
"a",
"list",
"of",
"IPOption",
"objects",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/ipv4.py#L289-L307 | train | 60,444 |
jsommers/switchyard | switchyard/lib/packet/ipv4.py | IPOptionList.to_bytes | def to_bytes(self):
'''
Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for ipopt in self._options:
raw += ipopt.to_bytes()
... | python | def to_bytes(self):
'''
Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for ipopt in self._options:
raw += ipopt.to_bytes()
... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"raw",
"=",
"b''",
"if",
"not",
"self",
".",
"_options",
":",
"return",
"raw",
"for",
"ipopt",
"in",
"self",
".",
"_options",
":",
"raw",
"+=",
"ipopt",
".",
"to_bytes",
"(",
")",
"padbytes",
"=",
"4",
"-",... | Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary. | [
"Takes",
"a",
"list",
"of",
"IPOption",
"objects",
"and",
"returns",
"a",
"packed",
"byte",
"string",
"of",
"options",
"appropriately",
"padded",
"if",
"necessary",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/ipv4.py#L309-L321 | train | 60,445 |
jsommers/switchyard | switchyard/llnetbase.py | _start_usercode | def _start_usercode(entryfunction, netobj, codeargdict):
'''
figure out how to correctly start the user code. warn if
args are passed on the command line, but the code doesn't
accept them.
'''
# p22, python3 lang ref
numargs = entryfunction.__code__.co_argcount
takenet = numargs >= 1
... | python | def _start_usercode(entryfunction, netobj, codeargdict):
'''
figure out how to correctly start the user code. warn if
args are passed on the command line, but the code doesn't
accept them.
'''
# p22, python3 lang ref
numargs = entryfunction.__code__.co_argcount
takenet = numargs >= 1
... | [
"def",
"_start_usercode",
"(",
"entryfunction",
",",
"netobj",
",",
"codeargdict",
")",
":",
"# p22, python3 lang ref",
"numargs",
"=",
"entryfunction",
".",
"__code__",
".",
"co_argcount",
"takenet",
"=",
"numargs",
">=",
"1",
"takestarargs",
"=",
"entryfunction",
... | figure out how to correctly start the user code. warn if
args are passed on the command line, but the code doesn't
accept them. | [
"figure",
"out",
"how",
"to",
"correctly",
"start",
"the",
"user",
"code",
".",
"warn",
"if",
"args",
"are",
"passed",
"on",
"the",
"command",
"line",
"but",
"the",
"code",
"doesn",
"t",
"accept",
"them",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L12-L46 | train | 60,446 |
jsommers/switchyard | switchyard/llnetbase.py | LLNetBase.interface_by_name | def interface_by_name(self, name):
'''
Given a device name, return the corresponding interface object
'''
if name in self._devinfo:
return self._devinfo[name]
raise KeyError("No device named {}".format(name)) | python | def interface_by_name(self, name):
'''
Given a device name, return the corresponding interface object
'''
if name in self._devinfo:
return self._devinfo[name]
raise KeyError("No device named {}".format(name)) | [
"def",
"interface_by_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_devinfo",
":",
"return",
"self",
".",
"_devinfo",
"[",
"name",
"]",
"raise",
"KeyError",
"(",
"\"No device named {}\"",
".",
"format",
"(",
"name",
")",
")... | Given a device name, return the corresponding interface object | [
"Given",
"a",
"device",
"name",
"return",
"the",
"corresponding",
"interface",
"object"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L105-L111 | train | 60,447 |
jsommers/switchyard | switchyard/llnetbase.py | LLNetBase.interface_by_ipaddr | def interface_by_ipaddr(self, ipaddr):
'''
Given an IP address, return the interface that 'owns' this address
'''
ipaddr = IPAddr(ipaddr)
for devname,iface in self._devinfo.items():
if iface.ipaddr == ipaddr:
return iface
raise KeyError("No dev... | python | def interface_by_ipaddr(self, ipaddr):
'''
Given an IP address, return the interface that 'owns' this address
'''
ipaddr = IPAddr(ipaddr)
for devname,iface in self._devinfo.items():
if iface.ipaddr == ipaddr:
return iface
raise KeyError("No dev... | [
"def",
"interface_by_ipaddr",
"(",
"self",
",",
"ipaddr",
")",
":",
"ipaddr",
"=",
"IPAddr",
"(",
"ipaddr",
")",
"for",
"devname",
",",
"iface",
"in",
"self",
".",
"_devinfo",
".",
"items",
"(",
")",
":",
"if",
"iface",
".",
"ipaddr",
"==",
"ipaddr",
... | Given an IP address, return the interface that 'owns' this address | [
"Given",
"an",
"IP",
"address",
"return",
"the",
"interface",
"that",
"owns",
"this",
"address"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L119-L127 | train | 60,448 |
jsommers/switchyard | switchyard/llnetbase.py | LLNetBase.interface_by_macaddr | def interface_by_macaddr(self, macaddr):
'''
Given a MAC address, return the interface that 'owns' this address
'''
macaddr = EthAddr(macaddr)
for devname,iface in self._devinfo.items():
if iface.ethaddr == macaddr:
return iface
raise KeyError(... | python | def interface_by_macaddr(self, macaddr):
'''
Given a MAC address, return the interface that 'owns' this address
'''
macaddr = EthAddr(macaddr)
for devname,iface in self._devinfo.items():
if iface.ethaddr == macaddr:
return iface
raise KeyError(... | [
"def",
"interface_by_macaddr",
"(",
"self",
",",
"macaddr",
")",
":",
"macaddr",
"=",
"EthAddr",
"(",
"macaddr",
")",
"for",
"devname",
",",
"iface",
"in",
"self",
".",
"_devinfo",
".",
"items",
"(",
")",
":",
"if",
"iface",
".",
"ethaddr",
"==",
"maca... | Given a MAC address, return the interface that 'owns' this address | [
"Given",
"a",
"MAC",
"address",
"return",
"the",
"interface",
"that",
"owns",
"this",
"address"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L135-L143 | train | 60,449 |
jsommers/switchyard | switchyard/lib/packet/icmpv6.py | ICMPv6OptionList.from_bytes | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
ICMPv6Option objects.
'''
icmpv6popts = ICMPv6OptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optnum = ICMPv6OptionNumber(opttype)
... | python | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
ICMPv6Option objects.
'''
icmpv6popts = ICMPv6OptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optnum = ICMPv6OptionNumber(opttype)
... | [
"def",
"from_bytes",
"(",
"rawbytes",
")",
":",
"icmpv6popts",
"=",
"ICMPv6OptionList",
"(",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"rawbytes",
")",
":",
"opttype",
"=",
"rawbytes",
"[",
"i",
"]",
"optnum",
"=",
"ICMPv6OptionNumber",
"(",
"... | Takes a byte string as a parameter and returns a list of
ICMPv6Option objects. | [
"Takes",
"a",
"byte",
"string",
"as",
"a",
"parameter",
"and",
"returns",
"a",
"list",
"of",
"ICMPv6Option",
"objects",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/icmpv6.py#L197-L212 | train | 60,450 |
jsommers/switchyard | switchyard/lib/packet/icmpv6.py | ICMPv6OptionList.to_bytes | def to_bytes(self):
'''
Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for icmpv6popt in self._options:
raw += icmpv6popt.t... | python | def to_bytes(self):
'''
Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for icmpv6popt in self._options:
raw += icmpv6popt.t... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"raw",
"=",
"b''",
"if",
"not",
"self",
".",
"_options",
":",
"return",
"raw",
"for",
"icmpv6popt",
"in",
"self",
".",
"_options",
":",
"raw",
"+=",
"icmpv6popt",
".",
"to_bytes",
"(",
")",
"# Padding doesn't see... | Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary. | [
"Takes",
"a",
"list",
"of",
"ICMPv6Option",
"objects",
"and",
"returns",
"a",
"packed",
"byte",
"string",
"of",
"options",
"appropriately",
"padded",
"if",
"necessary",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/icmpv6.py#L214-L230 | train | 60,451 |
jsommers/switchyard | switchyard/lib/openflow/openflow10.py | _unpack_bitmap | def _unpack_bitmap(bitmap, xenum):
'''
Given an integer bitmap and an enumerated type, build
a set that includes zero or more enumerated type values
corresponding to the bitmap.
'''
unpacked = set()
for enval in xenum:
if enval.value & bitmap == enval.value:
unpacked.add(... | python | def _unpack_bitmap(bitmap, xenum):
'''
Given an integer bitmap and an enumerated type, build
a set that includes zero or more enumerated type values
corresponding to the bitmap.
'''
unpacked = set()
for enval in xenum:
if enval.value & bitmap == enval.value:
unpacked.add(... | [
"def",
"_unpack_bitmap",
"(",
"bitmap",
",",
"xenum",
")",
":",
"unpacked",
"=",
"set",
"(",
")",
"for",
"enval",
"in",
"xenum",
":",
"if",
"enval",
".",
"value",
"&",
"bitmap",
"==",
"enval",
".",
"value",
":",
"unpacked",
".",
"add",
"(",
"enval",
... | Given an integer bitmap and an enumerated type, build
a set that includes zero or more enumerated type values
corresponding to the bitmap. | [
"Given",
"an",
"integer",
"bitmap",
"and",
"an",
"enumerated",
"type",
"build",
"a",
"set",
"that",
"includes",
"zero",
"or",
"more",
"enumerated",
"type",
"values",
"corresponding",
"to",
"the",
"bitmap",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L21-L31 | train | 60,452 |
jsommers/switchyard | switchyard/lib/openflow/openflow10.py | _make_wildcard_attr_map | def _make_wildcard_attr_map():
'''
Create a dictionary that maps an attribute name
in OpenflowMatch with a non-prefix-related wildcard
bit from the above OpenflowWildcard enumeration.
'''
_xmap = {}
for wc in OpenflowWildcard:
if not wc.name.endswith('All') and \
not wc.n... | python | def _make_wildcard_attr_map():
'''
Create a dictionary that maps an attribute name
in OpenflowMatch with a non-prefix-related wildcard
bit from the above OpenflowWildcard enumeration.
'''
_xmap = {}
for wc in OpenflowWildcard:
if not wc.name.endswith('All') and \
not wc.n... | [
"def",
"_make_wildcard_attr_map",
"(",
")",
":",
"_xmap",
"=",
"{",
"}",
"for",
"wc",
"in",
"OpenflowWildcard",
":",
"if",
"not",
"wc",
".",
"name",
".",
"endswith",
"(",
"'All'",
")",
"and",
"not",
"wc",
".",
"name",
".",
"endswith",
"(",
"'Mask'",
... | Create a dictionary that maps an attribute name
in OpenflowMatch with a non-prefix-related wildcard
bit from the above OpenflowWildcard enumeration. | [
"Create",
"a",
"dictionary",
"that",
"maps",
"an",
"attribute",
"name",
"in",
"OpenflowMatch",
"with",
"a",
"non",
"-",
"prefix",
"-",
"related",
"wildcard",
"bit",
"from",
"the",
"above",
"OpenflowWildcard",
"enumeration",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L761-L779 | train | 60,453 |
jsommers/switchyard | switchyard/lib/openflow/openflow10.py | OpenflowMatch.matches_packet | def matches_packet(self, pkt):
'''
Return True if the given packet matches this match object.
'''
match = []
wildbits = _make_bitmap(self._wildcards)
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
mf = "_{}".format(mf)
# if the a... | python | def matches_packet(self, pkt):
'''
Return True if the given packet matches this match object.
'''
match = []
wildbits = _make_bitmap(self._wildcards)
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
mf = "_{}".format(mf)
# if the a... | [
"def",
"matches_packet",
"(",
"self",
",",
"pkt",
")",
":",
"match",
"=",
"[",
"]",
"wildbits",
"=",
"_make_bitmap",
"(",
"self",
".",
"_wildcards",
")",
"for",
"mf",
",",
"pkttuple",
"in",
"OpenflowMatch",
".",
"_match_field_to_packet",
".",
"items",
"(",... | Return True if the given packet matches this match object. | [
"Return",
"True",
"if",
"the",
"given",
"packet",
"matches",
"this",
"match",
"object",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L537-L566 | train | 60,454 |
jsommers/switchyard | switchyard/lib/openflow/openflow10.py | OpenflowMatch.build_from_packet | def build_from_packet(pkt):
'''
Build and return a new OpenflowMatch object based on the
packet object passed as a parameter.
'''
m = OpenflowMatch()
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
for pktcls,field in pkttuple:
... | python | def build_from_packet(pkt):
'''
Build and return a new OpenflowMatch object based on the
packet object passed as a parameter.
'''
m = OpenflowMatch()
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
for pktcls,field in pkttuple:
... | [
"def",
"build_from_packet",
"(",
"pkt",
")",
":",
"m",
"=",
"OpenflowMatch",
"(",
")",
"for",
"mf",
",",
"pkttuple",
"in",
"OpenflowMatch",
".",
"_match_field_to_packet",
".",
"items",
"(",
")",
":",
"for",
"pktcls",
",",
"field",
"in",
"pkttuple",
":",
... | Build and return a new OpenflowMatch object based on the
packet object passed as a parameter. | [
"Build",
"and",
"return",
"a",
"new",
"OpenflowMatch",
"object",
"based",
"on",
"the",
"packet",
"object",
"passed",
"as",
"a",
"parameter",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L569-L580 | train | 60,455 |
jsommers/switchyard | switchyard/lib/openflow/openflow10.py | OpenflowHeader.pre_serialize | def pre_serialize(self, raw, pkt, i):
'''
Set length of the header based on
'''
self.length = len(raw) + OpenflowHeader._MINLEN | python | def pre_serialize(self, raw, pkt, i):
'''
Set length of the header based on
'''
self.length = len(raw) + OpenflowHeader._MINLEN | [
"def",
"pre_serialize",
"(",
"self",
",",
"raw",
",",
"pkt",
",",
"i",
")",
":",
"self",
".",
"length",
"=",
"len",
"(",
"raw",
")",
"+",
"OpenflowHeader",
".",
"_MINLEN"
] | Set length of the header based on | [
"Set",
"length",
"of",
"the",
"header",
"based",
"on"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L3378-L3382 | train | 60,456 |
jsommers/switchyard | switchyard/pcapffi.py | _PcapFfi.discoverdevs | def discoverdevs(self):
'''
Find all the pcap-eligible devices on the local system.
'''
if len(self._interfaces):
raise PcapException("Device discovery should only be done once.")
ppintf = self._ffi.new("pcap_if_t * *")
errbuf = self._ffi.new("cha... | python | def discoverdevs(self):
'''
Find all the pcap-eligible devices on the local system.
'''
if len(self._interfaces):
raise PcapException("Device discovery should only be done once.")
ppintf = self._ffi.new("pcap_if_t * *")
errbuf = self._ffi.new("cha... | [
"def",
"discoverdevs",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_interfaces",
")",
":",
"raise",
"PcapException",
"(",
"\"Device discovery should only be done once.\"",
")",
"ppintf",
"=",
"self",
".",
"_ffi",
".",
"new",
"(",
"\"pcap_if_t * *\"",
... | Find all the pcap-eligible devices on the local system. | [
"Find",
"all",
"the",
"pcap",
"-",
"eligible",
"devices",
"on",
"the",
"local",
"system",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/pcapffi.py#L208-L254 | train | 60,457 |
jsommers/switchyard | switchyard/pcapffi.py | PcapLiveDevice.set_bpf_filter_on_all_devices | def set_bpf_filter_on_all_devices(filterstr):
'''
Long method name, but self-explanatory. Set the bpf
filter on all devices that have been opened.
'''
with PcapLiveDevice._lock:
for dev in PcapLiveDevice._OpenDevices.values():
_PcapFfi.instance()._set... | python | def set_bpf_filter_on_all_devices(filterstr):
'''
Long method name, but self-explanatory. Set the bpf
filter on all devices that have been opened.
'''
with PcapLiveDevice._lock:
for dev in PcapLiveDevice._OpenDevices.values():
_PcapFfi.instance()._set... | [
"def",
"set_bpf_filter_on_all_devices",
"(",
"filterstr",
")",
":",
"with",
"PcapLiveDevice",
".",
"_lock",
":",
"for",
"dev",
"in",
"PcapLiveDevice",
".",
"_OpenDevices",
".",
"values",
"(",
")",
":",
"_PcapFfi",
".",
"instance",
"(",
")",
".",
"_set_filter",... | Long method name, but self-explanatory. Set the bpf
filter on all devices that have been opened. | [
"Long",
"method",
"name",
"but",
"self",
"-",
"explanatory",
".",
"Set",
"the",
"bpf",
"filter",
"on",
"all",
"devices",
"that",
"have",
"been",
"opened",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/pcapffi.py#L568-L575 | train | 60,458 |
jsommers/switchyard | switchyard/lib/packet/util.py | create_ip_arp_request | def create_ip_arp_request(srchw, srcip, targetip):
'''
Create and return a packet containing an Ethernet header
and ARP header.
'''
ether = Ethernet()
ether.src = srchw
ether.dst = SpecialEthAddr.ETHER_BROADCAST.value
ether.ethertype = EtherType.ARP
arp = Arp()
arp.operation = Ar... | python | def create_ip_arp_request(srchw, srcip, targetip):
'''
Create and return a packet containing an Ethernet header
and ARP header.
'''
ether = Ethernet()
ether.src = srchw
ether.dst = SpecialEthAddr.ETHER_BROADCAST.value
ether.ethertype = EtherType.ARP
arp = Arp()
arp.operation = Ar... | [
"def",
"create_ip_arp_request",
"(",
"srchw",
",",
"srcip",
",",
"targetip",
")",
":",
"ether",
"=",
"Ethernet",
"(",
")",
"ether",
".",
"src",
"=",
"srchw",
"ether",
".",
"dst",
"=",
"SpecialEthAddr",
".",
"ETHER_BROADCAST",
".",
"value",
"ether",
".",
... | Create and return a packet containing an Ethernet header
and ARP header. | [
"Create",
"and",
"return",
"a",
"packet",
"containing",
"an",
"Ethernet",
"header",
"and",
"ARP",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/util.py#L14-L29 | train | 60,459 |
jsommers/switchyard | switchyard/lib/logging.py | setup_logging | def setup_logging(debug, logfile=None):
'''
Setup logging format and log level.
'''
if debug:
level = logging.DEBUG
else:
level = logging.INFO
if logfile is not None:
logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=l... | python | def setup_logging(debug, logfile=None):
'''
Setup logging format and log level.
'''
if debug:
level = logging.DEBUG
else:
level = logging.INFO
if logfile is not None:
logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=l... | [
"def",
"setup_logging",
"(",
"debug",
",",
"logfile",
"=",
"None",
")",
":",
"if",
"debug",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"else",
":",
"level",
"=",
"logging",
".",
"INFO",
"if",
"logfile",
"is",
"not",
"None",
":",
"logging",
".",
"bas... | Setup logging format and log level. | [
"Setup",
"logging",
"format",
"and",
"log",
"level",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/logging.py#L6-L17 | train | 60,460 |
jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._spawn_threads | def _spawn_threads(self):
'''
Internal method. Creates threads to handle low-level
network receive.
'''
for devname,pdev in self._pcaps.items():
t = threading.Thread(target=LLNetReal._low_level_dispatch, args=(pdev, devname, self._pktqueue))
t.start()
... | python | def _spawn_threads(self):
'''
Internal method. Creates threads to handle low-level
network receive.
'''
for devname,pdev in self._pcaps.items():
t = threading.Thread(target=LLNetReal._low_level_dispatch, args=(pdev, devname, self._pktqueue))
t.start()
... | [
"def",
"_spawn_threads",
"(",
"self",
")",
":",
"for",
"devname",
",",
"pdev",
"in",
"self",
".",
"_pcaps",
".",
"items",
"(",
")",
":",
"t",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"LLNetReal",
".",
"_low_level_dispatch",
",",
"args",
"="... | Internal method. Creates threads to handle low-level
network receive. | [
"Internal",
"method",
".",
"Creates",
"threads",
"to",
"handle",
"low",
"-",
"level",
"network",
"receive",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L90-L98 | train | 60,461 |
jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._make_pcaps | def _make_pcaps(self):
'''
Internal method. Create libpcap devices
for every network interface we care about and
set them in non-blocking mode.
'''
self._pcaps = {}
for devname,intf in self._devinfo.items():
if intf.iftype == InterfaceType.Loopback:
... | python | def _make_pcaps(self):
'''
Internal method. Create libpcap devices
for every network interface we care about and
set them in non-blocking mode.
'''
self._pcaps = {}
for devname,intf in self._devinfo.items():
if intf.iftype == InterfaceType.Loopback:
... | [
"def",
"_make_pcaps",
"(",
"self",
")",
":",
"self",
".",
"_pcaps",
"=",
"{",
"}",
"for",
"devname",
",",
"intf",
"in",
"self",
".",
"_devinfo",
".",
"items",
"(",
")",
":",
"if",
"intf",
".",
"iftype",
"==",
"InterfaceType",
".",
"Loopback",
":",
... | Internal method. Create libpcap devices
for every network interface we care about and
set them in non-blocking mode. | [
"Internal",
"method",
".",
"Create",
"libpcap",
"devices",
"for",
"every",
"network",
"interface",
"we",
"care",
"about",
"and",
"set",
"them",
"in",
"non",
"-",
"blocking",
"mode",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L149-L161 | train | 60,462 |
jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._sig_handler | def _sig_handler(self, signum, stack):
'''
Handle process INT signal.
'''
log_debug("Got SIGINT.")
if signum == signal.SIGINT:
LLNetReal.running = False
if self._pktqueue.qsize() == 0:
# put dummy pkt in queue to unblock a
... | python | def _sig_handler(self, signum, stack):
'''
Handle process INT signal.
'''
log_debug("Got SIGINT.")
if signum == signal.SIGINT:
LLNetReal.running = False
if self._pktqueue.qsize() == 0:
# put dummy pkt in queue to unblock a
... | [
"def",
"_sig_handler",
"(",
"self",
",",
"signum",
",",
"stack",
")",
":",
"log_debug",
"(",
"\"Got SIGINT.\"",
")",
"if",
"signum",
"==",
"signal",
".",
"SIGINT",
":",
"LLNetReal",
".",
"running",
"=",
"False",
"if",
"self",
".",
"_pktqueue",
".",
"qsiz... | Handle process INT signal. | [
"Handle",
"process",
"INT",
"signal",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L163-L173 | train | 60,463 |
jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._low_level_dispatch | def _low_level_dispatch(pcapdev, devname, pktqueue):
'''
Thread entrypoint for doing low-level receive and dispatch
for a single pcap device.
'''
while LLNetReal.running:
# a non-zero timeout value is ok here; this is an
# independent thread that handles i... | python | def _low_level_dispatch(pcapdev, devname, pktqueue):
'''
Thread entrypoint for doing low-level receive and dispatch
for a single pcap device.
'''
while LLNetReal.running:
# a non-zero timeout value is ok here; this is an
# independent thread that handles i... | [
"def",
"_low_level_dispatch",
"(",
"pcapdev",
",",
"devname",
",",
"pktqueue",
")",
":",
"while",
"LLNetReal",
".",
"running",
":",
"# a non-zero timeout value is ok here; this is an",
"# independent thread that handles input for this",
"# one pcap device. it throws any packets re... | Thread entrypoint for doing low-level receive and dispatch
for a single pcap device. | [
"Thread",
"entrypoint",
"for",
"doing",
"low",
"-",
"level",
"receive",
"and",
"dispatch",
"for",
"a",
"single",
"pcap",
"device",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L176-L194 | train | 60,464 |
bronto/javasphinx | javasphinx/compiler.py | JavadocRestCompiler.__output_see | def __output_see(self, see):
""" Convert the argument to a @see tag to rest """
if see.startswith('<a href'):
# HTML link -- <a href="...">...</a>
return self.__html_to_rst(see)
elif '"' in see:
# Plain text
return see
else:
# ... | python | def __output_see(self, see):
""" Convert the argument to a @see tag to rest """
if see.startswith('<a href'):
# HTML link -- <a href="...">...</a>
return self.__html_to_rst(see)
elif '"' in see:
# Plain text
return see
else:
# ... | [
"def",
"__output_see",
"(",
"self",
",",
"see",
")",
":",
"if",
"see",
".",
"startswith",
"(",
"'<a href'",
")",
":",
"# HTML link -- <a href=\"...\">...</a>",
"return",
"self",
".",
"__html_to_rst",
"(",
"see",
")",
"elif",
"'\"'",
"in",
"see",
":",
"# Plai... | Convert the argument to a @see tag to rest | [
"Convert",
"the",
"argument",
"to",
"a"
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L95-L106 | train | 60,465 |
bronto/javasphinx | javasphinx/compiler.py | JavadocRestCompiler.compile_type_document | def compile_type_document(self, imports_block, package, name, declaration):
""" Compile a complete document, documenting a type and its members """
outer_type = name.rpartition('.')[0]
document = util.Document()
document.add(imports_block)
document.add_heading(name, '=')
... | python | def compile_type_document(self, imports_block, package, name, declaration):
""" Compile a complete document, documenting a type and its members """
outer_type = name.rpartition('.')[0]
document = util.Document()
document.add(imports_block)
document.add_heading(name, '=')
... | [
"def",
"compile_type_document",
"(",
"self",
",",
"imports_block",
",",
"package",
",",
"name",
",",
"declaration",
")",
":",
"outer_type",
"=",
"name",
".",
"rpartition",
"(",
"'.'",
")",
"[",
"0",
"]",
"document",
"=",
"util",
".",
"Document",
"(",
")"... | Compile a complete document, documenting a type and its members | [
"Compile",
"a",
"complete",
"document",
"documenting",
"a",
"type",
"and",
"its",
"members"
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L221-L288 | train | 60,466 |
bronto/javasphinx | javasphinx/compiler.py | JavadocRestCompiler.compile | def compile(self, ast):
""" Compile autodocs for the given Java syntax tree. Documents will be
returned documenting each separate type. """
documents = {}
imports = util.StringBuilder()
for imp in ast.imports:
if imp.static or imp.wildcard:
continue
... | python | def compile(self, ast):
""" Compile autodocs for the given Java syntax tree. Documents will be
returned documenting each separate type. """
documents = {}
imports = util.StringBuilder()
for imp in ast.imports:
if imp.static or imp.wildcard:
continue
... | [
"def",
"compile",
"(",
"self",
",",
"ast",
")",
":",
"documents",
"=",
"{",
"}",
"imports",
"=",
"util",
".",
"StringBuilder",
"(",
")",
"for",
"imp",
"in",
"ast",
".",
"imports",
":",
"if",
"imp",
".",
"static",
"or",
"imp",
".",
"wildcard",
":",
... | Compile autodocs for the given Java syntax tree. Documents will be
returned documenting each separate type. | [
"Compile",
"autodocs",
"for",
"the",
"given",
"Java",
"syntax",
"tree",
".",
"Documents",
"will",
"be",
"returned",
"documenting",
"each",
"separate",
"type",
"."
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L290-L341 | train | 60,467 |
jsommers/switchyard | switchyard/lib/packet/common.py | checksum | def checksum (data, start = 0, skip_word = None):
"""
Calculate standard internet checksum over data starting at start'th byte
skip_word: If specified, it's the word offset of a word in data to "skip"
(as if it were zero). The purpose is when data is received
data which contains a comp... | python | def checksum (data, start = 0, skip_word = None):
"""
Calculate standard internet checksum over data starting at start'th byte
skip_word: If specified, it's the word offset of a word in data to "skip"
(as if it were zero). The purpose is when data is received
data which contains a comp... | [
"def",
"checksum",
"(",
"data",
",",
"start",
"=",
"0",
",",
"skip_word",
"=",
"None",
")",
":",
"if",
"len",
"(",
"data",
")",
"%",
"2",
"!=",
"0",
":",
"arr",
"=",
"array",
".",
"array",
"(",
"'H'",
",",
"data",
"[",
":",
"-",
"1",
"]",
"... | Calculate standard internet checksum over data starting at start'th byte
skip_word: If specified, it's the word offset of a word in data to "skip"
(as if it were zero). The purpose is when data is received
data which contains a computed checksum that you are trying to
verify -... | [
"Calculate",
"standard",
"internet",
"checksum",
"over",
"data",
"starting",
"at",
"start",
"th",
"byte"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/common.py#L317-L349 | train | 60,468 |
bronto/javasphinx | javasphinx/extdoc.py | javadoc_role | def javadoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
""" Role for linking to external Javadoc """
has_explicit_title, title, target = split_explicit_title(text)
title = utils.unescape(title)
target = utils.unescape(target)
if not has_explicit_title:
target = targ... | python | def javadoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
""" Role for linking to external Javadoc """
has_explicit_title, title, target = split_explicit_title(text)
title = utils.unescape(title)
target = utils.unescape(target)
if not has_explicit_title:
target = targ... | [
"def",
"javadoc_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"{",
"}",
",",
"content",
"=",
"[",
"]",
")",
":",
"has_explicit_title",
",",
"title",
",",
"target",
"=",
"split_explicit_title",
"(",
... | Role for linking to external Javadoc | [
"Role",
"for",
"linking",
"to",
"external",
"Javadoc"
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/extdoc.py#L103-L124 | train | 60,469 |
jsommers/switchyard | switchyard/lib/openflow/ofswitch.py | PacketBufferManager.add | def add(self, port, pkt):
'''
Add new input port + packet to buffer.
'''
id = len(self._buffer) + 1
if id > self._buffsize:
raise FullBuffer()
self._buffer[id] = (port, deepcopy(pkt))
return id | python | def add(self, port, pkt):
'''
Add new input port + packet to buffer.
'''
id = len(self._buffer) + 1
if id > self._buffsize:
raise FullBuffer()
self._buffer[id] = (port, deepcopy(pkt))
return id | [
"def",
"add",
"(",
"self",
",",
"port",
",",
"pkt",
")",
":",
"id",
"=",
"len",
"(",
"self",
".",
"_buffer",
")",
"+",
"1",
"if",
"id",
">",
"self",
".",
"_buffsize",
":",
"raise",
"FullBuffer",
"(",
")",
"self",
".",
"_buffer",
"[",
"id",
"]",... | Add new input port + packet to buffer. | [
"Add",
"new",
"input",
"port",
"+",
"packet",
"to",
"buffer",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/ofswitch.py#L101-L110 | train | 60,470 |
jsommers/switchyard | switchyard/lib/openflow/ofswitch.py | OpenflowSwitch._handle_datapath | def _handle_datapath(self, inport, packet):
'''
Handle single packet on the data plane.
'''
inport = self._switchyard_net.port_by_name(inport)
portnum = inport.ifnum
log_info("Processing packet: {}->{}".format(portnum, packet))
actions = None
for tnum,t i... | python | def _handle_datapath(self, inport, packet):
'''
Handle single packet on the data plane.
'''
inport = self._switchyard_net.port_by_name(inport)
portnum = inport.ifnum
log_info("Processing packet: {}->{}".format(portnum, packet))
actions = None
for tnum,t i... | [
"def",
"_handle_datapath",
"(",
"self",
",",
"inport",
",",
"packet",
")",
":",
"inport",
"=",
"self",
".",
"_switchyard_net",
".",
"port_by_name",
"(",
"inport",
")",
"portnum",
"=",
"inport",
".",
"ifnum",
"log_info",
"(",
"\"Processing packet: {}->{}\"",
".... | Handle single packet on the data plane. | [
"Handle",
"single",
"packet",
"on",
"the",
"data",
"plane",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/ofswitch.py#L538-L562 | train | 60,471 |
jsommers/switchyard | switchyard/lib/packet/tcp.py | TCP.to_bytes | def to_bytes(self):
'''
Return packed byte representation of the TCP header.
'''
header = self._make_header(self._checksum)
return header + self._options.to_bytes() | python | def to_bytes(self):
'''
Return packed byte representation of the TCP header.
'''
header = self._make_header(self._checksum)
return header + self._options.to_bytes() | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"_make_header",
"(",
"self",
".",
"_checksum",
")",
"return",
"header",
"+",
"self",
".",
"_options",
".",
"to_bytes",
"(",
")"
] | Return packed byte representation of the TCP header. | [
"Return",
"packed",
"byte",
"representation",
"of",
"the",
"TCP",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/tcp.py#L110-L115 | train | 60,472 |
jsommers/switchyard | switchyard/lib/address/__init__.py | infer_netmask | def infer_netmask (addr):
"""
Uses network classes to guess the number of network bits
"""
addr = int(addr)
if addr == 0:
# Special case -- default network
return 32-32 # all bits wildcarded
if (addr & (1 << 31)) == 0:
# Class A
return 32-24
if (addr & (3 << 30)) == 2 << 30:
# Class B
... | python | def infer_netmask (addr):
"""
Uses network classes to guess the number of network bits
"""
addr = int(addr)
if addr == 0:
# Special case -- default network
return 32-32 # all bits wildcarded
if (addr & (1 << 31)) == 0:
# Class A
return 32-24
if (addr & (3 << 30)) == 2 << 30:
# Class B
... | [
"def",
"infer_netmask",
"(",
"addr",
")",
":",
"addr",
"=",
"int",
"(",
"addr",
")",
"if",
"addr",
"==",
"0",
":",
"# Special case -- default network",
"return",
"32",
"-",
"32",
"# all bits wildcarded",
"if",
"(",
"addr",
"&",
"(",
"1",
"<<",
"31",
")",... | Uses network classes to guess the number of network bits | [
"Uses",
"network",
"classes",
"to",
"guess",
"the",
"number",
"of",
"network",
"bits"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/address/__init__.py#L266-L287 | train | 60,473 |
jsommers/switchyard | switchyard/lib/address/__init__.py | EthAddr.isBridgeFiltered | def isBridgeFiltered (self):
"""
Checks if address is an IEEE 802.1D MAC Bridge Filtered MAC Group Address
This range is 01-80-C2-00-00-00 to 01-80-C2-00-00-0F. MAC frames that
have a destination MAC address within this range are not relayed by
bridges conforming to IEEE 802.1D
... | python | def isBridgeFiltered (self):
"""
Checks if address is an IEEE 802.1D MAC Bridge Filtered MAC Group Address
This range is 01-80-C2-00-00-00 to 01-80-C2-00-00-0F. MAC frames that
have a destination MAC address within this range are not relayed by
bridges conforming to IEEE 802.1D
... | [
"def",
"isBridgeFiltered",
"(",
"self",
")",
":",
"return",
"(",
"(",
"self",
".",
"__value",
"[",
"0",
"]",
"==",
"0x01",
")",
"and",
"(",
"self",
".",
"__value",
"[",
"1",
"]",
"==",
"0x80",
")",
"and",
"(",
"self",
".",
"__value",
"[",
"2",
... | Checks if address is an IEEE 802.1D MAC Bridge Filtered MAC Group Address
This range is 01-80-C2-00-00-00 to 01-80-C2-00-00-0F. MAC frames that
have a destination MAC address within this range are not relayed by
bridges conforming to IEEE 802.1D | [
"Checks",
"if",
"address",
"is",
"an",
"IEEE",
"802",
".",
"1D",
"MAC",
"Bridge",
"Filtered",
"MAC",
"Group",
"Address"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/address/__init__.py#L59-L72 | train | 60,474 |
jsommers/switchyard | switchyard/lib/address/__init__.py | EthAddr.toStr | def toStr (self, separator = ':'):
"""
Returns the address as string consisting of 12 hex chars separated
by separator.
"""
return separator.join(('{:02x}'.format(x) for x in self.__value)) | python | def toStr (self, separator = ':'):
"""
Returns the address as string consisting of 12 hex chars separated
by separator.
"""
return separator.join(('{:02x}'.format(x) for x in self.__value)) | [
"def",
"toStr",
"(",
"self",
",",
"separator",
"=",
"':'",
")",
":",
"return",
"separator",
".",
"join",
"(",
"(",
"'{:02x}'",
".",
"format",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"__value",
")",
")"
] | Returns the address as string consisting of 12 hex chars separated
by separator. | [
"Returns",
"the",
"address",
"as",
"string",
"consisting",
"of",
"12",
"hex",
"chars",
"separated",
"by",
"separator",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/address/__init__.py#L129-L134 | train | 60,475 |
jsommers/switchyard | switchyard/lib/packet/ethernet.py | Ethernet.to_bytes | def to_bytes(self):
'''
Return packed byte representation of the Ethernet header.
'''
return struct.pack(Ethernet._PACKFMT, self._dst.packed,
self._src.packed, self._ethertype.value) | python | def to_bytes(self):
'''
Return packed byte representation of the Ethernet header.
'''
return struct.pack(Ethernet._PACKFMT, self._dst.packed,
self._src.packed, self._ethertype.value) | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"Ethernet",
".",
"_PACKFMT",
",",
"self",
".",
"_dst",
".",
"packed",
",",
"self",
".",
"_src",
".",
"packed",
",",
"self",
".",
"_ethertype",
".",
"value",
")"
] | Return packed byte representation of the Ethernet header. | [
"Return",
"packed",
"byte",
"representation",
"of",
"the",
"Ethernet",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/ethernet.py#L142-L147 | train | 60,476 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer._init | def _init():
'''
Internal switchyard static initialization method.
'''
if ApplicationLayer._isinit:
return
ApplicationLayer._isinit = True
ApplicationLayer._to_app = {}
ApplicationLayer._from_app = Queue() | python | def _init():
'''
Internal switchyard static initialization method.
'''
if ApplicationLayer._isinit:
return
ApplicationLayer._isinit = True
ApplicationLayer._to_app = {}
ApplicationLayer._from_app = Queue() | [
"def",
"_init",
"(",
")",
":",
"if",
"ApplicationLayer",
".",
"_isinit",
":",
"return",
"ApplicationLayer",
".",
"_isinit",
"=",
"True",
"ApplicationLayer",
".",
"_to_app",
"=",
"{",
"}",
"ApplicationLayer",
".",
"_from_app",
"=",
"Queue",
"(",
")"
] | Internal switchyard static initialization method. | [
"Internal",
"switchyard",
"static",
"initialization",
"method",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L104-L112 | train | 60,477 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer.recv_from_app | def recv_from_app(timeout=_default_timeout):
'''
Called by a network stack implementer to receive application-layer
data for sending on to a remote location.
Can optionally take a timeout value. If no data are available,
raises NoPackets exception.
Returns a 2-tuple:... | python | def recv_from_app(timeout=_default_timeout):
'''
Called by a network stack implementer to receive application-layer
data for sending on to a remote location.
Can optionally take a timeout value. If no data are available,
raises NoPackets exception.
Returns a 2-tuple:... | [
"def",
"recv_from_app",
"(",
"timeout",
"=",
"_default_timeout",
")",
":",
"try",
":",
"return",
"ApplicationLayer",
".",
"_from_app",
".",
"get",
"(",
"timeout",
"=",
"timeout",
")",
"except",
"Empty",
":",
"pass",
"raise",
"NoPackets",
"(",
")"
] | Called by a network stack implementer to receive application-layer
data for sending on to a remote location.
Can optionally take a timeout value. If no data are available,
raises NoPackets exception.
Returns a 2-tuple: flowaddr and data.
The flowaddr consists of 5 items: pro... | [
"Called",
"by",
"a",
"network",
"stack",
"implementer",
"to",
"receive",
"application",
"-",
"layer",
"data",
"for",
"sending",
"on",
"to",
"a",
"remote",
"location",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L122-L138 | train | 60,478 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer.send_to_app | def send_to_app(proto, local_addr, remote_addr, data):
'''
Called by a network stack implementer to push application-layer
data "up" from the stack.
Arguments are protocol number, local_addr (a 2-tuple of IP address
and port), remote_addr (a 2-tuple of IP address and port), and ... | python | def send_to_app(proto, local_addr, remote_addr, data):
'''
Called by a network stack implementer to push application-layer
data "up" from the stack.
Arguments are protocol number, local_addr (a 2-tuple of IP address
and port), remote_addr (a 2-tuple of IP address and port), and ... | [
"def",
"send_to_app",
"(",
"proto",
",",
"local_addr",
",",
"remote_addr",
",",
"data",
")",
":",
"proto",
"=",
"IPProtocol",
"(",
"proto",
")",
"local_addr",
"=",
"_normalize_addrs",
"(",
"local_addr",
")",
"remote_addr",
"=",
"_normalize_addrs",
"(",
"remote... | Called by a network stack implementer to push application-layer
data "up" from the stack.
Arguments are protocol number, local_addr (a 2-tuple of IP address
and port), remote_addr (a 2-tuple of IP address and port), and the
message.
Returns True if a socket was found to which... | [
"Called",
"by",
"a",
"network",
"stack",
"implementer",
"to",
"push",
"application",
"-",
"layer",
"data",
"up",
"from",
"the",
"stack",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L141-L175 | train | 60,479 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer._registry_update | def _registry_update(s, oldid):
'''
Internal method used to update an existing socket registry when the socket
is re-bound to a different local port number. Requires the socket object
and old sockid. Returns None.
'''
with _lock:
sock_queue = ApplicationLaye... | python | def _registry_update(s, oldid):
'''
Internal method used to update an existing socket registry when the socket
is re-bound to a different local port number. Requires the socket object
and old sockid. Returns None.
'''
with _lock:
sock_queue = ApplicationLaye... | [
"def",
"_registry_update",
"(",
"s",
",",
"oldid",
")",
":",
"with",
"_lock",
":",
"sock_queue",
"=",
"ApplicationLayer",
".",
"_to_app",
".",
"pop",
"(",
"oldid",
")",
"ApplicationLayer",
".",
"_to_app",
"[",
"s",
".",
"_sockid",
"(",
")",
"]",
"=",
"... | Internal method used to update an existing socket registry when the socket
is re-bound to a different local port number. Requires the socket object
and old sockid. Returns None. | [
"Internal",
"method",
"used",
"to",
"update",
"an",
"existing",
"socket",
"registry",
"when",
"the",
"socket",
"is",
"re",
"-",
"bound",
"to",
"a",
"different",
"local",
"port",
"number",
".",
"Requires",
"the",
"socket",
"object",
"and",
"old",
"sockid",
... | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L190-L198 | train | 60,480 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer._unregister_socket | def _unregister_socket(s):
'''
Internal method used to remove the socket from AppLayer registry.
Warns if the "upward" socket queue has any left-over data.
'''
with _lock:
sock_queue = ApplicationLayer._to_app.pop(s._sockid())
if not sock_queue.empty():
... | python | def _unregister_socket(s):
'''
Internal method used to remove the socket from AppLayer registry.
Warns if the "upward" socket queue has any left-over data.
'''
with _lock:
sock_queue = ApplicationLayer._to_app.pop(s._sockid())
if not sock_queue.empty():
... | [
"def",
"_unregister_socket",
"(",
"s",
")",
":",
"with",
"_lock",
":",
"sock_queue",
"=",
"ApplicationLayer",
".",
"_to_app",
".",
"pop",
"(",
"s",
".",
"_sockid",
"(",
")",
")",
"if",
"not",
"sock_queue",
".",
"empty",
"(",
")",
":",
"log_warn",
"(",
... | Internal method used to remove the socket from AppLayer registry.
Warns if the "upward" socket queue has any left-over data. | [
"Internal",
"method",
"used",
"to",
"remove",
"the",
"socket",
"from",
"AppLayer",
"registry",
".",
"Warns",
"if",
"the",
"upward",
"socket",
"queue",
"has",
"any",
"left",
"-",
"over",
"data",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L201-L209 | train | 60,481 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | socket.bind | def bind(self, address):
'''
Alter the local address with which this socket is associated.
The address parameter is a 2-tuple consisting of an IP address
and port number.
NB: this method fails and returns -1 if the requested port
to bind to is already in use but does *n... | python | def bind(self, address):
'''
Alter the local address with which this socket is associated.
The address parameter is a 2-tuple consisting of an IP address
and port number.
NB: this method fails and returns -1 if the requested port
to bind to is already in use but does *n... | [
"def",
"bind",
"(",
"self",
",",
"address",
")",
":",
"portset",
"=",
"_gather_ports",
"(",
")",
".",
"union",
"(",
"ApplicationLayer",
".",
"_emuports",
"(",
")",
")",
"if",
"address",
"[",
"1",
"]",
"in",
"portset",
":",
"log_warn",
"(",
"\"Port is a... | Alter the local address with which this socket is associated.
The address parameter is a 2-tuple consisting of an IP address
and port number.
NB: this method fails and returns -1 if the requested port
to bind to is already in use but does *not* check that the
address is valid. | [
"Alter",
"the",
"local",
"address",
"with",
"which",
"this",
"socket",
"is",
"associated",
".",
"The",
"address",
"parameter",
"is",
"a",
"2",
"-",
"tuple",
"consisting",
"of",
"an",
"IP",
"address",
"and",
"port",
"number",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L314-L336 | train | 60,482 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | socket.recv | def recv(self, buffersize, flags=0):
'''
Receive data on the socket. The buffersize and flags
arguments are currently ignored. Only returns the data.
'''
_,_,data = self._recv(buffersize)
return data | python | def recv(self, buffersize, flags=0):
'''
Receive data on the socket. The buffersize and flags
arguments are currently ignored. Only returns the data.
'''
_,_,data = self._recv(buffersize)
return data | [
"def",
"recv",
"(",
"self",
",",
"buffersize",
",",
"flags",
"=",
"0",
")",
":",
"_",
",",
"_",
",",
"data",
"=",
"self",
".",
"_recv",
"(",
"buffersize",
")",
"return",
"data"
] | Receive data on the socket. The buffersize and flags
arguments are currently ignored. Only returns the data. | [
"Receive",
"data",
"on",
"the",
"socket",
".",
"The",
"buffersize",
"and",
"flags",
"arguments",
"are",
"currently",
"ignored",
".",
"Only",
"returns",
"the",
"data",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L393-L399 | train | 60,483 |
jsommers/switchyard | switchyard/lib/socket/socketemu.py | socket.settimeout | def settimeout(self, timeout):
'''
Set the timeout value for this socket.
'''
if timeout is None:
self._block = True
elif float(timeout) == 0.0:
self._block = False
else:
self._timeout = float(timeout)
self._block = True | python | def settimeout(self, timeout):
'''
Set the timeout value for this socket.
'''
if timeout is None:
self._block = True
elif float(timeout) == 0.0:
self._block = False
else:
self._timeout = float(timeout)
self._block = True | [
"def",
"settimeout",
"(",
"self",
",",
"timeout",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"self",
".",
"_block",
"=",
"True",
"elif",
"float",
"(",
"timeout",
")",
"==",
"0.0",
":",
"self",
".",
"_block",
"=",
"False",
"else",
":",
"self",
".... | Set the timeout value for this socket. | [
"Set",
"the",
"timeout",
"value",
"for",
"this",
"socket",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L487-L497 | train | 60,484 |
jsommers/switchyard | switchyard/lib/packet/arp.py | Arp.to_bytes | def to_bytes(self):
'''
Return packed byte representation of the ARP header.
'''
return struct.pack(Arp._PACKFMT, self._hwtype.value, self._prototype.value, self._hwaddrlen, self._protoaddrlen, self._operation.value, self._senderhwaddr.packed, self._senderprotoaddr.packed, self._targethw... | python | def to_bytes(self):
'''
Return packed byte representation of the ARP header.
'''
return struct.pack(Arp._PACKFMT, self._hwtype.value, self._prototype.value, self._hwaddrlen, self._protoaddrlen, self._operation.value, self._senderhwaddr.packed, self._senderprotoaddr.packed, self._targethw... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"Arp",
".",
"_PACKFMT",
",",
"self",
".",
"_hwtype",
".",
"value",
",",
"self",
".",
"_prototype",
".",
"value",
",",
"self",
".",
"_hwaddrlen",
",",
"self",
".",
"_proto... | Return packed byte representation of the ARP header. | [
"Return",
"packed",
"byte",
"representation",
"of",
"the",
"ARP",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/arp.py#L41-L45 | train | 60,485 |
bronto/javasphinx | javasphinx/htmlrst.py | Converter._process_table_cells | def _process_table_cells(self, table):
""" Compile all the table cells.
Returns a list of rows. The rows may have different lengths because of
column spans.
"""
rows = []
for i, tr in enumerate(table.find_all('tr')):
row = []
for c in tr.conte... | python | def _process_table_cells(self, table):
""" Compile all the table cells.
Returns a list of rows. The rows may have different lengths because of
column spans.
"""
rows = []
for i, tr in enumerate(table.find_all('tr')):
row = []
for c in tr.conte... | [
"def",
"_process_table_cells",
"(",
"self",
",",
"table",
")",
":",
"rows",
"=",
"[",
"]",
"for",
"i",
",",
"tr",
"in",
"enumerate",
"(",
"table",
".",
"find_all",
"(",
"'tr'",
")",
")",
":",
"row",
"=",
"[",
"]",
"for",
"c",
"in",
"tr",
".",
"... | Compile all the table cells.
Returns a list of rows. The rows may have different lengths because of
column spans. | [
"Compile",
"all",
"the",
"table",
"cells",
"."
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/htmlrst.py#L118-L148 | train | 60,486 |
jsommers/switchyard | switchyard/importcode.py | import_or_die | def import_or_die(module_name, entrypoint_names):
'''
Import user code; return reference to usercode function.
(str) -> function reference
'''
log_debug("Importing {}".format(module_name))
module_name = os.path.abspath(module_name)
if module_name.endswith('.py'):
module_name,ext = o... | python | def import_or_die(module_name, entrypoint_names):
'''
Import user code; return reference to usercode function.
(str) -> function reference
'''
log_debug("Importing {}".format(module_name))
module_name = os.path.abspath(module_name)
if module_name.endswith('.py'):
module_name,ext = o... | [
"def",
"import_or_die",
"(",
"module_name",
",",
"entrypoint_names",
")",
":",
"log_debug",
"(",
"\"Importing {}\"",
".",
"format",
"(",
"module_name",
")",
")",
"module_name",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"module_name",
")",
"if",
"module_name... | Import user code; return reference to usercode function.
(str) -> function reference | [
"Import",
"user",
"code",
";",
"return",
"reference",
"to",
"usercode",
"function",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/importcode.py#L7-L52 | train | 60,487 |
jsommers/switchyard | switchyard/hostfirewall.py | _runcmd | def _runcmd(progargs, stdinput=None):
'''
Run the command progargs with optional input to be fed in to stdin.
'''
stdin = None
if stdinput is not None:
assert(isinstance(stdinput, list))
stdin=PIPE
err = 0
output = b''
log_debug("Calling {} with input {}".format(' '.join... | python | def _runcmd(progargs, stdinput=None):
'''
Run the command progargs with optional input to be fed in to stdin.
'''
stdin = None
if stdinput is not None:
assert(isinstance(stdinput, list))
stdin=PIPE
err = 0
output = b''
log_debug("Calling {} with input {}".format(' '.join... | [
"def",
"_runcmd",
"(",
"progargs",
",",
"stdinput",
"=",
"None",
")",
":",
"stdin",
"=",
"None",
"if",
"stdinput",
"is",
"not",
"None",
":",
"assert",
"(",
"isinstance",
"(",
"stdinput",
",",
"list",
")",
")",
"stdin",
"=",
"PIPE",
"err",
"=",
"0",
... | Run the command progargs with optional input to be fed in to stdin. | [
"Run",
"the",
"command",
"progargs",
"with",
"optional",
"input",
"to",
"be",
"fed",
"in",
"to",
"stdin",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/hostfirewall.py#L17-L47 | train | 60,488 |
jsommers/switchyard | switchyard/hostfirewall.py | MacOSFirewall.block | def block(self):
'''
pfctl -a switchyard -f- < rules.txt
pfctl -a switchyard -F rules
pfctl -t switchyard -F r
'''
st,output = _runcmd("/sbin/pfctl -aswitchyard -f -", self._rules)
log_debug("Installing rules: {}".format(output)) | python | def block(self):
'''
pfctl -a switchyard -f- < rules.txt
pfctl -a switchyard -F rules
pfctl -t switchyard -F r
'''
st,output = _runcmd("/sbin/pfctl -aswitchyard -f -", self._rules)
log_debug("Installing rules: {}".format(output)) | [
"def",
"block",
"(",
"self",
")",
":",
"st",
",",
"output",
"=",
"_runcmd",
"(",
"\"/sbin/pfctl -aswitchyard -f -\"",
",",
"self",
".",
"_rules",
")",
"log_debug",
"(",
"\"Installing rules: {}\"",
".",
"format",
"(",
"output",
")",
")"
] | pfctl -a switchyard -f- < rules.txt
pfctl -a switchyard -F rules
pfctl -t switchyard -F r | [
"pfctl",
"-",
"a",
"switchyard",
"-",
"f",
"-",
"<",
"rules",
".",
"txt",
"pfctl",
"-",
"a",
"switchyard",
"-",
"F",
"rules",
"pfctl",
"-",
"t",
"switchyard",
"-",
"F",
"r"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/hostfirewall.py#L252-L259 | train | 60,489 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | show_graph | def show_graph(cn_topo, showintfs=False, showaddrs=False):
'''
Display the topology
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.show() | python | def show_graph(cn_topo, showintfs=False, showaddrs=False):
'''
Display the topology
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.show() | [
"def",
"show_graph",
"(",
"cn_topo",
",",
"showintfs",
"=",
"False",
",",
"showaddrs",
"=",
"False",
")",
":",
"__do_draw",
"(",
"cn_topo",
",",
"showintfs",
"=",
"showintfs",
",",
"showaddrs",
"=",
"showaddrs",
")",
"pyp",
".",
"show",
"(",
")"
] | Display the topology | [
"Display",
"the",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L436-L441 | train | 60,490 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | save_graph | def save_graph(cn_topo, filename, showintfs=False, showaddrs=False):
'''
Save the topology to an image file
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.savefig(filename) | python | def save_graph(cn_topo, filename, showintfs=False, showaddrs=False):
'''
Save the topology to an image file
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.savefig(filename) | [
"def",
"save_graph",
"(",
"cn_topo",
",",
"filename",
",",
"showintfs",
"=",
"False",
",",
"showaddrs",
"=",
"False",
")",
":",
"__do_draw",
"(",
"cn_topo",
",",
"showintfs",
"=",
"showintfs",
",",
"showaddrs",
"=",
"showaddrs",
")",
"pyp",
".",
"savefig",... | Save the topology to an image file | [
"Save",
"the",
"topology",
"to",
"an",
"image",
"file"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L443-L448 | train | 60,491 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | load_from_file | def load_from_file(filename):
'''
Load a topology from filename and return it.
'''
t = None
with open(filename, 'rU') as infile:
tdata = infile.read()
t = Topology.unserialize(tdata)
return t | python | def load_from_file(filename):
'''
Load a topology from filename and return it.
'''
t = None
with open(filename, 'rU') as infile:
tdata = infile.read()
t = Topology.unserialize(tdata)
return t | [
"def",
"load_from_file",
"(",
"filename",
")",
":",
"t",
"=",
"None",
"with",
"open",
"(",
"filename",
",",
"'rU'",
")",
"as",
"infile",
":",
"tdata",
"=",
"infile",
".",
"read",
"(",
")",
"t",
"=",
"Topology",
".",
"unserialize",
"(",
"tdata",
")",
... | Load a topology from filename and return it. | [
"Load",
"a",
"topology",
"from",
"filename",
"and",
"return",
"it",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L450-L458 | train | 60,492 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | save_to_file | def save_to_file(cn_topo, filename):
'''
Save a topology to a file.
'''
jstr = cn_topo.serialize()
with open(filename, 'w') as outfile:
outfile.write(jstr) | python | def save_to_file(cn_topo, filename):
'''
Save a topology to a file.
'''
jstr = cn_topo.serialize()
with open(filename, 'w') as outfile:
outfile.write(jstr) | [
"def",
"save_to_file",
"(",
"cn_topo",
",",
"filename",
")",
":",
"jstr",
"=",
"cn_topo",
".",
"serialize",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"outfile",
":",
"outfile",
".",
"write",
"(",
"jstr",
")"
] | Save a topology to a file. | [
"Save",
"a",
"topology",
"to",
"a",
"file",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L460-L466 | train | 60,493 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.__addNode | def __addNode(self, name, cls):
'''
Add a node to the topology
'''
if name in self.nodes:
raise Exception("A node by the name {} already exists. Can't add a duplicate.".format(name))
self.__nxgraph.add_node(name)
self.__nxgraph.node[name]['label'] = name
... | python | def __addNode(self, name, cls):
'''
Add a node to the topology
'''
if name in self.nodes:
raise Exception("A node by the name {} already exists. Can't add a duplicate.".format(name))
self.__nxgraph.add_node(name)
self.__nxgraph.node[name]['label'] = name
... | [
"def",
"__addNode",
"(",
"self",
",",
"name",
",",
"cls",
")",
":",
"if",
"name",
"in",
"self",
".",
"nodes",
":",
"raise",
"Exception",
"(",
"\"A node by the name {} already exists. Can't add a duplicate.\"",
".",
"format",
"(",
"name",
")",
")",
"self",
"."... | Add a node to the topology | [
"Add",
"a",
"node",
"to",
"the",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L122-L131 | train | 60,494 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.addHost | def addHost(self, name=None):
'''
Add a new host node to the topology.
'''
if name is None:
while True:
name = 'h' + str(self.__hnum)
self.__hnum += 1
if name not in self.__nxgraph:
break
self.__addNo... | python | def addHost(self, name=None):
'''
Add a new host node to the topology.
'''
if name is None:
while True:
name = 'h' + str(self.__hnum)
self.__hnum += 1
if name not in self.__nxgraph:
break
self.__addNo... | [
"def",
"addHost",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"while",
"True",
":",
"name",
"=",
"'h'",
"+",
"str",
"(",
"self",
".",
"__hnum",
")",
"self",
".",
"__hnum",
"+=",
"1",
"if",
"name",
"not",
"i... | Add a new host node to the topology. | [
"Add",
"a",
"new",
"host",
"node",
"to",
"the",
"topology",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L173-L184 | train | 60,495 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.addLink | def addLink(self, node1, node2, capacity, delay):
'''
Add a bidirectional link between node1 and node2 with the given
capacity and delay to the topology.
'''
for n in (node1, node2):
if not self.__nxgraph.has_node(n):
raise Exception("No node {} exists... | python | def addLink(self, node1, node2, capacity, delay):
'''
Add a bidirectional link between node1 and node2 with the given
capacity and delay to the topology.
'''
for n in (node1, node2):
if not self.__nxgraph.has_node(n):
raise Exception("No node {} exists... | [
"def",
"addLink",
"(",
"self",
",",
"node1",
",",
"node2",
",",
"capacity",
",",
"delay",
")",
":",
"for",
"n",
"in",
"(",
"node1",
",",
"node2",
")",
":",
"if",
"not",
"self",
".",
"__nxgraph",
".",
"has_node",
"(",
"n",
")",
":",
"raise",
"Exce... | Add a bidirectional link between node1 and node2 with the given
capacity and delay to the topology. | [
"Add",
"a",
"bidirectional",
"link",
"between",
"node1",
"and",
"node2",
"with",
"the",
"given",
"capacity",
"and",
"delay",
"to",
"the",
"topology",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L231-L251 | train | 60,496 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.serialize | def serialize(self):
'''
Return a JSON string of the serialized topology
'''
return json.dumps(json_graph.node_link_data(self.__nxgraph), cls=Encoder) | python | def serialize(self):
'''
Return a JSON string of the serialized topology
'''
return json.dumps(json_graph.node_link_data(self.__nxgraph), cls=Encoder) | [
"def",
"serialize",
"(",
"self",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"json_graph",
".",
"node_link_data",
"(",
"self",
".",
"__nxgraph",
")",
",",
"cls",
"=",
"Encoder",
")"
] | Return a JSON string of the serialized topology | [
"Return",
"a",
"JSON",
"string",
"of",
"the",
"serialized",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L266-L270 | train | 60,497 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.unserialize | def unserialize(jsonstr):
'''
Unserialize a JSON string representation of a topology
'''
topod = json.loads(jsonstr)
G = json_graph.node_link_graph(topod)
for n,ndict in G.nodes(data=True):
if 'nodeobj' not in ndict or 'type' not in ndict:
rais... | python | def unserialize(jsonstr):
'''
Unserialize a JSON string representation of a topology
'''
topod = json.loads(jsonstr)
G = json_graph.node_link_graph(topod)
for n,ndict in G.nodes(data=True):
if 'nodeobj' not in ndict or 'type' not in ndict:
rais... | [
"def",
"unserialize",
"(",
"jsonstr",
")",
":",
"topod",
"=",
"json",
".",
"loads",
"(",
"jsonstr",
")",
"G",
"=",
"json_graph",
".",
"node_link_graph",
"(",
"topod",
")",
"for",
"n",
",",
"ndict",
"in",
"G",
".",
"nodes",
"(",
"data",
"=",
"True",
... | Unserialize a JSON string representation of a topology | [
"Unserialize",
"a",
"JSON",
"string",
"representation",
"of",
"a",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L273-L286 | train | 60,498 |
jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.getInterfaceAddresses | def getInterfaceAddresses(self, node, interface):
'''
Return the Ethernet and IP+mask addresses assigned to a
given interface on a node.
'''
intf = self.getNode(node)['nodeobj'].getInterface(interface)
return intf.ethaddr,intf.ipaddr,intf.netmask | python | def getInterfaceAddresses(self, node, interface):
'''
Return the Ethernet and IP+mask addresses assigned to a
given interface on a node.
'''
intf = self.getNode(node)['nodeobj'].getInterface(interface)
return intf.ethaddr,intf.ipaddr,intf.netmask | [
"def",
"getInterfaceAddresses",
"(",
"self",
",",
"node",
",",
"interface",
")",
":",
"intf",
"=",
"self",
".",
"getNode",
"(",
"node",
")",
"[",
"'nodeobj'",
"]",
".",
"getInterface",
"(",
"interface",
")",
"return",
"intf",
".",
"ethaddr",
",",
"intf",... | Return the Ethernet and IP+mask addresses assigned to a
given interface on a node. | [
"Return",
"the",
"Ethernet",
"and",
"IP",
"+",
"mask",
"addresses",
"assigned",
"to",
"a",
"given",
"interface",
"on",
"a",
"node",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L348-L354 | train | 60,499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.