Skip to content

Commit

Permalink
Deployed 6707a17 with MkDocs version: 1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhcc committed Dec 30, 2024
1 parent 401ebb5 commit 9068bca
Show file tree
Hide file tree
Showing 16 changed files with 15,376 additions and 18,441 deletions.
5,135 changes: 4,713 additions & 422 deletions api_reference/beancount.core.html

Large diffs are not rendered by default.

144 changes: 106 additions & 38 deletions api_reference/beancount.loader.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
</li>
<li class="toctree-l3"><a class="reference internal" href="#beancount.loader.LoadError.__new__">__new__()</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#beancount.loader.LoadError.__replace__">__replace__()</a>
</li>
<li class="toctree-l3"><a class="reference internal" href="#beancount.loader.LoadError.__repr__">__repr__()</a>
</li>
</ul>
Expand Down Expand Up @@ -273,6 +275,9 @@ <h1 id="beancountloader">beancount.loader<a class="headerlink" href="#beancountl






<div class="doc doc-object doc-class">


Expand Down Expand Up @@ -361,6 +366,38 @@ <h3 id="beancount.loader.LoadError.__new__" class="doc doc-heading">



<h3 id="beancount.loader.LoadError.__replace__" class="doc doc-heading">
<code class="highlight language-python">beancount.loader.LoadError.__replace__(/, self, **kwds)</code>

<span class="doc doc-properties">
<small class="doc doc-property doc-property-special"><code>special</code></small>
</span>

<a href="#beancount.loader.LoadError.__replace__" class="headerlink" title="Permanent link"></a></h3>

<div class="doc doc-contents ">

<p>Return a new LoadError object replacing specified fields with new values</p>

<details class="quote">
<summary>Source code in <code>beancount/loader.py</code></summary>
<pre class="highlight"><code class="language-python">def _replace(self, /, **kwds):
result = self._make(_map(kwds.pop, field_names, self))
if kwds:
raise TypeError(f'Got unexpected field names: {list(kwds)!r}')
return result
</code></pre>
</details>
</div>

</div>



<div class="doc doc-object doc-method">



<h3 id="beancount.loader.LoadError.__repr__" class="doc doc-heading">
<code class="highlight language-python">beancount.loader.LoadError.__repr__(self)</code>

Expand Down Expand Up @@ -403,7 +440,7 @@ <h3 id="beancount.loader.LoadError.__repr__" class="doc doc-heading">


<h2 id="beancount.loader.aggregate_options_map" class="doc doc-heading">
<code class="highlight language-python">beancount.loader.aggregate_options_map(options_map, src_options_map)</code>
<code class="highlight language-python">beancount.loader.aggregate_options_map(options_map, other_options_map)</code>


<a href="#beancount.loader.aggregate_options_map" class="headerlink" title="Permanent link"></a></h2>
Expand All @@ -424,30 +461,41 @@ <h2 id="beancount.loader.aggregate_options_map" class="doc doc-heading">
<ul class="first simple">
<li><p><strong>options_map</strong> – The target map in which we want to aggregate attributes.
Note: This value is mutated in-place.</p></li>
<li><p><strong>src_options_map</strong> – A source map whose values we'd like to see aggregated.</p></li>
<li><p><strong>other_options_map</strong> – A list of other options maps, some of whose values
we'd like to see aggregated.</p></li>
</ul>
</td>
</tr>
</tbody>
</table>
<details class="quote">
<summary>Source code in <code>beancount/loader.py</code></summary>
<pre class="highlight"><code class="language-python">def aggregate_options_map(options_map, src_options_map):
<pre class="highlight"><code class="language-python">def aggregate_options_map(options_map, other_options_map):
"""Aggregate some of the attributes of options map.

Args:
options_map: The target map in which we want to aggregate attributes.
Note: This value is mutated in-place.
src_options_map: A source map whose values we'd like to see aggregated.
other_options_map: A list of other options maps, some of whose values
we'd like to see aggregated.
"""
op_currencies = options_map["operating_currency"]
for currency in src_options_map["operating_currency"]:
if currency not in op_currencies:
op_currencies.append(currency)

commodities = options_map["commodities"]
for currency in src_options_map["commodities"]:
commodities.add(currency)
options_map = copy.copy(options_map)

currencies = list(options_map["operating_currency"])
for omap in other_options_map:
currencies.extend(omap["operating_currency"])
options_map["dcontext"].update_from(omap["dcontext"])
options_map["operating_currency"] = list(misc_utils.uniquify(currencies))


# Produce a 'pythonpath' value for transformers.
pythonpath = set()
for omap in itertools.chain((options_map,), other_options_map):
if omap.get("insert_pythonpath", False):
pythonpath.add(path.dirname(omap["filename"]))
options_map["pythonpath"] = sorted(pythonpath)

return options_map
</code></pre>
</details>
</div>
Expand Down Expand Up @@ -1004,7 +1052,8 @@ <h2 id="beancount.loader.load_file" class="doc doc-heading">
<ul class="first simple">
<li><p><strong>filename</strong> – The name of the file to be parsed.</p></li>
<li><p><strong>log_timings</strong> – A file object or function to write timings to,
or None, if it should remain quiet.</p></li>
or None, if it should remain quiet. (Note that this is intended to use
the logging methods and does not insert a newline.)</p></li>
<li><p><strong>log_errors</strong> – A file object or function to write errors to,
or None, if it should remain quiet.</p></li>
<li><p><strong>extra_validations</strong> – A list of extra validation functions to run after loading
Expand Down Expand Up @@ -1043,7 +1092,8 @@ <h2 id="beancount.loader.load_file" class="doc doc-heading">
Args:
filename: The name of the file to be parsed.
log_timings: A file object or function to write timings to,
or None, if it should remain quiet.
or None, if it should remain quiet. (Note that this is intended to use
the logging methods and does not insert a newline.)
log_errors: A file object or function to write errors to,
or None, if it should remain quiet.
extra_validations: A list of extra validation functions to run after loading
Expand Down Expand Up @@ -1458,9 +1508,10 @@ <h2 id="beancount.loader.run_transformations" class="doc doc-heading">
if options_map['plugin_processing_mode'] == 'raw':
plugins_iter = options_map["plugin"]
elif options_map['plugin_processing_mode'] == 'default':
plugins_iter = itertools.chain(DEFAULT_PLUGINS_PRE,
plugins_iter = itertools.chain(PLUGINS_PRE,
options_map["plugin"],
DEFAULT_PLUGINS_POST)
PLUGINS_AUTO,
PLUGINS_POST)
else:
assert "Invalid value for plugin_processing_mode: {}".format(
options_map['plugin_processing_mode'])
Expand All @@ -1476,39 +1527,56 @@ <h2 id="beancount.loader.run_transformations" class="doc doc-heading">
plugin_name = renamed_name

# Try to import the module.
#
# Note: We intercept import errors and continue but let other plugin
# import time exceptions fail a run, by choice.
try:
module = importlib.import_module(plugin_name)
if not hasattr(module, '__plugins__'):
continue
except ImportError:
# Upon failure, just issue an error.
formatted_traceback = traceback.format_exc().replace("\n", "\n ")
errors.append(LoadError(data.new_metadata("&lt;load&gt;", 0),
'Error importing "{}": {}'.format(
plugin_name, formatted_traceback), None))
continue

# Apply it.
with misc_utils.log_time(plugin_name, log_timings, indent=2):
# Run each transformer function in the plugin.
for function_name in module.__plugins__:
if isinstance(function_name, str):
# Support plugin functions provided by name.
callback = getattr(module, function_name)
else:
# Support function types directly, not just names.
callback = function_name

with misc_utils.log_time(plugin_name, log_timings, indent=2):

# Run each transformer function in the plugin.
for function_name in module.__plugins__:
if isinstance(function_name, str):
# Support plugin functions provided by name.
callback = getattr(module, function_name)
else:
# Support function types directly, not just names.
callback = function_name

if plugin_config is not None:
entries, plugin_errors = callback(entries, options_map,
plugin_config)
else:
entries, plugin_errors = callback(entries, options_map)
# Provide arguments if config is provided.
# TODO(blais): Make this consistent in v3, not conditional.
args = () if plugin_config is None else (plugin_config,)

# Catch all exceptions raised in running the plugin, except exits.
try:
entries, plugin_errors = callback(entries, options_map, *args)
errors.extend(plugin_errors)
except Exception as exc:
# Allow the user to exit in a plugin.
if isinstance(exc, SystemExit):
raise

# Upon failure, just issue an error.
formatted_traceback = traceback.format_exc().replace("\n", "\n ")
errors.append(LoadError(data.new_metadata("&lt;load&gt;", 0),
'Error applying plugin "{}": {}'.format(
plugin_name, formatted_traceback), None))
continue

# Ensure that the entries are sorted. Don't trust the plugins
# themselves.
entries.sort(key=data.entry_sortkey)

except (ImportError, TypeError) as exc:
# Upon failure, just issue an error.
errors.append(LoadError(data.new_metadata("&lt;load&gt;", 0),
'Error importing "{}": {}'.format(
plugin_name, str(exc)), None))

return entries, errors
</code></pre>
</details>
Expand Down
Loading

0 comments on commit 9068bca

Please sign in to comment.