MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _check_dir

Method _check_dir

_pydev_bundle/fsnotify/__init__.py:116–163  ·  view source on GitHub ↗
(self, dir_path, single_visit_info, append_change, old_file_to_mtime, level)

Source from the content-addressed store, hash-verified

114 return hash(self._root_path)
115
116 def _check_dir(self, dir_path, single_visit_info, append_change, old_file_to_mtime, level):
117 # This is the actual poll loop
118 if dir_path in single_visit_info.visited_dirs or level > self._max_recursion_level:
119 return
120 single_visit_info.visited_dirs.add(dir_path)
121 try:
122 if isinstance(dir_path, bytes):
123 try:
124 dir_path = dir_path.decode(sys.getfilesystemencoding())
125 except UnicodeDecodeError:
126 try:
127 dir_path = dir_path.decode("utf-8")
128 except UnicodeDecodeError:
129 return # Ignore if we can't deal with the path.
130
131 new_files = single_visit_info.file_to_mtime
132
133 for entry in scandir(dir_path):
134 single_visit_info.count += 1
135
136 # Throttle if needed inside the loop
137 # to avoid consuming too much CPU.
138 if single_visit_info.count % 300 == 0:
139 if self.sleep_time > 0:
140 t = time.time()
141 diff = t - single_visit_info.last_sleep_time
142 if diff > self.sleep_at_elapsed:
143 time.sleep(self.sleep_time)
144 single_visit_info.last_sleep_time = time.time()
145
146 if entry.is_dir():
147 if self.accept_directory(entry.path):
148 self._check_dir(entry.path, single_visit_info, append_change, old_file_to_mtime, level + 1)
149
150 elif self.accept_file(entry.path):
151 stat = entry.stat()
152 mtime = (stat.st_mtime_ns, stat.st_size)
153 path = entry.path
154 new_files[path] = mtime
155
156 old_mtime = old_file_to_mtime.pop(path, None)
157 if not old_mtime:
158 append_change((Change.added, path))
159 elif old_mtime != mtime:
160 append_change((Change.modified, path))
161
162 except OSError:
163 pass # Directory was removed in the meanwhile.
164
165 def _check(self, single_visit_info, append_change, old_file_to_mtime):
166 self._check_dir(self._root_path, single_visit_info, append_change, old_file_to_mtime, 0)

Callers 1

_checkMethod · 0.95

Calls 5

popMethod · 0.80
addMethod · 0.45
decodeMethod · 0.45
accept_directoryMethod · 0.45
accept_fileMethod · 0.45

Tested by

no test coverage detected