From 82f40e06f9296d2f5bc2313b46aeb0ab095fdb49 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 20 Mar 2011 15:38:48 -0400 Subject: [PATCH] added flags, not_flags, files, not_files --- clint/arguments.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/clint/arguments.py b/clint/arguments.py index bb5c4f6..1fde0b3 100644 --- a/clint/arguments.py +++ b/clint/arguments.py @@ -301,20 +301,20 @@ class Args(object): return Args(_args, no_argv=True) - @property - def no_flags(self): - """Returns Arg object excluding flagged arguments.""" - - return self.all_without('-') - - @property - def only_flags(self): + def flags(self): """Returns Arg object including only flagged arguments.""" return self.all_with('-') + @property + def not_flags(self): + """Returns Arg object excluding flagged arguments.""" + + return self.all_without('-') + + @property def files(self, absolute=False): """Returns an expanded list of all valid paths that were passed in.""" @@ -332,6 +332,19 @@ class Args(object): return _paths + @property + def not_files(self): + """Returns a list of all arguments that aren't files/globs.""" + + _args = [] + + for arg in self.all: + if not len(_expand_path(arg)): + if not os.path.exists(arg): + _args.append(arg) + + return _args + @property def copy(self): """Returns a copy of Args object for temporary manipulation."""