Skip to content

Commit

Permalink
Merge branch 'develop' into update_automatic_api_documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugovdberg authored Aug 4, 2021
2 parents 48bf40a + 3050427 commit 7c76b89
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 116 deletions.
2 changes: 1 addition & 1 deletion PIconnect/PIAF.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
from warnings import warn

from PIconnect._operators import OPERATORS, add_operators
from PIconnect._utils import classproperty
from PIconnect.AFSDK import AF
from PIconnect.PIData import PISeriesContainer
from PIconnect.time import timestamp_to_index
from PIconnect._utils import classproperty

_NOTHING = object()

Expand Down
28 changes: 11 additions & 17 deletions PIconnect/time.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
from datetime import datetime

import pytz

from PIconnect.AFSDK import AF
from PIconnect.config import PIConfig


def to_af_time_range(start_time, end_time):
"""Convert a combination of start and end time to a time range.
Both `start_time` and `end_time` can be either a :any:`datetime.datetime` object or a string.
`datetime` objects are first converted to a string, before being passed to
:afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`. It is also
possible to specify either end as a `datetime` object, and then specify the other
boundary as a relative string.
"""to_af_time_range
Args:
start_time (str | datetime): Start time of the time range.
end_time (str | datetime): End time of the time range.
Return AF.Time.AFTimeRange object from datetime or string
using :afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`.
Returns:
:afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`: Time range covered by the start and end time.
If string is used, it is assumed that user knows the format
that should be passed to AF.Time.AFTimeRange.
"""

if isinstance(start_time, datetime):
start_time = start_time.isoformat()
if isinstance(end_time, datetime):
Expand All @@ -33,11 +26,12 @@ def to_af_time_range(start_time, end_time):
def timestamp_to_index(timestamp):
"""Convert AFTime object to datetime in local timezone.
Args:
timestamp (`System.DateTime`): Timestamp in .NET format to convert to `datetime`.
.. todo::
Allow to define timezone, default to UTC?
.. todo::
Returns:
`datetime`: Datetime with the timezone info from :data:`PIConfig.DEFAULT_TIMEZONE <PIconnect.config.PIConfigContainer.DEFAULT_TIMEZONE>`.
"""
local_tz = pytz.timezone(PIConfig.DEFAULT_TIMEZONE)
return (
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions docs/PIconnect.PI.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PIconnect.PI module
===================

.. automodule:: PIconnect.PI
:members:
:undoc-members:
:inherited-members:
:show-inheritance:
4 changes: 2 additions & 2 deletions docs/api/PIconnect.time.rst → docs/PIconnect.PIAF.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PIconnect.time module
PIconnect.PIAF module
=====================

.. automodule:: PIconnect.time
.. automodule:: PIconnect.PIAF
:members:
:undoc-members:
:inherited-members:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions docs/PIconnect.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PIconnect package
=================

.. automodule:: PIconnect
:members:
:undoc-members:
:inherited-members:
:show-inheritance:

Submodules
----------

.. toctree::

PIconnect.AFSDK
PIconnect.config
PIconnect.PI
PIconnect.PIAF
PIconnect.PIConsts
PIconnect.PIData
21 changes: 0 additions & 21 deletions docs/api/PI/PIconnect.PI.rst

This file was deleted.

27 changes: 0 additions & 27 deletions docs/api/PIAF/PIconnect.PIAF.rst

This file was deleted.

35 changes: 0 additions & 35 deletions docs/api/index.rst

This file was deleted.

17 changes: 8 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
sys.path.insert(0, os.path.abspath(".."))
import PIconnect

# sys.path.insert(0, os.path.abspath('..'))


class Mock(MagicMock):
Expand All @@ -33,15 +35,14 @@ def __getattr__(cls, name):
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

# Get the project root dir, which is the parent dir of this
# cwd = os.getcwd()
# project_root = os.path.dirname(cwd)
cwd = os.getcwd()
project_root = os.path.dirname(cwd)

# Insert the project root dir as the first element in the PYTHONPATH.
# This lets us ensure that the source package is imported, and that its
# version is used.
# sys.path.insert(0, project_root)
sys.path.insert(0, project_root)

import PIconnect

# -- General configuration ---------------------------------------------

Expand All @@ -54,7 +55,6 @@ def __getattr__(cls, name):
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.githubpages",
Expand Down Expand Up @@ -92,8 +92,7 @@ def __getattr__(cls, name):
extlinks = {"afsdk": ("https://docs.osisoft.com/bundle/af-sdk/page/html/%s", "")}

intersphinx_mapping = {
"python": ("https://docs.python.org/3.8", None),
"pandas": ("https://pandas.pydata.org/docs", None),
"pandas": ("http://pandas.pydata.org/docs", None),
"pytz": ("http://pytz.sourceforge.net", None),
}

Expand All @@ -115,7 +114,7 @@ def __getattr__(cls, name):
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

autosummary_generate = True

# -- Options for HTML output ----------------------------------------------


Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ structure:
- The basic introductions to using :py:mod:`PIconnect` are covered in the
:doc:`/tutorials`.
- The technical reference to all modules within :py:mod:`PIconnect` are
covered in :doc:`/api/index`. These also include several links to the original
covered in :doc:`/modules`. These also include several links to the original
SDK documentation for important implementation details.
- Background explanations and how-to guides still need to be written.

Expand All @@ -26,7 +26,7 @@ Contents

installation
tutorials
api/index
modules
contributing
authors
history
Expand Down
7 changes: 7 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
API Reference
=============

.. toctree::
:maxdepth: 4

PIconnect
1 change: 0 additions & 1 deletion docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ Data extraction
tutorials/interpolated_values
tutorials/summaries
tutorials/timezones
tutorials/update_value
1 change: 0 additions & 1 deletion docs/tutorials/update_value.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ buffer_option as AFBufferOption.


.. code-block:: python
from datetime import datetime
import pytz
import PIconnect as PI
Expand Down

0 comments on commit 7c76b89

Please sign in to comment.