MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / assertIsLanguageCode

Method assertIsLanguageCode

tests/common.py:155–162  ·  view source on GitHub ↗
(self, lang_id)

Source from the content-addressed store, hash-verified

153 self.assertIsInstance(obj, bytes, msg)
154
155 def assertIsLanguageCode(self, lang_id):
156 self.assertIsInstance(lang_id, str)
157 if lang_id in ('C', 'C.UTF-8', 'C.utf8', 'POSIX'):
158 return
159 self.assertTrue(len(lang_id) >= 2)
160 pattern = r'^[a-z]{2,3}([_-][A-Z][A-Za-z]{1,3})?(@\w+)?(\.[a-zA-Z][a-zA-Z0-9-]+)?$'
161 self.assertTrue(re.match(pattern, lang_id),
162 f'Invalid language code format: {lang_id}')
163
164 @staticmethod
165 def check_exists(func, path):

Calls 1

matchMethod · 0.80