Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/checks/directories/
Date: Mon, 02 Jun 2014 06:05:05
Message-Id: 1401689067.1369a76925496f835dd7076029926f57f9605f8a.dol-sen@gentoo
1 commit: 1369a76925496f835dd7076029926f57f9605f8a
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jun 2 06:04:27 2014 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Mon Jun 2 06:04:27 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1369a769
7
8 repoman/main.py: Create FileChecks class
9
10 Move file checks code block to a new checks/directories/ module
11
12 ---
13 pym/repoman/checks/directories/__init__.py | 0
14 pym/repoman/checks/directories/files.py | 77 ++++++++++++++++++++++++++++++
15 pym/repoman/main.py | 48 +++----------------
16 3 files changed, 84 insertions(+), 41 deletions(-)
17
18 diff --git a/pym/repoman/checks/directories/__init__.py b/pym/repoman/checks/directories/__init__.py
19 new file mode 100644
20 index 0000000..e69de29
21
22 diff --git a/pym/repoman/checks/directories/files.py b/pym/repoman/checks/directories/files.py
23 new file mode 100644
24 index 0000000..62f6169
25 --- /dev/null
26 +++ b/pym/repoman/checks/directories/files.py
27 @@ -0,0 +1,77 @@
28 +
29 +'''repoman/checks/diretories/files.py
30 +
31 +'''
32 +
33 +import io
34 +
35 +from portage import _encodings, _unicode_encode
36 +from portage import os
37 +
38 +
39 +
40 +class FileChecks(object):
41 +
42 + def __init__(self, qatracker, repoman_settings, repo_settings, portdb,
43 + vcs_settings, vcs_new_changed):
44 + '''
45 + @param qatracker: QATracker instance
46 + @param repoman_settings: settings instance
47 + @param repo_settings: repository settings instance
48 + @param portdb: portdb instance
49 + '''
50 + self.portdb = portdb
51 + self.qatracker = qatracker
52 + self.repo_settings = repo_settings
53 + self.repoman_settings = repoman_settings
54 + self.vcs_settings = vcs_settings
55 + self.vcs_new_changed = vcs_new_changed
56 +
57 +
58 + def check(self, checkdir, checkdirlist, checkdir_relative):
59 + '''Checks the ebuild sources and files for errors
60 +
61 + @param xpkg: the pacakge being checked
62 + @param checkdir: string, directory path
63 + @param checkdir_relative: repolevel determined path
64 + '''
65 + for y_file in checkdirlist:
66 + index = self.repo_settings.repo_config.find_invalid_path_char(y_file)
67 + if index != -1:
68 + y_relative = os.path.join(checkdir_relative, y_file)
69 + if self.vcs_settings.vcs is not None and not self.vcs_new_changed(y_relative):
70 + # If the file isn't in the VCS new or changed set, then
71 + # assume that it's an irrelevant temporary file (Manifest
72 + # entries are not generated for file names containing
73 + # prohibited characters). See bug #406877.
74 + index = -1
75 + if index != -1:
76 + self.qatracker.add_error("file.name",
77 + "%s/%s: char '%s'" % (checkdir, y_file, y_file[index]))
78 +
79 + if not (y_file in ("ChangeLog", "metadata.xml")
80 + or y_file.endswith(".ebuild")):
81 + continue
82 + f = None
83 + try:
84 + line = 1
85 + f = io.open(
86 + _unicode_encode(
87 + os.path.join(checkdir, y_file),
88 + encoding=_encodings['fs'], errors='strict'),
89 + mode='r', encoding=_encodings['repo.content'])
90 + for l in f:
91 + line += 1
92 + except UnicodeDecodeError as ue:
93 + s = ue.object[:ue.start]
94 + l2 = s.count("\n")
95 + line += l2
96 + if l2 != 0:
97 + s = s[s.rfind("\n") + 1:]
98 + self.qatracker.add_error("file.UTF8",
99 + "%s/%s: line %i, just after: '%s'" % (checkdir, y_file, line, s))
100 + finally:
101 + if f is not None:
102 + f.close()
103 + return
104 +
105
106 diff --git a/pym/repoman/main.py b/pym/repoman/main.py
107 index ffb9929..9db52c0 100755
108 --- a/pym/repoman/main.py
109 +++ b/pym/repoman/main.py
110 @@ -45,6 +45,7 @@ from portage.package.ebuild.digestgen import digestgen
111 from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
112
113 from repoman.argparser import parse_args
114 +from repoman.checks.directories.files import FileChecks
115 from repoman.checks.ebuilds.checks import run_checks, checks_init
116 from repoman.checks.ebuilds.fetches import FetchChecks
117 from repoman.checks.ebuilds.isebuild import IsEbuild
118 @@ -325,50 +326,15 @@ for xpkg in effective_scanlist:
119 # Sort ebuilds in ascending order for the KEYWORDS.dropped check.
120 ebuildlist = sorted(pkgs.values())
121 ebuildlist = [pkg.pf for pkg in ebuildlist]
122 -
123 - for y in checkdirlist:
124 - index = repo_settings.repo_config.find_invalid_path_char(y)
125 - if index != -1:
126 - y_relative = os.path.join(checkdir_relative, y)
127 - if vcs_settings.vcs is not None and not vcs_new_changed(y_relative):
128 - # If the file isn't in the VCS new or changed set, then
129 - # assume that it's an irrelevant temporary file (Manifest
130 - # entries are not generated for file names containing
131 - # prohibited characters). See bug #406877.
132 - index = -1
133 - if index != -1:
134 - qatracker.add_error("file.name",
135 - "%s/%s: char '%s'" % (checkdir, y, y[index]))
136 -
137 - if not (y in ("ChangeLog", "metadata.xml") or y.endswith(".ebuild")):
138 - continue
139 - f = None
140 - try:
141 - line = 1
142 - f = io.open(
143 - _unicode_encode(
144 - os.path.join(checkdir, y),
145 - encoding=_encodings['fs'], errors='strict'),
146 - mode='r', encoding=_encodings['repo.content'])
147 - for l in f:
148 - line += 1
149 - except UnicodeDecodeError as ue:
150 - s = ue.object[:ue.start]
151 - l2 = s.count("\n")
152 - line += l2
153 - if l2 != 0:
154 - s = s[s.rfind("\n") + 1:]
155 - qatracker.add_error("file.UTF8",
156 - "%s/%s: line %i, just after: '%s'" % (checkdir, y, line, s))
157 - finally:
158 - if f is not None:
159 - f.close()
160 -
161 -###############
162 +#######################
163 + filescheck = FileChecks(qatracker, repoman_settings, repo_settings, portdb,
164 + vcs_settings, vcs_new_changed)
165 + filescheck.check(checkdir, checkdirlist, checkdir_relative)
166 +#######################
167 status_check = VCSStatus(vcs_settings, checkdir, checkdir_relative, xpkg, qatracker)
168 status_check.check(check_ebuild_notadded)
169 eadded.extend(status_check.eadded)
170 -###############
171 +
172 #################
173 fetchcheck = FetchChecks(qatracker, repoman_settings, repo_settings, portdb,
174 vcs_settings, vcs_new_changed)