当前位置: 首页>>代码示例>>Python>>正文


Python pytoml.load方法代码示例

本文整理汇总了Python中pytoml.load方法的典型用法代码示例。如果您正苦于以下问题:Python pytoml.load方法的具体用法?Python pytoml.load怎么用?Python pytoml.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytoml的用法示例。


在下文中一共展示了pytoml.load方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadConfigs

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def loadConfigs():
	global mqttServer, mqttPort, siteId, hotwordId

	if os.path.isfile(SNIPS_CONFIG_PATH):
		with open(SNIPS_CONFIG_PATH) as confFile:
			configs = pytoml.load(confFile)
			if 'mqtt' in configs['snips-common']:
				if ':' in configs['snips-common']['mqtt']:
					mqttServer = configs['snips-common']['mqtt'].split(':')[0]
					mqttPort = int(configs['snips-common']['mqtt'].split(':')[1])
				elif '@' in configs['snips-common']['mqtt']:
					mqttServer = configs['snips-common']['mqtt'].split('@')[0]
					mqttPort = int(configs['snips-common']['mqtt'].split('@')[1])
			if 'bind' in configs['snips-audio-server']:
				if ':' in configs['snips-audio-server']['bind']:
					siteId = configs['snips-audio-server']['bind'].split(':')[0]
				elif '@' in configs['snips-audio-server']['bind']:
					siteId = configs['snips-audio-server']['bind'].split('@')[0]
			if 'hotword_id' in configs['snips-hotword']:
				hotwordId = configs['snips-hotword']['hotword_id']
	else:
		print('Snips configs not found') 
开发者ID:Psychokiller1888,项目名称:snips-custom-hotword,代码行数:24,代码来源:customHotword.py

示例2: from_toml

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def from_toml(self, *filenames):
        """Reinitializes this Config from a list of TOML configuration files.

        Existing settings are discarded. When multiple files are provided,
        configuration is overridden by later files in the list.

        Parameters
        ----------
        filenames : interable of str
            Filenames of TOML configuration files to load.
        """
        settings = []
        for filename in filenames:
            with open(filename, 'rb') as fin:
                settings.append(toml.load(fin))

        return self.__init__(settings) 
开发者ID:aschampion,项目名称:diluvian,代码行数:19,代码来源:config.py

示例3: from_toml

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def from_toml(filename):
        volumes = {}
        with open(filename, "rb") as fin:
            volume_configs = toml.load(fin).get("N5Volume", [])
            for volume_config in volume_configs:
                root_path = volume_config["root_path"]
                datasets = volume_config["datasets"]
                resolution = volume_config.get("resolution", None)
                translation = volume_config.get["translation", None]
                bounds = volume_config.get("bounds", None)
                volume = N5Volume(
                    root_path,
                    datasets,
                    bounds,
                    resolution,
                    translation,
                )
                volumes[volume_config["title"]] = volume

        return volumes 
开发者ID:aschampion,项目名称:diluvian,代码行数:22,代码来源:volumes.py

示例4: load

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def load(self, monster_name, count=1):
        # TODO: hey maybe make this more efficient, yeah?

        monster_files = self.get_available_monster_files()
        monsters = []

        for filename in monster_files:
            monster = toml.load(open(filename, 'r'))

            if monster['name'] != monster_name:
                continue

            image_url = monster.get('image_url')
            if image_url and not image_url.startswith('http'):
                monster['image_url'] = self.image_loader.get_monster_image_path(image_url)

            for i in range(count):
                monsters.append(Monster(**monster))
            break

        return monsters 
开发者ID:mpirnat,项目名称:dndme,代码行数:23,代码来源:loaders.py

示例5: read_pkg_ini

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def read_pkg_ini(path: Path):
    """Read and check the `pyproject.toml` or `flit.ini` file with data about the package.
    """
    if path.suffix == '.toml':
        with path.open() as f:
            d = toml.load(f)
        res = prep_toml_config(d, path)
    else:
        # Treat all other extensions as the older flit.ini format
        cp = _read_pkg_ini(path)
        res = _validate_config(cp, path)

    if validate_config(res):
        if os.environ.get('FLIT_ALLOW_INVALID'):
            log.warning("Allowing invalid data (FLIT_ALLOW_INVALID set). Uploads may still fail.")
        else:
            raise ConfigError("Invalid config values (see log)")
    return res 
开发者ID:holzschu,项目名称:Carnets,代码行数:20,代码来源:inifile.py

示例6: parse_toml

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def parse_toml(file):
    import pytoml as toml
    assert file.name.endswith('.toml')
    variables = toml.load(file)
    return variables if variables else dict() 
开发者ID:kblomqvist,项目名称:yasha,代码行数:7,代码来源:parsers.py

示例7: image_populator

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def image_populator(self, bounds):
        image_subvol = np.zeros(tuple(bounds[1] - bounds[0]), dtype=np.float32)
        col_range = list(map(int, (math.floor(bounds[0][self.DIM.X] / self.tile_width),
                                   math.ceil(bounds[1][self.DIM.X] / self.tile_width))))
        row_range = list(map(int, (math.floor(bounds[0][self.DIM.Y] / self.tile_height),
                                   math.ceil(bounds[1][self.DIM.Y] / self.tile_height))))
        tile_size = np.array([1, self.tile_height, self.tile_width]).astype(np.int64)
        for z in xrange(bounds[0][self.DIM.Z], bounds[1][self.DIM.Z]):
            if z in self.missing_z:
                image_subvol[int(z - bounds[0][self.DIM.Z]), :, :] = 0
                continue
            for r in xrange(*row_range):
                for c in xrange(*col_range):
                    url = self.tile_format_url.format(zoom_level=self.zoom_level, z=z, row=r, col=c)
                    try:
                        im = np.array(Image.open(requests.get(url, stream=True).raw))
                        # If the image is multichannel, throw our hands up and
                        # just use the first channel.
                        if im.ndim > 2:
                            im = im[:, :, 0].squeeze()
                        im = im / 256.0
                    except IOError:
                        logging.debug('Failed to load tile: %s', url)
                        im = np.full((self.tile_height, self.tile_width), 0, dtype=np.float32)
                    tile_coord = np.array([z, r, c]).astype(np.int64)
                    tile_loc = np.multiply(tile_coord, tile_size)

                    subvol = (np.maximum(np.zeros(3), tile_loc - bounds[0]).astype(np.int64),
                              np.minimum(np.array(image_subvol.shape),
                                         tile_loc + tile_size - bounds[0]).astype(np.int64))
                    tile_sub = (np.maximum(np.zeros(3), bounds[0] - tile_loc).astype(np.int64),
                                np.minimum(tile_size, bounds[1] - tile_loc).astype(np.int64))

                    image_subvol[subvol[0][self.DIM.Z],
                                 subvol[0][self.DIM.Y]:subvol[1][self.DIM.Y],
                                 subvol[0][self.DIM.X]:subvol[1][self.DIM.X]] = \
                        im[tile_sub[0][self.DIM.Y]:tile_sub[1][self.DIM.Y],
                           tile_sub[0][self.DIM.X]:tile_sub[1][self.DIM.X]]

        return image_subvol 
开发者ID:aschampion,项目名称:diluvian,代码行数:42,代码来源:volumes.py

示例8: get_available_encounters

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def get_available_encounters(self):
        available_encounter_files = glob.glob(f"{self.base_dir}/*.toml")
        encounters = [Encounter(**toml.load(open(filename, 'r')))
                for filename in sorted(available_encounter_files)]
        return encounters 
开发者ID:mpirnat,项目名称:dndme,代码行数:7,代码来源:loaders.py

示例9: _load_group

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def _load_group(self, group, monster_groups):
        count = self._determine_count(group, monster_groups)
        monsters = self.monster_loader.load(group['monster'], count=count)
        self._set_names(group, monsters)
        self._set_stats(group, monsters)
        self._set_hp(group, monsters)
        self._set_armor(group, monsters)
        self._set_alignment(group, monsters)
        self._set_race(group, monsters)
        self._set_languages(group, monsters)
        self._set_xp(group, monsters)
        self._set_disposition(group, monsters)
        self._add_attributes(group, monsters)
        self._remove_attributes(group, monsters)
        return monsters 
开发者ID:mpirnat,项目名称:dndme,代码行数:17,代码来源:loaders.py

示例10: loadTomlSettings

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def loadTomlSettings(settingsDivisionName):
    userSettingsAndDefaultSettings = [
        '%s.toml' % settingsDivisionName,
        '_%s.toml' % settingsDivisionName
    ]
    for targetFile in userSettingsAndDefaultSettings:
        filePath = os.path.join('settings', targetFile)
        if os.path.isfile(filePath):
            Settings = pytoml.load(open(filePath))
            return Settings

    exit("Failed to load settings! %s" % settingsDivisionName) 
开发者ID:Gab0,项目名称:japonicus,代码行数:14,代码来源:Settings.py

示例11: TOMLToParameters

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def TOMLToParameters(TOMLDATA):
    Parameters = pytoml.load(TOMLDATA)

    for Parameter in Parameters.keys():
        if type(Parameter) == str:
            if '=' in Parameter:
                Parameter = Parameter.replace('=', '')
                Parameter = float(Parameter)
            
    return Parameters 
开发者ID:Gab0,项目名称:japonicus,代码行数:12,代码来源:TOMLutils.py

示例12: loadStrategyRankings

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def loadStrategyRankings(self):
        W = json.load(open("gekkoStrategyRankings.json"))
        self.Strategies = []
        for s in W:
            S = strategyParameterSet(s)
            self.Strategies.append(S) 
开发者ID:Gab0,项目名称:japonicus,代码行数:8,代码来源:strategyRanker.py

示例13: loadParameterSet

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def loadParameterSet(self):
        self.parameterSet = pytoml.load(open(self.parameters)) 
开发者ID:Gab0,项目名称:japonicus,代码行数:4,代码来源:strategyRanker.py

示例14: operateStrategyScores

# 需要导入模块: import pytoml [as 别名]
# 或者: from pytoml import load [as 别名]
def operateStrategyScores(exchange, ranker,
                          Balances, runningTimeHours,
                          currentPortfolioStatistics, runningBotStrategies):
    print("Rebooting gekko trading bots.")

    markzeroTime = datetime.timedelta(minutes=runningTimeHours*3600)
    predictedStartTime = datetime.datetime.now() - markzeroTime
    # APPLY LAST SCORE TO STRATEGIES;
    ranker.loadStrategyRankings()

    def makeBalanceScore(entry):
        return (float(entry['BALANCE']) /
                float(entry['AVERAGE_PRICE']))

    pastCorrespondingScore = None
    for row in Balances:
        balanceDate = dateparser.parse(row['TIME'])
        timeDelta = predictedStartTime - balanceDate
        minuteDelta = abs(timeDelta.seconds) / 60
        if minuteDelta < 60:
            pastCorrespondingScore = makeBalanceScore(row)

    if pastCorrespondingScore is not None:
        currentScore =\
            makeBalanceScore(currentPortfolioStatistics)

        botRunScore = currentScore / pastCorrespondingScore * 100
        normalizedBotRunScore = botRunScore / runningTimeHours

        runningStrategy = None
        for Strategy in ranker.Strategies:
            equalStrats = True
            strategyParameters = pytoml.load(open(
                getParameterSettingsPath(Strategy.parameters)))
            print(runningBotStrategies[-1])
            comparateParameters =\
                runningBotStrategies[-1]['params']
            for param in comparateParameters.keys():
                if type(param) == dict:
                    continue
                if param not in strategyParameters.keys():
                    equalStrats = False
                    break
                if strategyParameters[param] !=\
                   comparateParameters[param]:
                    equalStrats = False
                    break
            if equalStrats:
                runningStrategy = Strategy
                break

        if runningStrategy:
            print("Runnnig strategy found at scoreboard.")
            runningStrategy.profits.append(normalizedBotRunScore)
        else:
            print("Running strategy not found at scoreboard.")

    # WRITE NEW STRATEGY SCORES;
    ranker.saveStrategyRankings() 
开发者ID:Gab0,项目名称:japonicus,代码行数:61,代码来源:gekkoChecker.py


注:本文中的pytoml.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。