Exemplo n.º 1
0
 def validate_options(self):
     try:
         re.compile(self.options.s_from)
         re.compile(self.options.s_to)
         return True
     except (sre_constants.error, re.error), e:
         re_exc = callbacks.RegularExpressionError(*e.args)
         callbacks.error_handler(re_exc)
Exemplo n.º 2
0
 def validate_options(self):
     try:
         re.compile(self.options.s_from)
         re.compile(self.options.s_to)
         return True
     except (sre_constants.error, re.error), e:
         re_exc = callbacks.RegularExpressionError(*e.args)
         callbacks.error_handler(re_exc)
Exemplo n.º 3
0
 def do_renames(cls, lst):
     for (f, g) in lst:
         try:
             cls.do_rename_exc(f, g)
         except EXCEPTION_LIST, e:
             callbacks.error_handler(e)
Exemplo n.º 4
0
 def do_renamedir(cls, f, g):
     if not os.path.exists(g) or cls.string_is_same_file(f, g):
         try:
             cls.do_rename_with_temp_exc(os.rename, f, g)
         except EXCEPTION_LIST, e:
             callbacks.error_handler(e)
Exemplo n.º 5
0
        else:
            cls.do_rename_with_temp_exc(os.renames, f, g)

    @classmethod
    def do_renamedir(cls, f, g):
        if not os.path.exists(g) or cls.string_is_same_file(f, g):
            try:
                cls.do_rename_with_temp_exc(os.rename, f, g)
            except EXCEPTION_LIST, e:
                callbacks.error_handler(e)
        else:
            for fp in os.listdir(f):
                try:
                    cls.do_rename_exc(os.path.join(f, fp), os.path.join(g, fp))
                except EXCEPTION_LIST, e:
                    callbacks.error_handler(e)

    @classmethod
    def io_set_actual_path(cls, filepath):
        """Fix a filepath that has the wrong case on the fs by renaming
        its parts directory by directory"""
        parts = filepath.split(os.sep)
        for (i, part) in enumerate(parts):
            prefix = os.sep.join(parts[:i]) if i > 0 else '.'
            fps = os.listdir(prefix)
            for fp in fps:
                if part.lower() == fp.lower() and not part == fp:
                    prefix = '' if prefix == '.' else prefix
                    fp_fs = os.path.join(prefix, fp)
                    fp_target = os.path.join(prefix, part)
                    cls.do_renamedir(fp_fs, fp_target)
Exemplo n.º 6
0
 def do_renames(cls, lst):
     for (f, g) in lst:
         try:
             cls.do_rename_exc(f, g)
         except EXCEPTION_LIST, e:
             callbacks.error_handler(e)
Exemplo n.º 7
0
 def do_renamedir(cls, f, g):
     if not os.path.exists(g) or cls.string_is_same_file(f, g):
         try:
             cls.do_rename_with_temp_exc(os.rename, f, g)
         except EXCEPTION_LIST, e:
             callbacks.error_handler(e)
Exemplo n.º 8
0
        else:
            cls.do_rename_with_temp_exc(os.renames, f, g)

    @classmethod
    def do_renamedir(cls, f, g):
        if not os.path.exists(g) or cls.string_is_same_file(f, g):
            try:
                cls.do_rename_with_temp_exc(os.rename, f, g)
            except EXCEPTION_LIST, e:
                callbacks.error_handler(e)
        else:
            for fp in os.listdir(f):
                try:
                    cls.do_rename_exc(os.path.join(f, fp), os.path.join(g, fp))
                except EXCEPTION_LIST, e:
                    callbacks.error_handler(e)

    @classmethod
    def io_set_actual_path(cls, filepath):
        """Fix a filepath that has the wrong case on the fs by renaming
        its parts directory by directory"""
        parts = filepath.split(os.sep)
        for (i, part) in enumerate(parts):
            prefix = os.sep.join(parts[:i]) if i > 0 else '.'
            fps = os.listdir(prefix)
            for fp in fps:
                if part.lower() == fp.lower() and not part == fp:
                    prefix = '' if prefix == '.' else prefix
                    fp_fs = os.path.join(prefix, fp)
                    fp_target = os.path.join(prefix, part)
                    cls.do_renamedir(fp_fs, fp_target)