2024-08-22 10:46:53 +08:00
|
|
|
|
import{_ as s,o as a,c as t,b as n,d as o,e}from"./app-275NBlFz.js";const i={},p=n("h3",{id:"def-flat-config-config-dict-str-any-dict-str-any",tabindex:"-1"},[n("a",{class:"header-anchor",href:"#def-flat-config-config-dict-str-any-dict-str-any"},[n("span",null,[n("em",null,[n("strong",null,"def")]),o(),n("code",null,"flat_config(config: dict[str, Any]) -> dict[str, Any]")])])],-1),c=n("p",null,"扁平化配置文件",-1),l=n("p",{"a.b.c:1":""},"{a:{b:{c:1}}} ->",-1),r=e(`<p>Args:</p><pre><code>config: 配置项目
|
2024-08-21 18:00:26 +08:00
|
|
|
|
</code></pre><p>Returns:</p><pre><code>扁平化后的配置文件,但也包含原有的键值对
|
|
|
|
|
</code></pre><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">flat_config</span><span class="token punctuation">(</span>config<span class="token punctuation">:</span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
扁平化配置文件
|
|
|
|
|
|
|
|
|
|
{a:{b:{c:1}}} -> {"a.b.c": 1}
|
|
|
|
|
Args:
|
|
|
|
|
config: 配置项目
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
扁平化后的配置文件,但也包含原有的键值对
|
|
|
|
|
"""</span>
|
|
|
|
|
new_config <span class="token operator">=</span> copy<span class="token punctuation">.</span>deepcopy<span class="token punctuation">(</span>config<span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">for</span> <span class="token punctuation">(</span>key<span class="token punctuation">,</span> value<span class="token punctuation">)</span> <span class="token keyword">in</span> config<span class="token punctuation">.</span>items<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token builtin">isinstance</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> <span class="token builtin">dict</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">for</span> <span class="token punctuation">(</span>k<span class="token punctuation">,</span> v<span class="token punctuation">)</span> <span class="token keyword">in</span> flat_config<span class="token punctuation">(</span>value<span class="token punctuation">)</span><span class="token punctuation">.</span>items<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
new_config<span class="token punctuation">[</span><span class="token string-interpolation"><span class="token string">f'</span><span class="token interpolation"><span class="token punctuation">{</span>key<span class="token punctuation">}</span></span><span class="token string">.</span><span class="token interpolation"><span class="token punctuation">{</span>k<span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">]</span> <span class="token operator">=</span> v
|
|
|
|
|
<span class="token keyword">return</span> new_config
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-load-from-yaml-file-str-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-load-from-yaml-file-str-dict-str-any"><span><em><strong>def</strong></em> <code>load_from_yaml(file: str) -> dict[str, Any]</code></span></a></h3><p>Load config from yaml file</p><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">load_from_yaml</span><span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
Load config from yaml file
|
|
|
|
|
|
|
|
|
|
"""</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>debug<span class="token punctuation">(</span><span class="token string-interpolation"><span class="token string">f'Loading YAML config from </span><span class="token interpolation"><span class="token punctuation">{</span><span class="token builtin">file</span><span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">)</span>
|
|
|
|
|
config <span class="token operator">=</span> yaml<span class="token punctuation">.</span>safe_load<span class="token punctuation">(</span><span class="token builtin">open</span><span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">,</span> <span class="token string">'r'</span><span class="token punctuation">,</span> encoding<span class="token operator">=</span><span class="token string">'utf-8'</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">return</span> flat_config<span class="token punctuation">(</span>config <span class="token keyword">if</span> config <span class="token keyword">is</span> <span class="token keyword">not</span> <span class="token boolean">None</span> <span class="token keyword">else</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-load-from-json-file-str-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-load-from-json-file-str-dict-str-any"><span><em><strong>def</strong></em> <code>load_from_json(file: str) -> dict[str, Any]</code></span></a></h3><p>Load config from json file</p><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">load_from_json</span><span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
Load config from json file
|
|
|
|
|
"""</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>debug<span class="token punctuation">(</span><span class="token string-interpolation"><span class="token string">f'Loading JSON config from </span><span class="token interpolation"><span class="token punctuation">{</span><span class="token builtin">file</span><span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">)</span>
|
|
|
|
|
config <span class="token operator">=</span> json<span class="token punctuation">.</span>load<span class="token punctuation">(</span><span class="token builtin">open</span><span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">,</span> <span class="token string">'r'</span><span class="token punctuation">,</span> encoding<span class="token operator">=</span><span class="token string">'utf-8'</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">return</span> flat_config<span class="token punctuation">(</span>config <span class="token keyword">if</span> config <span class="token keyword">is</span> <span class="token keyword">not</span> <span class="token boolean">None</span> <span class="token keyword">else</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-load-from-toml-file-str-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-load-from-toml-file-str-dict-str-any"><span><em><strong>def</strong></em> <code>load_from_toml(file: str) -> dict[str, Any]</code></span></a></h3><p>Load config from toml file</p><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">load_from_toml</span><span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
Load config from toml file
|
|
|
|
|
"""</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>debug<span class="token punctuation">(</span><span class="token string-interpolation"><span class="token string">f'Loading TOML config from </span><span class="token interpolation"><span class="token punctuation">{</span><span class="token builtin">file</span><span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">)</span>
|
|
|
|
|
config <span class="token operator">=</span> toml<span class="token punctuation">.</span>load<span class="token punctuation">(</span><span class="token builtin">open</span><span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">,</span> <span class="token string">'r'</span><span class="token punctuation">,</span> encoding<span class="token operator">=</span><span class="token string">'utf-8'</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">return</span> flat_config<span class="token punctuation">(</span>config <span class="token keyword">if</span> config <span class="token keyword">is</span> <span class="token keyword">not</span> <span class="token boolean">None</span> <span class="token keyword">else</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-load-from-files-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-load-from-files-dict-str-any"><span><em><strong>def</strong></em> <code>load_from_files() -> dict[str, Any]</code></span></a></h3><p>从指定文件加载配置项,会自动识别文件格式</p><p>默认执行扁平化选项</p><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">load_from_files</span><span class="token punctuation">(</span><span class="token operator">*</span>files<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> no_warning<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token operator">=</span><span class="token boolean">False</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
从指定文件加载配置项,会自动识别文件格式
|
|
|
|
|
默认执行扁平化选项
|
|
|
|
|
"""</span>
|
|
|
|
|
config <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
|
|
|
|
|
<span class="token keyword">for</span> <span class="token builtin">file</span> <span class="token keyword">in</span> files<span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">if</span> os<span class="token punctuation">.</span>path<span class="token punctuation">.</span>exists<span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token builtin">file</span><span class="token punctuation">.</span>endswith<span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token string">'.yaml'</span><span class="token punctuation">,</span> <span class="token string">'yml'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
config<span class="token punctuation">.</span>update<span class="token punctuation">(</span>load_from_yaml<span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">elif</span> <span class="token builtin">file</span><span class="token punctuation">.</span>endswith<span class="token punctuation">(</span><span class="token string">'.json'</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
config<span class="token punctuation">.</span>update<span class="token punctuation">(</span>load_from_json<span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">elif</span> <span class="token builtin">file</span><span class="token punctuation">.</span>endswith<span class="token punctuation">(</span><span class="token string">'.toml'</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
config<span class="token punctuation">.</span>update<span class="token punctuation">(</span>load_from_toml<span class="token punctuation">(</span><span class="token builtin">file</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">elif</span> <span class="token keyword">not</span> no_warning<span class="token punctuation">:</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>warning<span class="token punctuation">(</span><span class="token string-interpolation"><span class="token string">f'Unsupported config file format: </span><span class="token interpolation"><span class="token punctuation">{</span><span class="token builtin">file</span><span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">elif</span> <span class="token keyword">not</span> no_warning<span class="token punctuation">:</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>warning<span class="token punctuation">(</span><span class="token string-interpolation"><span class="token string">f'Config file not found: </span><span class="token interpolation"><span class="token punctuation">{</span><span class="token builtin">file</span><span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">return</span> config
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-load-configs-from-dirs-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-load-configs-from-dirs-dict-str-any"><span><em><strong>def</strong></em> <code>load_configs_from_dirs() -> dict[str, Any]</code></span></a></h3><p>从目录下加载配置文件,不递归</p><p>按照读取文件的优先级反向覆盖</p><p>默认执行扁平化选项</p><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">load_configs_from_dirs</span><span class="token punctuation">(</span><span class="token operator">*</span>directories<span class="token punctuation">:</span> <span class="token builtin">str</span><span class="token punctuation">,</span> no_waring<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token operator">=</span><span class="token boolean">False</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
从目录下加载配置文件,不递归
|
|
|
|
|
按照读取文件的优先级反向覆盖
|
|
|
|
|
默认执行扁平化选项
|
|
|
|
|
"""</span>
|
|
|
|
|
config <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
|
|
|
|
|
<span class="token keyword">for</span> directory <span class="token keyword">in</span> directories<span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token keyword">not</span> os<span class="token punctuation">.</span>path<span class="token punctuation">.</span>exists<span class="token punctuation">(</span>directory<span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token keyword">not</span> no_waring<span class="token punctuation">:</span>
|
|
|
|
|
logger<span class="token punctuation">.</span>warning<span class="token punctuation">(</span><span class="token string-interpolation"><span class="token string">f'Directory not found: </span><span class="token interpolation"><span class="token punctuation">{</span>directory<span class="token punctuation">}</span></span><span class="token string">'</span></span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">continue</span>
|
|
|
|
|
<span class="token keyword">for</span> <span class="token builtin">file</span> <span class="token keyword">in</span> os<span class="token punctuation">.</span>listdir<span class="token punctuation">(</span>directory<span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token keyword">if</span> <span class="token builtin">file</span><span class="token punctuation">.</span>endswith<span class="token punctuation">(</span>_SUPPORTED_CONFIG_FORMATS<span class="token punctuation">)</span><span class="token punctuation">:</span>
|
|
|
|
|
config<span class="token punctuation">.</span>update<span class="token punctuation">(</span>load_from_files<span class="token punctuation">(</span>os<span class="token punctuation">.</span>path<span class="token punctuation">.</span>join<span class="token punctuation">(</span>directory<span class="token punctuation">,</span> <span class="token builtin">file</span><span class="token punctuation">)</span><span class="token punctuation">,</span> no_warning<span class="token operator">=</span>no_waring<span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">return</span> config
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="def-load-config-in-default-no-waring-bool-dict-str-any" tabindex="-1"><a class="header-anchor" href="#def-load-config-in-default-no-waring-bool-dict-str-any"><span><em><strong>def</strong></em> <code>load_config_in_default(no_waring: bool) -> dict[str, Any]</code></span></a></h3><p>从一个标准的轻雪项目加载配置文件</p><p>项目目录下的config.*和config目录下的所有配置文件</p><p>项目目录下的配置文件优先</p><details><summary>源代码</summary><div class="language-python line-numbers-mode" data-ext="py" data-title="py"><pre class="language-python"><code><span class="token keyword">def</span> <span class="token function">load_config_in_default</span><span class="token punctuation">(</span>no_waring<span class="token punctuation">:</span> <span class="token builtin">bool</span><span class="token operator">=</span><span class="token boolean">False</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">dict</span><span class="token punctuation">[</span><span class="token builtin">str</span><span class="token punctuation">,</span> Any<span class="token punctuation">]</span><span class="token punctuation">:</span>
|
|
|
|
|
<span class="token triple-quoted-string string">"""
|
|
|
|
|
从一个标准的轻雪项目加载配置文件
|
|
|
|
|
项目目录下的config.*和config目录下的所有配置文件
|
|
|
|
|
项目目录下的配置文件优先
|
|
|
|
|
"""</span>
|
|
|
|
|
config <span class="token operator">=</span> load_configs_from_dirs<span class="token punctuation">(</span><span class="token string">'config'</span><span class="token punctuation">,</span> no_waring<span class="token operator">=</span>no_waring<span class="token punctuation">)</span>
|
|
|
|
|
config<span class="token punctuation">.</span>update<span class="token punctuation">(</span>load_from_files<span class="token punctuation">(</span><span class="token string">'config.yaml'</span><span class="token punctuation">,</span> <span class="token string">'config.toml'</span><span class="token punctuation">,</span> <span class="token string">'config.json'</span><span class="token punctuation">,</span> <span class="token string">'config.yml'</span><span class="token punctuation">,</span> no_warning<span class="token operator">=</span>no_waring<span class="token punctuation">)</span><span class="token punctuation">)</span>
|
|
|
|
|
<span class="token keyword">return</span> config
|
|
|
|
|
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details><h3 id="class-satorinodeconfig-basemodel" tabindex="-1"><a class="header-anchor" href="#class-satorinodeconfig-basemodel"><span><em><strong>class</strong></em> <code>SatoriNodeConfig(BaseModel)</code></span></a></h3><h3 id="class-satoriconfig-basemodel" tabindex="-1"><a class="header-anchor" href="#class-satoriconfig-basemodel"><span><em><strong>class</strong></em> <code>SatoriConfig(BaseModel)</code></span></a></h3><h3 id="class-basicconfig-basemodel" tabindex="-1"><a class="header-anchor" href="#class-basicconfig-basemodel"><span><em><strong>class</strong></em> <code>BasicConfig(BaseModel)</code></span></a></h3><h3 id="var-new-config-copy-deepcopy-config" tabindex="-1"><a class="header-anchor" href="#var-new-config-copy-deepcopy-config"><span><em><strong>var</strong></em> <code>new_config = copy.deepcopy(config)</code></span></a></h3><h3 id="var-config-yaml-safe-load-open-file-r-encoding-utf-8" tabindex="-1"><a class="header-anchor" href="#var-config-yaml-safe-load-open-file-r-encoding-utf-8"><span><em><strong>var</strong></em> <code>config = yaml.safe_load(open(file, 'r', encoding='utf-8'))</code></span></a></h3><h3 id="var-config-json-load-open-file-r-encoding-utf-8" tabindex="-1"><a class="header-anchor" href="#var-config-json-load-open-file-r-encoding-utf-8"><span><em><strong>var</strong></em> <code>config = json.load(open(file, 'r', encoding='utf-8'))</code></span></a></h3><h3 id="var-config-toml-load-open-file-r-encoding-utf-8" tabindex="-1"><a class="header-anchor" href="#var-config-toml-load-open-file-r-encoding-utf-8"><span><em><strong>var</strong></em> <code>config = toml.load(open(file, 'r', encoding='utf-8'))</code></span></a></h3><h3 id="var-config" tabindex="-1"><a class="header-anchor" href="#var-config"><span><em><strong>var</strong></em> <code>config = {}</code></span></a></h3><h3 id="var-config-1" tabindex="-1"><a class="header-anchor" href="#var-config-1"><span><em><strong>var</strong></em> <code>config = {}</code></span></a></h3><h3 id="var-config-load-configs-from-dirs-config-no-waring-no-waring" tabindex="-1"><a class="header-anchor" href="#var-config-load-configs-from-dirs-config-no-waring-no-waring"><span><em><strong>var</strong></em> <code>config = load_configs_from_dirs('config', no_waring=no_waring)</code></span></a></h3>`,38),u=[p,c,l,r];function d(k,f){return a(),t("div",null,u)}const m=s(i,[["render",d],["__file","config.html.vue"]]),v=JSON.parse(`{"path":"/dev/api/config.html","title":"liteyuki.config","lang":"zh-CN","frontmatter":{"title":"liteyuki.config","order":1,"icon":"laptop-code","category":"API","description":"def flat_config(config: dict[str, Any]) -> dict[str, Any] 扁平化配置文件 {a:{b:{c:1}}} -> Args: Returns: 源代码 def load_from_yaml(file: str) -> dict[str, Any] Load config from yaml file ...","head":[["link",{"rel":"alternate","hreflang":"en-us","href":"https://vuepress-theme-hope-docs-demo.netlify.app/en/dev/api/config.html"}],["meta",{"property":"og:url","content":"https://vuepress-theme-hope-docs-demo.netlify.app/dev/api/config.html"}],["meta",{"property":"og:site_name","content":"LiteyukiBot 轻雪机器人"}],["meta",{"property":"og:title","content":"liteyuki.config"}],["meta",{"property":"og:description","content":"def flat_config(config: dict[str, Any]) -> dict[str, Any] 扁平化配置文件 {a:{b:{c:1}}} -> Args: Returns: 源代码 def load_from_yaml(file: str) -> dict[str, Any] Load config from yaml file ..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:locale:alternate","content":"en-US"}],["meta",{"property":"og:updated_time","content":"2024-08-21T09:59:21.000Z
|