Skip to content

Commit

Permalink
Started moving things.
Browse files Browse the repository at this point in the history
  • Loading branch information
starcraftman committed Jun 2, 2016
1 parent 51e6e20 commit 65f7b8a
Show file tree
Hide file tree
Showing 10 changed files with 632 additions and 414 deletions.
3 changes: 2 additions & 1 deletion pakit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from __future__ import absolute_import

from pakit.recipe import Recipe
from pakshell.shell import Archive, Dummy, Git, Hg
from pakshell.shell import Dummy, Git, Hg
from pakshell.arc import Archive

__all__ = ['Archive', 'Dummy', 'Git', 'Hg', 'Recipe']

Expand Down
66 changes: 66 additions & 0 deletions pakit/ifaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""
Shared holder of interfaces for the project.
"""
from __future__ import absolute_import
from abc import ABCMeta, abstractmethod, abstractproperty

from pakshell.cmd import Command


class Fetchable(object):
"""
Establishes an abstract interface for fetching source code.
Subclasses are destined for Recipe.repos to be used to retrieve source
from the wild.
Attributes:
target: The folder the source code should end up in.
uri: The location of the source code.
"""
__metaclass__ = ABCMeta

def __init__(self, uri, target):
self.target = target
self.uri = uri

@abstractmethod
def __enter__(self):
"""
Guarantees that source is available at target
"""
raise NotImplementedError

@abstractmethod
def __exit__(self, exc_type, exc_value, exc_tb):
"""
Handles errors as needed
"""
raise NotImplementedError

@abstractproperty
def ready(self):
"""
True iff the source code is available at target
"""
raise NotImplementedError

@abstractproperty
def src_hash(self):
"""
A hash that identifies the source snapshot
"""
raise NotImplementedError

def clean(self):
"""
Purges the source tree from the system
"""
Command('rm -rf ' + self.target)

@abstractmethod
def download(self):
"""
Retrieves code from the remote, may require additional steps
"""
raise NotImplementedError
3 changes: 2 additions & 1 deletion pakit/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

from pakit.conf import RecipeURIDB
from pakit.exc import PakitDBError, PakitError
from pakshell.shell import Command, vcs_factory
from pakshell.cmd import Command
from pakshell.shell import vcs_factory


PLOG = logging.getLogger('pakit').info
Expand Down
5 changes: 3 additions & 2 deletions pakit/task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=not-an-iterable
# pylint: disable=not-an-iterable,unsubscriptable-object
"""
The Tasks that pakit can perform for the user.
Expand All @@ -17,9 +17,10 @@
import pakit.recipe
from pakit.exc import PakitCmdError, PakitLinkError
from pakshell.shell import (
Command, walk_and_link, walk_and_unlink, walk_and_unlink_all,
walk_and_link, walk_and_unlink, walk_and_unlink_all,
write_config, unlink_man_pages, user_input, cd_and_call
)
from pakshell.cmd import Command

PREFIX = '\n '
PLOG = logging.getLogger('pakit').info
Expand Down

0 comments on commit 65f7b8a

Please sign in to comment.