import logging
import glob
+# Third party modules
+import six
+
from distutils.version import LooseVersion
# portage stuff
print('---------------------------------------------------')
log.info("Performing %r ...", filename)
+ new_lines = []
+
with open(filename, 'rt') as fh:
line_nr = 0
for line in fh.readlines():
line_nr += 1
if self.re_empty_line.search(line) or self.re_comment.search(line):
+ new_lines.append(line.strip())
continue
match = self.re_line_keywords.search(line)
if not match:
log.error(
'Invalid line %r in %r (%d) found.', line.rstrip(),
filename, line_nr)
+ new_lines.append('# ' + line.strip())
continue
mypkg = match.group(1)
if self.verbose:
log.error(
'Invalid atom %r in %r (%d) found.', mypkg,
filename, line_nr)
+ new_lines.append('# ' + line.strip())
continue
log.debug("Checking atom %r in %r (%d) ...", mypkg,
filename, line_nr)
log.error(
'Invalid Package name %r in %r (%d) found.', mypkg,
filename, line_nr)
+ new_lines.append('# ' + line.strip())
continue
valid = None
if isjustname(my_cpv):
if valid:
log.debug("Atom %r in %r (%d) seems to be valid.", mypkg,
filename, line_nr)
+ new_lines.append(line.strip())
else:
log.warning("Atom %r in %r (%d) seems to be invalid.", mypkg,
filename, line_nr)
+ new_lines.append('# ' + line.strip())
+
+ print('')
+ print('----------')
+ log.info("Rewriting %r ...", filename)
+ if self.simulate:
+ if self.verbose:
+ for line in new_lines:
+ print(line)
+ else:
+ open_opts = {}
+ if six.PY3:
+ open_opts['encoding'] = 'utf-8'
+ with open(filename, 'wt', **open_opts) as fh:
+ for line in new_lines:
+ if self.verbose:
+ print(line)
+ fh.write(line + '\n')
# -------------------------------------------------------------------------
def check_package(self, package, slot, version, release, operator):
package, slot, version, release, operator)
pkg_dirs_glob = os.path.join(self.pkg_dir, package + '-[0-9]*')
+ if self.verbose > 2:
+ log.info("Searching installed package by %r ...", pkg_dirs_glob)
pkg_dirs = glob.glob(pkg_dirs_glob)
if not pkg_dirs:
log.info("Package %r seems not to be installed.", package)