Skip to content

Commit

Permalink
calculate some things that will not change just once
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhudson committed Feb 3, 2020
1 parent 7ded7c1 commit 52fc18b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions subiquity/models/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
],
}


def get_default_mirror():
return get_mirror(DEFAULT, "primary", get_architecture())
ARCHITECTURE = get_architecture()
DEFAULT_MIRROR = get_mirror(DEFAULT, "primary", ARCHITECTURE)


class MirrorModel(object):
Expand All @@ -53,21 +52,20 @@ def __init__(self):

def set_country(self, cc):
uri = self.get_mirror()
if uri != get_default_mirror():
if uri != DEFAULT_MIRROR:
return
parsed = parse.urlparse(uri)
new = parsed._replace(netloc=cc + '.' + parsed.netloc)
self.set_mirror(parse.urlunparse(new))

def get_mirror(self):
return get_mirror(self.config, "primary", get_architecture())
return get_mirror(self.config, "primary", ARCHITECTURE)

def set_mirror(self, mirror):
config = get_arch_mirrorconfig(
self.config, "primary", get_architecture())
config = get_arch_mirrorconfig(self.config, "primary", ARCHITECTURE)
config["uri"] = mirror

def render(self):
return {
'apt': self.config
'apt': copy.deepcopy(self.config)
}

0 comments on commit 52fc18b

Please sign in to comment.