def GetShip():
     strengths = Locale.text()["ship"]["strengths"]
     weaknesses = Locale.text()["ship"]["weaknesses"]
     ar = []
     i = 0
     while i < 2:
         choice = random.choice(strengths)
         strengths.remove(choice)
         ar.append(choice)
         i += 1
     ar.append(random.choice(weaknesses))
     return ar
    def read_from_ini(cls, ini_file_path):
        translator = CustomTranslator()
        locale = Locale.get_locale()

        dir_path = os.path.abspath(os.path.join(ini_file_path, os.path.pardir))
        ini_file = codecs.open(ini_file_path, 'r', 'utf-8')

        parser = ConfigParser()
        parser.readfp(ini_file)

        ds = DataSourceInfo()

        # Required
        ds.id = ConfigReaderHelper.try_read_config(parser, 'general', 'id', reraise=True)
        ds.type = ConfigReaderHelper.try_read_config(parser, 'general', 'type', reraise=True)

        ds.group = ConfigReaderHelper.try_read_config(parser, 'ui', 'group', reraise=True)
        ds.alias = ConfigReaderHelper.try_read_config(parser, 'ui', 'alias', reraise=True)
        ds.icon = ConfigReaderHelper.try_read_config(parser, 'ui', 'icon')

        # Lic & Terms
        ds.lic_name = ConfigReaderHelper.try_read_config(parser, 'license', 'name')
        ds.lic_link = ConfigReaderHelper.try_read_config(parser, 'license', 'link')
        ds.copyright_text = ConfigReaderHelper.try_read_config(parser, 'license', 'copyright_text')
        ds.copyright_link = ConfigReaderHelper.try_read_config(parser, 'license', 'copyright_link')
        ds.terms_of_use = ConfigReaderHelper.try_read_config(parser, 'license', 'terms_of_use')

        #TMS
        ds.tms_url = ConfigReaderHelper.try_read_config(parser, 'tms', 'url', reraise=(ds.type == KNOWN_DRIVERS.TMS))
        ds.tms_zmin = ConfigReaderHelper.try_read_config_int(parser, 'tms', 'zmin')
        ds.tms_zmax = ConfigReaderHelper.try_read_config_int(parser, 'tms', 'zmax')
        ds.tms_y_origin_top = ConfigReaderHelper.try_read_config_int(parser, 'tms', 'y_origin_top')
        ds.tms_epsg_crs_id = ConfigReaderHelper.try_read_config_int(parser, 'tms', 'epsg_crs_id')
        ds.tms_postgis_crs_id = ConfigReaderHelper.try_read_config_int(parser, 'tms', 'postgis_crs_id')
        ds.tms_custom_proj = ConfigReaderHelper.try_read_config(parser, 'tms', 'custom_proj')

        #WMS
        ds.wms_url = ConfigReaderHelper.try_read_config(parser, 'wms', 'url', reraise=(ds.type == KNOWN_DRIVERS.WMS))
        ds.wms_params = ConfigReaderHelper.try_read_config(parser, 'wms', 'params')
        ds.wms_layers = ConfigReaderHelper.try_read_config(parser, 'wms', 'layers')
        ds.wms_turn_over = ConfigReaderHelper.try_read_config_bool(parser, 'wms', 'turn_over')

        #GDAL
        if ds.type == KNOWN_DRIVERS.GDAL:
            gdal_conf = ConfigReaderHelper.try_read_config(parser, 'gdal', 'source_file', reraise=(ds.type == KNOWN_DRIVERS.GDAL))
            ds.gdal_source_file = os.path.join(dir_path, gdal_conf)

        #try read translations
        posible_trans = parser.items('ui')
        for key, val in posible_trans:
            if type(key) is unicode and key == 'alias[%s]' % locale:
                translator.append(ds.alias, val)
                break

        #internal stuff
        ds.file_path = ini_file_path
        ds.icon_path = os.path.join(dir_path, ds.icon) if ds.icon else None

        return ds
 def GetHeroes(numHeroes):
     styles = Locale.text()["hero"]["styles"]
     roles = Locale.text()["hero"]["roles"]
     numbers = [2, 3, 4, 5]
     goals = Locale.text()["hero"]["goals"]
     arHeroes = []
     for x in range(numHeroes):
         #only allows this role once
         role = random.choice(roles)
         roles.remove(role)
         name = Logic.GetName()
         style = random.choice(styles)
         number = random.choice(numbers)
         lof = Locale.text()[("lasers" if number > 3 else "feelings")]
         lofRating = f'{Locale.text()["high"]} ' if number == 2 or number == 5 else ""
         goal = random.choice(goals)
         arHeroes.append(
             f'{name} ({number}, {lofRating}{lof}) {style} {role}, {Locale.text()["goal"]}: {goal}'
         )
     return arHeroes
Ejemplo n.º 4
0
    def __init__(self, iface):
        """Constructor.

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__).decode(
            sys.getfilesystemencoding())

        # initialize locale
        self.translator = QTranslator()

        self.locale = Locale.get_locale()
        locale_path = os.path.join(
            self.plugin_dir, 'i18n',
            'QuickMapServices_{}.qm'.format(self.locale))
        if os.path.exists(locale_path):
            self.translator.load(locale_path)
            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        self.custom_translator = CustomTranslator()
        QCoreApplication.installTranslator(self.custom_translator)

        # Create the dialog (after translation) and keep reference
        self.info_dlg = AboutDialog()

        # Check Contrib and User dirs
        try:
            ExtraSources.check_extra_dirs()
        except:
            error_message = self.tr(
                'Extra dirs for %s can\'t be created: %s %s') % (
                    PluginSettings.product_name(), sys.exc_type, sys.exc_value)
            self.iface.messageBar().pushMessage(self.tr('Error'),
                                                error_message,
                                                level=QgsMessageBar.CRITICAL)

        # Declare instance attributes
        self.service_actions = []
        self.service_layers = []  # TODO: id and smart remove
        self._scales_list = None
    def __init__(self, iface):
        """Constructor.

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)

        # initialize locale
        self.translator = QTranslator()

        self.locale = Locale.get_locale()
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'QuickMapServices_{}.qm'.format(self.locale))
        if os.path.exists(locale_path):
            self.translator.load(locale_path)
            if qVersion() > '4.3.3':
                QCoreApplication.installTranslator(self.translator)

        self.custom_translator = CustomTranslator()
        QCoreApplication.installTranslator(self.custom_translator)

        # Create the dialog (after translation) and keep reference
        self.info_dlg = AboutDialog()

        # Check Contrib and User dirs
        try:
            ExtraSources.check_extra_dirs()
        except:
            error_message = self.tr('Extra dirs for %s can\'t be created: %s %s') % (PluginSettings.product_name(),
                                                                                      sys.exc_type,
                                                                                      sys.exc_value)
            self.iface.messageBar().pushMessage(self.tr('Error'),
                                                error_message,
                                                level=QgsMessageBar.CRITICAL)

        # Declare instance attributes
        self.service_actions = []
        self.service_layers = []  # TODO: id and smart remove
        self._scales_list = None
    def read_from_ini(cls, ini_file_path):
        translator = CustomTranslator()
        locale = Locale.get_locale()

        dir_path = os.path.abspath(os.path.join(ini_file_path, os.path.pardir))
        ini_file = codecs.open(ini_file_path, "r", "utf-8")

        parser = ConfigParser()
        parser.readfp(ini_file)

        ds = DataSourceInfo()

        # Required
        ds.id = ConfigReaderHelper.try_read_config(parser, "general", "id", reraise=True)
        ds.type = ConfigReaderHelper.try_read_config(parser, "general", "type", reraise=True)

        ds.group = ConfigReaderHelper.try_read_config(parser, "ui", "group", reraise=True)
        ds.alias = ConfigReaderHelper.try_read_config(parser, "ui", "alias", reraise=True)
        ds.icon = ConfigReaderHelper.try_read_config(parser, "ui", "icon")

        # Lic & Terms
        ds.lic_name = ConfigReaderHelper.try_read_config(parser, "license", "name")
        ds.lic_link = ConfigReaderHelper.try_read_config(parser, "license", "link")
        ds.copyright_text = ConfigReaderHelper.try_read_config(parser, "license", "copyright_text")
        ds.copyright_link = ConfigReaderHelper.try_read_config(parser, "license", "copyright_link")
        ds.terms_of_use = ConfigReaderHelper.try_read_config(parser, "license", "terms_of_use")

        # TMS
        ds.tms_url = ConfigReaderHelper.try_read_config(parser, "tms", "url", reraise=(ds.type == KNOWN_DRIVERS.TMS))
        ds.tms_zmin = ConfigReaderHelper.try_read_config_int(parser, "tms", "zmin")
        ds.tms_zmax = ConfigReaderHelper.try_read_config_int(parser, "tms", "zmax")
        ds.tms_y_origin_top = ConfigReaderHelper.try_read_config_int(parser, "tms", "y_origin_top")
        ds.tms_epsg_crs_id = ConfigReaderHelper.try_read_config_int(parser, "tms", "epsg_crs_id")
        ds.tms_postgis_crs_id = ConfigReaderHelper.try_read_config_int(parser, "tms", "postgis_crs_id")
        ds.tms_custom_proj = ConfigReaderHelper.try_read_config(parser, "tms", "custom_proj")

        # WMS
        ds.wms_url = ConfigReaderHelper.try_read_config(parser, "wms", "url", reraise=(ds.type == KNOWN_DRIVERS.WMS))
        ds.wms_params = ConfigReaderHelper.try_read_config(parser, "wms", "params")
        ds.wms_layers = ConfigReaderHelper.try_read_config(parser, "wms", "layers")
        ds.wms_turn_over = ConfigReaderHelper.try_read_config_bool(parser, "wms", "turn_over")

        # GDAL
        if ds.type == KNOWN_DRIVERS.GDAL:
            gdal_conf = ConfigReaderHelper.try_read_config(
                parser, "gdal", "source_file", reraise=(ds.type == KNOWN_DRIVERS.GDAL)
            )
            ds.gdal_source_file = os.path.join(dir_path, gdal_conf)

        # WMS
        ds.wfs_url = ConfigReaderHelper.try_read_config(parser, "wfs", "url", reraise=(ds.type == KNOWN_DRIVERS.WFS))
        # ds.wfs_layers = ConfigReaderHelper.try_read_config(parser, 'wfs', 'layers')

        # try read translations
        posible_trans = parser.items("ui")
        for key, val in posible_trans:
            if type(key) is unicode and key == "alias[%s]" % locale:
                translator.append(ds.alias, val)
                break

        # internal stuff
        ds.file_path = ini_file_path
        ds.icon_path = os.path.join(dir_path, ds.icon) if ds.icon else None

        return ds
    def read_from_ini(cls, ini_file_path):
        translator = CustomTranslator()
        locale = Locale.get_locale()

        dir_path = os.path.abspath(os.path.join(ini_file_path, os.path.pardir))
        ini_file = codecs.open(ini_file_path, 'r', 'utf-8')

        parser = ConfigParser()
        parser.readfp(ini_file)

        ds = DataSourceInfo()

        # Required
        ds.id = ConfigReaderHelper.try_read_config(parser,
                                                   'general',
                                                   'id',
                                                   reraise=True)
        ds.type = ConfigReaderHelper.try_read_config(parser,
                                                     'general',
                                                     'type',
                                                     reraise=True)

        ds.group = ConfigReaderHelper.try_read_config(parser,
                                                      'ui',
                                                      'group',
                                                      reraise=True)
        ds.alias = ConfigReaderHelper.try_read_config(parser,
                                                      'ui',
                                                      'alias',
                                                      reraise=True)
        ds.icon = ConfigReaderHelper.try_read_config(parser, 'ui', 'icon')

        # Lic & Terms
        ds.lic_name = ConfigReaderHelper.try_read_config(
            parser, 'license', 'name')
        ds.lic_link = ConfigReaderHelper.try_read_config(
            parser, 'license', 'link')
        ds.copyright_text = ConfigReaderHelper.try_read_config(
            parser, 'license', 'copyright_text')
        ds.copyright_link = ConfigReaderHelper.try_read_config(
            parser, 'license', 'copyright_link')
        ds.terms_of_use = ConfigReaderHelper.try_read_config(
            parser, 'license', 'terms_of_use')

        #TMS
        ds.tms_url = ConfigReaderHelper.try_read_config(
            parser, 'tms', 'url', reraise=(ds.type == KNOWN_DRIVERS.TMS))
        ds.tms_zmin = ConfigReaderHelper.try_read_config_int(
            parser, 'tms', 'zmin')
        ds.tms_zmax = ConfigReaderHelper.try_read_config_int(
            parser, 'tms', 'zmax')
        ds.tms_y_origin_top = ConfigReaderHelper.try_read_config_int(
            parser, 'tms', 'y_origin_top')
        ds.tms_epsg_crs_id = ConfigReaderHelper.try_read_config_int(
            parser, 'tms', 'epsg_crs_id')
        ds.tms_postgis_crs_id = ConfigReaderHelper.try_read_config_int(
            parser, 'tms', 'postgis_crs_id')
        ds.tms_custom_proj = ConfigReaderHelper.try_read_config(
            parser, 'tms', 'custom_proj')

        #WMS
        ds.wms_url = ConfigReaderHelper.try_read_config(
            parser, 'wms', 'url', reraise=(ds.type == KNOWN_DRIVERS.WMS))
        ds.wms_params = ConfigReaderHelper.try_read_config(
            parser, 'wms', 'params')
        ds.wms_layers = ConfigReaderHelper.try_read_config(
            parser, 'wms', 'layers')
        ds.wms_turn_over = ConfigReaderHelper.try_read_config_bool(
            parser, 'wms', 'turn_over')

        #GDAL
        if ds.type == KNOWN_DRIVERS.GDAL:
            gdal_conf = ConfigReaderHelper.try_read_config(
                parser,
                'gdal',
                'source_file',
                reraise=(ds.type == KNOWN_DRIVERS.GDAL))
            ds.gdal_source_file = os.path.join(dir_path, gdal_conf)

        #WMS
        ds.wfs_url = ConfigReaderHelper.try_read_config(
            parser, 'wfs', 'url', reraise=(ds.type == KNOWN_DRIVERS.WFS))
        # ds.wfs_layers = ConfigReaderHelper.try_read_config(parser, 'wfs', 'layers')

        #try read translations
        posible_trans = parser.items('ui')
        for key, val in posible_trans:
            if type(key) is unicode and key == 'alias[%s]' % locale:
                translator.append(ds.alias, val)
                break

        #internal stuff
        ds.file_path = ini_file_path
        ds.icon_path = os.path.join(dir_path, ds.icon) if ds.icon else None

        return ds
 def GetThreat():
     adversary = random.choice(Locale.text()["threat"]["adversary"])
     wantsTo = random.choice(Locale.text()["threat"]["wantsTo"])
     the = random.choice(Locale.text()["threat"]["the"])
     whichWill = random.choice(Locale.text()["threat"]["whichWill"])
     return f'{adversary} wants to {wantsTo} the {the} which will {whichWill}'
 def NumberOfHeroesText():
     return Locale.text()["numberOfHeroes"]
 def OpeningSpiel():
     return Locale.text()["openingSpiel"]
Ejemplo n.º 11
0
 def __init__(self, group_paths=ALL_GROUP_PATHS):
     self.locale = Locale.get_locale()
     self.translator = CustomTranslator()
     self.paths = group_paths
     self.groups = {}
     self._fill_groups_list()
Ejemplo n.º 12
0
 def __init__(self, group_paths=ALL_GROUP_PATHS):
     self.locale = Locale.get_locale()
     self.translator = CustomTranslator()
     self.paths = group_paths
     self.groups = {}
     self._fill_groups_list()