From 42c2d2e843ca1af4571e6c77b0240c319490a619 Mon Sep 17 00:00:00 2001 From: Thomas Conte Date: Wed, 12 Sep 2018 10:40:33 +0200 Subject: [PATCH] Remove stripes --- azfilebak/naming.py | 67 +++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/azfilebak/naming.py b/azfilebak/naming.py index ed0bf74..52021ac 100644 --- a/azfilebak/naming.py +++ b/azfilebak/naming.py @@ -28,29 +28,28 @@ class Naming(object): return ({"full":True, "tran":False})[type_str] @staticmethod - def construct_filename(fileset, is_full, start_timestamp, stripe_index, stripe_count): + def construct_filename(fileset, is_full, start_timestamp): """ - >>> Naming.construct_filename(fileset="test1fs", is_full=True, start_timestamp="20180601_112429", stripe_index=2, stripe_count=101) - 'test1fs_full_20180601_112429_S002-101.tar' - >>> Naming.construct_filename(fileset="test1fs", is_full=False, start_timestamp="20180601_112429", stripe_index=2, stripe_count=101) - 'test1fs_tran_20180601_112429_S002-101.tar' + >>> Naming.construct_filename(fileset="test1fs", is_full=True, start_timestamp="20180601_112429") + 'test1fs_full_20180601_112429.tar' + >>> Naming.construct_filename(fileset="test1fs", is_full=False, start_timestamp="20180601_112429") + 'test1fs_tran_20180601_112429.tar' """ - return "{fileset}_{type}_{start_timestamp}_S{idx:03d}-{cnt:03d}.tar".format( + return "{fileset}_{type}_{start_timestamp}.tar".format( fileset=fileset, type=Naming.backup_type_str(is_full), - start_timestamp=start_timestamp, - idx=int(stripe_index), cnt=int(stripe_count)) + start_timestamp=start_timestamp) @staticmethod - def local_filesystem_name(directory, fileset, is_full, start_timestamp, stripe_index, stripe_count): + def local_filesystem_name(directory, fileset, is_full, start_timestamp): """ Construct file name with directory. - >>> Naming.local_filesystem_name(directory="/tmp", fileset="test1fs", is_full=True, start_timestamp="20180601_112429", stripe_index=2, stripe_count=101) - '/tmp/test1fs_full_20180601_112429_S002-101.tar' + >>> Naming.local_filesystem_name(directory="/tmp", fileset="test1fs", is_full=True, start_timestamp="20180601_112429") + '/tmp/test1fs_full_20180601_112429.tar' """ file_name = Naming.construct_filename( - fileset, is_full, start_timestamp, stripe_index, stripe_count) + fileset, is_full, start_timestamp) return os.path.join(directory, file_name) @staticmethod @@ -62,52 +61,51 @@ class Naming(object): return "{fileset}_{type}_".format(fileset=fileset, type=Naming.backup_type_str(is_full)) @staticmethod - def construct_blobname(fileset, is_full, start_timestamp, end_timestamp, stripe_index, stripe_count): + def construct_blobname(fileset, is_full, start_timestamp, end_timestamp): """ - >>> Naming.construct_blobname(fileset="test1fs", is_full=True, start_timestamp="20180601_112429", end_timestamp="20180601_131234", stripe_index=2, stripe_count=101) - 'test1fs_full_20180601_112429--20180601_131234_S002-101.tar' + >>> Naming.construct_blobname(fileset="test1fs", is_full=True, start_timestamp="20180601_112429", end_timestamp="20180601_131234") + 'test1fs_full_20180601_112429--20180601_131234.tar' """ - return "{fileset}_{type}_{start}--{end}_S{idx:03d}-{cnt:03d}.tar".format( + return "{fileset}_{type}_{start}--{end}.tar".format( fileset=fileset, type=Naming.backup_type_str(is_full), - start=start_timestamp, end=end_timestamp, - idx=int(stripe_index), cnt=int(stripe_count)) + start=start_timestamp, end=end_timestamp) @staticmethod def parse_filename(filename): """ - >>> Naming.parse_filename('test1fs_full_20180601_112429_S002-101.tar') - ('test1fs', True, '20180601_112429', 2, 101) - >>> Naming.parse_filename('test1fs_tran_20180601_112429_S02-08.tar') - ('test1fs', False, '20180601_112429', 2, 8) + >>> Naming.parse_filename('test1fs_full_20180601_112429.tar') + ('test1fs', True, '20180601_112429') + >>> Naming.parse_filename('test1fs_tran_20180601_112429.tar') + ('test1fs', False, '20180601_112429') >>> Naming.parse_filename('bad_input') == None True """ - m = re.search(r'(?P\S+?)_(?Pfull|tran)_(?P\d{8}_\d{6})_S(?P\d+)-(?P\d+)\.tar', filename) + m = re.search(r'(?P\S+?)_(?Pfull|tran)_(?P\d{8}_\d{6})\.tar', filename) if m is None: return None - (fileset, is_full, start_timestamp, stripe_index, stripe_count) = (m.group('fileset'), Naming.type_str_is_full(m.group('type')), m.group('start'), int(m.group('idx')), int(m.group('cnt'))) + (fileset, is_full, start_timestamp) = (m.group('fileset'), Naming.type_str_is_full(m.group('type')), m.group('start')) - return fileset, is_full, start_timestamp, stripe_index, stripe_count + return fileset, is_full, start_timestamp @staticmethod def parse_blobname(filename): """ - >>> Naming.parse_blobname('test1fs_full_20180601_112429--20180601_131234_S002-101.tar') - ('test1fs', True, '20180601_112429', '20180601_131234', 2, 101) - >>> Naming.parse_blobname('test1fs_tran_20180601_112429--20180601_131234_S2-008.tar') - ('test1fs', False, '20180601_112429', '20180601_131234', 2, 8) + >>> Naming.parse_blobname('test1fs_full_20180601_112429--20180601_131234.tar') + ('test1fs', True, '20180601_112429', '20180601_131234') + >>> Naming.parse_blobname('test1fs_tran_20180601_112429--20180601_131234.tar') + ('test1fs', False, '20180601_112429', '20180601_131234') >>> Naming.parse_filename('bad_input') == None True """ - m = re.search(r'(?P\S+?)_(?Pfull|tran)_(?P\d{8}_\d{6})--(?P\d{8}_\d{6})_S(?P\d+)-(?P\d+)\.tar', filename) + m = re.search(r'(?P\S+?)_(?Pfull|tran)_(?P\d{8}_\d{6})--(?P\d{8}_\d{6})\.tar', filename) if m is None: return None - (fileset, is_full, start_timestamp, end_timestamp, stripe_index, stripe_count) = (m.group('fileset'), Naming.type_str_is_full(m.group('type')), m.group('start'), m.group('end'), int(m.group('idx')), int(m.group('cnt'))) + (fileset, is_full, start_timestamp, end_timestamp) = (m.group('fileset'), Naming.type_str_is_full(m.group('type')), m.group('start'), m.group('end')) - return fileset, is_full, start_timestamp, end_timestamp, stripe_index, stripe_count + return fileset, is_full, start_timestamp, end_timestamp @staticmethod def blobname_to_filename(blobname): @@ -116,7 +114,4 @@ class Naming(object): return Naming.construct_filename( fileset=parts[0], is_full=parts[1], - start_timestamp=parts[2], - # skip parts[3] which is end-timestamp - stripe_index=parts[4], - stripe_count=parts[5]) + start_timestamp=parts[2])