Product and Project directory protocol support.
Provides three classes of interest: Project, Product, and Context. Context manages a project set formed from a sequence of Products that make up a factor search path; Projects are cached on Context instances and Products primarily provide access and updates to a product directory's index, the .product directory.
Even in the case of single product directories, a Context should be used to access the projects. The primary function of a Product instance is to merely provide access to the data stored in the index, not as a general purpose abstraction for interacting with the product directory as that function usually involves multiple directories, an abstraction provided by Context.
typing
collections0
operator0
itertools0
tools0
Selector
Segment0
types0
parse_project_index0
parse_project_index(lines)
Generate tuples from the given space separated fields, lines. Intended to be interpreted as a dictionary, the items' initial element should be the project's (universal) identifier. The second element is a tuple of the local name and project protocol identifier.
parse_protocol_declaration20%
parse_protocol_declaration(text)
Split the text and return the fields as a tuple.
structure_project_declaration285%
structure_project_declaration(text)
Parse the contents of a .project file.
structure_project_declarationReturns
A pair, the project protocol and a fault.project.types.Information instance.
sequence_project_declaration0
sequence_project_declaration()
Format the contents of a .project file from the given protocol and fault.project.types.Information structure.
scan_product_directory285%
scan_product_directory(read_protocol, route)
Identify the projects within the given route. Usually only used through Product.update.
protocols0
protocols = {
'factors/polynomial-1': (__package__ + '.polynomial', 'V1'),
}
Product0
Project set root providing access to contexts and projects.
While often annotated as fault.route.types.Selector, usually filesystem operation must be supported by the selector.
Productproject_identity_segment0
project_identity_segment = Segment.from_sequence(['.project', 'f-identity'])
Productdefault_meta_directory0
default_meta_directory = Segment.from_sequence(['.product'])
Productdefault_images_directory0
default_images_directory = Segment.from_sequence(['.images'])
@classmethod
Productimport_protocol0types.FactorIsolationProtocol
import_protocol(Class, identifier)
Retrieve the protocol class using the identifier.
Productproject_index_route0Selector
Materialized project index file path.
Productconnections_index_route0Selector
Connection list fulfilling requirements.
Productconnections266%
The requirements of the product as a sequence of product directory routes.
This sequence is not cached and constructed at access time by opening the file connections_index_route.
Productclear0
clear(self)
Remove the instance local cache.
Product__init__0
__init__(self, route)
Initialize a Product using route with an empty local instance cache.
cache parameter is available as an override for the .product directory location, but should normally not be used.
Product__hash__10%
__hash__(self)
Product__eq__10%
__eq__(self, operand)
Productimage0
image(self, variants, project, factor)
Identify the location of the factor's image for the given variants.
Productidentifier_by_factor0typing.Tuple[str, types.FactorIsolationProtocol]
identifier_by_factor(self, factor)
Select the project identifier and protocol using a factor path (to the project). Uses the instance local cache populated by load or update.
Productfactor_by_identifier0typing.Tuple[types.FactorPath, types.FactorIsolationProtocol]
factor_by_identifier(self, identifier)
Select the factor path (to the project) and protocol using the project identifier. Uses the instance local cache populated by load or update.
Productselect736%typing.Iterable[types.FactorPath]
select(self, constraint)
Retrieve project (path) entries that have the given prefix, constraint.
If the argument identifies a context, generate the projects contained therein. If the argument is a nil fault.project.types.FactorPath, generate all project paths.
Productread_protocol0
read_protocol(self, route)
Retrieve the protocol data from the configured project_declaration_filesnames.
Product_spec0
Productload0
load(self)
Load the snapshot of the projects from the product's route.
Productstore0
store(self)
Store the snapshot of the projects to the product's route.
Productupdate0
update(self)
Update the snapshot of the projects by querying the filesystem. The effects of this should be recorded with a subsequent call to store.
Productiterprojects381%
iterprojects(self)
Query the route and retrieve all projects within the product.
Results may be inconsistent with the instance cache.
Productsplit0
split(self, fpath)
Separate the project portion from fpath. Returns a pair of fault.project.types.FactorPath; the project and the factor.
Project0
Project Interface joining relavant routes and protocol instances.
Projectmeta_directory_path0
meta_directory_path = Segment.from_sequence(['.project'])
@tools.cachedproperty
Projectmeta0
meta(self)
The directory containing project metadata.
Project__init__0
__init__(self, pd, pi, pf, proto)
Project_iid_corpus_name_pair0
_iid_corpus_name_pair(self)
Projectcorpus0str
The leading portion of the independent identifier.
Projectname0str
The name of the project as defined by the independent identifier.
Projectrequirements214%
requirements(self, context)
Identify the unique set of projects required by this project.
Projectinformation250%types.Information
information(self)
The identifying information of the project.
Projectextensions0types.Extensions
extensions(self)
Additional identifying information of the project.
Projecticon260%bytes
icon(self)
Read the icon reference contained in .project/icon.
ProjecticonReturns
b''When the filesystem resource could not be loaded or when only whitespace is present.
Exceptions are suppressed.
- bytes
The data content of the
self.meta / 'icon'filesystem resource as read by files.Path.fs_load.
Projectsynopsis260%bytes
synopsis(self)
Read the synopsis data contained in .project/synopsis.
ProjectsynopsisReturns
b''When the filesystem resource could not be loaded or when only whitespace is present.
Exceptions are suppressed.
- bytes
The data content of the
self.meta / 'synopsis'filesystem resource as read by files.Path.fs_load.
Projectimage0
image(self, variants, fp)
Projectselect0
select(self, factor)
Retrieve factors within the given path.
Projectsplit80%
split(self, fp)
Separate the factor path from the element path. Returns a pair, fault.project.types.FactorPath and a str; the project and the factor.
Projectfullsplit40%
fullsplit(self, qpath)
Separate the project path, factor path, and fragment path from the given fully qualified factor path.
Projectrefer0types.Reference
refer(self, factorpath)
Construct a fault.project.types.Reference instance using the given factorpath.
Context0
Product and Project instance cache and search path.
Contextimport_protocol0typing.Type[types.FactorIsolationProtocol]
import_protocol(Class, identifier)
Retrieve the protocol class using the identifier.
Contextfrom_product_connections0
from_product_connections(Class, pd)
Create a Context initializing it with the immediate connections identified by pd.
Context__init__0
__init__(self)
Contextconnect0Product
connect(self, route)
Add a new Product instance to the context.
Returns an existing Product instance if the route was in the cache, otherwise creates a new instance and places it in the cache.
Contextproject0Project
project(self, id)
Retrieve a Project instance from the context's instance cache.
ContextprojectExceptions
- LookupError
No project with the given identifier has been loadded in the context.
Contextiterprojects0typing.Iterable[Project]
iterprojects(self)
Generate Project instances cached from a prior load call.
This includes any Context Projects.
Contextload0
load(self)
Fully populate the instance cache with all of the projects from all of the connected products.
Contextconfigure0
configure(self)
Traverse the cached projects and apply protocol inheritance.
Contextindex40%
index(self, product)
Find the index of the Product whose route is equal to product.
Contextsplit0
split(self, qpath)
Identify the product, project, and factor path of the given qpath. Returns a triple identifying the Product, Project, and remaining fault.project.types.FactorPath.
ContextsplitParameters
Contextimage20%
image(self, variants, fp)
Contextrefer325%
refer(self, factorpath)
Construct a fault.project.types.Reference from the given factorpath string.
factorpath is first processed with fault.project.types.fpc before being analyzed by split.