Skip to content

Commit

Permalink
gchqgh-14 - Fix Python project layout
Browse files Browse the repository at this point in the history
  • Loading branch information
t616178 committed Nov 29, 2016
1 parent e34d2cd commit 138606b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 44 deletions.
6 changes: 2 additions & 4 deletions python-shell/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from . import gafferpy
from . import gaffer_connector
from . import gaffer_connector_pki
from . import example
from . import example_pki
from gafferpy import gaffer_connector
from gafferpy import gaffer_connector_pki

__version__ = "0.4.6"

Expand Down
30 changes: 15 additions & 15 deletions python-shell/src/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def get_filter_functions(gc):

def get_class_filter_functions(gc):
# Get Schema
class_name = 'gafferpy.function.simple.filter.IsMoreThan'
class_name = 'gaffer.function.simple.filter.IsMoreThan'
result = gc.execute_get(
g.GetClassFilterFunctions(class_name=class_name)
)

print('Class Filter Functions (gafferpy.function.simple.filter.IsMoreThan):')
print('Class Filter Functions (gaffer.function.simple.filter.IsMoreThan):')
print(result)
print()

Expand Down Expand Up @@ -111,12 +111,12 @@ def get_operations(gc):

def get_serialised_fields(gc):
# Get Schema
class_name = 'gafferpy.function.simple.filter.IsMoreThan'
class_name = 'gaffer.function.simple.filter.IsMoreThan'
result = gc.execute_get(
g.GetSerialisedFields(class_name=class_name)
)

print('Serialised Fields (gafferpy.function.simple.filter.IsMoreThan):')
print('Serialised Fields (gaffer.function.simple.filter.IsMoreThan):')
print(result)
print()

Expand All @@ -133,12 +133,12 @@ def get_store_traits(gc):


def is_operation_supported(gc):
operation = 'gafferpy.operation.impl.add.AddElements'
operation = 'gaffer.operation.impl.add.AddElements'
result = gc.is_operation_supported(
g.IsOperationSupported(operation=operation)
)

print('\nOperation supported ("gafferpy.operation.impl.add.AddElements"):')
print('\nOperation supported ("gaffer.operation.impl.add.AddElements"):')
print(result)
print()

Expand Down Expand Up @@ -196,8 +196,8 @@ def add_elements(gc):

def get_elements(gc):
# Get Elements
filter_class = 'gafferpy.function.simple.filter.IsEqual'
transform_class = 'gafferpy.rest.example.ExampleTransformFunction'
filter_class = 'gaffer.function.simple.filter.IsEqual'
transform_class = 'gaffer.rest.example.ExampleTransformFunction'
elements = gc.execute_operation(
g.GetRelatedElements(
seeds=[g.EntitySeed('1')],
Expand All @@ -210,14 +210,14 @@ def get_elements(gc):
],
filter_functions=[
g.FilterFunction(
class_name='gafferpy.function.simple.filter.IsEqual',
class_name='gaffer.function.simple.filter.IsEqual',
selection=['VERTEX'],
function_fields={'value': '1'}
)
],
transform_functions=[
g.TransformFunction(
class_name='gafferpy.rest.example.ExampleTransformFunction',
class_name='gaffer.rest.example.ExampleTransformFunction',
selection=['VERTEX'],
projection=['newProperty']
)
Expand Down Expand Up @@ -273,10 +273,10 @@ def get_all_elements(gc):
def generate_elements(gc):
# Generate Elements
elements = gc.execute_operation(
g.GenerateElements('gafferpy.rest.example.ExampleDomainObjectGenerator',
g.GenerateElements('gaffer.rest.example.ExampleDomainObjectGenerator',
objects=[
{
'class': 'gafferpy.rest.example.ExampleDomainObject',
'class': 'gaffer.rest.example.ExampleDomainObject',
'ids': [
'1',
'2',
Expand All @@ -285,7 +285,7 @@ def generate_elements(gc):
'type': 'edge'
},
{
'class': 'gafferpy.rest.example.ExampleDomainObject',
'class': 'gaffer.rest.example.ExampleDomainObject',
'ids': [
'1'
],
Expand All @@ -302,7 +302,7 @@ def generate_elements(gc):
def generate_domain_objs(gc):
# Generate Domain Objects - single provided element
objects = gc.execute_operation(
g.GenerateObjects('gafferpy.rest.example.ExampleDomainObjectGenerator',
g.GenerateObjects('gaffer.rest.example.ExampleDomainObjectGenerator',
elements=[
g.Entity('entity', '1'),
g.Edge('edge', '1', '2', True)
Expand All @@ -322,7 +322,7 @@ def generate_domain_objects_chain(gc):
seeds=[g.EntitySeed('1')]
),
g.GenerateObjects(
'gafferpy.rest.example.ExampleDomainObjectGenerator')
'gaffer.rest.example.ExampleDomainObjectGenerator')
]
)
print('Generated objects from get elements by seed')
Expand Down
48 changes: 24 additions & 24 deletions python-shell/src/gafferpy/gaffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def to_elements(result):
if result is not None and isinstance(result, list):
for result_item in result:
if 'class' in result_item:
if result_item['class'] == 'gafferpy.data.element.Entity':
if result_item['class'] == 'gaffer.data.element.Entity':
element = Entity(result_item['group'],
result_item['vertex'])
elif result_item['class'] == 'gafferpy.data.element.Edge':
elif result_item['class'] == 'gaffer.data.element.Edge':
element = Edge(result_item['group'],
result_item['source'],
result_item['destination'],
Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(self, vertex):
self.vertex = vertex

def to_json(self):
return {'class': 'gafferpy.operation.data.EntitySeed',
return {'class': 'gaffer.operation.data.EntitySeed',
'vertex': self.vertex}


Expand All @@ -102,7 +102,7 @@ def __init__(self, source, destination, directed):

def to_json(self):
return {
'class': 'gafferpy.operation.data.EdgeSeed',
'class': 'gaffer.operation.data.EdgeSeed',
'source': self.source,
'destination': self.destination,
'directed': self.directed}
Expand Down Expand Up @@ -130,7 +130,7 @@ def to_json(self):

class Entity(Element):
def __init__(self, group, vertex, properties=None):
super().__init__('gafferpy.data.element.Entity', group, properties)
super().__init__('gaffer.data.element.Entity', group, properties)
self.vertex = vertex

def to_json(self):
Expand All @@ -141,7 +141,7 @@ def to_json(self):

class Edge(Element):
def __init__(self, group, source, destination, directed, properties=None):
super().__init__('gafferpy.data.element.Edge', group, properties)
super().__init__('gaffer.data.element.Edge', group, properties)
# Validate the arguments
if not isinstance(directed, bool):
raise TypeError('Directed must be a boolean')
Expand Down Expand Up @@ -320,7 +320,7 @@ class AddElements(Operation):
def __init__(self, elements=None, skip_invalid_elements=False,
validate=True,
view=None, options=None):
super().__init__('gafferpy.operation.impl.add.AddElements', view, options)
super().__init__('gaffer.operation.impl.add.AddElements', view, options)
self.elements = elements
self.skip_invalid_elements = skip_invalid_elements
self.validate = validate
Expand All @@ -343,7 +343,7 @@ def convert_result(self, result):
class GenerateElements(Operation):
def __init__(self, generator_class_name, element_generator_fields=None,
objects=None, view=None, options=None):
super().__init__('gafferpy.operation.impl.generate.GenerateElements',
super().__init__('gaffer.operation.impl.generate.GenerateElements',
view, options)
self.generator_class_name = generator_class_name
self.element_generator_fields = element_generator_fields
Expand All @@ -369,7 +369,7 @@ def convert_result(self, result):
class GenerateObjects(Operation):
def __init__(self, generator_class_name, element_generator_fields=None,
elements=None, view=None, options=None):
super().__init__('gafferpy.operation.impl.generate.GenerateObjects', view,
super().__init__('gaffer.operation.impl.generate.GenerateObjects', view,
options)
self.generator_class_name = generator_class_name
self.element_generator_fields = element_generator_fields
Expand Down Expand Up @@ -398,7 +398,7 @@ def convert_result(self, result):
class InitialiseSetExport(Operation):
def __init__(self, key=None, options=None):
super().__init__(
'gafferpy.operation.impl.export.initialise.InitialiseSetExport',
'gaffer.operation.impl.export.initialise.InitialiseSetExport',
None,
options)
if not isinstance(key, str) and key is not None:
Expand All @@ -419,7 +419,7 @@ def convert_result(self, result):

class UpdateExport(Operation):
def __init__(self, key=None, options=None):
super().__init__('gafferpy.operation.impl.export.UpdateExport', None,
super().__init__('gaffer.operation.impl.export.UpdateExport', None,
options)
if not isinstance(key, str) and key is not None:
raise TypeError('key must be a string')
Expand All @@ -439,7 +439,7 @@ def convert_result(self, result):

class FetchExporter(Operation):
def __init__(self, options=None):
super().__init__('gafferpy.operation.impl.export.FetchExporter', None,
super().__init__('gaffer.operation.impl.export.FetchExporter', None,
options)

def convert_result(self, result):
Expand All @@ -448,7 +448,7 @@ def convert_result(self, result):

class FetchExport(Operation):
def __init__(self, key=None, options=None):
super().__init__('gafferpy.operation.impl.export.FetchExport', None,
super().__init__('gaffer.operation.impl.export.FetchExport', None,
options)
if not isinstance(key, str) and key is not None:
raise TypeError('key must be a string')
Expand Down Expand Up @@ -511,15 +511,15 @@ class GetRelatedElements(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
include_entities=True, include_edges=IncludeEdges.ALL,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetRelatedElements', seeds,
super().__init__('gaffer.operation.impl.get.GetRelatedElements', seeds,
view, result_limit, include_entities, include_edges,
in_out_type, deduplicate, options)


class GetRelatedEntities(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetRelatedEntities', seeds,
super().__init__('gaffer.operation.impl.get.GetRelatedEntities', seeds,
view, result_limit, True, IncludeEdges.NONE,
in_out_type, deduplicate, options)

Expand All @@ -528,7 +528,7 @@ class GetRelatedEdges(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
include_edges=IncludeEdges.ALL,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetRelatedEdges', seeds,
super().__init__('gaffer.operation.impl.get.GetRelatedEdges', seeds,
view, result_limit, False, include_edges,
in_out_type, deduplicate, options)

Expand All @@ -537,15 +537,15 @@ class GetElementsBySeed(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
include_entities=True, include_edges=IncludeEdges.ALL,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetElementsBySeed', seeds,
super().__init__('gaffer.operation.impl.get.GetElementsBySeed', seeds,
view, result_limit, include_entities, include_edges,
in_out_type, deduplicate, options)


class GetEntitiesBySeed(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetEntitiesBySeed', seeds,
super().__init__('gaffer.operation.impl.get.GetEntitiesBySeed', seeds,
view, result_limit, True, IncludeEdges.NONE,
in_out_type, deduplicate, options)

Expand All @@ -554,15 +554,15 @@ class GetEdgesBySeed(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
include_edges=IncludeEdges.ALL,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetEntitiesBySeed', seeds,
super().__init__('gaffer.operation.impl.get.GetEntitiesBySeed', seeds,
view, result_limit, False, include_edges,
in_out_type, deduplicate, options)


class GetAdjacentEntitySeeds(GetOperation):
def __init__(self, seeds=None, view=None, result_limit=None,
in_out_type=InOutType.BOTH, deduplicate=None, options=None):
super().__init__('gafferpy.operation.impl.get.GetAdjacentEntitySeeds',
super().__init__('gaffer.operation.impl.get.GetAdjacentEntitySeeds',
seeds, result_limit, view, True, IncludeEdges.ALL,
in_out_type, deduplicate, options)

Expand All @@ -574,7 +574,7 @@ class GetAllElements(GetOperation):
def __init__(self, view=None, include_entities=True, result_limit=None,
include_edges=IncludeEdges.ALL, deduplicate=None,
options=None):
super().__init__('gafferpy.operation.impl.get.GetAllElements',
super().__init__('gaffer.operation.impl.get.GetAllElements',
None, view, result_limit, include_entities,
include_edges,
InOutType.OUT, deduplicate, options)
Expand All @@ -586,7 +586,7 @@ def convert_result(self, result):
class GetAllEntities(GetOperation):
def __init__(self, view=None, result_limit=None, deduplicate=None,
options=None):
super().__init__('gafferpy.operation.impl.get.GetAllEntities',
super().__init__('gaffer.operation.impl.get.GetAllEntities',
None, view, result_limit, True, IncludeEdges.NONE,
InOutType.OUT, deduplicate, options)

Expand All @@ -598,7 +598,7 @@ class GetAllEdges(GetOperation):
def __init__(self, result_limit=None, view=None,
include_edges=IncludeEdges.ALL, deduplicate=None,
options=None):
super().__init__('gafferpy.operation.impl.get.GetAllEdges',
super().__init__('gaffer.operation.impl.get.GetAllEdges',
None, view, result_limit, False, include_edges,
InOutType.OUT, deduplicate, options)

Expand All @@ -608,7 +608,7 @@ def convert_result(self, result):

class CountGroups(Operation):
def __init__(self, limit=None, options=None):
super().__init__('gafferpy.operation.impl.CountGroups',
super().__init__('gaffer.operation.impl.CountGroups',
None, options)
self.limit = limit

Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/gafferpy/gaffer_connector_pki.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import urllib.error
import urllib.request

from gaffer import gaffer_connector
from gafferpy import gaffer_connector


class GafferConnector(gaffer_connector.GafferConnector):
Expand Down

0 comments on commit 138606b

Please sign in to comment.