don't set root is files in unique dir but still looking for cat. fix #185

This commit is contained in:
clinton-hall 2013-12-02 07:28:48 +10:30
commit c2af80dea0

View file

@ -54,10 +54,12 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
categorySearch = [os.path.normpath(inputDirectory), ""] # initializie categorySearch = [os.path.normpath(inputDirectory), ""] # initializie
notfound = 0 notfound = 0
unique = int(0)
for x in range(10): # loop up through 10 directories looking for category. for x in range(10): # loop up through 10 directories looking for category.
try: try:
categorySearch2 = os.path.split(os.path.normpath(categorySearch[0])) categorySearch2 = os.path.split(os.path.normpath(categorySearch[0]))
except: # this might happen when we can't go higher. except: # this might happen when we can't go higher.
if unique = int(0)
if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory. if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory.
Logger.info("SEARCH: Could not find a category in the directory structure") Logger.info("SEARCH: Could not find a category in the directory structure")
Logger.info("SEARCH: We will try and determine which files to process, individually") Logger.info("SEARCH: We will try and determine which files to process, individually")
@ -123,6 +125,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
break break
elif inputName and safeName(categorySearch2[1]) == safeName(inputName): # we have identified a unique directory. elif inputName and safeName(categorySearch2[1]) == safeName(inputName): # we have identified a unique directory.
Logger.info("SEARCH: Files appear to be in their own directory") Logger.info("SEARCH: Files appear to be in their own directory")
unique = int(1)
if inputCategory: # we are ok to proceed. if inputCategory: # we are ok to proceed.
break # we are done break # we are done
else: else:
@ -137,7 +140,7 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories):
categorySearch = categorySearch2 # ready for next loop categorySearch = categorySearch2 # ready for next loop
continue # keep going continue # keep going
if notfound == 1: if notfound == 1 and not unique = int(1):
if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory. if inputCategory and inputName: # if these exists, we are ok to proceed, but assume we are in a root/common directory.
Logger.info("SEARCH: Could not find a category in the directory structure") Logger.info("SEARCH: Could not find a category in the directory structure")
Logger.info("SEARCH: We will try and determine which files to process, individually") Logger.info("SEARCH: We will try and determine which files to process, individually")