コード例 #1
0
ファイル: users.py プロジェクト: bsherin/tactic
 def get_code_with_function(self, function_name):
     if self.code_collection_name not in db.collection_names():
         db.create_collection(self.code_collection_name)
     for doc in db[self.code_collection_name].find():
         if function_name in doc["metadata"]["functions"]:
             return doc["the_code"]
     return None
コード例 #2
0
ファイル: users.py プロジェクト: bsherin/tactic
 def get_code_with_class(self, class_name):
     if self.code_collection_name not in db.collection_names():
         db.create_collection(self.code_collection_name)
     for doc in db[self.code_collection_name].find():
         if class_name in doc["metadata"]["classes"]:
             return doc["the_code"]
     return None
コード例 #3
0
ファイル: users.py プロジェクト: technivore/tactic
 def tile_module_names(self,):
     if self.tile_collection_name not in db.collection_names():
         db.create_collection(self.tile_collection_name)
         return []
     my_tile_names = []
     for doc in db[self.tile_collection_name].find(projection=["tile_module_name"]):
         my_tile_names.append(doc["tile_module_name"])
     return sorted([str(t) for t in my_tile_names], key=str.lower)
コード例 #4
0
ファイル: users.py プロジェクト: technivore/tactic
 def list_names(self):
     if self.list_collection_name not in db.collection_names():
         db.create_collection(self.list_collection_name)
         return []
     my_list_names = []
     for doc in db[self.list_collection_name].find(projection=["list_name"]):
         my_list_names.append(doc["list_name"])
     return sorted([str(t) for t in my_list_names], key=str.lower)
コード例 #5
0
ファイル: users.py プロジェクト: bsherin/tactic
 def function_tags_dict(self):
     if self.code_collection_name not in db.collection_names():
         db.create_collection(self.code_collection_name)
         return {}
     functions = {}
     for doc in db[self.code_collection_name].find():
         tags = doc["metadata"]["tags"]
         for f in doc["metadata"]["functions"]:
             functions[f] = tags
     return functions
コード例 #6
0
ファイル: users.py プロジェクト: bsherin/tactic
 def class_tags_dict(self,):
     if self.code_collection_name not in db.collection_names():
         db.create_collection(self.code_collection_name)
         return {}
     classes = {}
     for doc in db[self.code_collection_name].find():
         tags = doc["metadata"]["tags"]
         for c in doc["metadata"]["classes"]:
             classes[c] = tags
     return classes
コード例 #7
0
ファイル: users.py プロジェクト: technivore/tactic
 def tile_module_names_with_metadata(self):
     if self.tile_collection_name not in db.collection_names():
         db.create_collection(self.tile_collection_name)
         return []
     my_tile_names = []
     for doc in db[self.tile_collection_name].find(projection=["tile_module_name", "metadata"]):
         if "metadata" in doc:
             my_tile_names.append([doc["tile_module_name"], doc["metadata"]])
         else:
             my_tile_names.append([doc["tile_module_name"], None])
     return sorted(my_tile_names, key=self.sort_data_list_key)
コード例 #8
0
ファイル: users.py プロジェクト: technivore/tactic
 def get_resource_names(self, res_type, tag_filter=None, search_filter=None):
     if tag_filter is not None:
         tag_filter = tag_filter.lower()
     if search_filter is not None:
         search_filter = search_filter.lower()
     if res_type == "collection":
         dcollections = self.data_collections
         res_names = []
         for dcol in dcollections:
             cname = self.build_data_collection_name(dcol)
             mdata = db[cname].find_one({"name": "__metadata__"})
             if tag_filter is not None:
                 if mdata is not None and "tags" in mdata:
                     if tag_filter in mdata["tags"].lower():
                         res_names.append(dcol)
             elif search_filter is not None:
                 if search_filter in dcol.lower():
                     res_names.append(dcol)
             else:
                 res_names.append(dcol)
     else:
         cnames = {"tile": self.tile_collection_name, "list": self.list_collection_name,
                   "project": self.project_collection_name}
         name_keys = {"tile": "tile_module_name", "list": "list_name", "project": "project_name"}
         cname = cnames[res_type]
         name_key = name_keys[res_type]
         if cname not in db.collection_names():
             db.create_collection(cname)
             return []
         res_names = []
         for doc in db[cname].find():
             if tag_filter is not None:
                 if "metadata" in doc:
                     if "tags" in doc["metadata"]:
                         if tag_filter in doc["metadata"]["tags"].lower():
                             res_names.append(doc[name_key])
             elif search_filter is not None:
                 if search_filter in doc[name_key].lower():
                     res_names.append(doc[name_key])
             else:
                 res_names.append(doc[name_key])
     return sorted([str(t) for t in res_names], key=str.lower)