MCPcopy Index your code
hub / github.com/RustPython/RustPython / create

Method create

Lib/test/test_site.py:420–440  ·  view source on GitHub ↗

Create a .pth file with a comment, blank lines, an ``import ``, a line with self.good_dirname, and a line with self.bad_dirname. Creation of the directory for self.good_dir_path (based off of self.good_dirname) is also performed. Make sure to

(self)

Source from the content-addressed store, hash-verified

418 self.bad_dir_path = os.path.join(self.base_dir, self.bad_dirname)
419
420 def create(self):
421 """Create a .pth file with a comment, blank lines, an ``import
422 <self.imported>``, a line with self.good_dirname, and a line with
423 self.bad_dirname.
424
425 Creation of the directory for self.good_dir_path (based off of
426 self.good_dirname) is also performed.
427
428 Make sure to call self.cleanup() to undo anything done by this method.
429
430 """
431 FILE = open(self.file_path, 'w')
432 try:
433 print("#import @bad module name", file=FILE)
434 print("\n", file=FILE)
435 print("import %s" % self.imported, file=FILE)
436 print(self.good_dirname, file=FILE)
437 print(self.bad_dirname, file=FILE)
438 finally:
439 FILE.close()
440 os.mkdir(self.good_dir_path)
441
442 def cleanup(self, prep=False):
443 """Make sure that the .pth file is deleted, self.imported is not in

Calls 4

openFunction · 0.50
printFunction · 0.50
closeMethod · 0.45
mkdirMethod · 0.45

Tested by

no test coverage detected