def __init__(self, parent=None): super().__init__(parent) self.files = files.get_files() self.height = 300 self.checkboxes = [] self.col_selects = [] self.initUI()
def test_get_files(size): with TemporaryDirectory(dir=TMP) as dirname: test_size_in_kb = size * ONE_KB _create_files(dirname) files = list(get_files(dirname, test_size_in_kb)) filenames = [os.path.splitext(os.path.basename(f))[0] for f in files] assert all(int(fn) >= test_size_in_kb for fn in filenames)
def test_get_files(byte_sizes, size_in_kb, expected): with TemporaryDirectory(dir=TMP) as dirname: for size in byte_sizes: with open(os.path.join(dirname, str(size)), 'wb') as f: f.write(os.urandom(size)) actual = [os.path.basename(fi) for fi in get_files(dirname, size_in_kb)] assert sorted(actual) == sorted(expected)
def select_data(in_path,out_path,prefix="bin"): files.make_dir(out_path) all_files=files.get_files(in_path) prefix_files=[f for f in all_files if files.extract_prefix(f)==prefix] in_prefix_files=files.append_path(in_path,prefix_files) out_prefix_files=files.append_path(out_path,prefix_files) for in_file,out_file in zip(in_prefix_files,out_prefix_files): shutil.copyfile(in_file, out_file) print(in_file)
def list_file(): user = session['user'] users = None if user.id == 1: users = auth.get_users_dict() fs = files.get_files([user.id] if user.id != 1 else None) folders = files.get_folders_dict() return render_template('files.html', files=fs, users=users, user=user, folders=folders)
def main(): directory = "E:\Vidur\Analysis ongoing\FCS-arranged\Non RNAi" root = Tkinter.Tk() folder = tkFileDialog.askdirectory(initialdir = directory,parent=root,title='Choose a folder') root.withdraw() row_count = 1 fileiter = 0 file_list = files.get_files(folder, only=[".dat", "100", "tet","ALM"], skip=["codes",".png","away","branch","end"]) start_time_final = time.time() for datafile in file_list: start_time = time.time() fileiter = process(row_count, fileiter, datafile, file_list) print("--- %s seconds ---" % (time.time() - start_time)) print("--- %s seconds to complete---" % (time.time() - start_time_final))
def gather_data(directory): """ Gathers evaluation data from all csv files in a given directory. Arguments: directory Directory the csv files are stored in """ # Get all the csv files data = [] paths = files.get_files(directory, ['csv']) # Open each csv and dum all the responses to a list for p in paths: with open(p, 'r') as f: reader = csv.reader(f) data.extend(list(map(tuple, reader))[1:]) return data
def search_files(): query = request.args.get('q', None) if query is None: return redirect(request.referrer) user = None group_view = False if 'user' in session: is_own_file = request.args.get('is_own_file', '1') == '1' user = session['user'] users = None if user.id == 1: # shared files are not enabled for superuser if is_own_file is False: abort(404) users = auth.get_users_dict() folders = None if is_own_file is False: users = auth.get_users_dict() elif user.id != 1: folders = files.get_folders_dict() fs = files.get_files([user.id] if user.id != 1 else None) if is_own_file else files.get_user_shared_files(user.id) # group view else: group = session['group'] group_view = True fs = files.get_files_by_group(group.id) folders = files.get_folders_dict() users = auth.get_users_in_the_group(group.id) users = dict([[user.id, user] for user in users]) fs = [ f for f in fs if f.name.find(query) >= 0 ] return render_template('files.html', files=fs, users=users, user=user, folders=folders, group_view=group_view, search_view=True, query=query)
for i, ext in enumerate(exts): if ext[0] != '.': exts[i] = '.' + ext try: folders = [Path(folder) for folder in folders] is_folder = [folder.is_dir() for folder in folders] assert all(is_folder) except AssertionError: print('Invalid folder. Folder doesn\'t exist.') else: if not Path(folder_to_save).is_dir(): os.mkdir(folder_to_save) files_list = get_files('.', folders=folders, exts=exts) list_files_2('.', folders=folders, exts=exts) if exts: if mode == '-c': for file in files_list: shutil.copy(str(file), Path('.') / folder_to_save / file.name) elif mode == '-m': for file in files_list: shutil.move(str(file), Path('.') / folder_to_save / file.name) else: if mode == '-c': for folder in folders: