def build_mirror_list(self): def build_mirror_list(self, number): def build_mirror_list(self): URL_MIRROR_JSON = \
    "https://github.com/manjaro/manjaro-web-repo/raw/master/mirrors.json"
URL_STATUS_JSON = "http://repo.manjaro.org/status.json"
INET_CONN_CHECK_URLS = ["https://wikipedia.org",
                        "https://github.com",
                        "https://bitbucket.org"]
CONFIG_FILE = "/etc/pacman-mirrors.conf"
MIRROR_LIST = "/etc/pacman.d/mirrorlist"
WORK_DIR = "/var/lib/pacman-mirrors/"
USR_DIR = "/usr/share/pacman-mirrors"
CUSTOM_FILE = "/var/lib/pacman-mirrors/custom-mirrors.json"
MIRROR_FILE = "/usr/share/pacman-mirrors/mirrors.json"
STATUS_FILE = "/var/lib/pacman-mirrors/status.json"
BRANCHES = ("stable", "testing", "unstable")
X32_BRANCHES = ("x32-stable", "x32-testing", "x32-unstable")
PROTOCOLS = ("https", "http", "ftp", "ftps")
METHODS = ("rank", "random")
SSL = ("True", "False")
REPO_ARCH = "/$repo/$arch"
O_CUST_FILE = "/var/lib/pacman-mirrors/Custom"
TO_BE_REMOVED = "/var/lib/pacman-mirrors/mirrors.json" def parse_command_line(self, gtk_available): def setup_config():
def sanitize_config(config): def load_config_mirror_pool(self):
def load_default_mirror_pool(self):
def seed_mirrors(self, file, status=False):
def sort_mirror_countries(self): def check_existance_of(filename, folder=False):
def create_dir(foldername):
def delete_file(filename):
def return_mirror_filename(config):
def write_mirror_list(config, servers, custom=False,
                      quiet=False, interactive=False):
def read_mirror_file(filename):
def write_mirrorlist_header(handle, custom=False):
def write_mirrorlist_entry(handle, mirror): def download_mirrors(config):
def get_geoip_country():
def get_mirror_response(url, maxwait=2, count=1, quiet=False, ssl_verify=True):
def inet_conn_check(maxwait=2):
def ping_host(host, count=1):
def update_mirror_pool(config, quiet=False): def extract_mirror_url(data):
def get_country(data):
def get_protocol(data):
def get_protocol_from_url(url):
def get_server_location_from_url(url):
def i686_check(self, write=False):
def internet_message():
def terminal_size(): class Mirror:
    """Mirror Class"""

    def __init__(self):
        self.country_pool = []
        self.mirror_pool = []

    def add(self, country, url, protocols,
            branches=None, last_sync=None, resp_time=None):
        """Append mirror
        :param country:
        :param url:
        :param protocols:
        :param branches: optional from status.json
        :param last_sync: optional from status.json
        :param resp_time: optional from status.json
        """
        if last_sync is None:
            last_sync = "00:00"
        if resp_time is None:
            resp_time = "00.00"
        if branches is None:
            branches = [-1, -1, -1]
        if country not in self.country_pool:
            self.country_pool.append(country)
        # translate negative integer in status.json
        if last_sync == -1:
            last_sync = txt.SERVER_BAD
            resp_time = txt.SERVER_RES
        # sort protocols in reversed order https,http,ftps,ftp
        protocols = sorted(protocols, reverse=True)
        mirror = {
            "branches": branches,
            "country": country,
            "last_sync": last_sync,
            "protocols": protocols,
            "resp_time": resp_time,
            "url": url
        }
        self.mirror_pool.append(mirror)

    def seed(self, servers, status=False, custom=False):
        """
        Seed mirrorlist
        :param servers:
        :param status:
        :param custom:
        """
        if custom:  # clear previous data
            self.country_pool = []
            self.mirror_pool = []
        for server in servers:
            if status:
                self.add(server["country"],
                         server["url"],
                         server["protocols"],
                         server["branches"],
                         server["last_sync"])
            else:
                self.add(server["country"],
                         server["url"],
                         server["protocols"]) APP_NAME = "pacman_mirrors"
APP_DIR = os.path.join(sys.prefix, "share")
LOCALE_DIR = os.path.join(APP_DIR, "locale")
LANGUAGES = []
import importlib.util
import sys
import pacman_mirrors.functions.util
from pacman_mirrors.builder import common, fasttrack, interactive
from pacman_mirrors.config import configuration as conf
from pacman_mirrors.functions import cliFn
from pacman_mirrors.functions import configFn
from pacman_mirrors.functions import defaultFn
from pacman_mirrors.functions import fileFn
from pacman_mirrors.functions import httpFn
from pacman_mirrors.functions import util
from pacman_mirrors.mirrors.mirror import Mirror
from pacman_mirrors.translation import i18n
#!/usr/bin/env python
#
# This file is part of pacman-mirrors.
#
# pacman-mirrors is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pacman-mirrors is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pacman-mirrors.  If not, see <http://www.gnu.org/licenses/>.
#
# Authors: Esclapion <esclapion@manjaro.org>
#          philm <philm@manjaro.org>
#          Ramon Buldó <rbuldo@gmail.com>
#          Hugo Posnic <huluti@manjaro.org>
#          Frede Hundewadt <echo ZmhAbWFuamFyby5vcmcK | base64 -d>

"""Pacman-Mirrors Main Module"""




try:
    importlib.util.find_spec("gi.repository.Gtk")
except ImportError:
    GTK_AVAILABLE = False
else:
    GTK_AVAILABLE = True
_ = i18n.language.gettext


class PacmanMirrors:
    """Class PacmanMirrors"""

    def __init__(self):
        """Init"""
        self.config = {
            "config_file": conf.CONFIG_FILE
        }
        self.custom = False
        self.default = False
        self.fasttrack = None
        self.geoip = False
        self.interactive = False
        self.max_wait_time = 2
        self.mirrors = Mirror()
        self.network = True
        self.no_display = False
        self.no_mirrorlist = False
        self.no_status = False
        self.quiet = False
        self.selected_countries = []

    def run(self):
        """
        Run
        # Setup config: retunrs the config dictionary and true/false on custom
        # Parse commandline
        # i686 check - change branch to x32-$branch
        # sanitize config
        # Check network
        # Update mirror pool
        # Check if mirrorlist is not to be touched - normal exit
        # Handle missing network
        # Load default mirror pool
        # Build mirror list
        """
        (self.config, self.custom) = configFn.setup_config()
        fileFn.create_dir(self.config["work_dir"])

        cliFn.parse_command_line(self, GTK_AVAILABLE)