Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pprint
- pp = pprint.PrettyPrinter(indent=2)
- drives = {
- 'C:':{},
- 'D:':{},
- 'E:':{},
- 'F:':{},
- 'G:':{},
- }
- def parse(line):
- global drives
- tokens = line.split("\\")
- for x in xrange(1,len(tokens)):
- if x==1:
- if not tokens[1] in drives[tokens[0]]:
- drives[tokens[0]][tokens[1]]={}
- else:
- evalstring = """drives[tokens[0]]["""
- for j in xrange(1,x):
- evalstring+="tokens[%d]][" % j
- exec "if not tokens[x] in " + evalstring[:-1] + " : " + evalstring[:-1] + ".update({tokens[x]:{}})"
- def getcount(folder, counted=[]):
- count=0
- for stuff in folder:
- if not "." in stuff:
- count+=1 + getcount(folder[stuff])
- return count
- def find_max_subs():
- maxcount=0
- for drive in drives:
- for folder in drives[drive]:
- subcount = getcount(drives[drive][folder])
- if subcount>maxcount:
- maxcount=subcount
- return maxcount
- def getfilecount(folder):
- count = 0
- for stuff in folder:
- if "." in stuff:
- count += 1
- else:
- count += getfilecount(folder[stuff])
- return count
- def find_max_files():
- maxcount=0
- for drive in drives:
- for folder in drives[drive]:
- subcount = getfilecount(drives[drive][folder])
- if subcount>maxcount:
- maxcount=subcount
- return maxcount
- line = raw_input()
- while len(line)>0:
- parse(line)
- try:
- line = raw_input()
- except:
- break
- print find_max_subs(),find_max_files()
Add Comment
Please, Sign In to add comment