11import os
2+ import patch
23import sys
34import time
45from textwrap import dedent
@@ -155,7 +156,7 @@ def check_yang_model_directories(app_configs, **kwargs):
155156 " %s = %s" % (s , p ),
156157 hint = ("Please either update your local settings to point at the correct\n "
157158 "\t directory, or if the setting is correct, create the indicated directory.\n " ),
158- id = "datatracker.E0006 " ,
159+ id = "datatracker.E0017 " ,
159160 ))
160161 return errors
161162
@@ -285,6 +286,7 @@ def cache_error(msg, errnum):
285286 if not cache .get (key ) == val :
286287 errors .append (cache_error ("Cache didn't accept session cookie age" , "E0016" ))
287288 return errors
289+
288290
289291def maybe_create_svn_symlinks (settings ):
290292 site_packages_dir = None
@@ -307,7 +309,7 @@ def maybe_create_svn_symlinks(settings):
307309 " %s\n " % path ,
308310 hint = "Please provide the correct python system site-package paths for\n "
309311 "\t svn and libsvn in SVN_PACKAGES.\n " ,
310- id = "datatracker.E0015 " ,))
312+ id = "datatracker.E0018 " ,))
311313 return errors
312314
313315@checks .register ('cache' )
@@ -344,10 +346,30 @@ def check_svn_import(app_configs, **kwargs):
344346 available at https://trac.edgewall.org/wiki/TracSubversion.
345347
346348 """ ).replace ('\n ' , '\n ' ).rstrip (),
347- id = "datatracker.E0014 " ,
349+ id = "datatracker.E0019 " ,
348350 ))
349351 return errors
350352
353+ @checks .register ('files' )
354+ def maybe_patch_django_db_model_fields_unicode_comparison (app_configs , ** kwargs ):
355+ errors = []
356+ for patch_file in settings .CHECKS_PATCHES_TO_APPLY :
357+ patch_set = patch .fromfile (patch_file )
358+ if patch_set :
359+ if not patch_set .apply ():
360+ errors .append (checks .Warning (
361+ "Could not apply patch from file '%s'" % patch_file ,
362+ hint = "Make sure that the patch file contains a unified diff and has valid file paths" ,
363+ id = "datatracker.W0002" ,
364+ ))
365+ else :
366+ errors .append (checks .Warning (
367+ "Could not parse patch file '%s'" % patch_file ,
368+ hint = "Make sure that the patch file contains a unified diff" ,
369+ id = "datatracker.W0001" ,
370+ ))
371+ return errors
372+
351373@checks .register ('security' )
352374def check_api_key_in_local_settings (app_configs , ** kwargs ):
353375 errors = []
@@ -366,7 +388,7 @@ def check_api_key_in_local_settings(app_configs, **kwargs):
366388 extract the public key with 'openssl rsa -in apikey.pem -pubout > apikey.pub'.
367389
368390 """ ).replace ('\n ' , '\n ' ).rstrip (),
369- id = "datatracker.E0015 " ,
391+ id = "datatracker.E0020 " ,
370392 ))
371393 elif not ( settings_local .API_PUBLIC_KEY_PEM == settings .API_PUBLIC_KEY_PEM
372394 and settings_local .API_PRIVATE_KEY_PEM == settings .API_PRIVATE_KEY_PEM ):
@@ -379,7 +401,7 @@ def check_api_key_in_local_settings(app_configs, **kwargs):
379401 Please check if you have multiple settings_local.py files.
380402
381403 """ ).replace ('\n ' , '\n ' ).rstrip (),
382- id = "datatracker.E0016 " ,
404+ id = "datatracker.E0021 " ,
383405 ))
384406
385407 return errors
0 commit comments