Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def merge(move, output_dir, sources):
"""
Merge multiple results folder into one, by copying the results over to a new folder.
For a faster operation (which on the other hand destroys the campaign data
if interrupted), the move option can be used to directly move results to
the new folder.
"""
# Get paths for all campaign JSONS
jsons = []
for s in sources:
filename = "%s.json" % os.path.split(s)[1]
jsons += [os.path.join(s, filename)]
# Check that the configuration for all campaigns is the same
reference_config = TinyDB(jsons[0]).table('config')
for j in jsons[1:]:
for i, j in zip(reference_config.all(), TinyDB(j).table('config').all()):
assert i == j
# Create folders for new results directory
filename = "%s.json" % os.path.split(output_dir)[1]
output_json = os.path.join(output_dir, filename)
output_data = os.path.join(output_dir, 'data')
os.makedirs(output_data)
# Create new database
db = TinyDB(output_json)
db.table('config').insert_multiple(reference_config.all())
# Import results from all databases to the new JSON file
for s in sources:
def setupExperimentDataFiles(self):
unique_name = ExperimentManager.makeUniqueName() + "_" + self.config['mode']
folderName = os.path.join(self.cpfSourceDir, "data", "experiments", unique_name)
cmd = "mkdir -p " + folderName
print cmd
os.system(cmd)
time.sleep(0.5)
self.dataFolderName = folderName
self.db_json = os.path.join(folderName, 'db.json')
self.db = tinydb.TinyDB(self.db_json)
# create tinydb database
def clearplayedvideos(): # type: () -> None
"""
Clear played videos.
"""
# ask user for confirmation
if not xbmcgui.Dialog().yesno(
ADDON.getLocalizedString(30059).encode('utf-8'),
ADDON.getLocalizedString(30033).encode('utf-8')
):
return
# purge db table
db = tinydb.TinyDB(buildfp(FILENAME_DB))
db.purge_table(DBT_PLAYEDVIDEOS)
# refresh content
xbmc.executebuiltin('Container.Refresh()')
def restore_default_settings(self):
dbase = TinyDB('settings.json')
dbase.purge()
dbase.close()
self.__init__()
def db_scans(self):
"""The DB for scan files"""
try:
return self._db_scans
except AttributeError:
self._db_scans = TDB(os.path.join(self.basepath,
"%s.json" % self.dbname_scans))
return self._db_scans
def main(driver=None):
args = parse_args()
repo_status = []
with tinydb.TinyDB(args.infile[0].name) as db:
gh = db.table("GitHub")
for repo in get_repos(gh):
if of_interest(args, repo):
status = collect_status(gh, repo)
repo_status.append(status)
report_repos(args, repo_status)
tw_user (str): Twitter username of the person querying DragonfireAI Twitter account with a mention
"""
self.args = args
self.userin = userin
self.user_full_name = user_full_name
self.user_prefix = user_prefix
self.userin.twitter_user = tw_user
self.testing = testing
self.inactive = False
self.h = None
if not self.args["server"]:
self.inactive = True
if self.testing:
home = expanduser("~")
self.config_file = TinyDB(home + '/.dragonfire_config.json')
def __init__(self):
self.ownstorj_playlists_db = TinyDB('ownstorj_playlists.json')
self.playlists_table = self.ownstorj_playlists_db.table('playlists')
self.tracks_table = self.ownstorj_playlists_db.table('tracks')