dcicutils 8.8.4.1b5__py3-none-any.whl → 8.8.4.1b7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,9 @@ def temporary_file(name: Optional[str] = None, suffix: Optional[str] = None,
26
26
 
27
27
 
28
28
  def remove_temporary_directory(tmp_directory_name: str) -> None:
29
+ """
30
+ Removes the given directory, recursively; but ONLY if it is (somewhere) within the system temporary directory.
31
+ """
29
32
  def is_temporary_directory(path: str) -> bool:
30
33
  try:
31
34
  tmpdir = tempfile.gettempdir()
@@ -34,3 +37,26 @@ def remove_temporary_directory(tmp_directory_name: str) -> None:
34
37
  return False
35
38
  if is_temporary_directory(tmp_directory_name): # Guard against errant deletion.
36
39
  shutil.rmtree(tmp_directory_name)
40
+
41
+
42
+ def create_temporary_file_name(prefix: Optional[str] = None, suffix: Optional[str] = None) -> str:
43
+ """
44
+ Generates and returns the full path to file within the system temporary directory.
45
+ """
46
+ with tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, delete=False) as tmp_file:
47
+ tmp_file_name = tmp_file.name
48
+ return tmp_file_name
49
+
50
+
51
+ def remove_temporary_file(tmp_file_name: str) -> bool:
52
+ """
53
+ Removes the given file; but ONLY if it is (somewhere) within the system temporary directory.
54
+ """
55
+ try:
56
+ tmpdir = tempfile.gettempdir()
57
+ if (os.path.commonpath([tmpdir, tmp_file_name]) == tmpdir) and os.path.isfile(tmp_file_name):
58
+ os.remove(tmp_file_name)
59
+ return True
60
+ return False
61
+ except Exception:
62
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.8.4.1b5
3
+ Version: 8.8.4.1b7
4
4
  Summary: Utility package for interacting with the 4DN Data Portal and other 4DN resources
5
5
  Home-page: https://github.com/4dn-dcic/utils
6
6
  License: MIT
@@ -68,13 +68,13 @@ dcicutils/structured_data.py,sha256=BQuIMv6OPySsn6YxtXE2Er-zLE2QJuCYhEQ3V0u_UXY,
68
68
  dcicutils/submitr/progress_constants.py,sha256=5bxyX77ql8qEJearfHEvsvXl7D0GuUODW0T65mbRmnE,2895
69
69
  dcicutils/submitr/ref_lookup_strategy.py,sha256=Js2cVznTmgjciLWBPLCvMiwLIHXjDn3jww-gJPjYuFw,3467
70
70
  dcicutils/task_utils.py,sha256=MF8ujmTD6-O2AC2gRGPHyGdUrVKgtr8epT5XU8WtNjk,8082
71
- dcicutils/tmpfile_utils.py,sha256=n95XF8dZVbQRSXBZTGToXXfSs3JUVRyN6c3ZZ0nhAWI,1403
71
+ dcicutils/tmpfile_utils.py,sha256=6p9aw8xZn4aQqhX26Vt3aJj-3POcLYM5A9SVD-SUqsY,2340
72
72
  dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
73
73
  dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
74
74
  dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
75
75
  dcicutils/zip_utils.py,sha256=_Y9EmL3D2dUZhxucxHvrtmmlbZmK4FpSsHEb7rGSJLU,3265
76
- dcicutils-8.8.4.1b5.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
77
- dcicutils-8.8.4.1b5.dist-info/METADATA,sha256=JGv98GgKLtpDb9OXbNTELSoMang15R3vJFgpDIcPvTg,3396
78
- dcicutils-8.8.4.1b5.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
79
- dcicutils-8.8.4.1b5.dist-info/entry_points.txt,sha256=51Q4F_2V10L0282W7HFjP4jdzW4K8lnWDARJQVFy_hw,270
80
- dcicutils-8.8.4.1b5.dist-info/RECORD,,
76
+ dcicutils-8.8.4.1b7.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
77
+ dcicutils-8.8.4.1b7.dist-info/METADATA,sha256=P-vuNEwPUaQk7FNobMyvyXJ1IQCr6WwEhN8DjwMa7t8,3396
78
+ dcicutils-8.8.4.1b7.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
79
+ dcicutils-8.8.4.1b7.dist-info/entry_points.txt,sha256=51Q4F_2V10L0282W7HFjP4jdzW4K8lnWDARJQVFy_hw,270
80
+ dcicutils-8.8.4.1b7.dist-info/RECORD,,