def execute(input, options, environment): assert len(options) == 0 or len(options) == 1 if input != None: assert isinstance(input, iotypes.Directory) path = input.path elif len(options) != 0: path = access.interpret_path(options[0]) else: path = access.interpret_path("~") if not os.path.exists(path): raise IOError(html.strong(path) + ' is not accessible') elif not os.path.isdir(path): raise IOError(html.strong(path) + ' is not a directory') else: try: os.chdir(path) except Exception as error: raise IOError("Can't move to " + html.strong(path) + \ "; error is:" + html.br() + str(error))
def get_file_superstrings(substring): quoted_directory, fragment = os.path.split(substring) absolute_directory = access.interpret_path(quoted_directory) superstrings = [] for filename in os.listdir(absolute_directory): if filename.startswith(fragment): candidate = os.path.join(absolute_directory, filename) if os.path.isdir(candidate): filename += os.sep # add separator to directories filename = escape_spaces(filename) superstrings.append(os.path.join(quoted_directory, filename)) #superstrings = filter(lambda f:f.startswith(fragment), filenames) return superstrings
def execute(input, options, environment): files = [] if (input != None and len(input) > 0): # check input is all files? files = input assert len(options) == 1 path = access.interpret_path(options[0]) if globbing.is_glob_command(path): paths = expand_globs(path) else: paths = [path] for path in paths: files.append(recognise_file.create_file(path)) return files
#!/usr/bin/env python # (C) Rich Smith 2014 # [email protected] import os from view import ui from control import access, output, processor from apps import * name = "Fluidic" version = "0.4.0" if __name__ == '__main__': path = access.interpret_path("~") os.chdir(path) output.clear() output.welcome() ls_output = processor.process('ls'); output.print_outputs(ls_output) ui.setup()