code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
with open(path + outfile, 'w') as out_f:
for i in infiles:
if os.path.isfile("{0}{1}".format(path, i)):
with open(path + i, "r") as in_f:
for line in in_f:
out_f.write(line) | def merge(self, path, outfile, infiles) | Merge files | 2.234193 | 2.273705 | 0.982622 |
if os.path.isfile(path + filename):
os.remove(path + filename) | def file_remove(self, path, filename) | Check if filename exists and remove | 2.644058 | 2.607401 | 1.014059 |
local = ""
filename = url.split("/")[-1]
server = FileSize(url).server()
if os.path.isfile(log_path + filename):
local = FileSize(log_path + filename).local()
if server != local:
return True
return False | def checks_logs(self, log_path, url) | Checks ChangeLog.txt for changes | 4.836487 | 4.434995 | 1.090528 |
repositories = self.meta.repositories
if only:
repositories = only
for repo in repositories:
changelogs = "{0}{1}{2}".format(self.log_path, repo,
"/ChangeLog.txt")
if os.path.isfile(changelogs):
... | def upgrade(self, only) | Remove all package lists with changelog and checksums files
and create lists again | 3.021674 | 2.818109 | 1.072235 |
print("\nCheck and update repositories:\n")
default = self.meta.default_repositories
enabled = self.meta.repositories
if only:
enabled = only
for repo in enabled:
if check_for_local_repos(repo) is True:
continue
sys.std... | def repository(self, only) | Update repositories lists | 4.851276 | 4.795256 | 1.011682 |
choice = []
for item in self.data:
choice.append((item, "", self.status))
code, self.tags = self.d.checklist(
text=self.text, height=20, width=65, list_height=13,
choices=choice, title=self.title, backtitle=self.backtitle)
if code == "ok":
... | def checklist(self) | Run dialog checklist | 7.037611 | 6.591612 | 1.067661 |
choice = []
for item in self.data:
choice.append((item, False))
for item in enabled:
choice.append((item, True))
items = [(tag, tag, sta) for (tag, sta) in choice]
code, self.tags = self.d.buildlist(
text=self.text, items=items, visit_... | def buildlist(self, enabled) | Run dialog buildlist | 6.570037 | 6.588237 | 0.997238 |
for tag in self.tags:
self.ununicode.append(str(tag)) | def unicode_to_string(self) | Convert unicode in string | 12.91133 | 11.634463 | 1.109749 |
Msg().checking()
upgrade_names = []
data = SBoGrep(name="").names()
blacklist = BlackList().packages(pkgs=data, repo="sbo")
for pkg in sbo_list():
status(0.02)
name = split_package(pkg)[0]
ver = split_package(pkg)[1]
if (name in data and name not in skip and name... | def sbo_upgrade(skip, flag) | Return packages for upgrade | 6.796005 | 6.388972 | 1.063709 |
sbo_packages = []
for pkg in os.listdir(_meta_.pkg_path):
if pkg.endswith("_SBo"):
sbo_packages.append(pkg)
return sbo_packages | def sbo_list() | Return all SBo packages | 5.837188 | 4.022426 | 1.451161 |
if _meta_.del_all in ["on", "ON"]:
for pkg in packages:
os.remove(path + pkg) | def delete_package(path, packages) | Remove downloaded packages | 14.57476 | 13.307847 | 1.0952 |
status = "{0}disabled{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"])
self.form["Status:"] = status
self.form["Default:"] = "no"
if repo in self.meta.default_repositories:
self.form["Default:"] = "yes"
if (... | def view(self, repo) | View repository information | 2.659066 | 2.627032 | 1.012194 |
sum_pkgs, size, unsize, last_upd = 0, [], [], ""
for line in (Utils().read_file(
self.meta.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip()
if line.startswith("PACKAGE... | def repository_data(self, repo) | Grap data packages | 4.752528 | 4.588885 | 1.035661 |
if _meta_.del_build in ["on", "ON"] and os.path.exists(build_folder):
shutil.rmtree(build_folder) | def delete(build_folder) | Delete build directory and all its contents. | 6.981953 | 7.032962 | 0.992747 |
self.store()
self.msg.done()
if self.upgrade_all:
if "--checklist" in self.flag:
self.dialog_checklist()
print("\nThese packages need upgrading:\n")
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
... | def start(self) | Install new patches from official Slackware mirrors | 5.914302 | 5.658983 | 1.045118 |
data = repo_data(self.PACKAGES_TXT, "slack", self.flag)
black = BlackList().packages(pkgs=data[0], repo="slack")
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
status(0.0003)
repo_pkg_name = split_package(name)[0]
if (not os.p... | def store(self) | Store and return packages for upgrading | 6.937751 | 6.341833 | 1.093966 |
data = []
for upg in self.upgrade_all:
data.append(upg[:-4])
text = "Press 'spacebar' to unchoose packages from upgrade"
title = " Upgrade "
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
st... | def dialog_checklist(self) | Create checklist to choose packages for upgrade | 5.915939 | 5.209309 | 1.135647 |
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_repo = split_package(upg[:-4])
color = self.meta.color["RED"]
pkg_inst = GetFromInstalled(pkg_repo[0]).name()
if pkg_repo[0] == pkg_inst:
color = self.meta.color["YELLOW"]
... | def views(self) | Views packages | 4.444403 | 4.267554 | 1.04144 |
for pkg in self.upgrade_all:
check_md5(pkg_checksum(pkg, "slack_patches"), self.patch_path + pkg)
pkg_ver = "{0}-{1}".format(split_package(pkg)[0],
split_package(pkg)[1])
if find_package(split_package(pkg)[0] + self.meta.sp,
... | def upgrade(self) | Upgrade packages | 4.575495 | 4.320085 | 1.059122 |
for core in self.upgrade_all:
if "kernel" in core:
if self.meta.default_answer in ["y", "Y"]:
answer = self.meta.default_answer
else:
print("")
self.msg.template(78)
print("| {0}*... | def kernel(self) | Check if kernel upgraded if true
then reinstall "lilo" | 6.680239 | 5.553479 | 1.202893 |
NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading()
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt.old"):
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt.old")
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt"):
sh... | def slackpkg_update(self) | This replace slackpkg ChangeLog.txt file with new
from Slackware official mirrors after update distribution. | 2.52605 | 2.142909 | 1.178795 |
print("{0}Update the package lists ?{1}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"]))
print("=" * 79)
if self.msg.answer() in ["y", "Y"]:
Update().repository(["slack"]) | def update_lists(self) | Update packages list and ChangeLog.txt file after
upgrade distribution | 16.727772 | 13.866603 | 1.206335 |
selected_packages, data = [], []
if packages:
for pkg in packages:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
binary = "{0}{1}".format(name, ver)
installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
... | def choose_upg(packages) | Create checklist to choose packages for upgrade | 6.980724 | 6.425323 | 1.086439 |
with open(path + log_file, "w") as log:
log.write("#" * 79 + "\n\n")
log.write("File : " + log_file + "\n")
log.write("Path : " + path + "\n")
log.write("Date : " + time.strftime("%d/%m/%Y") + "\n")
log.write("Time : " + log_time + "\n\n")
log.write("#" * 79 + "\... | def log_head(path, log_file, log_time) | write headers to log file | 1.776046 | 1.73176 | 1.025573 |
with open(path + log_file, "a") as log:
log.seek(2)
log.write("#" * 79 + "\n\n")
log.write("Time : " + time.strftime("%H:%M:%S") + "\n")
log.write("Total build time : {0}\n".format(sum_time))
log.write(" " * 38 + "E N D\n\n")
log.write("#" * 79 + "\n\n")
... | def log_end(path, log_file, sum_time) | append END tag to a log file | 2.900827 | 2.810152 | 1.032267 |
diff_time = round(time.time() - start_time, 2)
if diff_time <= 59.99:
sum_time = str(diff_time) + " Sec"
elif diff_time > 59.99 and diff_time <= 3599.99:
sum_time = round(diff_time / 60, 2)
sum_time_list = re.findall(r"\d+", str(sum_time))
sum_time = ("{0} Min {1} Sec".f... | def build_time(start_time) | Calculate build time per package | 1.709075 | 1.683371 | 1.01527 |
try:
self._delete_dir()
try:
tar = tarfile.open(self.script)
except Exception as err:
print err
raise SystemExit()
tar.extractall()
tar.close()
self._makeflags()
self._del... | def build(self) | Build package from source and create log
file in path /var/log/slpkg/sbo/build_logs/.
Also check md5sum calculates. | 4.519181 | 4.337511 | 1.041884 |
self.sbo_md5 = {}
md5_lists = SBoGrep(self.prgnam).checksum()
for src, md5 in zip(self.sources, md5_lists):
self.sbo_md5[src] = md5 | def _create_md5_dict(self) | Create md5 dictionary per source | 8.411402 | 6.691444 | 1.257038 |
if self.meta.makeflags in ["on", "ON"]:
cpus = multiprocessing.cpu_count()
os.environ["MAKEFLAGS"] = "-j{0}".format(cpus) | def _makeflags(self) | Set variable MAKEFLAGS with the numbers of
processors | 7.791119 | 6.023086 | 1.293543 |
pass_var = []
for var in os.environ.keys():
expVAR = var.split("_")
if expVAR[0] == self.prgnam.upper() and expVAR[1] != "PATH":
pass_var.append("{0}={1}".format(expVAR[1], os.environ[var]))
return pass_var | def _pass_variable(self) | Return enviroment variables | 4.601148 | 3.826474 | 1.202451 |
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) | Delete slackbuild tar.gz file after untar | 6.030252 | 4.999367 | 1.206203 |
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) | Delete old folder if exists before start build | 6.425978 | 5.203776 | 1.234868 |
blacklist = []
for read in self.black_conf.splitlines():
read = read.lstrip()
if not read.startswith("#"):
blacklist.append(read.replace("\n", ""))
return blacklist | def get_black(self) | Return blacklist packages from /etc/slpkg/blacklist
configuration file. | 5.418431 | 4.058167 | 1.335192 |
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"]))
self.quit = True
if self.quit:
... | def listed(self) | Print blacklist packages | 7.07788 | 4.997122 | 1.416391 |
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:
print("{0}{1}{2}".format(self.meta.color["GREEN"], pk... | def add(self, pkgs) | Add blacklist packages if not exist | 4.29099 | 3.744295 | 1.146008 |
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")
else:
print("{0}{1}{2}".format(... | def remove(self, pkgs) | Remove packages from blacklist | 4.348516 | 3.964593 | 1.096838 |
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)
return self.black | def packages(self, pkgs, repo) | Return packages in blacklist or by repository | 7.965858 | 6.87909 | 1.157981 |
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].endswith("*"):
if pkg.startswith(pr[1][:-1]):
self.black.app... | def __priority(self, pr, repo, pkg) | Add packages in blacklist by priority | 1.954746 | 1.86633 | 1.047374 |
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.black.append(self.__add(repo, pkg))
elif bl.startswith("*"):
... | def __blackpkg(self, bl, repo, pkg) | Add packages in blacklist | 2.100749 | 2.025529 | 1.037136 |
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)
for line in PACKAGES_TXT.splitlines():
if line.st... | def view(self) | Print package description by repository | 6.195859 | 5.500426 | 1.126433 |
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].replace("%2B", "+")
if dwn.startswith("file:///"):
source_dir = dwn[7:-7].replace(slack_... | def start(self) | Download files using wget or other downloader.
Optional curl, aria2c and httpie | 3.789721 | 3.548676 | 1.067925 |
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) | Create .tar.gz file | 1.620178 | 1.514441 | 1.069819 |
if self.downder == "wget":
self.dir_prefix = "--directory-prefix="
elif self.downder == "aria2c":
self.dir_prefix = "--dir=" | def _directory_prefix(self) | Downloader options for specific directory | 6.530904 | 4.340031 | 1.504806 |
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"],
self.meta.color["ENDC"]))
self.msg.template(7... | def _check_if_downloaded(self) | Check if file downloaded | 5.986135 | 5.66426 | 1.056826 |
if (self.file_name.startswith("jdk-") and self.repo == "sbo" and
self.downder == "wget"):
certificate = (' --no-check-certificate --header="Cookie: '
'oraclelicense=accept-securebackup-cookie"')
self.msg.template(78)
print("... | def _check_certificate(self) | Check for certificates options for wget | 14.435165 | 12.549032 | 1.150301 |
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:
if LooseVersion(bins) > LooseVersion(cache):
binary = bins
cache ... | def slack_package(prgnam) | Return maximum binary Slackware package from output directory | 9.946371 | 8.576827 | 1.15968 |
try:
tar = urllib2.urlopen(self.registry)
meta = tar.info()
return int(meta.getheaders("Content-Length")[0])
except (urllib2.URLError, IndexError):
return " " | def server(self) | Returns the size of remote files | 6.353105 | 5.64758 | 1.124925 |
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)
comp_unit = "Gb"
if uncompressed > 1024:
uncompressed =... | def units(comp_sum, uncomp_sum) | Calculate package size | 1.775091 | 1.688182 | 1.05148 |
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"]))
sys.stdout.flush()
time.sleep(float(sec)... | def status(sec) | Toolbar progressive status | 5.645301 | 5.372246 | 1.050827 |
tagc = ""
self.is_upgrade = is_upgrade
self.case_insensitive()
for _sbo in self.slackbuilds:
status(0.03)
if _sbo in self.data and _sbo not in self.blacklist:
sbo_deps = Requires(self.flag).sbo(_sbo)
self.deps += sbo_deps
... | def start(self, is_upgrade) | Start view, build and install SBo packages | 4.123743 | 4.045682 | 1.019295 |
onelist, dependencies = [], []
onelist = Utils().dimensional_list(self.deps)
dependencies = Utils().remove_dbs(onelist)
for dep in dependencies:
deps = Requires(self.flag).sbo(dep)
self.deps_dict[dep] = self.one_for_all(deps) | def update_deps(self) | Update dependencies dictionary with all package | 16.092249 | 15.818956 | 1.017276 |
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 = self.build_install()
if "--download-only" in self.fl... | def continue_to_install(self) | Continue to install ? | 10.159408 | 9.78872 | 1.037869 |
self.master_packages = Utils().remove_dbs(self.master_packages)
for mas in self.master_packages:
if mas in self.dependencies:
self.master_packages.remove(mas) | def clear_masters(self) | Clear master slackbuilds if already exist in dependencies
or if added to install two or more times | 7.007704 | 5.38485 | 1.301374 |
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) | Return found matching SBo packages | 7.102692 | 4.184104 | 1.697542 |
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.append(SBoGrep(sbo).source())
return [sbo_versions, sources] | def sbo_version_source(self, slackbuilds) | Create sbo name with version | 4.542221 | 4.334364 | 1.047955 |
requires, dependencies = [], []
deps.reverse()
# Inverting the list brings the
# dependencies in order to be installed.
requires = Utils().dimensional_list(deps)
dependencies = Utils().remove_dbs(requires)
return dependencies | 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. | 27.032051 | 20.885265 | 1.294312 |
ver = GetFromInstalled(args[1]).version()
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
args[0], args[1] + ver, self.meta.color["ENDC"],
" " * (23-len(args[1] + ver)), args[2],
" " * (18-len(args[2])), args[3],
" " * (15-len(a... | def view_packages(self, *args) | :View slackbuild packages with version and arch
args[0] package color
args[1] package
args[2] version
args[3] arch | 5.608769 | 5.025715 | 1.116014 |
# split sbo name with version and get name
sbo_name = "-".join(sbo.split("-")[:-1])
find = GetFromInstalled(sbo_name).name()
if find_package(sbo, self.meta.pkg_path):
paint = self.meta.color["GREEN"]
self.count_ins += 1
if "--rebuild" in self.... | def tag(self, sbo) | Tag with color green if package already installed,
color yellow for packages to upgrade and color red
if not installed. | 5.999272 | 5.11071 | 1.173863 |
arch = self.arch
for item in self.unst:
if item in src:
arch = item
return arch | def select_arch(self, src) | Looks if sources unsupported or untested
from arch else select arch. | 8.079822 | 6.48455 | 1.246011 |
filename = []
for src in sources:
filename.append(src.split("/")[-1])
return filename | def filenames(self, sources) | Return filenames from sources links | 4.136075 | 3.484848 | 1.186874 |
slackbuilds = self.dependencies + self.master_packages
installs, upgraded, = [], []
if not os.path.exists(self.build_folder):
os.makedirs(self.build_folder)
if not os.path.exists(self._SOURCES):
os.makedirs(self._SOURCES)
os.chdir(self.build_folde... | def build_install(self) | Build and install packages if not already installed | 4.620227 | 4.556123 | 1.01407 |
name = "-".join(prgnam.split("-")[:-1])
sbo_ver = prgnam.split("-")[-1]
ins_ver = GetFromInstalled(name).version()[1:]
if not ins_ver:
ins_ver = "0"
if LooseVersion(sbo_ver) < LooseVersion(ins_ver):
self.msg.template(78)
print("| Packa... | def not_downgrade(self, prgnam) | Don't downgrade packages if sbo version is lower than
installed | 6.722169 | 5.196573 | 1.293577 |
sources = []
name = "-".join(prgnam.split("-")[:-1])
category = "{0}/{1}/".format(sbo_link.split("/")[-2], name)
for link in src_link:
source = link.split("/")[-1]
sources.append("{0}{1}{2}".format(self.meta.sbosrcarch_link,
... | def sbosrcarsh(self, prgnam, sbo_link, src_link) | Alternative repository for sbo sources | 4.312536 | 4.259552 | 1.012439 |
print("Version : {0}\n"
"Licence : {1}\n"
"Email : {2}\n"
"Maintainer: {3}".format(_meta_.__version__,
_meta_.__license__,
_meta_.__email__,
_meta_.__maintainer__)) | def prog_version() | Print version, license and email | 3.291124 | 2.935071 | 1.12131 |
if self.meta.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
sys.setrecursionlimit(10000)
dependencies = []
requires = Requires(name, self.repo).get_deps()
if requires:
for req in requires:
status(0)
... | def binary(self, name, flag) | Build all dependencies of a package | 7.153839 | 6.631028 | 1.078843 |
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol)) | def pkg_not_found(self, bol, pkg, message, eol) | Print message when package not found | 4.554527 | 4.446271 | 1.024347 |
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 in '{0}/var/log/slpkg/sbo/build_logs{1}' "
"directory or read the RE... | def build_FAILED(self, prgnam) | Print error message if build failed | 7.4381 | 7.115548 | 1.045331 |
sys.stdout.write("{0}Reading package lists...{1} ".format(
self.meta.color["GREY"], self.meta.color["ENDC"]))
sys.stdout.flush() | def reading(self) | Message reading | 8.307515 | 8.962955 | 0.926872 |
sys.stdout.write("\b{0}Done{1}\n".format(self.meta.color["GREY"],
self.meta.color["ENDC"])) | def done(self) | Message done | 9.302471 | 10.591748 | 0.878275 |
if self.meta.default_answer in ["y", "Y"]:
answer = self.meta.default_answer
else:
try:
answer = raw_input("Would you like to continue [y/N]? ")
except EOFError:
print("")
raise SystemExit()
return answe... | def answer(self) | Message answer | 4.612083 | 4.956024 | 0.930602 |
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 with the package '{0}' will you must read\n"
"| the README file. You can... | def security_pkg(self, pkg) | Warning message for some special reasons | 10.249939 | 9.461198 | 1.083366 |
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))))
self.template(78)
for installed, upgraded in itertools.izip_longest(install, upgrade):
... | def reference(self, install, upgrade) | Reference list with packages installed
and upgraded | 3.567545 | 3.577558 | 0.997201 |
print("\nNot found package with the name [ {0}{1}{2} ]. "
"Matching packages:\nNOTE: Not dependenc"
"ies are resolved\n".format(self.meta.color["CYAN"],
"".join(packages),
self.meta.color["EN... | def matching(self, packages) | Message for matching packages | 13.107533 | 12.821198 | 1.022333 |
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(ver, location, name)
else:
http = repo + "slackware64-{0}/{1}{2}".format(rel, location, name)
elif... | def mirrors(name, location) | Select Slackware official mirror packages
based architecture and version. | 2.531252 | 2.415956 | 1.047723 |
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:")
self.msg.template(78)
for com in sorted(self.comm... | def select(self) | Select Slackware command | 3.861902 | 3.51437 | 1.098889 |
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(
self.commands[self.choice][11:]) | def execute(self) | Execute Slackware command | 6.530998 | 6.009074 | 1.086856 |
keys =
self.read_enabled()
self.read_disabled()
text, title, backtitle, status = keys, " Repositories ", "", False
self.selected = DialogUtil(self.disabled, text, title, backtitle,
status).buildlist(self.enabled)
if self.select... | def choose(self) | Choose repositories | 13.019078 | 11.557025 | 1.126508 |
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 not in line):
self.enabled.append(line)
... | def read_enabled(self) | Read enable repositories | 4.10927 | 3.781092 | 1.086794 |
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("#")).strip()
self.disabled.append(line)
se... | def read_disabled(self) | Read disable repositories | 3.847426 | 3.688097 | 1.043201 |
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
... | def update_repos(self) | Update repositories.conf file with enabled or disabled
repositories | 3.231688 | 3.088504 | 1.04636 |
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(
self.meta.color["RED"],
sel... | def reference(self) | Reference enable repositories | 5.521164 | 5.090574 | 1.084586 |
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 SLACKBUILDS_TXT.splitlines():
if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (lin... | def sbo_search_pkg(name) | Search for package path from SLACKBUILDS.TXT file and
return url | 6.891533 | 5.619915 | 1.22627 |
gotpkt = True
try:
timestamp,dev,pkt = self.net.recv_packet(timeout=1.0)
except NoPackets:
log_debug("No packets available in recv_packet")
gotpkt = False
except Shutdown:
log_debug("Got shutdown signal")
... | 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 | Main method for router; we stay in a loop in this method, receiving
packets until the end of time. | 6.197469 | 5.945385 | 1.0424 |
java_files = []
input_path = os.path.normpath(os.path.abspath(input_path))
for dirpath, dirnames, filenames in os.walk(input_path):
if is_excluded(dirpath, excludes):
del dirnames[:]
continue
for filename in filenames:
if filename.endswith(".java"... | def find_source_files(input_path, excludes) | Get a list of filenames for all Java source files within the given
directory. | 1.926296 | 1.775554 | 1.084899 |
'''
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
optclass = (opt... | def from_bytes(rawbytes) | Takes a byte string as a parameter and returns a list of
IPOption objects. | 4.71994 | 3.73478 | 1.26378 |
'''
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()
padbytes = 4 - (... | def to_bytes(self) | Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary. | 4.841393 | 2.319421 | 2.087328 |
'''
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
takestarargs = entryfunction.__code__.co_flags & 0x04 ... | 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. | 4.101006 | 3.234653 | 1.267835 |
'''
Can be called when an interface goes down.
FIXME: doesn't really do anything at this point.
'''
intf = self._devinfo.get(interface, None)
if intf and self._devupdown_callback:
self._devupdown_callback(intf, 'down') | def intf_down(self, interface) | Can be called when an interface goes down.
FIXME: doesn't really do anything at this point. | 6.549571 | 3.376361 | 1.939831 |
'''
Can be called when an interface is put in service.
FIXME: not currently used; more needs to be done to
correctly put a new intf into service.
'''
if interface.name not in self._devinfo:
self._devinfo[interface.name] = interface
if self._devupdo... | def intf_up(self, interface) | Can be called when an interface is put in service.
FIXME: not currently used; more needs to be done to
correctly put a new intf into service. | 7.468018 | 2.817895 | 2.650211 |
'''
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) | Given a device name, return the corresponding interface object | 5.522773 | 3.619311 | 1.525918 |
'''
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 device has IP address {}".format(ipaddr)) | def interface_by_ipaddr(self, ipaddr) | Given an IP address, return the interface that 'owns' this address | 4.791652 | 3.361221 | 1.425569 |
'''
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("No device has MAC address {}".format(mac... | def interface_by_macaddr(self, macaddr) | Given a MAC address, return the interface that 'owns' this address | 5.256346 | 3.648792 | 1.440572 |
'''
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)
obj = ICMPv6Optio... | def from_bytes(rawbytes) | Takes a byte string as a parameter and returns a list of
ICMPv6Option objects. | 3.996105 | 2.909754 | 1.373348 |
'''
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.to_bytes()
# ... | def to_bytes(self) | Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary. | 8.009993 | 5.026769 | 1.593467 |
'''
Accept some number of bits/sec (i.e., a link capacity) as an
integer, and return a string representing a 'human'(-like)
representation of the capacity, e.g., 10 Mb/s, 1.5 Mb/s,
900 Gb/s.
As is the standard in networking, capacity values are assumed
to be base-10 values (not base 2), so ... | def humanize_bandwidth(bits) | Accept some number of bits/sec (i.e., a link capacity) as an
integer, and return a string representing a 'human'(-like)
representation of the capacity, e.g., 10 Mb/s, 1.5 Mb/s,
900 Gb/s.
As is the standard in networking, capacity values are assumed
to be base-10 values (not base 2), so 1000 is 1 Kb... | 2.668247 | 1.41125 | 1.890698 |
'''
Take a string representing a link capacity, e.g., 10 Mb/s, and
return an integer representing the number of bits/sec.
Recognizes:
- 'bits/sec' or 'b/s' are treated as plain bits per second
- 'Kb' or 'kb' as thousand bits/sec
- 'Mb' or 'mb' as million bits/sec
- 'Gb' o... | def unhumanize_bandwidth(bitsstr) | Take a string representing a link capacity, e.g., 10 Mb/s, and
return an integer representing the number of bits/sec.
Recognizes:
- 'bits/sec' or 'b/s' are treated as plain bits per second
- 'Kb' or 'kb' as thousand bits/sec
- 'Mb' or 'mb' as million bits/sec
- 'Gb' or 'gb' as bi... | 3.725591 | 1.667582 | 2.234128 |
'''
Accept a floating point number presenting link propagation delay
in seconds (e.g., 0.1 for 100 milliseconds delay), and return
a human(-like) string like '100 milliseconds'. Handles values as
small as 1 microsecond, but no smaller.
Because of imprecision in floating point numbers, a relat... | def humanize_delay(delay) | Accept a floating point number presenting link propagation delay
in seconds (e.g., 0.1 for 100 milliseconds delay), and return
a human(-like) string like '100 milliseconds'. Handles values as
small as 1 microsecond, but no smaller.
Because of imprecision in floating point numbers, a relatively easy
... | 4.142767 | 2.032754 | 2.038008 |
'''
Accept a string representing link propagation delay (e.g.,
'100 milliseconds' or '100 msec' or 100 millisec') and return
a floating point number representing the delay in seconds.
Recognizes:
- us, usec, micros* all as microseconds
- ms, msec, millisec* all as milliseconds
... | def unhumanize_delay(delaystr) | Accept a string representing link propagation delay (e.g.,
'100 milliseconds' or '100 msec' or 100 millisec') and return
a floating point number representing the delay in seconds.
Recognizes:
- us, usec, micros* all as microseconds
- ms, msec, millisec* all as milliseconds
- s, sec*... | 3.278465 | 1.596396 | 2.053667 |
'''
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(enval)
return unpacked | 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. | 5.575988 | 2.436644 | 2.288389 |
'''
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.name.endswith('Mask'):
... | 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. | 7.151923 | 2.839216 | 2.518978 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.