diff --git a/bears/general/FilenameBear.py b/bears/general/FilenameBear.py index 13b1e0fe11..8f1a957905 100644 --- a/bears/general/FilenameBear.py +++ b/bears/general/FilenameBear.py @@ -17,7 +17,9 @@ class FilenameBear(LocalBear): "pascal": to_pascalcase, "snake": to_snakecase} - def run(self, filename, file, file_naming_convention: str="snake"): + def run(self, filename, file, + file_naming_convention: str="snake", + ignore_uppercase_filenames: bool=True): """ Checks whether the filename follows a certain naming-convention. @@ -26,6 +28,9 @@ def run(self, filename, file, file_naming_convention: str="snake"): - ``camel`` (``thisIsCamelCase``) - ``pascal`` (``ThisIsPascalCase``) - ``snake`` (``this_is_snake_case``) + :param ignore_uppercase_filenames: + Whether or not to ignore fully uppercase filenames completely, + e.g. COPYING, LICENSE etc. """ head, tail = os.path.split(filename) filename_without_extension, extension = os.path.splitext(tail) @@ -37,6 +42,9 @@ def run(self, filename, file, file_naming_convention: str="snake"): file_naming_convention) return + if ignore_uppercase_filenames and filename_without_extension.isupper(): + return + if new_name != filename_without_extension: diff = Diff(file, rename=os.path.join(head, new_name + extension)) diff --git a/tests/general/FilenameBearTest.py b/tests/general/FilenameBearTest.py index 443a7d2a19..bb812d4cb6 100644 --- a/tests/general/FilenameBearTest.py +++ b/tests/general/FilenameBearTest.py @@ -44,3 +44,10 @@ def test_pascal_case(self): valid=False) self.check_validity(self.uut, [""], filename="XYZ/__Init__.py") self.check_validity(self.uut, [""], filename="/a/PascalCase") + + def test_ignore_upper(self): + self.check_validity(self.uut, [""], filename='/LICENSE') + + self.section['ignore_uppercase_filenames'] = 'nope' + + self.check_validity(self.uut, [""], filename='/LICENSE', valid=False)