Kaydet (Commit) 9c059fff authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Some inspections

*Cleaned:
- deleted useless backslash
- deleted useless import statements
- deleted recursive and default parameter input
- deleted useless variables
- deleted useless returns
üst cb682c00
......@@ -87,8 +87,7 @@ def configure(parameters=''):
--sysconfdir=/{5} \
--localstatedir=/{6} \
--libexecdir=/{7} \
{8}{9}'.format(prefix, \
get.HOST(), get.manDIR(), get.infoDIR(),
{8}{9}'.format(prefix, get.HOST(), get.manDIR(), get.infoDIR(),
get.dataDIR(), get.confDIR(), get.localstateDIR(), get.libexecDIR(),
"--libdir=/usr/lib32 " if get.buildTYPE() == "emul32" else "",
parameters)
......
# -*- coding: utf-8 -*-
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
# Copyright (C) 2016 - 2018, Suleyman POYRAZ (Zaryob)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
import inary.actionsapi
import inary.util as util
import inary.context as ctx
......
......@@ -16,6 +16,7 @@
# standard library modules
import os
import lzma
import stat
import errno
import shutil
......@@ -64,10 +65,6 @@ class _LZMAProxy(object):
self.init()
def init(self):
try:
import lzma
except ImportError:
from backports import lzma
self.pos = 0
if self.mode == "r":
self.lzmaobj = lzma.LZMADecompressor()
......@@ -266,10 +263,6 @@ class ArchiveLzma(ArchiveBase):
if output_path.endswith(ext):
output_path = output_path[:-len(ext)]
try:
import lzma
except:
from backports import lzma
lzma_file = lzma.LZMAFile(self.file_path, "r")
output = open(output_path, "w")
output.write(lzma_file.read().decode("utf-8"))
......@@ -520,8 +513,7 @@ class ArchiveTar(ArchiveBase):
compresslevel = int(ctx.config.values.build.compressionlevel)
self.tar = TarFile.lzmaopen(self.file_path, "w",
fileobj=self.fileobj,
compresslevel=compresslevel,
compressformat=format
compresslevel=compresslevel
)
else:
raise UnknownArchiveType
......
......@@ -14,16 +14,15 @@
import locale
import sys
import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import inary.errors
import inary.context as ctx
import inary.ui
import inary.util as util
import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
class Error(inary.errors.Error):
pass
......
......@@ -168,7 +168,7 @@ class Command(object):
else:
ui = inary.cli.CLI()
if (write and not os.access(inary.context.config.packages_dir(), os.W_OK) or \
if (write and not os.access(inary.context.config.packages_dir(), os.W_OK) or
('sf' == self.get_name() or 'cp' == self.get_name() and not os.access(
os.path.join(ctx.config.info_dir(), ctx.const.files_db), os.W_OK))):
raise inary.cli.Error(_("You have to be root for this operation."))
......
......@@ -252,7 +252,7 @@ class ConfigurationFile(object):
break
# Comment or blank line?
if line.strip() == '' or line[0] in '#;' or \
(line.split(None, 1)[0].lower() == 'rem' and \
(line.split(None, 1)[0].lower() == 'rem' and
line[0] in "rR"):
current.write(line)
continue
......
......@@ -93,7 +93,7 @@ class InstallDB(lazydb.LazyDB):
def __get_marked_packages(_type):
info_path = os.path.join(ctx.config.info_dir(), _type)
if os.path.exists(info_path):
return open(info_path, "r").read().split()
return open(info_path).read().split()
return []
def __add_to_revdeps(self, package, revdeps):
......
......@@ -189,11 +189,10 @@ class RepoDB(lazydb.LazyDB):
@staticmethod
def get_repo_url(repo):
urifile_path = util.join_path(ctx.config.index_dir(), repo, "uri")
uri = open(urifile_path, "r").read()
uri = open(urifile_path).read()
return uri.rstrip()
def add_repo(self, name, repo_info, at=None):
#Fixme: Fucking at
repo_path = util.join_path(ctx.config.index_dir(), name)
###########
try:
......
......@@ -20,6 +20,7 @@ like all inary classes, it has been programmed in a non-restrictive way
"""
import os
import lzma
import shutil
import gettext
......@@ -96,11 +97,6 @@ class File:
def decompress(localfile, compress):
compress = File.choose_method(localfile, compress)
if compress == File.COMPRESSION_TYPE_XZ:
try:
import lzma
except:
from backports import lzma
open(localfile[:-3], "w").write(lzma.LZMAFile(localfile).read().decode('utf-8'))
localfile = localfile[:-3]
elif compress == File.COMPRESSION_TYPE_BZ2:
......@@ -224,10 +220,6 @@ class File:
compressed_files = []
ctypes = self.compress or 0
if ctypes & File.COMPRESSION_TYPE_XZ:
try:
import lzma
except:
from backports import lzma
compressed_file = self.localfile + ".xz"
compressed_files.append(compressed_file)
lzma_file = lzma.LZMAFile(compressed_file, "w")
......@@ -265,7 +257,7 @@ class File:
sigfilename = File.download(inary.uri.URI(uri + '.sig'), transfer_dir)
except KeyboardInterrupt:
raise
except Exception as e: # FIXME: what exception could we catch here, replace with that.
except Exception: # FIXME: what exception could we catch here, replace with that.
raise NoSignatureFound(uri)
if os.system('gpg --verify ' + sigfilename) != 0:
raise InvalidSignature(uri) # everything is all right here
......
......@@ -340,8 +340,8 @@ def preprocess(infile, outfile=sys.stdout, defines=None,
if __preprocessedFiles is None:
__preprocessedFiles = []
log.info("preprocess(infile=%r, outfile=%r, defines=%r, force=%r, " \
"keepLines=%r, includePath=%r, contentType=%r, " \
log.info("preprocess(infile=%r, outfile=%r, defines=%r, force=%r, "
"keepLines=%r, includePath=%r, contentType=%r, "
"__preprocessedFiles=%r)", infile, outfile, defines, force,
keepLines, includePath, contentType, __preprocessedFiles)
absInfile = os.path.normpath(os.path.abspath(infile))
......@@ -503,7 +503,7 @@ def preprocess(infile, outfile=sys.stdout, defines=None,
expr = match.group("expr")
try:
if states[-1][2]: # already had #else in this if-block
raise PreprocessError("illegal #elif after #else in " \
raise PreprocessError("illegal #elif after #else in "
"same #if block", defines['__FILE__'],
defines['__LINE__'], line)
elif states[-1][1]: # if have emitted in this if-block
......@@ -516,13 +516,13 @@ def preprocess(infile, outfile=sys.stdout, defines=None,
else:
states[-1] = (SKIP, 0, 0)
except IndexError:
raise PreprocessError("#elif stmt without leading #if " \
raise PreprocessError("#elif stmt without leading #if "
"stmt", defines['__FILE__'],
defines['__LINE__'], line)
elif op == "else":
try:
if states[-1][2]: # already had #else in this if-block
raise PreprocessError("illegal #else after #else in " \
raise PreprocessError("illegal #else after #else in "
"same #if block", defines['__FILE__'],
defines['__LINE__'], line)
elif states[-1][1]: # if have emitted in this if-block
......@@ -533,14 +533,14 @@ def preprocess(infile, outfile=sys.stdout, defines=None,
else:
states[-1] = (EMIT, 1, 1)
except IndexError:
raise PreprocessError("#else stmt without leading #if " \
raise PreprocessError("#else stmt without leading #if "
"stmt", defines['__FILE__'],
defines['__LINE__'], line)
elif op == "endif":
try:
states.pop()
except IndexError:
raise PreprocessError("#endif stmt without leading #if" \
raise PreprocessError("#endif stmt without leading #if"
"stmt", defines['__FILE__'],
defines['__LINE__'], line)
elif op == "error":
......@@ -731,7 +731,7 @@ class ContentTypesRegistry:
# Try to determine from the path.
if not contentType and basename in self.filenameMap:
contentType = self.filenameMap[basename]
log.debug("Content type of '%s' is '%s' (determined from full " \
log.debug("Content type of '%s' is '%s' (determined from full "
"path).", path, contentType)
# Try to determine from the suffix.
if not contentType and '.' in basename:
......@@ -741,7 +741,7 @@ class ContentTypesRegistry:
suffix = suffix.lower()
if suffix in self.suffixMap:
contentType = self.suffixMap[suffix]
log.debug("Content type of '%s' is '%s' (determined from " \
log.debug("Content type of '%s' is '%s' (determined from "
"suffix '%s').", path, contentType, suffix)
# Try to determine from the registered set of regex patterns.
if not contentType:
......
......@@ -11,3 +11,12 @@
#
# Please read the COPYING file.
#
import inary.errors
class Error(inary.errors.Error):
pass
class Exception(inary.errors.Exception):
pass
......@@ -26,7 +26,7 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import inary
import inary.errors
import inary.data.specfile as Specfile
import inary.util as util
import inary.file
......
......@@ -31,7 +31,7 @@ import inary.data
def emerge(A):
"""
Builds and installs the given packages from source
@param packages: list of package names -> list_of_strings
@param A: list of package names -> list_of_strings
"""
inary.db.historydb.HistoryDB().create_history("emerge")
......
......@@ -87,8 +87,6 @@ def install_pkg_names(A, reinstall=False, extra=False):
ctx.ui.notify(ui.packagestogo, order=order)
ignore_dep = ctx.config.get_option('ignore_dependency') # Fixme: Fuck
conflicts = []
if not ctx.get_option('ignore_package_conflicts'):
conflicts = operations.helper.check_conflicts(order, packagedb)
......@@ -180,7 +178,7 @@ def install_pkg_files(package_URIs, reinstall=False):
pkg = d_t[x]
if pkg.distributionRelease != ctx.config.values.general.distribution_release:
raise Exception(_('Package {0} is not compatible with your distribution release {1} {2}.').format(
x, ctx.config.values.general.distribution, \
x, ctx.config.values.general.distribution,
ctx.config.values.general.distribution_release))
if pkg.architecture != ctx.config.values.general.architecture:
raise Exception(
......
......@@ -53,7 +53,7 @@ def remove(A, ignore_dep=False, ignore_safety=False):
raise inary.errors.Error(_("Safety switch prevents the removal of "
"following packages:\n") +
util.format_by_columns(sorted(refused)))
A = A - systembase
A -= systembase
else:
ctx.ui.warning(_("Safety switch: The component system.base cannot be found."))
......
......@@ -73,7 +73,7 @@ def search_file(term):
@param term: used to search file -> list_of_strings
>>> import inary.operations
>>> files = inary.operation.search.search_file("kvm-")
>>> files = inary.operations.search.search_file("kvm-")
>>> print files
......
......@@ -183,8 +183,6 @@ def addNode(node, tagpath, newnode=None, branch=True):
# had only one tag..
return addTagPath(node, tags, newnode)
return node
def addText(node, tagpath, text):
node = addNode(node, tagpath)
......
......@@ -59,8 +59,8 @@ def parseString(fileString):
dom = minidom.parseString(fileString)
return dom.documentElement
except ExpatError as inst:
raise XMLError(_("File '{}' has invalid XML: {}\n").format(fileName,
str(inst)))
raise XMLError(_("FileString is an invalid XML: {}\nFileScript: {}\n").format(
str(inst),fileString))
def getAllNodes(node, tagPath):
......@@ -207,9 +207,6 @@ def addNode(node, tagpath, newnode=None, branch=True):
# had only one tag..
return addTagPath(node, tags, newnode)
return node
def addText(node, tagPath, text, branch=True):
newnode = node.ownerDocument.createTextNode(text)
return addNode(node, tagPath, newnode, branch=branch)
......
......@@ -15,7 +15,6 @@
"""Simplifies working with URLs, purl module provides common URL
parsing and processing"""
import gettext
import os.path
import urllib.parse
......
......@@ -102,7 +102,7 @@ class Install(install):
def run(self):
install.run(self)
self.installi18n()
self.installdoc()
#self.installdoc()
self.generateConfigFile()
def installi18n(self):
......@@ -201,8 +201,7 @@ setup(name="inary",
'inary.db',
'inary.libraries',
'inary.operations',
'inary.sxml',
'inary.scenarioapi'],
'inary.sxml'],
cmdclass = {'build' : Build,
'build_po' : BuildPo,
'install' : Install,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment