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