Commit ffd66c90 authored by Julian Andres Klode's avatar Julian Andres Klode
Browse files

Remove `if True` and dedent

Code cleanup I did not want to mix with the actual work.

Gbp-Dch: ignore
parent aa412176
......@@ -265,92 +265,91 @@ class DistInfo(object):
dist_fname = "%s/%s.info" % (base_dir, dist)
csv_fname = "/usr/share/distro-info/{}.csv".format(dist.lower())
if True:
template = None
component = None
for line in _expand_template(dist_fname, csv_fname):
tokens = line.split(':', 1)
if len(tokens) < 2:
continue
field = tokens[0].strip()
value = tokens[1].strip()
if field == 'ChangelogURI':
self.changelogs_uri = _(value)
elif field == 'MetaReleaseURI':
self.metarelease_uri = value
elif field == 'Suite':
self.finish_template(template, component)
component = None
template = Template()
template.name = value
template.distribution = dist
template.match_name = "^%s$" % value
elif field == 'MatchName':
template.match_name = value
elif field == 'ParentSuite':
template.child = True
for nanny in self.templates:
# look for parent and add back ref to it
if nanny.name == value:
template.parents.append(nanny)
nanny.children.append(template)
elif field == 'Available':
template.available = apt_pkg.string_to_bool(value)
elif field == 'Official':
template.official = apt_pkg.string_to_bool(value)
elif field == 'RepositoryType':
template.type = value
elif field == 'BaseURI' and not template.base_uri:
template.base_uri = value
elif field == 'BaseURI-%s' % self.arch:
template.base_uri = value
elif field == 'MatchURI' and not template.match_uri:
template.match_uri = value
elif field == 'MatchURI-%s' % self.arch:
template.match_uri = value
elif (field == 'MirrorsFile' or
field == 'MirrorsFile-%s' % self.arch):
# Make the path absolute.
value = os.path.isabs(value) and value or \
os.path.abspath(os.path.join(base_dir, value))
if value not in map_mirror_sets:
mirror_set = {}
try:
with open(value) as value_f:
mirror_data = list(filter(
match_mirror_line.match,
[x.strip() for x in value_f]))
except Exception:
print("WARNING: Failed to read mirror file")
mirror_data = []
for line in mirror_data:
if line.startswith("#LOC:"):
location = match_loc.sub(r"\1", line)
continue
(proto, hostname, dir) = split_url(line)
if hostname in mirror_set:
mirror_set[hostname].add_repository(proto, dir)
else:
mirror_set[hostname] = Mirror(
proto, hostname, dir, location)
map_mirror_sets[value] = mirror_set
template.mirror_set = map_mirror_sets[value]
elif field == 'Description':
template.description = _(value)
elif field == 'Component':
if (component and not
template.has_component(component.name)):
template.components.append(component)
component = Component(value)
elif field == 'CompDescription':
component.set_description(_(value))
elif field == 'CompDescriptionLong':
component.set_description_long(_(value))
elif field == 'ParentComponent':
component.set_parent_component(value)
self.finish_template(template, component)
template = None
component = None
template = None
component = None
for line in _expand_template(dist_fname, csv_fname):
tokens = line.split(':', 1)
if len(tokens) < 2:
continue
field = tokens[0].strip()
value = tokens[1].strip()
if field == 'ChangelogURI':
self.changelogs_uri = _(value)
elif field == 'MetaReleaseURI':
self.metarelease_uri = value
elif field == 'Suite':
self.finish_template(template, component)
component = None
template = Template()
template.name = value
template.distribution = dist
template.match_name = "^%s$" % value
elif field == 'MatchName':
template.match_name = value
elif field == 'ParentSuite':
template.child = True
for nanny in self.templates:
# look for parent and add back ref to it
if nanny.name == value:
template.parents.append(nanny)
nanny.children.append(template)
elif field == 'Available':
template.available = apt_pkg.string_to_bool(value)
elif field == 'Official':
template.official = apt_pkg.string_to_bool(value)
elif field == 'RepositoryType':
template.type = value
elif field == 'BaseURI' and not template.base_uri:
template.base_uri = value
elif field == 'BaseURI-%s' % self.arch:
template.base_uri = value
elif field == 'MatchURI' and not template.match_uri:
template.match_uri = value
elif field == 'MatchURI-%s' % self.arch:
template.match_uri = value
elif (field == 'MirrorsFile' or
field == 'MirrorsFile-%s' % self.arch):
# Make the path absolute.
value = os.path.isabs(value) and value or \
os.path.abspath(os.path.join(base_dir, value))
if value not in map_mirror_sets:
mirror_set = {}
try:
with open(value) as value_f:
mirror_data = list(filter(
match_mirror_line.match,
[x.strip() for x in value_f]))
except Exception:
print("WARNING: Failed to read mirror file")
mirror_data = []
for line in mirror_data:
if line.startswith("#LOC:"):
location = match_loc.sub(r"\1", line)
continue
(proto, hostname, dir) = split_url(line)
if hostname in mirror_set:
mirror_set[hostname].add_repository(proto, dir)
else:
mirror_set[hostname] = Mirror(
proto, hostname, dir, location)
map_mirror_sets[value] = mirror_set
template.mirror_set = map_mirror_sets[value]
elif field == 'Description':
template.description = _(value)
elif field == 'Component':
if (component and not
template.has_component(component.name)):
template.components.append(component)
component = Component(value)
elif field == 'CompDescription':
component.set_description(_(value))
elif field == 'CompDescriptionLong':
component.set_description_long(_(value))
elif field == 'ParentComponent':
component.set_parent_component(value)
self.finish_template(template, component)
template = None
component = None
def finish_template(self, template, component):
" finish the current tempalte "
......
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