Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

py36compat.py 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import sys
  2. from distutils.errors import DistutilsOptionError
  3. from distutils.util import strtobool
  4. from distutils.debug import DEBUG
  5. class Distribution_parse_config_files:
  6. """
  7. Mix-in providing forward-compatibility for functionality to be
  8. included by default on Python 3.7.
  9. Do not edit the code in this class except to update functionality
  10. as implemented in distutils.
  11. """
  12. def parse_config_files(self, filenames=None):
  13. from configparser import ConfigParser
  14. # Ignore install directory options if we have a venv
  15. if sys.prefix != sys.base_prefix:
  16. ignore_options = [
  17. 'install-base', 'install-platbase', 'install-lib',
  18. 'install-platlib', 'install-purelib', 'install-headers',
  19. 'install-scripts', 'install-data', 'prefix', 'exec-prefix',
  20. 'home', 'user', 'root']
  21. else:
  22. ignore_options = []
  23. ignore_options = frozenset(ignore_options)
  24. if filenames is None:
  25. filenames = self.find_config_files()
  26. if DEBUG:
  27. self.announce("Distribution.parse_config_files():")
  28. parser = ConfigParser(interpolation=None)
  29. for filename in filenames:
  30. if DEBUG:
  31. self.announce(" reading %s" % filename)
  32. parser.read(filename)
  33. for section in parser.sections():
  34. options = parser.options(section)
  35. opt_dict = self.get_option_dict(section)
  36. for opt in options:
  37. if opt != '__name__' and opt not in ignore_options:
  38. val = parser.get(section,opt)
  39. opt = opt.replace('-', '_')
  40. opt_dict[opt] = (filename, val)
  41. # Make the ConfigParser forget everything (so we retain
  42. # the original filenames that options come from)
  43. parser.__init__()
  44. # If there was a "global" section in the config file, use it
  45. # to set Distribution options.
  46. if 'global' in self.command_options:
  47. for (opt, (src, val)) in self.command_options['global'].items():
  48. alias = self.negative_opt.get(opt)
  49. try:
  50. if alias:
  51. setattr(self, alias, not strtobool(val))
  52. elif opt in ('verbose', 'dry_run'): # ugh!
  53. setattr(self, opt, strtobool(val))
  54. else:
  55. setattr(self, opt, val)
  56. except ValueError as msg:
  57. raise DistutilsOptionError(msg)
  58. if sys.version_info < (3,):
  59. # Python 2 behavior is sufficient
  60. class Distribution_parse_config_files:
  61. pass
  62. if False:
  63. # When updated behavior is available upstream,
  64. # disable override here.
  65. class Distribution_parse_config_files:
  66. pass