Browse Source

PEP8 and deleted the import of the mongodbconnect function in the mongodb datasource

Roland Haroutiounian 8 years ago
parent
commit
8ca2869bbd

+ 2
- 2
plugins/mongodb_datasource/datasource.py View File

@@ -11,8 +11,8 @@ import urllib
11 11
 
12 12
 from lodel import logger
13 13
 
14
-from .utils import mongodbconnect, object_collection_name, \
15
-    connect, MONGODB_SORT_OPERATORS_MAP, connection_string
14
+from .utils import object_collection_name, connect, \
15
+    MONGODB_SORT_OPERATORS_MAP, connection_string
16 16
 
17 17
 class MongoDbDataSourceError(Exception):
18 18
     pass

+ 2
- 0
plugins/mongodb_datasource/main.py View File

@@ -1,9 +1,11 @@
1 1
 from lodel.plugin import LodelHook
2 2
 
3
+
3 4
 @LodelHook('mongodb_mh_init')
4 5
 def mongodb_migration_handler_init():
5 6
     import plugins.mongodb_datasource.migration_handler as migration_handler
6 7
 
8
+
7 9
 @LodelHook('mongodb_ds_init')
8 10
 def mongodb_datasource_init():
9 11
     import plugins.mongodb_datasource.datasource as datasource

+ 19
- 14
plugins/mongodb_datasource/utils.py View File

@@ -49,9 +49,11 @@ def get_connection_args(connnection_name='default'):
49 49
     return connect(host, port, dbname, login, password)
50 50
 '''
51 51
 
52
+
52 53
 def connection_string(host, port, db_name, username, password):
53 54
     return 'mongodb://%s:%s@%s:%s' % (username, password, host, port)
54 55
 
56
+
55 57
 def connect(host, port, db_name, username, password):
56 58
     connection = MongoClient(
57 59
         connection_string(host, port, db_name, username, password))
@@ -59,7 +61,6 @@ def connect(host, port, db_name, username, password):
59 61
     return database
60 62
 
61 63
 
62
-
63 64
 ## @brief Returns a collection name given a EmClass
64 65
 # @param class_object EmClass
65 66
 # @return str
@@ -72,26 +73,30 @@ def object_collection_name(class_object):
72 73
 
73 74
     return collection_name
74 75
 
75
-##@brief Determine a collection field name given a lodel2 fieldname
76
-#@note For the moment this method only return the argument but EVERYWHERE
77
-#in the datasource we should use this method to gather proper fieldnames
78
-#@param fieldname str : A lodel2 fieldname
79
-#@return A string representing a well formated mongodb fieldname
80
-#@see mongo_filednames
76
+
77
+## @brief Determine a collection field name given a lodel2 fieldname
78
+# @note For the moment this method only return the argument but EVERYWHERE
79
+# in the datasource we should use this method to gather proper fieldnames
80
+# @param fieldname str : A lodel2 fieldname
81
+# @return A string representing a well formated mongodb fieldname
82
+# @see mongo_filednames
81 83
 def mongo_fieldname(fieldname):
82 84
     return fieldname
83
-##@brief Same as mongo_fieldname but for list of fields
85
+
86
+
87
+## @brief Same as mongo_fieldname but for list of fields
84 88
 #
85
-#A small utility function
86
-#@param fieldnames iterable : contains str only
87
-#@return a list of converted fildnames (str)
88
-#@see mongo_fieldname
89
+# A small utility function
90
+# @param fieldnames iterable : contains str only
91
+# @return a list of converted fildnames (str)
92
+# @see mongo_fieldname
89 93
 def mongo_fieldnames(fieldnames):
90 94
     return [mongo_fieldname(fname) for fname in fieldnames]
91 95
 
96
+
92 97
 ## @brief Returns a list of orting options
93 98
 # @param query_filters_order list
94 99
 # @return list
95 100
 def parse_query_order(query_filters_order):
96
-    return [    (field, LODEL_SORT_OPERATORS_MAP[direction])
97
-                for field, direction in query_filters_order]
101
+    return [(field, LODEL_SORT_OPERATORS_MAP[direction])
102
+            for field, direction in query_filters_order]

Loading…
Cancel
Save