Skip to content

Commit 5741ca3

Browse files
jasonbotbchew
authored andcommitted
Correct wildcard matching (#36)
1 parent 115d33a commit 5741ca3

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

dynamodump.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
import argparse
12+
import fnmatch
1213
import json
1314
import logging
1415
import os
@@ -23,6 +24,7 @@
2324
import zipfile
2425
import tarfile
2526
import urllib2
27+
2628
import boto.dynamodb2.layer1
2729
from boto.dynamodb2.exceptions import ProvisionedThroughputExceededException
2830
import botocore
@@ -279,16 +281,8 @@ def get_table_name_matches(conn, table_name_wildcard, separator):
279281

280282
matching_tables = []
281283
for table_name in all_tables:
282-
if table_name_wildcard == "*":
283-
matching_tables.append(table_name)
284-
elif separator is None:
285-
if table_name.startswith(table_name_wildcard.split("*", 1)[0]):
286-
matching_tables.append(table_name)
287-
elif separator == "":
288-
if table_name.startswith(re.sub(r"([A-Z])", r" \1",
289-
table_name_wildcard.split("*", 1)[0]).split()[0]):
290-
matching_tables.append(table_name)
291-
elif table_name.split(separator, 1)[0] == table_name_wildcard.split("*", 1)[0]:
284+
if fnmatch.fnmatch(table_name, table_name_wildcard):
285+
logging.info("Adding %s", table_name)
292286
matching_tables.append(table_name)
293287

294288
return matching_tables
@@ -914,6 +908,8 @@ def main():
914908
try:
915909
if args.srcTable.find("*") == -1:
916910
do_backup(conn, args.read_capacity, tableQueue=None)
911+
else:
912+
do_backup(conn, args.read_capacity, matching_backup_tables)
917913
except AttributeError:
918914
# Didn't specify srcTable if we get here
919915

0 commit comments

Comments
 (0)