Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamancer authored Feb 27, 2024
2 parents bcb8228 + de06fba commit 20bd05f
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 35 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Quickstart
----------

``` python
from xmu import EMuReader, EMuRecord, EMuSchema, write_import
from xmu import EMuReader, EMuRecord, EMuSchema, write_xml

# Loading an EMu schema file allows xmu to validate data, coerce data to
# the proper type, and manage grids
Expand Down Expand Up @@ -69,5 +69,21 @@ for rec in reader:
records.append(update)

# Write the XML import file from the list of EMu records
write_import(records, "update.xml")
write_xml(records, "update.xml")
```

You can use the experimental `from_xml_parallel()` method to read large
XML files more quickly. For example, to create a dict mapping IRNs to
records:

``` python
def callback(path):
reader = EMuReader("xmldata.xml")
results = {}
for rec in reader:
rec = EMuRecord(rec, module=reader.module)
results[rec["irn"]] = rec
return results

results = EMuReader("xmldata.xml").from_xml_parallel(callback)
```
36 changes: 6 additions & 30 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
API
===

xmu.containers
--------------
.. toctree::
:maxdepth: 2

.. automodule:: xmu.containers
:members:
:undoc-members:
:show-inheritance:

xmu.io
------

.. automodule:: xmu.io
:members:
:undoc-members:
:show-inheritance:

xmu.types
---------

.. automodule:: xmu.types
:members:
:undoc-members:
:show-inheritance:

xmu.utils
---------

.. automodule:: xmu.utils
:members:
:undoc-members:
:show-inheritance:
containers
io
types
utils
6 changes: 6 additions & 0 deletions docs/containers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
xmu.containers
==============

.. automodule:: xmu.containers
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/io.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
xmu.io
======

.. automodule:: xmu.io
:members:
:show-inheritance:
6 changes: 6 additions & 0 deletions docs/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
xmu.types
=========

.. automodule:: xmu.types
:members:
:show-inheritance:
21 changes: 19 additions & 2 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Quickstart
----------

``` python
from xmu import EMuReader, EMuRecord, EMuSchema, write_import
from xmu import EMuReader, EMuRecord, EMuSchema, write_xml

# Loading an EMu schema file allows xmu to validate data, coerce data to
# the proper type, and manage grids
Expand Down Expand Up @@ -60,5 +60,22 @@ for rec in reader:
records.append(update)

# Write the XML import file from the list of EMu records
write_import(records, "update.xml")
write_xml(records, "update.xml")
```

You can use the experimental
:py:meth:`~xmu.io.EMuReader.from_xml_parallel` method to read large XML
files more quickly. For example, to create a dict mapping IRNs to
records:

``` python
def callback(path):
reader = EMuReader("xmldata.xml")
results = {}
for rec in reader:
rec = EMuRecord(rec, module=reader.module)
results[rec["irn"]] = rec
return results

results = EMuReader("xmldata.xml").from_xml_parallel(callback)
```
6 changes: 6 additions & 0 deletions docs/utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
xmu.utils
=========

.. automodule:: xmu.utils
:members:
:show-inheritance:
18 changes: 18 additions & 0 deletions xmu/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ class EMuSchema(dict):

#: EMuConfig : module-wide configuration parameters. Set automatically
#: when an EMuConfig object is created.
#:
#: :meta hide-value:
config = None

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -625,10 +627,14 @@ class to use for lists

#: EMuConfig : module-wide configuration parameters. Set automatically
#: when an EMuConfig object is created.
#:
#: :meta hide-value:
config = None

#: EMuSchema : info about a specific EMu configuration. Set automatically
#: when an EMuSchema object is created.
#:
#: :meta hide-value:
schema = None

def __init__(
Expand Down Expand Up @@ -772,10 +778,14 @@ class EMuRow(MutableMapping):

#: EMuConfig : module-wide configuration parameters. Set automatically
#: when an EMuConfig object is created.
#:
#: :meta hide-value:
config = None

#: EMuSchema : info about a specific EMu configuration. Set automatically
#: when an EMuSchema object is created.
#:
#: :meta hide-value:
schema = None

def __init__(self, rec, path, index, fill_value=None):
Expand Down Expand Up @@ -871,10 +881,14 @@ class EMuGrid(MutableSequence):

#: EMuConfig : module-wide configuration parameters. Set automatically
#: when an EMuConfig object is created.
#:
#: :meta hide-value:
config = None

#: EMuSchema : info about a specific EMu configuration. Set automatically
#: when an EMuSchema object is created.
#:
#: :meta hide-value:
schema = None

def __init__(self, rec, path, fill_value=None):
Expand Down Expand Up @@ -1085,10 +1099,14 @@ class to use for lists

#: EMuConfig : module-wide configuration parameters. Set automatically
#: when an EMuConfig object is created.
#:
#: :meta hide-value:
config = None

#: EMuSchema : info about a specific EMu configuration. Set automatically
#: when an EMuSchema object is created.
#:
#: :meta hide-value:
schema = None

def __init__(
Expand Down
6 changes: 5 additions & 1 deletion xmu/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ class EMuReader:

#: EMuConfig : module-wide configuration parameters. Set automatically
#: when an EMuConfig object is created.
config = None
#:
#: :meta hide-value:
config = None

#: EMuSchema : info about a specific EMu configuration. Set automatically
#: when an EMuSchema object is created.
#:
#: :meta hide-value:
schema = None

def __init__(self, path, json_path=None):
Expand Down

0 comments on commit 20bd05f

Please sign in to comment.