Skip to content

Commit

Permalink
Better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Dec 17, 2019
1 parent b89b966 commit b49eaef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion data/src/file_gridfs/__init__.py
Expand Up @@ -36,4 +36,4 @@

from . import system

from .system import FileGridfs
from .system import FileGridFS
32 changes: 16 additions & 16 deletions data/src/file_gridfs/system.py
Expand Up @@ -45,9 +45,9 @@
ENGINE_NAME = "gridfs"
""" The engine name """

class FileGridfs(colony.System):
class FileGridFS(colony.System):
"""
The file gridfs class.
The file GridFS class.
"""

def get_engine_name(self):
Expand Down Expand Up @@ -83,38 +83,38 @@ def create_connection(self, connection_parameters):
# database from it (as the connection)
is_new = int(pymongo.version[0]) >= 3
if is_new: connection = pymongo.MongoClient(hostname, port)
else: connection = pymongo.Connection(hostname, port)
else: connection = pymongo.Connection(hostname, port) #@UndefinedVariable
connection_database = connection[database]

# creates the gridfs system from the connection
# creates the GridFS system from the connection
# database reference
gridfs_sytem = gridfs.GridFS(connection_database)

# returns the gridfs system as the connection
# returns the GridFS system as the connection
return gridfs_sytem

def close_connection(self, connection):
pass

def get(self, connection, file_name):
# retrieves the base file connection as the
# gridfs system
# GridFS system
gridfs_sytem = connection.file_connection

# adds the path separator value to the file name
# in case it's necessary
file_name = file_name.startswith("/") and file_name or "/" + file_name

# retrieves the (last version) target file from the
# given file name, from the gridfs system
# given file name, from the GridFS system
target_file = gridfs_sytem.get_last_version(file_name)

# returns the target file
return target_file

def put(self, connection, file_path, file_name):
# retrieves the base file connection as the
# gridfs system
# GridFS system
gridfs_sytem = connection.file_connection

# adds the path separator value to the file name
Expand All @@ -128,7 +128,7 @@ def put(self, connection, file_path, file_name):
try:
# reads the contents from the source file
# and writes them to the target file in the
# gridfs system
# GridFS system
source_contents = source_file.read()
gridfs_sytem.put(source_contents, filename = file_name)
finally:
Expand All @@ -137,7 +137,7 @@ def put(self, connection, file_path, file_name):

def put_file(self, connection, file, file_name):
# retrieves the base file connection as the
# gridfs system
# GridFS system
gridfs_sytem = connection.file_connection

# adds the path separator value to the file name
Expand All @@ -146,26 +146,26 @@ def put_file(self, connection, file, file_name):

# reads the contents from the (source) file
# and writes them to the target file in the
# gridfs system
# GridFS system
source_contents = file.read()
gridfs_sytem.put(source_contents, filename = file_name)

def put_data(self, connection, data, file_name):
# retrieves the base file connection as the
# gridfs system
# GridFS system
gridfs_sytem = connection.file_connection

# adds the path separator value to the file name
# in case it's necessary
file_name = file_name.startswith("/") and file_name or "/" + file_name

# writes the data to the target file in the
# gridfs system
# GridFS system
gridfs_sytem.put(data, filename = file_name)

def delete(self, connection, file_name):
# retrieves the base file connection as the
# gridfs system
# GridFS system
gridfs_sytem = connection.file_connection

# adds the path separator value to the file name
Expand All @@ -182,7 +182,7 @@ def delete(self, connection, file_name):

def list(self, connection, directory_name):
# retrieves the base file connection as the
# gridfs system
# GridFS system
gridfs_sytem = connection.file_connection

# adds the path separator value to the directory name
Expand All @@ -193,7 +193,7 @@ def list(self, connection, directory_name):
directory_name = directory_name.endswith("/") and directory_name or directory_name + "/"

# retrieves the file name list from the
# gridfs system and filters the values
# GridFS system and filters the values
# based on the directory name prefix
file_name_list = gridfs_sytem.list()
file_name_list = [value[len(directory_name):] for value in file_name_list if value.startswith(directory_name)]
Expand Down
10 changes: 5 additions & 5 deletions data/src/file_gridfs_plugin.py
Expand Up @@ -39,14 +39,14 @@

import colony

class FileGridfsPlugin(colony.Plugin):
class FileGridFSPlugin(colony.Plugin):
"""
The main class for the File Gridfs plugin.
The main class for the File GridFS plugin.
"""

id = "pt.hive.colony.plugins.data.file.gridfs"
name = "File Gridfs"
description = "File Gridfs Plugin"
name = "File GridFS"
description = "File GridFS Plugin"
version = "1.0.0"
author = "Hive Solutions Lda. <development@hive.pt>"
platforms = [
Expand All @@ -67,7 +67,7 @@ class FileGridfsPlugin(colony.Plugin):
def load_plugin(self):
colony.Plugin.load_plugin(self)
import file_gridfs
self.system = file_gridfs.FileGridfs(self)
self.system = file_gridfs.FileGridFS(self)

def get_engine_name(self):
return self.system.get_engine_name()
Expand Down

0 comments on commit b49eaef

Please sign in to comment.