Guest User

Untitled

a guest
Apr 23rd, 2012
36
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def batch_move(self, *args, **kwargs):
  2.   '''
  3.  Move a batch of files to its respective destinations.
  4.  Return type: tuple (boolean, message)
  5.                      T/F    , 'string' / str(exception)
  6.  '''
  7.  
  8.   srcs= kwargs.get('srcs', None)
  9.   dests = kwargs.get('dests', None)
  10.  
  11.   try:
  12.     if srcs and dests:
  13.        # map srcs and dests into dictionary (srcs --> keys, dests --> values)
  14.        src_dest= dict(zip(srcs, dests))    
  15.  
  16.        for src, dest in src_dest:
  17.          if os.path.exists(src):
  18.            if os.path.exists(dest):
  19.               shutil.rmtree(dest)
  20.            shutil.move(src, dest)   # either way we will proceed to move
  21.          else:
  22.            return (False, '%s does not exist!' % src)
  23.        return (True, 'Success!')
  24.  
  25.     else:
  26.        return (False, 'Something gone wrong with those kwargs...')
  27.   except Exception as e:
  28.     return (False, e)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×