def _read_file_as_dict(self): """Load the config file into self.config, with recursive loading.""" # This closure is made available in the namespace that is used # to exec the config file. It allows users to call # load_subconfig('myconfig.py') to load config files recursively. # It needs to be a closure because it has references to self.path # and self.config. The sub-config is loaded with the same path # as the parent, but it uses an empty config which is then merged # with the parents. # If a profile is specified, the config file will be loaded # from that profile def load_subconfig(fname, profile=None): # import here to prevent circular imports from IPython.core.profiledir import ProfileDir, ProfileDirError if profile is not None: try: profile_dir = ProfileDir.find_profile_dir_by_name( get_ipython_dir(), profile, ) except ProfileDirError: return path = profile_dir.location else: path = self.path loader = PyFileConfigLoader(fname, path) try: sub_config = loader.load_config() except ConfigFileNotFound: # Pass silently if the sub config is not there. This happens # when a user s using a profile, but not the default config. pass else: self.config.merge(sub_config) # Again, this needs to be a closure and should be used in config # files to get the config being loaded. def get_config(): return self.config namespace = dict( load_subconfig=load_subconfig, get_config=get_config, __file__=self.full_filename, ) fs_encoding = sys.getfilesystemencoding() or 'ascii' conf_filename = self.full_filename.encode(fs_encoding) py3compat.execfile(conf_filename, namespace)
def _read_file_as_dict(self): """Load the config file into self.config, with recursive loading.""" def get_config(): """Unnecessary now, but a deprecation warning is more trouble than it's worth.""" return self.config namespace = dict( c=self.config, load_subconfig=self.load_subconfig, get_config=get_config, __file__=self.full_filename, ) fs_encoding = sys.getfilesystemencoding() or 'ascii' conf_filename = self.full_filename.encode(fs_encoding) py3compat.execfile(conf_filename, namespace)
# pprint.pprint(ratingList) for i in range(len(ratingList)): bulk.find({ "userid": ratingList[i]["uid"] }).upsert().update({ "$setOnInsert": { "userid": ratingList[i]["uid"], "ratings": [] } }) bulk.find({ "userid": ratingList[i]["uid"] }).update({ "$push": { "ratings": { "movie": ratingList[i]["movie"], "rating": ratingList[i]["rating"], "date": ratingList[i]["date"] } } }) bulk.execute() print(filename) print("------------Calling Accuracy File--------------") execfile('calculate_accuracy_item_item.py') print("--------------DONE--------------")