code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
# write out all the commands to a temp file and then have psql run that file
f = self._get_file()
for q in queries:
f.write("{};\n".format(q))
f.close()
psql_args = self._get_args('psql', '-X', '-f {}'.format(f.name))
return self._run_cmd(' '.join(ps... | def _run_queries(self, queries, *args, **kwargs) | run the queries
queries -- list -- the queries to run
return -- string -- the results of the query? | 4.385788 | 4.430917 | 0.989815 |
query, seq_table, seq_column, seq_name = self._get_auto_increment_info(table)
if query:
queries = [query, "select nextval('{}')".format(seq_name)]
return self._run_queries(queries) | def _restore_auto_increment(self, table) | restore the auto increment value for the table to what it was previously | 4.966052 | 4.696454 | 1.057405 |
query = ''
seq_table = ''
seq_column = ''
seq_name = ''
find_query = "\n".join([
"SELECT",
" t.relname as related_table,",
" a.attname as related_column,",
" s.relname as sequence_name",
"FROM pg_class s",
... | def _get_auto_increment_info(self, table) | figure out the the autoincrement value for the given table | 2.325472 | 2.29686 | 1.012457 |
'''
cli hook
return -- integer -- the exit code
'''
parser = argparse.ArgumentParser(description="backup/restore PostgreSQL databases", add_help=False)
parser.add_argument("--version", action='version', version="%(prog)s {}".format(__version__))
parent_parser = argparse.ArgumentParser(add_... | def console() | cli hook
return -- integer -- the exit code | 1.86559 | 1.775877 | 1.050518 |
sql_files = []
for root, dirs, files in os.walk(self.directory):
for f in files:
if f.endswith(".sql.gz"):
path = os.path.join(self.directory, f)
self._run_cmd(["gunzip", path])
sql_files.append(f.rstrip(".g... | def restore(self) | use the self.directory to restore a db
NOTE -- this will only restore a database dumped with one of the methods
of this class | 3.228976 | 3.052435 | 1.057836 |
if not table: raise ValueError("no table")
cmds = []
logger.info('------- dumping table {}'.format(table))
cmd = self._get_args(
"pg_dump",
"--table={}".format(table),
#"--data-only",
"--clean",
"--no-owner",
... | def table_dump(self, table) | dump all the rows of the given table name | 4.392766 | 4.387364 | 1.001231 |
if hasattr(self, 'env'): return self.env
# create a temporary pgpass file
pgpass = self._get_file()
# format: http://www.postgresql.org/docs/9.2/static/libpq-pgpass.html
pgpass.write('*:*:*:{}:{}\n'.format(self.username, self.password).encode("utf-8"))
pgpass.cl... | def _get_env(self) | this returns an environment dictionary we want to use to run the command
this will also create a fake pgpass file in order to make it possible for
the script to be passwordless | 3.677634 | 3.201326 | 1.148785 |
if 'code' not in kwargs:
kwargs['code'] = 200
if 'headers' not in kwargs:
kwargs['headers'] = dict()
if 'version' not in kwargs:
kwargs['version'] = 'HTTP/1.1'
return dict(**kwargs) | def _get_response(**kwargs) | Get a template response
Use kwargs to add things to the dictionary | 2.424998 | 2.351578 | 1.031222 |
if isinstance(string, str): # we need to convert to bytes
self.transport.write(string.encode('utf-8'))
else:
self.transport.write(string) | def _write_transport(self, string) | Convenience function to write to the transport | 3.233299 | 2.988836 | 1.081792 |
status = '{} {} {}\r\n'.format(response['version'],
response['code'],
responses[response['code']])
self.logger.debug("Responding status: '%s'", status.strip())
self._write_transport(status)
if 'body' ... | def _write_response(self, response) | Write the response back to the client
Arguments:
response -- the dictionary containing the response. | 2.447523 | 2.510619 | 0.974868 |
self.logger.info('Connection made at object %s', id(self))
self.transport = transport
self.keepalive = True
if self._timeout:
self.logger.debug('Registering timeout event')
self._timout_handle = self._loop.call_later(
self._timeout, self.... | def connection_made(self, transport) | Called when the connection is made | 4.138097 | 3.956924 | 1.045786 |
if exception:
self.logger.exception('Connection lost!')
else:
self.logger.info('Connection lost') | def connection_lost(self, exception) | Called when the connection is lost or closed.
The argument is either an exception object or None. The latter means
a regular EOF is received, or the connection was aborted or closed by
this side of the connection. | 4.078123 | 4.72887 | 0.862388 |
self.logger.debug('Received data: %s', repr(data))
try:
request = self._parse_headers(data)
self._handle_request(request)
except InvalidRequestError as e:
self._write_response(e.get_http_response())
if not self.keepalive:
if self... | def data_received(self, data) | Process received data from the socket
Called when we receive data | 2.870811 | 2.926683 | 0.980909 |
request_uri = request['target']
if request_uri.startswith('/'): # eg. GET /index.html
return (request.get('Host', 'localhost').split(':')[0],
request_uri[1:])
elif '://' in request_uri: # eg. GET http://rded.nl
locator = request_uri.split(':... | def _get_request_uri(self, request) | Parse the request URI into something useful
Server MUST accept full URIs (5.1.2) | 4.141554 | 3.882194 | 1.066808 |
# Check if this is a persistent connection.
if request['version'] == 'HTTP/1.1':
self.keepalive = not request.get('Connection') == 'close'
elif request['version'] == 'HTTP/1.0':
self.keepalive = request.get('Connection') == 'Keep-Alive'
# Check if we're... | def _handle_request(self, request) | Process the headers and get the file | 2.884461 | 2.849603 | 1.012232 |
return _get_response(
code=self.code,
body=str(self),
headers={
'Content-Type': 'text/plain'
}
) | def get_http_response(self) | Get this exception as an HTTP response suitable for output | 4.515129 | 3.67247 | 1.229453 |
import asyncio
from .httpserver import HttpProtocol
loop = asyncio.get_event_loop()
coroutine = loop.create_server(lambda: HttpProtocol(hostname, folder),
bindaddr,
port)
server = loop.run_until_complete(coroutine)
print... | def _start_server(bindaddr, port, hostname, folder) | Starts an asyncio server | 2.283752 | 2.213686 | 1.031651 |
print('This python version is not supported. Please use python 3.4')
exit(1)
argv = argv or sys.argv[1:]
# remove some RST formatting
docblock = run.__doc__.replace('::', ':')
args = docopt.docopt(textwrap.dedent(docblock), argv)
if args['--version']:
print("httpserver ver... | def run(argv=None): # pragma: no cover
import sys
import os
import docopt
import textwrap
# Check for the version
if not sys.version_info >= (3, 4) | Run the HTTP server
Usage:
httpserver [options] [<folder>]
Options::
-h,--host=<hostname> What host name to serve (default localhost)
-a,--bindaddress=<address> Address to bind to (default 127.0.0.1)
-p,--port=<port> Port to listen on (default 8080)
... | 3.337894 | 3.05094 | 1.094054 |
try:
# testing proxy
proxies = {}
try:
proxies["http_proxy"] = os.environ['http_proxy']
except KeyError:
pass
try:
proxies["https_proxy"] = os.environ['https_proxy']
except KeyError:
... | def reading(self) | Open url and read | 2.771758 | 2.671606 | 1.037488 |
if (self.meta.rsl_deps in ["on", "ON"] and
"--resolve-off" not in self.flag):
sys.setrecursionlimit(10000)
dependencies = []
requires = SBoGrep(name).requires()
if requires:
for req in requires:
status(0... | def sbo(self, name) | Build all dependencies of a package | 11.054731 | 10.142256 | 1.089968 |
pkgs = []
if os.path.isdir(directory):
installed = sorted(os.listdir(directory))
blacklist = BlackList().packages(pkgs=installed, repo="local")
if os.path.exists(directory):
for pkg in installed:
if (not pkg.startswith(".") and pkg.startswith(find_pkg) an... | def find_package(find_pkg, directory) | Find packages | 4.602514 | 4.713168 | 0.976522 |
assert cell.cell_type == 'markdown', cell.cell_type
lines = cell.source.splitlines()
if lines[0].startswith('# '):
header_lines = 1
elif len(lines) > 1 and lines[1].startswith('==='):
header_lines = 2
else:
raise NoHeader
header = '\n'.join(lines[:header_lines])
... | def add_sec_label(cell: NotebookNode, nbname) -> Sequence[NotebookNode] | Adds a Latex \\label{} under the chapter heading.
This takes the first cell of a notebook, and expects it to be a Markdown
cell starting with a level 1 heading. It inserts a label with the notebook
name just underneath this heading. | 2.774183 | 2.756438 | 1.006438 |
def_cnt, cus_cnt = 0, 0
print("")
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}".format(
"| Repo id", " " * 2,
"Repo URL", " " * 44,
"Default", " " * 3,
"Status"))
self.msg.template(78)
for repo_id, repo_URL in... | def repos(self) | View or enabled or disabled repositories | 3.943888 | 3.821146 | 1.032122 |
print("") # new line at start
conf_args = [
"RELEASE",
"SLACKWARE_VERSION",
"COMP_ARCH",
"BUILD_PATH",
"PACKAGES",
"PATCHES",
"CHECKMD5",
"DEL_ALL",
"DEL_BUILD",
"SBO_BUILD_... | def view(self) | View slpkg config file | 7.756125 | 7.194479 | 1.078066 |
subprocess.call("{0} {1}".format(self.meta.editor,
self.config_file), shell=True) | def edit(self) | Edit configuration file | 8.23059 | 6.902672 | 1.192377 |
shutil.copy2(self.config_file + ".orig", self.config_file)
if filecmp.cmp(self.config_file + ".orig", self.config_file):
print("{0}The reset was done{1}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"]))
else:
print("{0}Reset failed{1}".... | def reset(self) | Reset slpkg.conf file with default values | 3.524641 | 3.237443 | 1.088711 |
if self.arch.startswith("i") and self.arch.endswith("86"):
self.arch = self.x86
elif self.meta.arch.startswith("arm"):
self.arch = self.arm
return self.arch | def get(self) | Return sbo arch | 4.991202 | 4.093406 | 1.219327 |
print("")
per = int(round((float(self.cf) / (self.cf + self.cn)) * 100))
if per > 90:
color = self.meta.color["GREEN"]
elif per < 90 and per > 60:
color = self.meta.color["YELLOW"]
elif per < 60:
color = self.meta.color["RED"]
... | def results(self) | Print results | 3.38975 | 3.286602 | 1.031384 |
dictionary = {}
for pkg in lst:
dictionary[pkg.lower()] = pkg
return dictionary | def case_sensitive(self, lst) | Create dictionary from list with key in lower case
and value with default | 6.592057 | 5.923616 | 1.112843 |
one = []
for dup in double:
if dup not in one:
one.append(dup)
return one | def remove_dbs(self, double) | Remove double item from list | 5.602254 | 4.870022 | 1.150355 |
with open(registry, "r") as file_txt:
read_file = file_txt.read()
file_txt.close()
return read_file | def read_file(self, registry) | Returns reading file | 4.203488 | 3.447027 | 1.219453 |
packages = []
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
packages.append(split_package(line[14:].strip())[0])
return packages | def package_name(self, PACKAGES_TXT) | Returns list with all the names of packages repository | 3.999821 | 3.666108 | 1.091027 |
downloaded = []
for pkg in maybe_downloaded:
if os.path.isfile(path + pkg):
downloaded.append(pkg)
return downloaded | def check_downloaded(self, path, maybe_downloaded) | Check if files downloaded and return downloaded
packages | 3.640732 | 2.81764 | 1.292121 |
for name, dependencies in deps_dict.iteritems():
if find_package(name + _meta_.sp, _meta_.pkg_path):
dep_path = _meta_.log_path + "dep/"
if not os.path.exists(dep_path):
os.mkdir(dep_path)
if os.path.isfile(dep_path + name):
os.remove(... | def write_deps(deps_dict) | Write dependencies in a log file
into directory `/var/log/slpkg/dep/` | 3.103538 | 2.9461 | 1.05344 |
try:
import pygraphviz as pgv
except ImportError:
graph_easy, comma = "", ""
if (self.image == "ascii" and
not os.path.isfile("/usr/bin/graph-easy")):
comma = ","
graph_easy = " graph-easy"
print... | def dependencies(self, deps_dict) | Generate graph file with depenndencies map tree | 5.068702 | 4.945634 | 1.024884 |
try:
image_type = ".{0}".format(self.image.split(".")[1])
if image_type not in self.file_format:
print("Format: '{0}' not recognized. Use one of "
"them:\n{1}".format(self.image.split(".")[1],
", ".j... | def check_file(self) | Check for file format and type | 4.936888 | 4.524749 | 1.091085 |
if not os.path.isfile("/usr/bin/graph-easy"):
print("Require 'graph-easy': Install with 'slpkg -s sbo "
"graph-easy'")
self.remove_dot()
raise SystemExit()
subprocess.call("graph-easy {0}.dot".format(self.image), shell=True)
self.rem... | def graph_easy(self) | Draw ascii diagram. graph-easy perl module require | 8.14333 | 6.764784 | 1.203783 |
if os.path.isfile("{0}.dot".format(self.image)):
os.remove("{0}.dot".format(self.image)) | def remove_dot(self) | Remove .dot files | 3.518026 | 2.863639 | 1.228516 |
security_packages = Utils().read_file("/etc/slpkg/pkg_security")
packages = []
for read in security_packages.splitlines():
read = read.lstrip()
if not read.startswith("#"):
packages.append(read.replace("\n", ""))
for p in pkgs:
for pkg in packages:
if... | def pkg_security(pkgs) | Check packages before install or upgrade for security
reasons. Configuration file in the /etc/slpkg/pkg_security | 6.133966 | 4.583564 | 1.338253 |
cache, npkg, nsize = [], [], []
for p, s in zip(packages, sizes):
name = split_package(p)[0]
if name not in cache:
cache.append(name)
npkg.append(p)
nsize.append(s)
return npkg, nsize | def alien_filter(packages, sizes) | This filter avoid list double packages from
alien repository | 2.914051 | 3.029495 | 0.961893 |
for pkg in self.binary:
try:
subprocess.call("upgradepkg {0} {1}".format(flag, pkg),
shell=True)
check = pkg[:-4].split("/")[-1]
if os.path.isfile(self.meta.pkg_path + check):
print("Complete... | def upgrade(self, flag) | Upgrade Slackware binary packages with new | 6.081058 | 5.591316 | 1.08759 |
self.flag = flag
self.extra = extra
self.dep_path = self.meta.log_path + "dep/"
dependencies, rmv_list = [], []
self.removed = self._view_removed()
if not self.removed:
print("") # new line at end
else:
msg = "package"
... | def remove(self, flag, extra) | Remove Slackware binary packages | 4.894156 | 4.743371 | 1.031789 |
if self.meta.remove_deps_answer in ["y", "Y"]:
remove_dep = self.meta.remove_deps_answer
else:
try:
remove_dep = raw_input(
"\nRemove dependencies (maybe used by "
"other packages) [y/N]? ")
print(""... | def _rmv_deps_answer(self) | Remove dependencies answer | 5.787317 | 5.22079 | 1.108514 |
removed, packages = [], []
if "--tag" in self.extra:
for pkg in find_package("", self.meta.pkg_path):
for tag in self.binary:
if pkg.endswith(tag):
removed.append(split_package(pkg)[0])
packages.appe... | def _get_removed(self) | Manage removed packages by extra options | 4.785779 | 4.357895 | 1.098186 |
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
removed, packages = self._get_removed()
if packages and "--checklist" in self.extra:
removed = []
text... | def _view_removed(self) | View packages before removed | 8.20439 | 7.6613 | 1.070887 |
if self.size > 1024:
self.unit = "Mb"
self.size = (self.size / 1024)
if self.size > 1024:
self.unit = "Gb"
self.size = (self.size / 1024) | def _calc_sizes(self) | Package size calculation | 2.168581 | 1.967841 | 1.10201 |
if self.size > 0:
print("\nRemoved summary")
print("=" * 79)
print("{0}Size of removed packages {1} {2}.{3}".format(
self.meta.color["GREY"], round(self.size, 2), self.unit,
self.meta.color["ENDC"])) | def _remove_summary(self) | Removed packge size summary | 7.180902 | 5.28295 | 1.35926 |
self.size = 0
packages = []
dependencies = (Utils().read_file(path + package)).splitlines()
for dep in dependencies:
if GetFromInstalled(dep).name():
ver = GetFromInstalled(dep).version()
packages.append(dep + ver)
else:
... | def _view_deps(self, path, package) | View dependencies before remove | 5.644292 | 5.490054 | 1.028094 |
try:
subprocess.call("removepkg {0} {1}".format(self.flag, package),
shell=True)
if os.path.isfile(self.dep_path + package):
os.remove(self.dep_path + package) # remove log
except subprocess.CalledProcessError as er:
... | def _removepkg(self, package) | removepkg Slackware command | 4.380404 | 4.255356 | 1.029386 |
removes = []
dependencies.append(package)
self._check_if_used(dependencies)
for dep in dependencies:
if dep not in self.skip and GetFromInstalled(dep).name():
ver = GetFromInstalled(dep).version()
removes.append(dep + ver)
... | def _rmv_deps(self, dependencies, package) | Remove dependencies | 7.804587 | 7.12909 | 1.094752 |
removes = []
if GetFromInstalled(package).name() and package not in self.skip:
ver = GetFromInstalled(package).version()
removes.append(package + ver)
self._removepkg(package)
return removes | def _rmv_pkg(self, package) | Remove one signle package | 10.534039 | 10.051428 | 1.048014 |
if "--checklist" not in self.extra:
self.msg.template(78)
print("| Insert packages to exception remove:")
self.msg.template(78)
try:
self.skip = raw_input(" > ").split()
except EOFError:
print("")
... | def _skip_remove(self) | Skip packages from remove | 8.704854 | 7.571825 | 1.149638 |
if "--check-deps" in self.extra:
package, dependency, pkg_dep = [], [], []
for pkg in find_package("", self.dep_path):
deps = Utils().read_file(self.dep_path + pkg)
for rmv in removes:
if GetFromInstalled(rmv).name() and rmv in... | def _check_if_used(self, removes) | Check package if dependencies for another package
before removed | 5.419259 | 5.18803 | 1.04457 |
print("")
self.msg.template(78)
msg_pkg = "package"
if len(removes) > 1:
msg_pkg = "packages"
print("| Total {0} {1} removed".format(len(removes), msg_pkg))
self.msg.template(78)
for pkg in removes:
if not GetFromInstalled(pkg).nam... | def _reference_rmvs(self, removes) | Prints all removed packages | 4.378143 | 3.763041 | 1.163459 |
matching, pkg_cache, match_cache = 0, "", ""
print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
for pkg in self.binary:
for match in find_package("", self.meta.pkg_p... | def find(self, flag) | Find installed Slackware packages | 4.019688 | 3.838223 | 1.047278 |
data = Utils().read_file(self.meta.pkg_path + package)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
digit = float((''.join(re.findall(
"[-+]?\d+[\.]?\d*[eE]?[-+]?\d*", line[26:]))))
self.file_siz... | def _sizes(self, package) | Package size summary | 5.108863 | 4.883227 | 1.046206 |
for pkg in self.binary:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
find = find_package("{0}{1}{2}".format(name, ver, self.meta.sp),
self.meta.pkg_path)
if find:
package = Utils... | def display(self) | Print the Slackware packages contents | 6.909851 | 6.451338 | 1.071072 |
tty_size = os.popen("stty size", "r").read().split()
row = int(tty_size[0]) - 2
try:
all_installed_names = []
index, page, pkg_list = 0, row, []
r = self.list_lib(repo)
pkg_list = self.list_greps(repo, r)[0]
all_installed_names... | def package_list(self, repo, name, INDEX, installed) | List with the installed packages | 3.479377 | 3.491077 | 0.996649 |
if name and repo != "sbo":
pkg = split_package(pkg)[0]
elif not name and repo != "sbo":
pkg = pkg[:-4]
return pkg | def _splitting_packages(self, pkg, repo, name) | Return package name from repositories | 7.253016 | 6.446134 | 1.125173 |
pkg_list, pkg_size = [], []
for line in packages.splitlines():
if repo == "sbo":
if line.startswith("SLACKBUILD NAME: "):
pkg_list.append(line[17:].strip())
pkg_size.append("0 K")
else:
if line.start... | def list_greps(self, repo, packages) | Grep packages | 3.970987 | 3.900357 | 1.018108 |
packages = ""
if repo == "sbo":
if (os.path.isfile(
self.meta.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
repo))):
packages = Utils().read_file(self.meta.lib_path + "{0}_repo/"
... | def list_lib(self, repo) | Return package lists | 3.003779 | 2.881575 | 1.042409 |
name = GetFromInstalled(pkg).name()
find = name + self.meta.sp
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
find = pkg[:-4]
if find_package(find, self.meta.pkg_path):
pkg = "{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
... | def list_color_tag(self, pkg) | Tag with color installed packages | 8.23828 | 7.411156 | 1.111605 |
all_installed_names = []
all_installed_packages = find_package("", self.meta.pkg_path)
for inst in all_installed_packages:
if repo == "sbo" and inst.endswith("_SBo"):
name = split_package(inst)[0]
all_installed_names.append(name)
e... | def list_of_installed(self, repo, name) | Return installed packages | 3.746018 | 3.70128 | 1.012087 |
(name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8))
for line in PACKAGES_TXT.splitlines():
if _meta_.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
status(0.000005)
if line.startswith("PACKAGE NAME:"):
name.append... | def repo_data(PACKAGES_TXT, repo, flag) | Grap data packages | 2.913788 | 2.896453 | 1.005985 |
arch = _meta_.arch
if arch.startswith("i") and arch.endswith("86"):
arch = "i486"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
loc = l.split("/")
if arch == loc[-1]:
fname.append(n)
f... | def rlw_filter(name, location, size, unsize) | Filter rlw repository data | 3.194033 | 3.26151 | 0.979311 |
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
if "slackbuilds" != l:
fname.append(n)
flocation.append(l)
fsize.append(s)
funsize.append(u)
return [fname, flocation, fsize, funsize] | def alien_filter(name, location, size, unsize) | Fix to avoid packages include in slackbuilds folder | 2.812398 | 2.228487 | 1.262022 |
ver = slack_ver()
if _meta_.slack_rel == "current":
ver = "current"
path_pkg = "pkg"
if _meta_.arch == "x86_64":
path_pkg = "pkg64"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
if path_pkg == l.split... | def rested_filter(name, location, size, unsize) | Filter Alien"s repository data | 3.550691 | 3.613528 | 0.982611 |
if self.repo == "rlw":
dependencies = {}
rlw_deps = Utils().read_file(_meta_.conf_path + "rlworkman.deps")
for line in rlw_deps.splitlines():
if line and not line.startswith("#"):
pkgs = line.split(":")
dependen... | def get_deps(self) | Grap package requirements from repositories | 4.718144 | 4.445679 | 1.061288 |
deps = []
for dep in line[18:].strip().split(","):
dep = dep.split("|")
if self.repo == "slacky":
if len(dep) > 1:
for d in dep:
deps.append(d.split()[0])
dep = "".join(dep)
deps.... | def _req_fix(self, line) | Fix slacky and salix requirements because many dependencies splitting
with "," and others with "|" | 2.988713 | 2.292552 | 1.303662 |
self.find_new()
for n in self.news:
print("{0}".format(n))
print("")
self.msg.template(78)
print("| Installed {0} new configuration files:".format(
len(self.news)))
self.msg.template(78)
self.choices() | def run(self) | print .new configuration files | 9.578998 | 7.172468 | 1.335523 |
print("\nSearch for .new configuration files:\n")
for path, dirs, files in os.walk(self.etc):
del dirs # delete unsed
for f in files:
if f.endswith(".new"):
self.news.append(os.path.join(path, f))
if not self.news:
... | def find_new(self) | Find all '.new' files from /etc/ folder
and subfolders | 5.354535 | 4.48225 | 1.194609 |
print("| {0}K{1}{2}eep the old and .new files, no changes".format(
self.red, self.endc, self.br))
print("| {0}O{1}{2}verwrite all old configuration files with new "
"ones".format(self.red, self.endc, self.br))
print("| The old files will be saved with suffix .... | def choices(self) | Menu options for new configuration files | 4.076794 | 3.827672 | 1.065084 |
self.msg.template(78)
print("| Choose what to do file by file:")
print("| {0}K{1}{2}eep, {3}O{4}{5}verwrite, {6}R{7}{8}emove, "
"{9}D{10}{11}iff, {12}M{13}{14}erge, {15}Q{16}{17}uit".format(
self.red, self.endc, self.br, self.red, self.endc, self.br,
... | def prompt(self) | Select file | 3.321301 | 3.27538 | 1.01402 |
print("")
prompt_ask = raw_input("{0} [K/O/R/D/M/Q]? ".format(n))
print("")
if prompt_ask in ("K", "k"):
self.keep()
elif prompt_ask in ("O", "o"):
self._overwrite(n)
elif prompt_ask in ("R", "r"):
self._remove(n)
elif ... | def question(self, n) | Choose what do to file by file | 3.012352 | 2.92006 | 1.031606 |
if os.path.isfile(n):
os.remove(n)
if not os.path.isfile(n):
print("File '{0}' removed".format(n)) | def _remove(self, n) | Remove one single file | 3.557076 | 3.056229 | 1.163878 |
if os.path.isfile(n[:-4]):
shutil.copy2(n[:-4], n[:-4] + ".old")
print("Old file {0} saved as {1}.old".format(
n[:-4].split("/")[-1], n[:-4].split("/")[-1]))
if os.path.isfile(n):
shutil.move(n, n[:-4])
print("New file {0} overwrit... | def _overwrite(self, n) | Overwrite old file with new and keep file with suffix .old | 2.642647 | 2.325282 | 1.136484 |
if os.path.isfile(n[:-4]):
diff1 = Utils().read_file(n[:-4]).splitlines()
if os.path.isfile(n):
diff2 = Utils().read_file(n).splitlines()
lines, l, c = [], 0, 0
for a, b in itertools.izip_longest(diff1, diff2):
l += 1
if a != b:
... | def diff(self, n) | Print the differences between the two files | 2.589863 | 2.506479 | 1.033268 |
if os.path.isfile(n[:-4]):
old = Utils().read_file(n[:-4]).splitlines()
if os.path.isfile(n):
new = Utils().read_file(n).splitlines()
with open(n[:-4], "w") as out:
for l1, l2 in itertools.izip_longest(old, new):
if l1 is None:
... | def merge(self, n) | Merge new file into old | 2.611157 | 2.422556 | 1.077852 |
print("")
self.msg.template(78)
print("| Repository Status")
self.msg.template(78) | def status_bar(self) | Top view bar status | 28.675028 | 24.212669 | 1.184298 |
if (self.repo in self.meta.default_repositories and
self.repo in self.meta.repositories):
try:
self.check = self.all_repos[self.repo]()
except OSError:
usage(self.repo)
raise SystemExit()
elif self.repo in s... | def run(self) | Run and check if new in ChangeLog.txt | 4.95803 | 4.767543 | 1.039955 |
self.count_repo += 1
if self.check == 1:
self.count_news += 1
self.st = "{0}News in ChangeLog.txt{1}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"])
elif self.check == 0:
self.st = "No changes in ChangeLog.txt" | def status(self) | Set messages | 6.91982 | 6.518757 | 1.061524 |
print(" {0}{1}{2}".format(repo, " " * (19 - len(repo)), self.st)) | def print_status(self, repo) | Print status | 6.566795 | 6.526975 | 1.006101 |
print("\nSummary")
print("=" * 79)
cmd = "All repositories are updated."
if self.count_repo == 1:
cmd = "Repository is updated."
if self.count_news > 0:
cmd = "Run the command 'slpkg update'."
print("{0}From {1} repositories need {2} updat... | def summary(self) | Print summary | 6.917491 | 6.609108 | 1.04666 |
# fix passing char '+' from source
source = source.replace("%2B", "+")
with open(source) as file_to_check:
data = file_to_check.read()
return hashlib.md5(data).hexdigest() | def md5(source) | Return MD5 Checksum | 6.29404 | 6.162066 | 1.021417 |
self.msg.resolving()
self.repositories()
if self.find_pkg:
self.dependencies_list.reverse()
self.requires = Utils().dimensional_list(self.dependencies_list)
self.dependencies = Utils().remove_dbs(self.requires)
if self.dependencies == []:
... | def run(self) | Run tracking dependencies | 4.557725 | 4.513076 | 1.009893 |
if self.repo == "sbo":
self.sbo_case_insensitive()
self.find_pkg = sbo_search_pkg(self.name)
if self.find_pkg:
self.dependencies_list = Requires(self.flag).sbo(self.name)
else:
PACKAGES_TXT = Utils().read_file(
self... | def repositories(self) | Get dependencies by repositories | 5.68881 | 5.360168 | 1.061312 |
if "--case-ins" in self.flag:
data = SBoGrep(name="").names()
data_dict = Utils().case_sensitive(data)
for key, value in data_dict.iteritems():
if key == self.name.lower():
self.name = value | def sbo_case_insensitive(self) | Matching packages distinguish between uppercase and
lowercase for sbo repository | 12.328475 | 12.202637 | 1.010312 |
if "--case-ins" in self.flag:
data_dict = Utils().case_sensitive(self.names)
for key, value in data_dict.iteritems():
if key == self.name.lower():
self.name = value | def bin_case_insensitive(self) | Matching packages distinguish between uppercase and
lowercase | 9.240539 | 8.848182 | 1.044343 |
used = []
dep_path = self.meta.log_path + "dep/"
logs = find_package("", dep_path)
for log in logs:
deps = Utils().read_file(dep_path + log)
for dep in deps.splitlines():
if pkg == dep:
used.append(log)
return u... | def check_used(self, pkg) | Check if dependencies used | 5.554692 | 5.160674 | 1.07635 |
dependencies = self.dependencies + [self.name]
if self.repo == "sbo":
for dep in dependencies:
deps = Requires(flag="").sbo(dep)
if dep not in self.deps_dict.values():
self.deps_dict[dep] = Utils().dimensional_list(deps)
el... | def deps_tree(self) | Package dependencies image map file | 5.399815 | 5.45457 | 0.989962 |
if find_package(pkg + self.meta.sp, self.meta.pkg_path):
if pkg not in self.deps_dict.values():
self.deps_dict[pkg] = used
else:
self.deps_dict[pkg] += used | def deps_used(self, pkg, used) | Create dependencies dictionary | 5.207049 | 4.857973 | 1.071856 |
if self.find:
return self.meta.sp + split_package(self.find)[1]
return "" | def version(self) | Return version from installed packages | 23.432646 | 20.259912 | 1.156602 |
__new_version__ = ""
repository = "gitlab"
branch = "master"
ver_link = ("https://raw.{0}usercontent.com/{1}/{2}/"
"{3}/{4}/__metadata__.py".format(repository, _meta_.__author__,
_meta_.__all__, branch,
... | def it_self_update() | Check from GitHub slpkg repository if new version is available
download and update itself | 3.414653 | 3.17563 | 1.075268 |
self.case_insensitive()
# fix if packages is for upgrade
self.is_upgrade = is_upgrade
mas_sum = dep_sum = sums = [0, 0, 0]
self.msg.done()
self.dependencies = self.resolving_deps()
self.update_deps()
(self.dep_dwn, self.dep_install, self.dep_comp_... | def start(self, is_upgrade) | Install packages from official Slackware distribution | 4.249577 | 4.212511 | 1.008799 |
count_inst = 0
for inst in (self.dep_install + self.install):
if (os.path.isfile(self.meta.pkg_path + inst[:-4]) and
"--download-only" not in self.flag):
count_inst += 1
if (count_inst == len(self.dep_install + self.install) and
... | def if_all_installed(self) | Check if all packages is already installed | 5.464934 | 5.03593 | 1.085189 |
if "--case-ins" in self.flag:
data = []
data = Utils().package_name(self.PACKAGES_TXT)
data_dict = Utils().case_sensitive(data)
for pkg in self.packages:
index = self.packages.index(pkg)
for key, value in data_dict.iteritem... | def case_insensitive(self) | Matching packages distinguish between uppercase and
lowercase | 6.595465 | 6.06834 | 1.086865 |
for dep in self.dependencies:
deps = Utils().dimensional_list(Dependencies(
self.repo, self.blacklist).binary(
dep, self.flag))
self.deps_dict[dep] = deps | def update_deps(self) | Update dependencies dictionary with all package | 20.434147 | 17.923231 | 1.140093 |
packages = []
for mas in Utils().remove_dbs(self.packages):
if mas not in self.dependencies:
packages.append(mas)
self.packages = packages | def clear_masters(self) | Clear master packages if already exist in dependencies
or if added to install two or more times | 12.586927 | 9.216483 | 1.365697 |
installs, upgraded = [], []
for inst in (self.dep_install + self.install):
package = (self.tmp_path + inst).split()
pkg_ver = "{0}-{1}".format(split_package(inst)[0],
split_package(inst)[1])
self.checksums(inst)
... | def install_packages(self) | Install or upgrade packages | 4.624161 | 4.558138 | 1.014485 |
name = split_package(package)[0]
rep_ver = split_package(package)[1]
ins_ver = GetFromInstalled(name).version()[1:]
if not ins_ver:
ins_ver = "0"
if LooseVersion(rep_ver) < LooseVersion(ins_ver):
self.msg.template(78)
print("| Package ... | def not_downgrade(self, package) | Don't downgrade packages if repository version is lower than
installed | 7.14815 | 6.267469 | 1.140516 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.