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.

brain_pkg_resources.py 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (c) 2016 Claudiu Popa <pcmanticore@gmail.com>
  2. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  3. # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
  4. import astroid
  5. from astroid import parse
  6. from astroid import inference_tip
  7. from astroid import register_module_extender
  8. from astroid import MANAGER
  9. def pkg_resources_transform():
  10. return parse('''
  11. def require(*requirements):
  12. return pkg_resources.working_set.require(*requirements)
  13. def run_script(requires, script_name):
  14. return pkg_resources.working_set.run_script(requires, script_name)
  15. def iter_entry_points(group, name=None):
  16. return pkg_resources.working_set.iter_entry_points(group, name)
  17. def resource_exists(package_or_requirement, resource_name):
  18. return get_provider(package_or_requirement).has_resource(resource_name)
  19. def resource_isdir(package_or_requirement, resource_name):
  20. return get_provider(package_or_requirement).resource_isdir(
  21. resource_name)
  22. def resource_filename(package_or_requirement, resource_name):
  23. return get_provider(package_or_requirement).get_resource_filename(
  24. self, resource_name)
  25. def resource_stream(package_or_requirement, resource_name):
  26. return get_provider(package_or_requirement).get_resource_stream(
  27. self, resource_name)
  28. def resource_string(package_or_requirement, resource_name):
  29. return get_provider(package_or_requirement).get_resource_string(
  30. self, resource_name)
  31. def resource_listdir(package_or_requirement, resource_name):
  32. return get_provider(package_or_requirement).resource_listdir(
  33. resource_name)
  34. def extraction_error():
  35. pass
  36. def get_cache_path(archive_name, names=()):
  37. extract_path = self.extraction_path or get_default_cache()
  38. target_path = os.path.join(extract_path, archive_name+'-tmp', *names)
  39. return target_path
  40. def postprocess(tempname, filename):
  41. pass
  42. def set_extraction_path(path):
  43. pass
  44. def cleanup_resources(force=False):
  45. pass
  46. def get_distribution(dist):
  47. return Distribution(dist)
  48. ''')
  49. register_module_extender(MANAGER, 'pkg_resources', pkg_resources_transform)