Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
#23: Use absolute imports
Browse files Browse the repository at this point in the history
  • Loading branch information
derrix060 committed Nov 22, 2018
1 parent ace9d35 commit 0d7525e
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 72 deletions.
2 changes: 1 addition & 1 deletion onedrive_client/od_api_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import onedrivesdk.error
import requests

from . import od_dateutils
from onedrive_client import od_dateutils

THROTTLE_PAUSE_SEC = 60

Expand Down
4 changes: 2 additions & 2 deletions onedrive_client/od_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import os
import yaml

from . import od_api_session
from .od_models import account_profile
from onedrive_client import od_api_session
from onedrive_client.od_models import account_profile

PATH = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
with open(os.path.join(PATH, 'onedrive_client', 'data', 'security_config.yml')) as config:
Expand Down
6 changes: 3 additions & 3 deletions onedrive_client/od_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import click


from . import mkdir, get_resource, od_webhooks
from .od_models import account_profile
from .od_models import drive_config as _drive_config
from onedrive_client import mkdir, get_resource, od_webhooks
from onedrive_client.od_models import account_profile
from onedrive_client.od_models import drive_config as _drive_config


def is_invalid_username(s):
Expand Down
2 changes: 1 addition & 1 deletion onedrive_client/od_i18n.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from . import get_resource
from onedrive_client import get_resource


class Translator:
Expand Down
16 changes: 8 additions & 8 deletions onedrive_client/od_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import click
import daemonocle.cli

from . import od_repo
from . import od_task
from . import od_threads
from . import od_webhook
from .od_tasks import start_repo, merge_dir, update_subscriptions
from .od_auth import get_authenticator_and_drives
from .od_context import load_context
from .od_watcher import LocalRepositoryWatcher
from onedrive_client import od_repo
from onedrive_client import od_task
from onedrive_client import od_threads
from onedrive_client import od_webhook
from onedrive_client.od_tasks import start_repo, merge_dir, update_subscriptions
from onedrive_client.od_auth import get_authenticator_and_drives
from onedrive_client.od_context import load_context
from onedrive_client.od_watcher import LocalRepositoryWatcher


context = load_context(asyncio.get_event_loop())
Expand Down
2 changes: 1 addition & 1 deletion onedrive_client/od_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import (
from onedrive_client.od_models import (
account_profile,
bidict,
drive_config,
Expand Down
2 changes: 1 addition & 1 deletion onedrive_client/od_models/dict_guard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from . import exceptions
from onedrive_client.od_models.dict_guard import exceptions


class DictEntryTypes:
Expand Down
2 changes: 1 addition & 1 deletion onedrive_client/od_models/webhook_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:license: MIT
"""

from .. import od_dateutils
from onedrive_client import od_dateutils


class WebhookNotification:
Expand Down
14 changes: 7 additions & 7 deletions onedrive_client/od_pref.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import keyring
import tabulate

from . import __version__
from . import mkdir, get_resource, od_i18n, od_auth
from .od_models import pretty_api, drive_config, account_profile
from .od_api_session import OneDriveAPISession, get_keyring_key
from .od_models.dict_guard import GuardedDict, exceptions as guard_errors
from .od_context import load_context, save_context
from .od_repo import get_drive_db_path
from onedrive_client import __version__
from onedrive_client import mkdir, get_resource, od_i18n, od_auth
from onedrive_client.od_models import pretty_api, drive_config, account_profile
from onedrive_client.od_api_session import OneDriveAPISession, get_keyring_key
from onedrive_client.od_models.dict_guard import GuardedDict, exceptions as guard_errors
from onedrive_client.od_context import load_context, save_context
from onedrive_client.od_repo import get_drive_db_path


context = load_context()
Expand Down
8 changes: 4 additions & 4 deletions onedrive_client/od_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from contextlib import closing


from . import get_resource as _get_resource
from .od_models.path_filter import PathFilter as _PathFilter
from .od_api_helper import get_item_modified_datetime, get_item_created_datetime
from .od_dateutils import str_to_datetime, datetime_to_str
from onedrive_client import get_resource as _get_resource
from onedrive_client.od_models.path_filter import PathFilter as _PathFilter
from onedrive_client.od_api_helper import get_item_modified_datetime, get_item_created_datetime
from onedrive_client.od_dateutils import str_to_datetime, datetime_to_str


class ItemRecord:
Expand Down
4 changes: 2 additions & 2 deletions onedrive_client/od_tasks/delete_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import onedrivesdk.error

from . import update_item_base
from .. import od_api_helper
from onedrive_client.od_tasks import update_item_base
from onedrive_client import od_api_helper


class DeleteRemoteItemTask(update_item_base.UpdateItemTaskBase):
Expand Down
12 changes: 6 additions & 6 deletions onedrive_client/od_tasks/download_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import onedrivesdk.error

from . import base
from .. import fix_owner_and_timestamp
from ..od_api_helper import get_item_modified_datetime
from ..od_api_helper import item_request_call
from ..od_dateutils import datetime_to_timestamp
from ..od_hashutils import sha1_value
from onedrive_client.od_tasks import base
from onedrive_client import fix_owner_and_timestamp
from onedrive_client.od_api_helper import get_item_modified_datetime
from onedrive_client.od_api_helper import item_request_call
from onedrive_client.od_dateutils import datetime_to_timestamp
from onedrive_client.od_hashutils import sha1_value


class DownloadFileTask(base.TaskBase):
Expand Down
16 changes: 9 additions & 7 deletions onedrive_client/od_tasks/merge_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from onedrivesdk import Item, Folder, ChildrenCollectionRequest
from send2trash import send2trash

from . import base
from . import delete_item, download_file, upload_file
from .. import mkdir, fix_owner_and_timestamp
from ..od_api_helper import get_item_modified_datetime, item_request_call
from ..od_dateutils import datetime_to_timestamp, diff_timestamps
from ..od_hashutils import hash_match, sha1_value
from ..od_repo import ItemRecordType
from onedrive_client.od_tasks import base, delete_item, download_file, upload_file
from onedrive_client import mkdir, fix_owner_and_timestamp
from onedrive_client.od_api_helper import (
get_item_modified_datetime,
item_request_call,
)
from onedrive_client.od_dateutils import datetime_to_timestamp, diff_timestamps
from onedrive_client.od_hashutils import hash_match, sha1_value
from onedrive_client.od_repo import ItemRecordType


def rename_with_suffix(parent_abspath, name, host_name):
Expand Down
4 changes: 2 additions & 2 deletions onedrive_client/od_tasks/move_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import onedrivesdk.error
from onedrivesdk import Item, ItemReference

from . import update_mtime
from ..od_api_helper import item_request_call
from onedrive_client.od_tasks import update_mtime
from onedrive_client.od_api_helper import item_request_call


class MoveItemTask(update_mtime.UpdateTimestampTask):
Expand Down
6 changes: 4 additions & 2 deletions onedrive_client/od_tasks/start_repo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging
import os

from . import base
from . import merge_dir
from onedrive_client.od_tasks import (
base,
merge_dir,
)


class StartRepositoryTask(base.TaskBase):
Expand Down
2 changes: 1 addition & 1 deletion onedrive_client/od_tasks/update_item_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import base
from onedrive_client.od_tasks import base


class UpdateItemTaskBase(base.TaskBase):
Expand Down
12 changes: 7 additions & 5 deletions onedrive_client/od_tasks/update_mtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import onedrivesdk.error
from onedrivesdk import Item, FileSystemInfo

from . import update_item_base
from .. import fix_owner_and_timestamp
from ..od_api_helper import get_item_modified_datetime
from ..od_api_helper import item_request_call
from ..od_dateutils import datetime_to_timestamp
from onedrive_client.od_tasks import update_item_base
from onedrive_client import fix_owner_and_timestamp
from onedrive_client.od_api_helper import (
get_item_modified_datetime,
item_request_call,
)
from onedrive_client.od_dateutils import datetime_to_timestamp


class UpdateTimestampTask(update_item_base.UpdateItemTaskBase):
Expand Down
6 changes: 3 additions & 3 deletions onedrive_client/od_tasks/update_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import onedrivesdk
import onedrivesdk.error

from .base import TaskBase
from .. import od_api_helper
from onedrive_client.od_tasks import base
from onedrive_client import od_api_helper


class UpdateSubscriptionTask(TaskBase):
class UpdateSubscriptionTask(base.TaskBase):

def __init__(self, repo, task_pool, webhook_worker, subscription_id=None):
"""
Expand Down
4 changes: 2 additions & 2 deletions onedrive_client/od_tasks/upload_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import onedrivesdk
import onedrivesdk.error

from . import update_mtime
from ..od_api_helper import item_request_call
from onedrive_client.od_tasks import update_mtime
from onedrive_client.od_api_helper import item_request_call


class UploadFileTask(update_mtime.UpdateTimestampTask):
Expand Down
28 changes: 19 additions & 9 deletions onedrive_client/od_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
import threading

import onedrivesdk.error
from inotify_simple import flags as _inotify_flags, masks as _inotify_masks, INotify as _INotify

from .od_tasks import delete_item, move_item, merge_dir, update_mtime, upload_file
from .od_models.path_filter import PathFilter
from .od_models.bidict import loosebidict
from .od_api_helper import item_request_call
from .od_hashutils import hash_match
from .od_repo import ItemRecordType
from .od_stringutils import get_filename_with_incremented_count
from inotify_simple import (
flags as _inotify_flags,
masks as _inotify_masks,
INotify as _INotify,
)

from onedrive_client.od_tasks import (
delete_item,
move_item,
merge_dir,
update_mtime,
upload_file,
)
from onedrive_client.od_models.path_filter import PathFilter
from onedrive_client.od_models.bidict import loosebidict
from onedrive_client.od_api_helper import item_request_call
from onedrive_client.od_hashutils import hash_match
from onedrive_client.od_repo import ItemRecordType
from onedrive_client.od_stringutils import get_filename_with_incremented_count


class ParentTaskExistsException(Exception):
Expand Down
6 changes: 3 additions & 3 deletions onedrive_client/od_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import queue
import urllib.parse

from .od_models.webhook_notification import WebhookNotification
from onedrive_client.od_models.webhook_notification import WebhookNotification

try:
JSONDecodeError = json.JSONDecodeError
Expand All @@ -20,10 +20,10 @@ def get_webhook_server(context):
:param onedrive_client.od_context.UserContext context:
"""
if context.config['webhook_type'] == 'direct':
from .od_webhooks.http_server import WebhookConfig, WebhookListener
from onedrive_client.od_webhooks.http_server import WebhookConfig, WebhookListener
wh_config = WebhookConfig(host=context.config['webhook_host'], port=context.config['webhook_port'])
elif context.config['webhook_type'] == 'ngrok':
from .od_webhooks.ngrok_server import WebhookConfig, WebhookListener
from onedrive_client.od_webhooks.ngrok_server import WebhookConfig, WebhookListener
ngrok_config_file = context.config_dir + '/' + context.DEFAULT_NGROK_CONF_FILENAME
if not os.path.isfile(ngrok_config_file):
ngrok_config_file = None
Expand Down
2 changes: 1 addition & 1 deletion onedrive_client/od_webhooks/ngrok_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import psutil
import requests

from . import http_server
from onedrive_client.od_webhooks import http_server


class WebhookConfig(http_server.WebhookConfig):
Expand Down

0 comments on commit 0d7525e

Please sign in to comment.