mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-27260: IDEA-CR-27654: Add hint to field, support several names
This commit is contained in:
@@ -14,22 +14,22 @@ class FileChangesTracker(object):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, folder, pattern="*"):
|
||||
self.old_files = self._get_changes_from(folder, pattern)
|
||||
def __init__(self, folder, patterns="*"):
|
||||
self.old_files = self._get_changes_from(folder, patterns)
|
||||
self.folder = folder
|
||||
self.pattern = pattern
|
||||
self.patterns = patterns
|
||||
|
||||
def get_changed_files(self):
|
||||
assert self.folder, "No changes recorded"
|
||||
new_files = self._get_changes_from(self.folder, pattern=self.pattern)
|
||||
new_files = self._get_changes_from(self.folder, patterns=self.patterns)
|
||||
return filter(lambda f: f not in self.old_files or self.old_files[f] != new_files[f], new_files.keys())
|
||||
|
||||
@staticmethod
|
||||
def _get_changes_from(folder, pattern):
|
||||
def _get_changes_from(folder, patterns):
|
||||
result = {}
|
||||
for tmp_folder, sub_dirs, files in os.walk(folder):
|
||||
sub_dirs[:] = [s for s in sub_dirs if not s.startswith(".")]
|
||||
if fnmatch.fnmatch(os.path.basename(tmp_folder), pattern):
|
||||
if any([fnmatch.fnmatch(os.path.basename(tmp_folder), p) for p in patterns]):
|
||||
for file in map(lambda f: os.path.join(tmp_folder, f), files):
|
||||
try:
|
||||
result.update({file: os.path.getmtime(file)})
|
||||
@@ -137,4 +137,4 @@ class _Py3KUtils(VersionAgnosticUtils):
|
||||
for option in args:
|
||||
assert isinstance(option, OptionDescription)
|
||||
parser.add_argument(option.name, help=option.description, action=option.action)
|
||||
return parser.parse_args()
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -48,7 +48,7 @@ if __name__ == "__main__":
|
||||
|
||||
if track_files_pattern:
|
||||
print("Tracking file by folder pattern: ", track_files_pattern)
|
||||
file_changes_tracker = FileChangesTracker(os.getcwd(), track_files_pattern)
|
||||
file_changes_tracker = FileChangesTracker(os.getcwd(), track_files_pattern.split(":"))
|
||||
run_command()
|
||||
# Report files affected/created by commands. This info is used on Java side.
|
||||
changed_files = list(file_changes_tracker.get_changed_files())
|
||||
|
||||
Reference in New Issue
Block a user