utils.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # stolen from python docs
  2. def trim(docstring):
  3. if not docstring:
  4. return ""
  5. # Convert tabs to spaces (following the normal Python rules)
  6. # and split into a list of lines:
  7. lines = docstring.expandtabs().splitlines()
  8. # Determine minimum indentation (first line doesn't count):
  9. indent = 232323
  10. for line in lines[1:]:
  11. stripped = line.lstrip()
  12. if stripped:
  13. indent = min(indent, len(line) - len(stripped))
  14. # Remove indentation (first line is special):
  15. trimmed = [lines[0].strip()]
  16. if indent < 232323:
  17. for line in lines[1:]:
  18. trimmed.append(line[indent:].rstrip())
  19. # Strip off trailing and leading blank lines:
  20. while trimmed and not trimmed[-1]:
  21. trimmed.pop()
  22. while trimmed and not trimmed[0]:
  23. trimmed.pop(0)
  24. # Return a single string:
  25. return "\n".join(trimmed)
  26. # dont want envs which contain these
  27. kill_strs = [
  28. "eterministic",
  29. "ALE",
  30. "-ram",
  31. "Frameskip",
  32. "Hard",
  33. "LanderContinu",
  34. "8x8",
  35. "uessing",
  36. "otter",
  37. "oinflip",
  38. "hain",
  39. "oulette",
  40. "DomainRandom",
  41. "RacingDiscrete",
  42. ]