Skip to content

Commit

Permalink
global refactor (#71)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 authored Aug 10, 2023
1 parent 9b43353 commit 34cfd4c
Show file tree
Hide file tree
Showing 66 changed files with 874 additions and 776 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repos:
(?x)^(
nc_py_api/|
benchmarks/|
examples/|
tests/
)
Expand All @@ -30,6 +31,7 @@ repos:
(?x)^(
nc_py_api/|
benchmarks/|
examples/|
tests/
)
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ All notable changes to this project will be documented in this file.

## [0.0.28 - 2023-08-11]

### Added

- APIs for enabling\disabling External Applications.

### Changed

- Finished documentation.
- Different small adjustments to API, to be it more consistent.
- Much more documentation.
- Regroup APIs, hopes for the last time.

### Fixed

Expand Down
14 changes: 6 additions & 8 deletions docs/reference/Apps.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
.. py:currentmodule:: nc_py_api.apps
Applications Management
-----------------------

.. autoclass:: AppAPI
.. autoclass:: nc_py_api.apps.apps.AppsAPI
:members:

.. autoclass:: ExAppInfo
.. autoclass:: nc_py_api.apps.apps.ExAppInfo
:members:

Preferences
^^^^^^^^^^^

.. autoclass:: nc_py_api.appcfg_prefs_ex.CfgRecord
.. autoclass:: nc_py_api.apps.preferences_ex.CfgRecord
:members:
:undoc-members:

User specific
"""""""""""""

.. autoclass:: nc_py_api.preferences.PreferencesAPI
.. autoclass:: nc_py_api.apps.preferences.PreferencesAPI
:members:

.. autoclass:: nc_py_api.appcfg_prefs_ex.PreferencesExAPI
.. autoclass:: nc_py_api.apps.preferences_ex.PreferencesExAPI
:members:
:inherited-members:

Non-user specific
"""""""""""""""""

.. autoclass:: nc_py_api.appcfg_prefs_ex.AppConfigExAPI
.. autoclass:: nc_py_api.apps.preferences_ex.AppConfigExAPI
:members:
:inherited-members:
19 changes: 0 additions & 19 deletions docs/reference/Constants.rst

This file was deleted.

13 changes: 13 additions & 0 deletions docs/reference/ExApp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. py:currentmodule:: nc_py_api.ex_app
External Application
====================

Constants
---------

.. autoclass:: ApiScope
:members:

.. autoclass:: LogLvl
:members:
10 changes: 3 additions & 7 deletions docs/reference/Exceptions.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
.. py:currentmodule:: nc_py_api.exceptions
.. py:currentmodule:: nc_py_api._exceptions
Exceptions
==========

Avalaible as `nc_py_api.{exception_name}`

.. autoclass:: NextcloudException
:members:

.. autoclass:: NextcloudExceptionNotFound
:members:


Functions
---------

.. autofunction:: check_error
6 changes: 3 additions & 3 deletions docs/reference/Files/Files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Refer to the **fs examples** to see how to use them nicely.

All File APIs are designed to work relative to the current user.

.. autoclass:: nc_py_api.files_defs.FsNodeInfo
.. autoclass:: nc_py_api.files.files.FilesAPI
:members:

.. autoclass:: nc_py_api.files_defs.FsNode
.. autoclass:: nc_py_api.files.FsNodeInfo
:members:

.. autoclass:: nc_py_api.files.FilesAPI
.. autoclass:: nc_py_api.files.FsNode
:members:
13 changes: 11 additions & 2 deletions docs/reference/Files/Shares.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ File Sharing
The Shares API is universal for both modes and provides all the necessary methods for working with the Nextcloud Shares system.
Refer to the **share examples** to see how to use them nicely.

.. autoclass:: nc_py_api.files_defs.Share
.. autoclass:: nc_py_api.files.sharing._FilesSharingAPI
:members:

.. autoclass:: nc_py_api.files_sharing.FilesSharingAPI
.. autoclass:: nc_py_api.files.sharing.Share
:members:

.. autoclass:: nc_py_api.files.sharing.SharePermissions
:members:

.. autoclass:: nc_py_api.files.sharing.ShareType
:members:

.. autoclass:: nc_py_api.files.sharing.ShareStatus
:members:
6 changes: 3 additions & 3 deletions docs/reference/Session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Session Structures
.. autoclass:: ServerVersion
:members:

.. autoclass:: nc_py_api.theming.ThemingInfo
.. autoclass:: nc_py_api._theming.ThemingInfo
:members:

.. autoclass:: AppConfig
:members:

Sessions Internal
=================
Internal
^^^^^^^^

Currently Session API is private, and not exposed.

Expand Down
11 changes: 11 additions & 0 deletions docs/reference/Users/Notifications.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Notifications
-------------

.. autoclass:: nc_py_api.users.notifications._NotificationsAPI
:members:

.. autoclass:: nc_py_api.users.notifications.Notification
:members:

.. autoclass:: nc_py_api.users.notifications.NotificationInfo
:members:
4 changes: 1 addition & 3 deletions docs/reference/Users/Users.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.. py:currentmodule:: nc_py_api.users
User Management
---------------

.. autoclass:: UsersAPI
.. autoclass:: nc_py_api.users.users.UsersAPI
:members:
4 changes: 2 additions & 2 deletions docs/reference/Users/UsersGroups.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
User Groups Management
----------------------

.. autoclass:: nc_py_api.users_groups.UserGroupsAPI
.. autoclass:: nc_py_api.users.groups._UserGroupsAPI
:members:

.. autoclass:: nc_py_api.users_defs.GroupDetails
.. autoclass:: nc_py_api.users.groups.GroupDetails
:members:
10 changes: 5 additions & 5 deletions docs/reference/Users/UsersStatus.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
User Status
-----------

.. autoclass:: nc_py_api.users_status.UserStatusAPI
.. autoclass:: nc_py_api.users.status._UserStatusAPI
:members:

.. autoclass:: nc_py_api.users_defs.CurrentUserStatus
.. autoclass:: nc_py_api.users.status.CurrentUserStatus
:members:

.. autoclass:: nc_py_api.users_defs.UserStatus
.. autoclass:: nc_py_api.users.status.UserStatus
:members:

.. autoclass:: nc_py_api.users_defs.PredefinedStatus
.. autoclass:: nc_py_api.users.status.PredefinedStatus
:members:

.. autoclass:: nc_py_api.users_defs.ClearAt
.. autoclass:: nc_py_api.users.status.ClearAt
:members:
6 changes: 3 additions & 3 deletions docs/reference/Users/WeatherStatus.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Weather Status
--------------

.. autoclass:: nc_py_api.users_weather.WeatherStatusAPI
.. autoclass:: nc_py_api.users.weather._WeatherStatusAPI
:members:

.. autoclass:: nc_py_api.users_defs.WeatherLocation
.. autoclass:: nc_py_api.users.weather.WeatherLocation
:members:

.. autoclass:: nc_py_api.users_defs.WeatherLocationMode
.. autoclass:: nc_py_api.users.weather.WeatherLocationMode
:members:
1 change: 1 addition & 0 deletions docs/reference/Users/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Users API
Users
UsersGroups
UsersStatus
Notifications
WeatherStatus
4 changes: 2 additions & 2 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Reference
Apps
Files/index.rst
Users/index.rst
Session
Constants
ExApp
Exceptions
Session
12 changes: 6 additions & 6 deletions examples/as_app/to_gif/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from pygifsicle import optimize
from requests import Response

from nc_py_api import (
from nc_py_api import NextcloudApp
from nc_py_api.ex_app import (
ApiScope,
GuiActionFileInfo,
GuiFileActionHandlerInfo,
LogLvl,
NextcloudApp,
UiActionFileInfo,
UiFileActionHandlerInfo,
enable_heartbeat,
nc_app,
set_enabled_handler,
Expand All @@ -28,7 +28,7 @@
APP = FastAPI()


def convert_video_to_gif(input_params: GuiActionFileInfo, nc: NextcloudApp):
def convert_video_to_gif(input_params: UiActionFileInfo, nc: NextcloudApp):
source_path = path.join(input_params.directory, input_params.name)
save_path = path.splitext(source_path)[0] + ".gif"
nc.log(LogLvl.WARNING, f"Processing:{source_path} -> {save_path}")
Expand Down Expand Up @@ -73,7 +73,7 @@ def convert_video_to_gif(input_params: GuiActionFileInfo, nc: NextcloudApp):

@APP.post("/video_to_gif")
async def video_to_gif(
file: GuiFileActionHandlerInfo,
file: UiFileActionHandlerInfo,
nc: Annotated[NextcloudApp, Depends(nc_app)],
background_tasks: BackgroundTasks,
):
Expand Down
2 changes: 1 addition & 1 deletion examples/as_client/files_download.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from io import BytesIO

from PIL import Image # this example requires `pillow` to be installed

import nc_py_api


if __name__ == "__main__":
# run this example after ``files_upload.py`` or adjust the image file path.
nc = nc_py_api.Nextcloud(nextcloud_url="http://nextcloud.local", nc_auth_user="admin", nc_auth_pass="admin")
Expand Down
1 change: 0 additions & 1 deletion examples/as_client/files_listing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import nc_py_api


if __name__ == "__main__":
# create Nextcloud client instance class
nc = nc_py_api.Nextcloud(nextcloud_url="http://nextcloud.local", nc_auth_user="admin", nc_auth_pass="admin")
Expand Down
6 changes: 4 additions & 2 deletions examples/as_client/files_upload.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from io import BytesIO

from PIL import Image # this example requires `pillow` to be installed

import nc_py_api


if __name__ == "__main__":
nc = nc_py_api.Nextcloud(nextcloud_url="http://nextcloud.local", nc_auth_user="admin", nc_auth_pass="admin")
buf = BytesIO()
Expand All @@ -14,7 +14,9 @@
Image.linear_gradient(mode="L").transpose(Image.ROTATE_90),
Image.linear_gradient(mode="L").transpose(Image.ROTATE_180),
],
).save(buf, format="PNG") # saving image to the buffer
).save(
buf, format="PNG"
) # saving image to the buffer
buf.seek(0) # setting the pointer to the start of buffer
nc.files.upload_stream("RGB.png", buf) # uploading file from the memory to the user's root folder
exit(0)
23 changes: 5 additions & 18 deletions nc_py_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
"""Import all possible stuff that can be used."""
"""All possible stuff for Nextcloud & NextcloudApp that can be used."""

from . import ex_app
from ._exceptions import NextcloudException, NextcloudExceptionNotFound
from ._version import __version__
from .constants import ApiScope, LogLvl
from .exceptions import NextcloudException, NextcloudExceptionNotFound, check_error
from .files_defs import (
FsNode,
FsNodeInfo,
Share,
SharePermissions,
ShareStatus,
ShareType,
)
from .gui_defs import GuiActionFileInfo, GuiFileActionHandlerInfo
from .integration_fastapi import (
enable_heartbeat,
nc_app,
set_enabled_handler,
set_scopes,
)
from .files import FsNode
from .files.sharing import SharePermissions, ShareType
from .nextcloud import Nextcloud, NextcloudApp
File renamed without changes.
2 changes: 1 addition & 1 deletion nc_py_api/misc.py → nc_py_api/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from string import ascii_lowercase, ascii_uppercase, digits
from typing import Union

from .exceptions import NextcloudException
from ._exceptions import NextcloudException


def kwargs_to_dict(keys: list[str], **kwargs) -> dict:
Expand Down
Loading

0 comments on commit 34cfd4c

Please sign in to comment.