MCPcopy
hub / github.com/django/django / has_leading_dir

Method has_leading_dir

django/utils/archive.py:129–143  ·  view source on GitHub ↗

Return True if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive).

(self, paths)

Source from the content-addressed store, hash-verified

127 return path, ""
128
129 def has_leading_dir(self, paths):
130 """
131 Return True if all the paths have the same leading path name
132 (i.e., everything is in one subdirectory in an archive).
133 """
134 common_prefix = None
135 for path in paths:
136 prefix, rest = self.split_leading_dir(path)
137 if not prefix:
138 return False
139 elif common_prefix is None:
140 common_prefix = prefix
141 elif prefix != common_prefix:
142 return False
143 return True
144
145 def target_filename(self, to_path, name):
146 target_path = os.path.abspath(to_path)

Callers 2

extractMethod · 0.80
extractMethod · 0.80

Calls 1

split_leading_dirMethod · 0.95

Tested by

no test coverage detected