PY-27260: IDEA-CR-27654: Add hint to field, support several names

This commit is contained in:
Ilya.Kazakevich
2017-12-19 00:00:44 +03:00
parent fddc3ded2f
commit 55e06a8e46
2 changed files with 8 additions and 8 deletions
+7 -7
View File
@@ -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()
+1 -1
View File
@@ -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())