-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51e6e20
commit 65f7b8a
Showing
10 changed files
with
632 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.