Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename package from 'op' to 'ops' #77

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion op/charm.py → ops/charm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from op.framework import Object, Event, EventBase, EventsBase
from ops.framework import Object, Event, EventBase, EventsBase


class HookEvent(EventBase):
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions op/main.py → ops/main.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import yaml

import op.charm
import op.framework
import op.model
import ops.charm
import ops.framework
import ops.model

CHARM_STATE_FILE = '.unit-state.db'

Expand Down Expand Up @@ -40,7 +40,7 @@ def _create_event_link(charm_dir, event_dir, target_path, bound_event):
bound_event -- An event for which to create a symlink.
"""
# TODO: Handle function/action events here.
if not issubclass(bound_event.event_type, op.charm.HookEvent):
if not issubclass(bound_event.event_type, ops.charm.HookEvent):
raise RuntimeError(f'cannot create a symlink: unsupported event type {bound_event.event_type}')

if not event_dir.exists():
Expand Down Expand Up @@ -71,7 +71,7 @@ def _setup_event_links(charm_dir, charm):
for bound_event in charm.on.events().values():
# Only events that originate from Juju need symlinks.
# TODO: handle function/action events here.
if issubclass(bound_event.event_type, op.charm.HookEvent):
if issubclass(bound_event.event_type, ops.charm.HookEvent):
event_dir = charm_dir / 'hooks'
_create_event_link(charm_dir, event_dir, charm_exec_path, bound_event)

Expand Down Expand Up @@ -101,7 +101,7 @@ def _get_event_args(charm, bound_event):
event_type = bound_event.event_type
model = charm.framework.model

if issubclass(event_type, op.charm.RelationEvent):
if issubclass(event_type, ops.charm.RelationEvent):
relation_name = os.environ['JUJU_RELATION']
relation_id = int(os.environ['JUJU_RELATION_ID'].split(':')[-1])
relation = model.get_relation(relation_name, relation_id)
Expand Down Expand Up @@ -138,15 +138,15 @@ def main(charm_class):
# TODO: For Windows, when symlinks are used, this is not a valid method of getting an event name (see LP: #1854505).
juju_event_name = Path(sys.argv[0]).name

meta = op.charm.CharmMeta(_load_metadata(charm_dir))
meta = ops.charm.CharmMeta(_load_metadata(charm_dir))
unit_name = os.environ['JUJU_UNIT_NAME']
model = op.model.Model(unit_name, meta, op.model.ModelBackend())
model = ops.model.Model(unit_name, meta, ops.model.ModelBackend())

# TODO: If Juju unit agent crashes after exit(0) from the charm code
# the framework will commit the snapshot but Juju will not commit its
# operation.
charm_state_path = charm_dir / CHARM_STATE_FILE
framework = op.framework.Framework(charm_state_path, charm_dir, meta, model)
framework = ops.framework.Framework(charm_state_path, charm_dir, meta, model)
try:
charm = charm_class(framework, None)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/charms/test_main/lib/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import base64
import pickle

from op.charm import CharmBase
from op.main import main
from ops.charm import CharmBase
from ops.main import main

import logging

Expand Down
1 change: 0 additions & 1 deletion test/charms/test_main/lib/op

This file was deleted.

1 change: 1 addition & 0 deletions test/charms/test_main/lib/ops
8 changes: 4 additions & 4 deletions test/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

from pathlib import Path

from op.charm import CharmBase, CharmMeta
from op.charm import CharmEvents
from op.framework import Framework, Event, EventBase
from op.model import Model, ModelBackend
from ops.charm import CharmBase, CharmMeta
from ops.charm import CharmEvents
from ops.framework import Framework, Event, EventBase
from ops.model import Model, ModelBackend


class TestCharm(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from pathlib import Path

from op.framework import (
from ops.framework import (
Framework, Handle, Event, EventsBase, EventBase, Object, PreCommitEvent, CommitEvent,
NoSnapshotError, StoredState, StoredList, BoundStoredState, StoredStateData
)
Expand Down
2 changes: 1 addition & 1 deletion test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from pathlib import Path

from op.charm import (
from ops.charm import (
CharmBase,
CharmEvents,
HookEvent,
Expand Down
Loading