updated to python 3

master
idziubenko 2 years ago
parent e00d77ae28
commit 1026cc2dd3

@ -14,7 +14,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import argparse
import sys
import re
@ -75,7 +74,7 @@ class PackageDb(object):
for fn in listDirectory(path.join(rep_dn,"profiles/updates"),
fullPath=True):
for line in (x for x in readLinesFile(fn) if x.startswith("move ")):
words = filter(None, line.split())
words = [x for x in line.split() if x]
if len(words) == 3:
self.renames[words[1]] = words[2]
@ -103,8 +102,12 @@ class ScanTemplates(object):
patch_dirs = []
for root, dirs, files in os.walk(dn):
for fn in (path.join(root,x) for x in files):
data = readFile(fn)
for fname, pkg in self.reMerge.findall(data):
data = readFile(fn, binary=True)
try:
data_decoded = data.decode("UTF-8")
except UnicodeDecodeError as e:
continue
for fname, pkg in self.reMerge.findall(data_decoded):
pkg = pkg or get_pkgname_by_filename(fn)
if pkg not in self.db:
self._check_pkg(pkg, fname, fn)
@ -131,8 +134,12 @@ class ScanTemplates(object):
for root, dirs, files in os.walk(dn):
for fn in (path.join(root,x) for x in files
if x.endswith(self.CLT_SUFFIX)):
data = readFile(fn)
for fname, pkg in self.reMerge.findall(data):
data = readFile(fn, binary=True)
try:
data_decoded = data.decode("UTF-8")
except UnicodeDecodeError as e:
continue
for fname, pkg in self.reMerge.findall(data_decoded):
pkg = pkg or get_pkgname_by_filename(fn)
self._check_pkg(pkg, fname, fn)

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2017 Mir Calculate. http://www.calculate-linux.org

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2017 Mir Calculate. http://www.calculate-linux.org

Loading…
Cancel
Save