Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
RegisterLookupMixin._unregister_lookup
(cls, lookup)
Removes given lookup from cls lookups. Meant to be used in tests only.
Removes given lookup from cls lookups. Meant to be used in tests only.
def _unregister_lookup(cls, lookup): """ Removes given lookup from cls lookups. Meant to be used in tests only. """ del cls.class_lookups[lookup.lookup_name]
[ "def", "_unregister_lookup", "(", "cls", ",", "lookup", ")", ":", "del", "cls", ".", "class_lookups", "[", "lookup", ".", "lookup_name", "]" ]
[ 50, 4 ]
[ 55, 49 ]
python
en
['en', 'error', 'th']
False
get_msvcr
()
Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later.
Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later.
def get_msvcr(): """Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. """ msc_pos = sys.version.find('MSC v.') if msc_pos != -1: msc_ver = sys.version[msc_pos+6:msc_pos+10] if msc_ver == '1300': # MSVC 7.0 return ['msvcr7...
[ "def", "get_msvcr", "(", ")", ":", "msc_pos", "=", "sys", ".", "version", ".", "find", "(", "'MSC v.'", ")", "if", "msc_pos", "!=", "-", "1", ":", "msc_ver", "=", "sys", ".", "version", "[", "msc_pos", "+", "6", ":", "msc_pos", "+", "10", "]", "i...
[ 60, 0 ]
[ 83, 73 ]
python
en
['en', 'en', 'en']
True
check_config_h
()
Check if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CONFIG_H_UNCERTAIN: not sure --...
Check if the current Python installation appears amenable to building extensions with GCC.
def check_config_h(): """Check if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CO...
[ "def", "check_config_h", "(", ")", ":", "# XXX since this function also checks sys.version, it's not strictly a", "# \"pyconfig.h\" check -- should probably be renamed...", "from", "distutils", "import", "sysconfig", "# if sys.version contains GCC then python was compiled with GCC, and the", ...
[ 325, 0 ]
[ 366, 62 ]
python
en
['en', 'en', 'en']
True
_find_exe_version
(cmd)
Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None.
Find the version of an executable by running `cmd` in the shell.
def _find_exe_version(cmd): """Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None. """ executable = cmd.split()[0] if find_executable(executable) is None: return None out = Popen(cmd, ...
[ "def", "_find_exe_version", "(", "cmd", ")", ":", "executable", "=", "cmd", ".", "split", "(", ")", "[", "0", "]", "if", "find_executable", "(", "executable", ")", "is", "None", ":", "return", "None", "out", "=", "Popen", "(", "cmd", ",", "shell", "=...
[ 370, 0 ]
[ 389, 49 ]
python
en
['en', 'en', 'en']
True
get_versions
()
Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it.
Try to find out the versions of gcc, ld and dllwrap.
def get_versions(): """ Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it. """ commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version'] return tuple([_find_exe_version(cmd) for cmd in commands])
[ "def", "get_versions", "(", ")", ":", "commands", "=", "[", "'gcc -dumpversion'", ",", "'ld -v'", ",", "'dllwrap --version'", "]", "return", "tuple", "(", "[", "_find_exe_version", "(", "cmd", ")", "for", "cmd", "in", "commands", "]", ")" ]
[ 391, 0 ]
[ 397, 62 ]
python
en
['en', 'en', 'en']
True
is_cygwingcc
()
Try to determine if the gcc that would be used is from cygwin.
Try to determine if the gcc that would be used is from cygwin.
def is_cygwingcc(): '''Try to determine if the gcc that would be used is from cygwin.''' out_string = check_output(['gcc', '-dumpmachine']) return out_string.strip().endswith(b'cygwin')
[ "def", "is_cygwingcc", "(", ")", ":", "out_string", "=", "check_output", "(", "[", "'gcc'", ",", "'-dumpmachine'", "]", ")", "return", "out_string", ".", "strip", "(", ")", ".", "endswith", "(", "b'cygwin'", ")" ]
[ 399, 0 ]
[ 402, 49 ]
python
en
['en', 'en', 'en']
True
CygwinCCompiler._compile
(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
Compiles the source by spawning GCC and windres if needed.
Compiles the source by spawning GCC and windres if needed.
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): """Compiles the source by spawning GCC and windres if needed.""" if ext == '.rc' or ext == '.res': # gcc needs '.res' and '.rc' compiled to object files !!! try: self.spawn(["windres", "-i", src,...
[ "def", "_compile", "(", "self", ",", "obj", ",", "src", ",", "ext", ",", "cc_args", ",", "extra_postargs", ",", "pp_opts", ")", ":", "if", "ext", "==", "'.rc'", "or", "ext", "==", "'.res'", ":", "# gcc needs '.res' and '.rc' compiled to object files !!!", "try...
[ 156, 4 ]
[ 169, 39 ]
python
en
['en', 'en', 'en']
True
CygwinCCompiler.link
(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None)
Link the objects.
Link the objects.
def link(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None): """Link the objects.""" #...
[ "def", "link", "(", "self", ",", "target_desc", ",", "objects", ",", "output_filename", ",", "output_dir", "=", "None", ",", "libraries", "=", "None", ",", "library_dirs", "=", "None", ",", "runtime_library_dirs", "=", "None", ",", "export_symbols", "=", "No...
[ 171, 4 ]
[ 245, 39 ]
python
en
['en', 'en', 'en']
True
CygwinCCompiler.object_filenames
(self, source_filenames, strip_dir=0, output_dir='')
Adds supports for rc and res files.
Adds supports for rc and res files.
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): """Adds supports for rc and res files.""" if output_dir is None: output_dir = '' obj_names = [] for src_name in source_filenames: # use normcase to make sure '.rc' is really '.rc' and not '....
[ "def", "object_filenames", "(", "self", ",", "source_filenames", ",", "strip_dir", "=", "0", ",", "output_dir", "=", "''", ")", ":", "if", "output_dir", "is", "None", ":", "output_dir", "=", "''", "obj_names", "=", "[", "]", "for", "src_name", "in", "sou...
[ 249, 4 ]
[ 269, 24 ]
python
en
['en', 'en', 'en']
True
make_user_stats_chunk
(error_dict: Dict[str, Any])
Creates a stat chunk about total occurrences and users affected for the error. Example: usersAffected: 2, totalOccurrences: 10 Output: 2 users affected with 10 total occurrences :param error_dict: The error dictionary containing the error keys and values :returns: A message chunk that will be ...
Creates a stat chunk about total occurrences and users affected for the error.
def make_user_stats_chunk(error_dict: Dict[str, Any]) -> str: """Creates a stat chunk about total occurrences and users affected for the error. Example: usersAffected: 2, totalOccurrences: 10 Output: 2 users affected with 10 total occurrences :param error_dict: The error dictionary containing the ...
[ "def", "make_user_stats_chunk", "(", "error_dict", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "users_affected", "=", "error_dict", "[", "\"usersAffected\"", "]", "total_occurrences", "=", "error_dict", "[", "\"totalOccurrences\"", "]", "# O...
[ 45, 0 ]
[ 60, 92 ]
python
en
['en', 'en', 'en']
True
make_time_chunk
(error_dict: Dict[str, Any])
Creates a time message chunk. Example: firstOccurredOn: "X", lastOccurredOn: "Y" Output: First occurred: X Last occurred: Y :param error_dict: The error dictionary containing the error keys and values :returns: A message chunk that will be added to the main message
Creates a time message chunk.
def make_time_chunk(error_dict: Dict[str, Any]) -> str: """Creates a time message chunk. Example: firstOccurredOn: "X", lastOccurredOn: "Y" Output: First occurred: X Last occurred: Y :param error_dict: The error dictionary containing the error keys and values :returns: A message chunk ...
[ "def", "make_time_chunk", "(", "error_dict", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "# Make the timestamp more readable to a human.", "time_first", "=", "parse_time", "(", "error_dict", "[", "\"firstOccurredOn\"", "]", ")", "time_last", "...
[ 63, 0 ]
[ 80, 84 ]
python
en
['en', 'en', 'en']
True
make_message_chunk
(message: str)
Creates a message chunk if exists. Example: message: "This is an example message" returns "Message: This is an example message". Whereas message: "" returns "". :param message: The value of message inside of the error dictionary :returns: A message chunk if there exists an additional message, otherwis...
Creates a message chunk if exists.
def make_message_chunk(message: str) -> str: """Creates a message chunk if exists. Example: message: "This is an example message" returns "Message: This is an example message". Whereas message: "" returns "". :param message: The value of message inside of the error dictionary :returns: A message c...
[ "def", "make_message_chunk", "(", "message", ":", "str", ")", "->", "str", ":", "# \"Message\" shouldn't be included if there is none supplied.", "return", "f\"* **Message**: {message}\\n\"", "if", "message", "!=", "\"\"", "else", "\"\"" ]
[ 83, 0 ]
[ 94, 65 ]
python
en
['en', 'en', 'en']
True
make_app_info_chunk
(app_dict: Dict[str, str])
Creates a message chunk that contains the application info and the link to the Raygun dashboard about the application. :param app_dict: The application dictionary obtained from the payload :returns: A message chunk that will be added to the main message
Creates a message chunk that contains the application info and the link to the Raygun dashboard about the application.
def make_app_info_chunk(app_dict: Dict[str, str]) -> str: """Creates a message chunk that contains the application info and the link to the Raygun dashboard about the application. :param app_dict: The application dictionary obtained from the payload :returns: A message chunk that will be added to the m...
[ "def", "make_app_info_chunk", "(", "app_dict", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "str", ":", "app_name", "=", "app_dict", "[", "\"name\"", "]", "app_url", "=", "app_dict", "[", "\"url\"", "]", "return", "f\"* **Application details**: [{app_n...
[ 97, 0 ]
[ 106, 66 ]
python
en
['en', 'en', 'en']
True
notification_message_follow_up
(payload: Dict[str, Any])
Creates a message for a repeating error follow up :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted
Creates a message for a repeating error follow up
def notification_message_follow_up(payload: Dict[str, Any]) -> str: """Creates a message for a repeating error follow up :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted """ message = "" # Link to Raygun about the follow up followup_link_md = "[fo...
[ "def", "notification_message_follow_up", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "message", "=", "\"\"", "# Link to Raygun about the follow up", "followup_link_md", "=", "\"[follow-up error]({})\"", ".", "format", "(", "paylo...
[ 109, 0 ]
[ 140, 18 ]
python
en
['en', 'en', 'en']
True
notification_message_error_occurred
(payload: Dict[str, Any])
Creates a message for a new error or reoccurred error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted
Creates a message for a new error or reoccurred error
def notification_message_error_occurred(payload: Dict[str, Any]) -> str: """Creates a message for a new error or reoccurred error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted """ message = "" # Provide a clickable link that goes to Raygun about th...
[ "def", "notification_message_error_occurred", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "message", "=", "\"\"", "# Provide a clickable link that goes to Raygun about this error.", "error_link_md", "=", "\"[Error]({})\"", ".", "form...
[ 143, 0 ]
[ 198, 18 ]
python
en
['en', 'en', 'en']
True
compose_notification_message
(payload: Dict[str, Any])
Composes a message that contains information on the error :param payload: Raygun payload :return: Returns a response message
Composes a message that contains information on the error
def compose_notification_message(payload: Dict[str, Any]) -> str: """Composes a message that contains information on the error :param payload: Raygun payload :return: Returns a response message """ # Get the event type of the error. This can be "NewErrorOccurred", # "ErrorReoccurred", "OneMinu...
[ "def", "compose_notification_message", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "# Get the event type of the error. This can be \"NewErrorOccurred\",", "# \"ErrorReoccurred\", \"OneMinuteFollowUp\", \"FiveMinuteFollowUp\", ...,", "# \"HourlyF...
[ 201, 0 ]
[ 225, 53 ]
python
en
['en', 'en', 'en']
True
activity_message
(payload: Dict[str, Any])
Creates a message from an activity that is being taken for an error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted
Creates a message from an activity that is being taken for an error
def activity_message(payload: Dict[str, Any]) -> str: """Creates a message from an activity that is being taken for an error :param payload: Raygun payload :return: Returns the message, somewhat beautifully formatted """ message = "" error_link_md = "[Error]({})".format(payload["error"]["url"]...
[ "def", "activity_message", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "message", "=", "\"\"", "error_link_md", "=", "\"[Error]({})\"", ".", "format", "(", "payload", "[", "\"error\"", "]", "[", "\"url\"", "]", ")", ...
[ 228, 0 ]
[ 255, 18 ]
python
en
['en', 'en', 'en']
True
compose_activity_message
(payload: Dict[str, Any])
Composes a message that contains an activity that is being taken to an error, such as commenting, assigning an error to a user, ignoring the error, etc. :param payload: Raygun payload :return: Returns a response message
Composes a message that contains an activity that is being taken to an error, such as commenting, assigning an error to a user, ignoring the error, etc.
def compose_activity_message(payload: Dict[str, Any]) -> str: """Composes a message that contains an activity that is being taken to an error, such as commenting, assigning an error to a user, ignoring the error, etc. :param payload: Raygun payload :return: Returns a response message """ e...
[ "def", "compose_activity_message", "(", "payload", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "event_type", "=", "payload", "[", "\"eventType\"", "]", "# Activity is separated into three main categories: status changes (", "# ignores, resolved), erro...
[ 258, 0 ]
[ 283, 53 ]
python
en
['en', 'en', 'en']
True
parse_time
(timestamp: str)
Parses and returns the timestamp provided :param timestamp: The timestamp provided by the payload :returns: A string containing the time
Parses and returns the timestamp provided
def parse_time(timestamp: str) -> str: """Parses and returns the timestamp provided :param timestamp: The timestamp provided by the payload :returns: A string containing the time """ # Raygun provides two timestamp format, one with the Z at the end, # and one without the Z. format = "%Y-%...
[ "def", "parse_time", "(", "timestamp", ":", "str", ")", "->", "str", ":", "# Raygun provides two timestamp format, one with the Z at the end,", "# and one without the Z.", "format", "=", "\"%Y-%m-%dT%H:%M:%S\"", "format", "+=", "\"Z\"", "if", "timestamp", "[", "-", "1", ...
[ 286, 0 ]
[ 299, 22 ]
python
en
['en', 'en', 'en']
True
require_http_methods
(request_method_list)
Decorator to make a view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def my_view(request): # I can assume now that only GET or POST requests make it this far # ... Note that request methods should be in uppercase.
Decorator to make a view only accept particular request methods. Usage::
def require_http_methods(request_method_list): """ Decorator to make a view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def my_view(request): # I can assume now that only GET or POST requests make it this far # ... Note th...
[ "def", "require_http_methods", "(", "request_method_list", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", ...
[ 17, 0 ]
[ 41, 20 ]
python
en
['en', 'error', 'th']
False
condition
(etag_func=None, last_modified_func=None)
Decorator to support conditional retrieval (or change) for a view function. The parameters are callables to compute the ETag and last modified time for the requested resource, respectively. The callables are passed the same parameters as the view itself. The ETag function should return a string (o...
Decorator to support conditional retrieval (or change) for a view function.
def condition(etag_func=None, last_modified_func=None): """ Decorator to support conditional retrieval (or change) for a view function. The parameters are callables to compute the ETag and last modified time for the requested resource, respectively. The callables are passed the same parameters ...
[ "def", "condition", "(", "etag_func", "=", "None", ",", "last_modified_func", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs",...
[ 54, 0 ]
[ 111, 20 ]
python
en
['en', 'error', 'th']
False
RecorderTests.test_apply
(self)
Tests marking migrations as applied/unapplied.
Tests marking migrations as applied/unapplied.
def test_apply(self): """ Tests marking migrations as applied/unapplied. """ recorder = MigrationRecorder(connection) self.assertEqual( set((x, y) for (x, y) in recorder.applied_migrations() if x == "myapp"), set(), ) recorder.record_applie...
[ "def", "test_apply", "(", "self", ")", ":", "recorder", "=", "MigrationRecorder", "(", "connection", ")", "self", ".", "assertEqual", "(", "set", "(", "(", "x", ",", "y", ")", "for", "(", "x", ",", "y", ")", "in", "recorder", ".", "applied_migrations",...
[ 15, 4 ]
[ 39, 9 ]
python
en
['en', 'error', 'th']
False
LoaderTests.test_load
(self)
Makes sure the loader can load the migrations for the test apps, and then render them out to a new Apps.
Makes sure the loader can load the migrations for the test apps, and then render them out to a new Apps.
def test_load(self): """ Makes sure the loader can load the migrations for the test apps, and then render them out to a new Apps. """ # Load and test the plan migration_loader = MigrationLoader(connection) self.assertEqual( migration_loader.graph.forwa...
[ "def", "test_load", "(", "self", ")", ":", "# Load and test the plan", "migration_loader", "=", "MigrationLoader", "(", "connection", ")", "self", ".", "assertEqual", "(", "migration_loader", ".", "graph", ".", "forwards_plan", "(", "(", "\"migrations\"", ",", "\"...
[ 50, 4 ]
[ 81, 55 ]
python
en
['en', 'error', 'th']
False
LoaderTests.test_load_unmigrated_dependency
(self)
Makes sure the loader can load migrations with a dependency on an unmigrated app.
Makes sure the loader can load migrations with a dependency on an unmigrated app.
def test_load_unmigrated_dependency(self): """ Makes sure the loader can load migrations with a dependency on an unmigrated app. """ # Load and test the plan migration_loader = MigrationLoader(connection) self.assertEqual( migration_loader.graph.forwards_plan(...
[ "def", "test_load_unmigrated_dependency", "(", "self", ")", ":", "# Load and test the plan", "migration_loader", "=", "MigrationLoader", "(", "connection", ")", "self", ".", "assertEqual", "(", "migration_loader", ".", "graph", ".", "forwards_plan", "(", "(", "\"migra...
[ 84, 4 ]
[ 106, 9 ]
python
en
['en', 'error', 'th']
False
LoaderTests.test_run_before
(self)
Makes sure the loader uses Migration.run_before.
Makes sure the loader uses Migration.run_before.
def test_run_before(self): """ Makes sure the loader uses Migration.run_before. """ # Load and test the plan migration_loader = MigrationLoader(connection) self.assertEqual( migration_loader.graph.forwards_plan(("migrations", "0002_second")), [ ...
[ "def", "test_run_before", "(", "self", ")", ":", "# Load and test the plan", "migration_loader", "=", "MigrationLoader", "(", "connection", ")", "self", ".", "assertEqual", "(", "migration_loader", ".", "graph", ".", "forwards_plan", "(", "(", "\"migrations\"", ",",...
[ 109, 4 ]
[ 122, 9 ]
python
en
['en', 'error', 'th']
False
LoaderTests.test_first
(self)
Makes sure the '__first__' migrations build correctly.
Makes sure the '__first__' migrations build correctly.
def test_first(self): """ Makes sure the '__first__' migrations build correctly. """ migration_loader = MigrationLoader(connection) self.assertEqual( migration_loader.graph.forwards_plan(("migrations", "second")), [ ("migrations", "thefirst...
[ "def", "test_first", "(", "self", ")", ":", "migration_loader", "=", "MigrationLoader", "(", "connection", ")", "self", ".", "assertEqual", "(", "migration_loader", ".", "graph", ".", "forwards_plan", "(", "(", "\"migrations\"", ",", "\"second\"", ")", ")", ",...
[ 129, 4 ]
[ 142, 9 ]
python
en
['en', 'error', 'th']
False
LoaderTests.test_name_match
(self)
Tests prefix name matching
Tests prefix name matching
def test_name_match(self): "Tests prefix name matching" migration_loader = MigrationLoader(connection) self.assertEqual( migration_loader.get_migration_by_prefix("migrations", "0001").name, "0001_initial", ) with self.assertRaises(AmbiguityError): ...
[ "def", "test_name_match", "(", "self", ")", ":", "migration_loader", "=", "MigrationLoader", "(", "connection", ")", "self", ".", "assertEqual", "(", "migration_loader", ".", "get_migration_by_prefix", "(", "\"migrations\"", ",", "\"0001\"", ")", ".", "name", ",",...
[ 145, 4 ]
[ 155, 75 ]
python
en
['en', 'jv', 'en']
True
LoaderTests.test_loading_squashed
(self)
Tests loading a squashed migration
Tests loading a squashed migration
def test_loading_squashed(self): "Tests loading a squashed migration" migration_loader = MigrationLoader(connection) recorder = MigrationRecorder(connection) # Loading with nothing applied should just give us the one node self.assertEqual( len([x for x in migration_lo...
[ "def", "test_loading_squashed", "(", "self", ")", ":", "migration_loader", "=", "MigrationLoader", "(", "connection", ")", "recorder", "=", "MigrationRecorder", "(", "connection", ")", "# Loading with nothing applied should just give us the one node", "self", ".", "assertEq...
[ 172, 4 ]
[ 188, 24 ]
python
en
['en', 'en', 'en']
True
TestDefaults.test_staticfiles_dirs
(self)
Can find a file in a STATICFILES_DIRS directory.
Can find a file in a STATICFILES_DIRS directory.
def test_staticfiles_dirs(self): """ Can find a file in a STATICFILES_DIRS directory. """ self.assertFileContains('test.txt', 'Can we find') self.assertFileContains(os.path.join('prefix', 'test.txt'), 'Prefix')
[ "def", "test_staticfiles_dirs", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'test.txt'", ",", "'Can we find'", ")", "self", ".", "assertFileContains", "(", "os", ".", "path", ".", "join", "(", "'prefix'", ",", "'test.txt'", ")", ",", "'Pr...
[ 157, 4 ]
[ 162, 77 ]
python
en
['en', 'error', 'th']
False
TestDefaults.test_staticfiles_dirs_subdir
(self)
Can find a file in a subdirectory of a STATICFILES_DIRS directory.
Can find a file in a subdirectory of a STATICFILES_DIRS directory.
def test_staticfiles_dirs_subdir(self): """ Can find a file in a subdirectory of a STATICFILES_DIRS directory. """ self.assertFileContains('subdir/test.txt', 'Can we find')
[ "def", "test_staticfiles_dirs_subdir", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'subdir/test.txt'", ",", "'Can we find'", ")" ]
[ 164, 4 ]
[ 169, 65 ]
python
en
['en', 'error', 'th']
False
TestDefaults.test_staticfiles_dirs_priority
(self)
File in STATICFILES_DIRS has priority over file in app.
File in STATICFILES_DIRS has priority over file in app.
def test_staticfiles_dirs_priority(self): """ File in STATICFILES_DIRS has priority over file in app. """ self.assertFileContains('test/file.txt', 'STATICFILES_DIRS')
[ "def", "test_staticfiles_dirs_priority", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'test/file.txt'", ",", "'STATICFILES_DIRS'", ")" ]
[ 171, 4 ]
[ 175, 68 ]
python
en
['en', 'error', 'th']
False
TestDefaults.test_app_files
(self)
Can find a file in an app static/ directory.
Can find a file in an app static/ directory.
def test_app_files(self): """ Can find a file in an app static/ directory. """ self.assertFileContains('test/file1.txt', 'file1 in the app dir')
[ "def", "test_app_files", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'test/file1.txt'", ",", "'file1 in the app dir'", ")" ]
[ 177, 4 ]
[ 181, 73 ]
python
en
['en', 'error', 'th']
False
TestDefaults.test_nonascii_filenames
(self)
Can find a file with non-ASCII character in an app static/ directory.
Can find a file with non-ASCII character in an app static/ directory.
def test_nonascii_filenames(self): """ Can find a file with non-ASCII character in an app static/ directory. """ self.assertFileContains('test/⊗.txt', '⊗ in the app dir')
[ "def", "test_nonascii_filenames", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'test/⊗.txt', ", "'", " in the app dir')", "" ]
[ 183, 4 ]
[ 187, 69 ]
python
en
['en', 'error', 'th']
False
TestDefaults.test_camelcase_filenames
(self)
Can find a file with capital letters.
Can find a file with capital letters.
def test_camelcase_filenames(self): """ Can find a file with capital letters. """ self.assertFileContains('test/camelCase.txt', 'camelCase')
[ "def", "test_camelcase_filenames", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'test/camelCase.txt'", ",", "'camelCase'", ")" ]
[ 189, 4 ]
[ 193, 66 ]
python
en
['en', 'error', 'th']
False
TestFindStatic.test_all_files
(self)
Test that findstatic returns all candidate files if run without --first and -v1.
Test that findstatic returns all candidate files if run without --first and -v1.
def test_all_files(self): """ Test that findstatic returns all candidate files if run without --first and -v1. """ out = six.StringIO() call_command('findstatic', 'test/file.txt', verbosity=1, stdout=out) out.seek(0) lines = [l.strip() for l in out.readlines()] ...
[ "def", "test_all_files", "(", "self", ")", ":", "out", "=", "six", ".", "StringIO", "(", ")", "call_command", "(", "'findstatic'", ",", "'test/file.txt'", ",", "verbosity", "=", "1", ",", "stdout", "=", "out", ")", "out", ".", "seek", "(", "0", ")", ...
[ 208, 4 ]
[ 218, 51 ]
python
en
['en', 'error', 'th']
False
TestFindStatic.test_all_files_less_verbose
(self)
Test that findstatic returns all candidate files if run without --first and -v0.
Test that findstatic returns all candidate files if run without --first and -v0.
def test_all_files_less_verbose(self): """ Test that findstatic returns all candidate files if run without --first and -v0. """ out = six.StringIO() call_command('findstatic', 'test/file.txt', verbosity=0, stdout=out) out.seek(0) lines = [l.strip() for l in out.re...
[ "def", "test_all_files_less_verbose", "(", "self", ")", ":", "out", "=", "six", ".", "StringIO", "(", ")", "call_command", "(", "'findstatic'", ",", "'test/file.txt'", ",", "verbosity", "=", "0", ",", "stdout", "=", "out", ")", "out", ".", "seek", "(", "...
[ 220, 4 ]
[ 230, 51 ]
python
en
['en', 'error', 'th']
False
TestFindStatic.test_all_files_more_verbose
(self)
Test that findstatic returns all candidate files if run without --first and -v2. Also, test that findstatic returns the searched locations with -v2.
Test that findstatic returns all candidate files if run without --first and -v2. Also, test that findstatic returns the searched locations with -v2.
def test_all_files_more_verbose(self): """ Test that findstatic returns all candidate files if run without --first and -v2. Also, test that findstatic returns the searched locations with -v2. """ out = six.StringIO() call_command('findstatic', 'test/file.txt', verbosity=2...
[ "def", "test_all_files_more_verbose", "(", "self", ")", ":", "out", "=", "six", ".", "StringIO", "(", ")", "call_command", "(", "'findstatic'", ",", "'test/file.txt'", ",", "verbosity", "=", "2", ",", "stdout", "=", "out", ")", "out", ".", "seek", "(", "...
[ 232, 4 ]
[ 257, 41 ]
python
en
['en', 'error', 'th']
False
TestCollection.test_ignore
(self)
Test that -i patterns are ignored.
Test that -i patterns are ignored.
def test_ignore(self): """ Test that -i patterns are ignored. """ self.assertFileNotFound('test/test.ignoreme')
[ "def", "test_ignore", "(", "self", ")", ":", "self", ".", "assertFileNotFound", "(", "'test/test.ignoreme'", ")" ]
[ 300, 4 ]
[ 304, 53 ]
python
en
['en', 'error', 'th']
False
TestCollection.test_common_ignore_patterns
(self)
Common ignore patterns (*~, .*, CVS) are ignored.
Common ignore patterns (*~, .*, CVS) are ignored.
def test_common_ignore_patterns(self): """ Common ignore patterns (*~, .*, CVS) are ignored. """ self.assertFileNotFound('test/.hidden') self.assertFileNotFound('test/backup~') self.assertFileNotFound('test/CVS')
[ "def", "test_common_ignore_patterns", "(", "self", ")", ":", "self", ".", "assertFileNotFound", "(", "'test/.hidden'", ")", "self", ".", "assertFileNotFound", "(", "'test/backup~'", ")", "self", ".", "assertFileNotFound", "(", "'test/CVS'", ")" ]
[ 306, 4 ]
[ 312, 43 ]
python
en
['en', 'error', 'th']
False
TestCollectionExcludeNoDefaultIgnore.test_no_common_ignore_patterns
(self)
With --no-default-ignore, common ignore patterns (*~, .*, CVS) are not ignored.
With --no-default-ignore, common ignore patterns (*~, .*, CVS) are not ignored.
def test_no_common_ignore_patterns(self): """ With --no-default-ignore, common ignore patterns (*~, .*, CVS) are not ignored. """ self.assertFileContains('test/.hidden', 'should be ignored') self.assertFileContains('test/backup~', 'should be ignored') self.assert...
[ "def", "test_no_common_ignore_patterns", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'test/.hidden'", ",", "'should be ignored'", ")", "self", ".", "assertFileContains", "(", "'test/backup~'", ",", "'should be ignored'", ")", "self", ".", "assertFi...
[ 338, 4 ]
[ 346, 64 ]
python
en
['en', 'error', 'th']
False
TestNoFilesCreated.test_no_files_created
(self)
Make sure no files were create in the destination directory.
Make sure no files were create in the destination directory.
def test_no_files_created(self): """ Make sure no files were create in the destination directory. """ self.assertEqual(os.listdir(settings.STATIC_ROOT), [])
[ "def", "test_no_files_created", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "os", ".", "listdir", "(", "settings", ".", "STATIC_ROOT", ")", ",", "[", "]", ")" ]
[ 351, 4 ]
[ 355, 62 ]
python
en
['en', 'error', 'th']
False
TestCollectionFilesOverride.test_ordering_override
(self)
Test if collectstatic takes files in proper order
Test if collectstatic takes files in proper order
def test_ordering_override(self): """ Test if collectstatic takes files in proper order """ self.assertFileContains('file2.txt', 'duplicate of file2.txt') # run collectstatic again self.run_collectstatic() self.assertFileContains('file2.txt', 'duplicate of file2...
[ "def", "test_ordering_override", "(", "self", ")", ":", "self", ".", "assertFileContains", "(", "'file2.txt'", ",", "'duplicate of file2.txt'", ")", "# run collectstatic again", "self", ".", "run_collectstatic", "(", ")", "self", ".", "assertFileContains", "(", "'file...
[ 399, 4 ]
[ 419, 70 ]
python
en
['en', 'error', 'th']
False
TestHashedFiles.test_template_tag_return
(self)
Test the CachedStaticFilesStorage backend.
Test the CachedStaticFilesStorage backend.
def test_template_tag_return(self): """ Test the CachedStaticFilesStorage backend. """ self.assertStaticRaises(ValueError, "does/not/exist.png", "/static/does/not/exist.png") self.assertStaticRenders("test/file.txt",...
[ "def", "test_template_tag_return", "(", "self", ")", ":", "self", ".", "assertStaticRaises", "(", "ValueError", ",", "\"does/not/exist.png\"", ",", "\"/static/does/not/exist.png\"", ")", "self", ".", "assertStaticRenders", "(", "\"test/file.txt\"", ",", "\"/static/test/fi...
[ 440, 4 ]
[ 456, 55 ]
python
en
['en', 'error', 'th']
False
TestHashedFiles.test_post_processing
(self)
Test that post_processing behaves correctly. Files that are alterable should always be post-processed; files that aren't should be skipped. collectstatic has already been called once in setUp() for this testcase, therefore we check by verifying behavior on a second run.
Test that post_processing behaves correctly.
def test_post_processing(self): """Test that post_processing behaves correctly. Files that are alterable should always be post-processed; files that aren't should be skipped. collectstatic has already been called once in setUp() for this testcase, therefore we check by verifyin...
[ "def", "test_post_processing", "(", "self", ")", ":", "collectstatic_args", "=", "{", "'interactive'", ":", "False", ",", "'verbosity'", ":", "0", ",", "'link'", ":", "False", ",", "'clear'", ":", "False", ",", "'dry_run'", ":", "False", ",", "'post_process'...
[ 557, 4 ]
[ 582, 84 ]
python
en
['en', 'en', 'en']
True
TestHashedFiles.test_post_processing_failure
(self)
Test that post_processing indicates the origin of the error when it fails. Regression test for #18986.
Test that post_processing indicates the origin of the error when it fails. Regression test for #18986.
def test_post_processing_failure(self): """ Test that post_processing indicates the origin of the error when it fails. Regression test for #18986. """ finders.get_finder.cache_clear() err = six.StringIO() with self.assertRaises(Exception): call_command...
[ "def", "test_post_processing_failure", "(", "self", ")", ":", "finders", ".", "get_finder", ".", "cache_clear", "(", ")", "err", "=", "six", ".", "StringIO", "(", ")", "with", "self", ".", "assertRaises", "(", "Exception", ")", ":", "call_command", "(", "'...
[ 596, 4 ]
[ 605, 84 ]
python
en
['en', 'error', 'th']
False
get_active_download_resources
(exchange_configs)
Get resources that are enabled for downward (to-Respa) sync. :param exchange_configs: Exchange configurations to look at. These will be assigned to the respective resources. :type exchange_configs: list[respa_exchange.models.ExchangeConfiguration] :rtype: list[respa_exchange.models.ExchangeResource] ...
Get resources that are enabled for downward (to-Respa) sync.
def get_active_download_resources(exchange_configs): """ Get resources that are enabled for downward (to-Respa) sync. :param exchange_configs: Exchange configurations to look at. These will be assigned to the respective resources. :type exchange_configs: list[respa_exchange.models.ExchangeConfiguration...
[ "def", "get_active_download_resources", "(", "exchange_configs", ")", ":", "resources", "=", "[", "]", "for", "exchange", "in", "exchange_configs", ":", "for", "ex_resource", "in", "ExchangeResource", ".", "objects", ".", "filter", "(", "sync_to_respa", "=", "True...
[ 11, 0 ]
[ 28, 20 ]
python
en
['en', 'error', 'th']
False
register_serializer
(format, serializer_module, serializers=None)
Register a new serializer. ``serializer_module`` should be the fully qualified module name for the serializer. If ``serializers`` is provided, the registration will be added to the provided dictionary. If ``serializers`` is not provided, the registration will be made directly into the global ...
Register a new serializer.
def register_serializer(format, serializer_module, serializers=None): """Register a new serializer. ``serializer_module`` should be the fully qualified module name for the serializer. If ``serializers`` is provided, the registration will be added to the provided dictionary. If ``serializers``...
[ "def", "register_serializer", "(", "format", ",", "serializer_module", ",", "serializers", "=", "None", ")", ":", "if", "serializers", "is", "None", "and", "not", "_serializers", ":", "_load_serializers", "(", ")", "try", ":", "module", "=", "importlib", ".", ...
[ 52, 0 ]
[ 81, 36 ]
python
en
['en', 'en', 'en']
True
unregister_serializer
(format)
Unregister a given serializer. This is not a thread-safe operation.
Unregister a given serializer. This is not a thread-safe operation.
def unregister_serializer(format): "Unregister a given serializer. This is not a thread-safe operation." if not _serializers: _load_serializers() if format not in _serializers: raise SerializerDoesNotExist(format) del _serializers[format]
[ "def", "unregister_serializer", "(", "format", ")", ":", "if", "not", "_serializers", ":", "_load_serializers", "(", ")", "if", "format", "not", "in", "_serializers", ":", "raise", "SerializerDoesNotExist", "(", "format", ")", "del", "_serializers", "[", "format...
[ 84, 0 ]
[ 90, 28 ]
python
en
['en', 'en', 'en']
True
serialize
(format, queryset, **options)
Serialize a queryset (or any iterator that returns database objects) using a certain serializer.
Serialize a queryset (or any iterator that returns database objects) using a certain serializer.
def serialize(format, queryset, **options): """ Serialize a queryset (or any iterator that returns database objects) using a certain serializer. """ s = get_serializer(format)() s.serialize(queryset, **options) return s.getvalue()
[ "def", "serialize", "(", "format", ",", "queryset", ",", "*", "*", "options", ")", ":", "s", "=", "get_serializer", "(", "format", ")", "(", ")", "s", ".", "serialize", "(", "queryset", ",", "*", "*", "options", ")", "return", "s", ".", "getvalue", ...
[ 121, 0 ]
[ 128, 23 ]
python
en
['en', 'error', 'th']
False
deserialize
(format, stream_or_string, **options)
Deserialize a stream or a string. Returns an iterator that yields ``(obj, m2m_relation_dict)``, where ``obj`` is an instantiated -- but *unsaved* -- object, and ``m2m_relation_dict`` is a dictionary of ``{m2m_field_name : list_of_related_objects}``.
Deserialize a stream or a string. Returns an iterator that yields ``(obj, m2m_relation_dict)``, where ``obj`` is an instantiated -- but *unsaved* -- object, and ``m2m_relation_dict`` is a dictionary of ``{m2m_field_name : list_of_related_objects}``.
def deserialize(format, stream_or_string, **options): """ Deserialize a stream or a string. Returns an iterator that yields ``(obj, m2m_relation_dict)``, where ``obj`` is an instantiated -- but *unsaved* -- object, and ``m2m_relation_dict`` is a dictionary of ``{m2m_field_name : list_of_related_obje...
[ "def", "deserialize", "(", "format", ",", "stream_or_string", ",", "*", "*", "options", ")", ":", "d", "=", "get_deserializer", "(", "format", ")", "return", "d", "(", "stream_or_string", ",", "*", "*", "options", ")" ]
[ 131, 0 ]
[ 139, 41 ]
python
en
['en', 'error', 'th']
False
_load_serializers
()
Register built-in and settings-defined serializers. This is done lazily so that user code has a chance to (e.g.) set up custom settings without needing to be careful of import order.
Register built-in and settings-defined serializers. This is done lazily so that user code has a chance to (e.g.) set up custom settings without needing to be careful of import order.
def _load_serializers(): """ Register built-in and settings-defined serializers. This is done lazily so that user code has a chance to (e.g.) set up custom settings without needing to be careful of import order. """ global _serializers serializers = {} for format in BUILTIN_SERIALIZERS: ...
[ "def", "_load_serializers", "(", ")", ":", "global", "_serializers", "serializers", "=", "{", "}", "for", "format", "in", "BUILTIN_SERIALIZERS", ":", "register_serializer", "(", "format", ",", "BUILTIN_SERIALIZERS", "[", "format", "]", ",", "serializers", ")", "...
[ 142, 0 ]
[ 155, 30 ]
python
en
['en', 'error', 'th']
False
create_command
(name, **kwargs)
Create an instance of the Command class with the given name.
Create an instance of the Command class with the given name.
def create_command(name, **kwargs): # type: (str, **Any) -> Command """ Create an instance of the Command class with the given name. """ module_path, class_name, summary = commands_dict[name] module = importlib.import_module(module_path) command_class = getattr(module, class_name) comman...
[ "def", "create_command", "(", "name", ",", "*", "*", "kwargs", ")", ":", "# type: (str, **Any) -> Command", "module_path", ",", "class_name", ",", "summary", "=", "commands_dict", "[", "name", "]", "module", "=", "importlib", ".", "import_module", "(", "module_p...
[ 97, 0 ]
[ 107, 18 ]
python
en
['en', 'error', 'th']
False
get_similar_commands
(name)
Command name auto-correct.
Command name auto-correct.
def get_similar_commands(name): """Command name auto-correct.""" from difflib import get_close_matches name = name.lower() close_commands = get_close_matches(name, commands_dict.keys()) if close_commands: return close_commands[0] else: return False
[ "def", "get_similar_commands", "(", "name", ")", ":", "from", "difflib", "import", "get_close_matches", "name", "=", "name", ".", "lower", "(", ")", "close_commands", "=", "get_close_matches", "(", "name", ",", "commands_dict", ".", "keys", "(", ")", ")", "i...
[ 110, 0 ]
[ 121, 20 ]
python
en
['en', 'sm', 'en']
True
OracleGeometryColumns.table_name_col
(cls)
Return the name of the metadata column used to store the feature table name.
Return the name of the metadata column used to store the feature table name.
def table_name_col(cls): """ Return the name of the metadata column used to store the feature table name. """ return 'table_name'
[ "def", "table_name_col", "(", "cls", ")", ":", "return", "'table_name'" ]
[ 29, 4 ]
[ 34, 27 ]
python
en
['en', 'error', 'th']
False
OracleGeometryColumns.geom_col_name
(cls)
Return the name of the metadata column used to store the feature geometry column.
Return the name of the metadata column used to store the feature geometry column.
def geom_col_name(cls): """ Return the name of the metadata column used to store the feature geometry column. """ return 'column_name'
[ "def", "geom_col_name", "(", "cls", ")", ":", "return", "'column_name'" ]
[ 37, 4 ]
[ 42, 28 ]
python
en
['en', 'error', 'th']
False
Composable.as_string
(self, context)
Return the string value of the object. :param context: the context to evaluate the string into. :type context: `connection` or `cursor` The method is automatically invoked by `~cursor.execute()`, `~cursor.executemany()`, `~cursor.copy_expert()` if a `!Composable` is pa...
Return the string value of the object.
def as_string(self, context): """ Return the string value of the object. :param context: the context to evaluate the string into. :type context: `connection` or `cursor` The method is automatically invoked by `~cursor.execute()`, `~cursor.executemany()`, `~cursor.copy_e...
[ "def", "as_string", "(", "self", ",", "context", ")", ":", "raise", "NotImplementedError" ]
[ 55, 4 ]
[ 66, 33 ]
python
en
['en', 'error', 'th']
False
Composed.seq
(self)
The list of the content of the `!Composed`.
The list of the content of the `!Composed`.
def seq(self): """The list of the content of the `!Composed`.""" return list(self._wrapped)
[ "def", "seq", "(", "self", ")", ":", "return", "list", "(", "self", ".", "_wrapped", ")" ]
[ 115, 4 ]
[ 117, 34 ]
python
en
['en', 'en', 'en']
True
Composed.join
(self, joiner)
Return a new `!Composed` interposing the *joiner* with the `!Composed` items. The *joiner* must be a `SQL` or a string which will be interpreted as an `SQL`. Example:: >>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Composed >>> print(fields.jo...
Return a new `!Composed` interposing the *joiner* with the `!Composed` items.
def join(self, joiner): """ Return a new `!Composed` interposing the *joiner* with the `!Composed` items. The *joiner* must be a `SQL` or a string which will be interpreted as an `SQL`. Example:: >>> fields = sql.Identifier('foo') + sql.Identifier('bar') # a Compo...
[ "def", "join", "(", "self", ",", "joiner", ")", ":", "if", "isinstance", "(", "joiner", ",", "string_types", ")", ":", "joiner", "=", "SQL", "(", "joiner", ")", "elif", "not", "isinstance", "(", "joiner", ",", "SQL", ")", ":", "raise", "TypeError", "...
[ 136, 4 ]
[ 156, 32 ]
python
en
['en', 'error', 'th']
False
SQL.string
(self)
The string wrapped by the `!SQL` object.
The string wrapped by the `!SQL` object.
def string(self): """The string wrapped by the `!SQL` object.""" return self._wrapped
[ "def", "string", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 187, 4 ]
[ 189, 28 ]
python
en
['en', 'en', 'en']
True
SQL.format
(self, *args, **kwargs)
Merge `Composable` objects into a template. :param `Composable` args: parameters to replace to numbered (``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders :param `Composable` kwargs: parameters to replace to named (``{name}``) placeholders :return: the un...
Merge `Composable` objects into a template.
def format(self, *args, **kwargs): """ Merge `Composable` objects into a template. :param `Composable` args: parameters to replace to numbered (``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders :param `Composable` kwargs: parameters to replace to named (``{name}``) ...
[ "def", "format", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "rv", "=", "[", "]", "autonum", "=", "0", "for", "pre", ",", "name", ",", "spec", ",", "conv", "in", "_formatter", ".", "parse", "(", "self", ".", "_wrapped", ")...
[ 194, 4 ]
[ 256, 27 ]
python
en
['en', 'error', 'th']
False
SQL.join
(self, seq)
Join a sequence of `Composable`. :param seq: the elements to join. :type seq: iterable of `!Composable` Use the `!SQL` object's *string* to separate the elements in *seq*. Note that `Composed` objects are iterable too, so they can be used as argument for this method. ...
Join a sequence of `Composable`.
def join(self, seq): """ Join a sequence of `Composable`. :param seq: the elements to join. :type seq: iterable of `!Composable` Use the `!SQL` object's *string* to separate the elements in *seq*. Note that `Composed` objects are iterable too, so they can be used as ...
[ "def", "join", "(", "self", ",", "seq", ")", ":", "rv", "=", "[", "]", "it", "=", "iter", "(", "seq", ")", "try", ":", "rv", ".", "append", "(", "next", "(", "it", ")", ")", "except", "StopIteration", ":", "pass", "else", ":", "for", "i", "in...
[ 258, 4 ]
[ 287, 27 ]
python
en
['en', 'error', 'th']
False
Identifier.strings
(self)
A tuple with the strings wrapped by the `Identifier`.
A tuple with the strings wrapped by the `Identifier`.
def strings(self): """A tuple with the strings wrapped by the `Identifier`.""" return self._wrapped
[ "def", "strings", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 332, 4 ]
[ 334, 28 ]
python
en
['en', 'en', 'en']
True
Identifier.string
(self)
The string wrapped by the `Identifier`.
The string wrapped by the `Identifier`.
def string(self): """The string wrapped by the `Identifier`. """ if len(self._wrapped) == 1: return self._wrapped[0] else: raise AttributeError( "the Identifier wraps more than one than one string")
[ "def", "string", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_wrapped", ")", "==", "1", ":", "return", "self", ".", "_wrapped", "[", "0", "]", "else", ":", "raise", "AttributeError", "(", "\"the Identifier wraps more than one than one string\"", "...
[ 337, 4 ]
[ 344, 69 ]
python
en
['en', 'en', 'en']
True
Literal.wrapped
(self)
The object wrapped by the `!Literal`.
The object wrapped by the `!Literal`.
def wrapped(self): """The object wrapped by the `!Literal`.""" return self._wrapped
[ "def", "wrapped", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 376, 4 ]
[ 378, 28 ]
python
en
['en', 'en', 'en']
True
Placeholder.name
(self)
The name of the `!Placeholder`.
The name of the `!Placeholder`.
def name(self): """The name of the `!Placeholder`.""" return self._wrapped
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_wrapped" ]
[ 438, 4 ]
[ 440, 28 ]
python
en
['en', 'en', 'en']
True
_dnsname_match
(dn, hostname, max_wildcards=1)
Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3
Matching according to RFC 6125, section 6.4.3
def _dnsname_match(dn, hostname, max_wildcards=1): """Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 """ pats = [] if not dn: return False # Ported from python3-syntax: # leftmost, *remainder = dn.split(r'.') parts = dn.split(r"."...
[ "def", "_dnsname_match", "(", "dn", ",", "hostname", ",", "max_wildcards", "=", "1", ")", ":", "pats", "=", "[", "]", "if", "not", "dn", ":", "return", "False", "# Ported from python3-syntax:", "# leftmost, *remainder = dn.split(r'.')", "parts", "=", "dn", ".", ...
[ 24, 0 ]
[ 75, 30 ]
python
en
['en', 'en', 'en']
True
_ipaddress_match
(ipname, host_ip)
Exact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope").
Exact matching of IP addresses.
def _ipaddress_match(ipname, host_ip): """Exact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope"). """ # OpenSSL may add a trailing newline to a subjectAltName's IP address # Divergence from upstream: ipaddress can't handle byte ...
[ "def", "_ipaddress_match", "(", "ipname", ",", "host_ip", ")", ":", "# OpenSSL may add a trailing newline to a subjectAltName's IP address", "# Divergence from upstream: ipaddress can't handle byte str", "ip", "=", "ipaddress", ".", "ip_address", "(", "_to_unicode", "(", "ipname"...
[ 84, 0 ]
[ 93, 24 ]
python
en
['en', 'sn', 'en']
True
match_hostname
(cert, hostname)
Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing.
Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*.
def match_hostname(cert, hostname): """Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function r...
[ "def", "match_hostname", "(", "cert", ",", "hostname", ")", ":", "if", "not", "cert", ":", "raise", "ValueError", "(", "\"empty or no certificate, match_hostname needs a \"", "\"SSL socket or SSL context with either \"", "\"CERT_OPTIONAL or CERT_REQUIRED\"", ")", "try", ":", ...
[ 96, 0 ]
[ 159, 9 ]
python
en
['en', 'en', 'en']
True
check_requires_python
(requires_python, version_info)
Check if the given Python version matches a "Requires-Python" specifier. :param version_info: A 3-tuple of ints representing a Python major-minor-micro version to check (e.g. `sys.version_info[:3]`). :return: `True` if the given Python version satisfies the requirement. Otherwise, return ...
Check if the given Python version matches a "Requires-Python" specifier.
def check_requires_python(requires_python, version_info): # type: (Optional[str], Tuple[int, ...]) -> bool """ Check if the given Python version matches a "Requires-Python" specifier. :param version_info: A 3-tuple of ints representing a Python major-minor-micro version to check (e.g. `sys.vers...
[ "def", "check_requires_python", "(", "requires_python", ",", "version_info", ")", ":", "# type: (Optional[str], Tuple[int, ...]) -> bool", "if", "requires_python", "is", "None", ":", "# The package provides no information", "return", "True", "requires_python_specifier", "=", "s...
[ 21, 0 ]
[ 40, 54 ]
python
en
['en', 'error', 'th']
False
get_metadata
(dist)
:raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None.
:raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None.
def get_metadata(dist): # type: (Distribution) -> Message """ :raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None. """ metadata_name = 'METADATA' if (isinstance(dist, pkg_resources.DistInfoDistribution) and dist.has_m...
[ "def", "get_metadata", "(", "dist", ")", ":", "# type: (Distribution) -> Message", "metadata_name", "=", "'METADATA'", "if", "(", "isinstance", "(", "dist", ",", "pkg_resources", ".", "DistInfoDistribution", ")", "and", "dist", ".", "has_metadata", "(", "metadata_na...
[ 43, 0 ]
[ 67, 30 ]
python
en
['en', 'error', 'th']
False
get_requires_python
(dist)
Return the "Requires-Python" metadata for a distribution, or None if not present.
Return the "Requires-Python" metadata for a distribution, or None if not present.
def get_requires_python(dist): # type: (pkg_resources.Distribution) -> Optional[str] """ Return the "Requires-Python" metadata for a distribution, or None if not present. """ pkg_info_dict = get_metadata(dist) requires_python = pkg_info_dict.get('Requires-Python') if requires_python is ...
[ "def", "get_requires_python", "(", "dist", ")", ":", "# type: (pkg_resources.Distribution) -> Optional[str]", "pkg_info_dict", "=", "get_metadata", "(", "dist", ")", "requires_python", "=", "pkg_info_dict", ".", "get", "(", "'Requires-Python'", ")", "if", "requires_python...
[ 70, 0 ]
[ 84, 26 ]
python
en
['en', 'error', 'th']
False
vary_on_headers
(*headers)
A view decorator that adds the specified headers to the Vary header of the response. Usage: @vary_on_headers('Cookie', 'Accept-language') def index(request): ... Note that the header names are not case-sensitive.
A view decorator that adds the specified headers to the Vary header of the response. Usage:
def vary_on_headers(*headers): """ A view decorator that adds the specified headers to the Vary header of the response. Usage: @vary_on_headers('Cookie', 'Accept-language') def index(request): ... Note that the header names are not case-sensitive. """ def decorator(fun...
[ "def", "vary_on_headers", "(", "*", "headers", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "*", "args",...
[ 5, 0 ]
[ 23, 20 ]
python
en
['en', 'error', 'th']
False
vary_on_cookie
(func)
A view decorator that adds "Cookie" to the Vary header of a response. This indicates that a page's contents depends on cookies. Usage: @vary_on_cookie def index(request): ...
A view decorator that adds "Cookie" to the Vary header of a response. This indicates that a page's contents depends on cookies. Usage:
def vary_on_cookie(func): """ A view decorator that adds "Cookie" to the Vary header of a response. This indicates that a page's contents depends on cookies. Usage: @vary_on_cookie def index(request): ... """ @wraps(func) def inner_func(*args, **kwargs): resp...
[ "def", "vary_on_cookie", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "patch_vary_headers", ...
[ 26, 0 ]
[ 40, 21 ]
python
en
['en', 'error', 'th']
False
wrap
(text, width)
A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines. All white space is preserved except added line breaks consume the space on which they break the line. Long words are not wrapped, so the output text may have lines longer than ``wid...
A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines.
def wrap(text, width): """ A word-wrap function that preserves existing line breaks. Expects that existing line breaks are posix newlines. All white space is preserved except added line breaks consume the space on which they break the line. Long words are not wrapped, so the output text may ha...
[ "def", "wrap", "(", "text", ",", "width", ")", ":", "text", "=", "force_text", "(", "text", ")", "def", "_generator", "(", ")", ":", "for", "line", "in", "text", ".", "splitlines", "(", "True", ")", ":", "# True keeps trailing linebreaks", "max_width", "...
[ 34, 0 ]
[ 63, 32 ]
python
en
['en', 'error', 'th']
False
get_valid_filename
(s)
Returns the given string converted to a string that can be used for a clean filename. Specifically, leading and trailing spaces are removed; other spaces are converted to underscores; and anything that is not a unicode alphanumeric, dash, underscore, or dot, is removed. >>> get_valid_filename("john...
Returns the given string converted to a string that can be used for a clean filename. Specifically, leading and trailing spaces are removed; other spaces are converted to underscores; and anything that is not a unicode alphanumeric, dash, underscore, or dot, is removed. >>> get_valid_filename("john...
def get_valid_filename(s): """ Returns the given string converted to a string that can be used for a clean filename. Specifically, leading and trailing spaces are removed; other spaces are converted to underscores; and anything that is not a unicode alphanumeric, dash, underscore, or dot, is removed...
[ "def", "get_valid_filename", "(", "s", ")", ":", "s", "=", "force_text", "(", "s", ")", ".", "strip", "(", ")", ".", "replace", "(", "' '", ",", "'_'", ")", "return", "re", ".", "sub", "(", "r'(?u)[^-\\w.]'", ",", "''", ",", "s", ")" ]
[ 233, 0 ]
[ 243, 40 ]
python
en
['en', 'error', 'th']
False
get_text_list
(list_, last_word=ugettext_lazy('or'))
>>> get_text_list(['a', 'b', 'c', 'd']) 'a, b, c or d' >>> get_text_list(['a', 'b', 'c'], 'and') 'a, b and c' >>> get_text_list(['a', 'b'], 'and') 'a and b' >>> get_text_list(['a']) 'a' >>> get_text_list([]) ''
>>> get_text_list(['a', 'b', 'c', 'd']) 'a, b, c or d' >>> get_text_list(['a', 'b', 'c'], 'and') 'a, b and c' >>> get_text_list(['a', 'b'], 'and') 'a and b' >>> get_text_list(['a']) 'a' >>> get_text_list([]) ''
def get_text_list(list_, last_word=ugettext_lazy('or')): """ >>> get_text_list(['a', 'b', 'c', 'd']) 'a, b, c or d' >>> get_text_list(['a', 'b', 'c'], 'and') 'a, b and c' >>> get_text_list(['a', 'b'], 'and') 'a and b' >>> get_text_list(['a']) 'a' >>> get_text_list([]) '' ...
[ "def", "get_text_list", "(", "list_", ",", "last_word", "=", "ugettext_lazy", "(", "'or'", ")", ")", ":", "if", "len", "(", "list_", ")", "==", "0", ":", "return", "''", "if", "len", "(", "list_", ")", "==", "1", ":", "return", "force_text", "(", "...
[ 247, 0 ]
[ 267, 53 ]
python
en
['en', 'error', 'th']
False
normalize_newlines
(text)
Normalizes CRLF and CR newlines to just LF.
Normalizes CRLF and CR newlines to just LF.
def normalize_newlines(text): """Normalizes CRLF and CR newlines to just LF.""" text = force_text(text) return re_newlines.sub('\n', text)
[ "def", "normalize_newlines", "(", "text", ")", ":", "text", "=", "force_text", "(", "text", ")", "return", "re_newlines", ".", "sub", "(", "'\\n'", ",", "text", ")" ]
[ 271, 0 ]
[ 274, 38 ]
python
en
['en', 'en', 'en']
True
phone2numeric
(phone)
Converts a phone number with letters into its numeric equivalent.
Converts a phone number with letters into its numeric equivalent.
def phone2numeric(phone): """Converts a phone number with letters into its numeric equivalent.""" char2number = {'a': '2', 'b': '2', 'c': '2', 'd': '3', 'e': '3', 'f': '3', 'g': '4', 'h': '4', 'i': '4', 'j': '5', 'k': '5', 'l': '5', 'm': '6', 'n': '6', 'o': '6', 'p': '7', 'q': '7', 'r': '7', '...
[ "def", "phone2numeric", "(", "phone", ")", ":", "char2number", "=", "{", "'a'", ":", "'2'", ",", "'b'", ":", "'2'", ",", "'c'", ":", "'2'", ",", "'d'", ":", "'3'", ",", "'e'", ":", "'3'", ",", "'f'", ":", "'3'", ",", "'g'", ":", "'4'", ",", "...
[ 278, 0 ]
[ 284, 64 ]
python
en
['en', 'en', 'en']
True
smart_split
(text)
r""" Generator that splits a string by spaces, leaving quoted phrases together. Supports both single and double quotes, and supports escaping quotes with backslashes. In the output, strings will keep their initial and trailing quote marks and escaped quotes will remain escaped (the results can then ...
r""" Generator that splits a string by spaces, leaving quoted phrases together. Supports both single and double quotes, and supports escaping quotes with backslashes. In the output, strings will keep their initial and trailing quote marks and escaped quotes will remain escaped (the results can then ...
def smart_split(text): r""" Generator that splits a string by spaces, leaving quoted phrases together. Supports both single and double quotes, and supports escaping quotes with backslashes. In the output, strings will keep their initial and trailing quote marks and escaped quotes will remain escaped...
[ "def", "smart_split", "(", "text", ")", ":", "text", "=", "force_text", "(", "text", ")", "for", "bit", "in", "smart_split_re", ".", "finditer", "(", "text", ")", ":", "yield", "bit", ".", "group", "(", "0", ")" ]
[ 371, 0 ]
[ 388, 26 ]
python
cy
['en', 'cy', 'hi']
False
unescape_string_literal
(s)
r""" Convert quoted string literals to unquoted strings with escaped quotes and backslashes unquoted:: >>> unescape_string_literal('"abc"') 'abc' >>> unescape_string_literal("'abc'") 'abc' >>> unescape_string_literal('"a \"bc\""') 'a "bc"' >>> unescape_st...
r""" Convert quoted string literals to unquoted strings with escaped quotes and backslashes unquoted::
def unescape_string_literal(s): r""" Convert quoted string literals to unquoted strings with escaped quotes and backslashes unquoted:: >>> unescape_string_literal('"abc"') 'abc' >>> unescape_string_literal("'abc'") 'abc' >>> unescape_string_literal('"a \"bc\""') ...
[ "def", "unescape_string_literal", "(", "s", ")", ":", "if", "s", "[", "0", "]", "not", "in", "\"\\\"'\"", "or", "s", "[", "-", "1", "]", "!=", "s", "[", "0", "]", ":", "raise", "ValueError", "(", "\"Not a string literal: %r\"", "%", "s", ")", "quote"...
[ 417, 0 ]
[ 434, 70 ]
python
cy
['en', 'cy', 'hi']
False
slugify
(value)
Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace.
Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace.
def slugify(value): """ Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. """ value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') value = re.sub('[...
[ "def", "slugify", "(", "value", ")", ":", "value", "=", "unicodedata", ".", "normalize", "(", "'NFKD'", ",", "value", ")", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ".", "decode", "(", "'ascii'", ")", "value", "=", "re", ".", "sub", "(", ...
[ 438, 0 ]
[ 446, 50 ]
python
en
['en', 'error', 'th']
False
camel_case_to_spaces
(value)
Splits CamelCase and converts to lower case. Also strips leading and trailing whitespace.
Splits CamelCase and converts to lower case. Also strips leading and trailing whitespace.
def camel_case_to_spaces(value): """ Splits CamelCase and converts to lower case. Also strips leading and trailing whitespace. """ return re_camel_case.sub(r' \1', value).strip().lower()
[ "def", "camel_case_to_spaces", "(", "value", ")", ":", "return", "re_camel_case", ".", "sub", "(", "r' \\1'", ",", "value", ")", ".", "strip", "(", ")", ".", "lower", "(", ")" ]
[ 450, 0 ]
[ 455, 59 ]
python
en
['en', 'error', 'th']
False
Truncator.chars
(self, num, truncate=None, html=False)
Returns the text truncated to be no longer than the specified number of characters. Takes an optional argument of what should be used to notify that the string has been truncated, defaulting to a translatable string of an ellipsis (...).
Returns the text truncated to be no longer than the specified number of characters.
def chars(self, num, truncate=None, html=False): """ Returns the text truncated to be no longer than the specified number of characters. Takes an optional argument of what should be used to notify that the string has been truncated, defaulting to a translatable string of an ...
[ "def", "chars", "(", "self", ",", "num", ",", "truncate", "=", "None", ",", "html", "=", "False", ")", ":", "length", "=", "int", "(", "num", ")", "text", "=", "unicodedata", ".", "normalize", "(", "'NFC'", ",", "self", ".", "_wrapped", ")", "# Cal...
[ 90, 4 ]
[ 111, 69 ]
python
en
['en', 'error', 'th']
False
Truncator._text_chars
(self, length, truncate, text, truncate_len)
Truncates a string after a certain number of chars.
Truncates a string after a certain number of chars.
def _text_chars(self, length, truncate, text, truncate_len): """ Truncates a string after a certain number of chars. """ s_len = 0 end_index = None for i, char in enumerate(text): if unicodedata.combining(char): # Don't consider combining chara...
[ "def", "_text_chars", "(", "self", ",", "length", ",", "truncate", ",", "text", ",", "truncate_len", ")", ":", "s_len", "=", "0", "end_index", "=", "None", "for", "i", ",", "char", "in", "enumerate", "(", "text", ")", ":", "if", "unicodedata", ".", "...
[ 114, 4 ]
[ 134, 19 ]
python
en
['en', 'error', 'th']
False
Truncator.words
(self, num, truncate=None, html=False)
Truncates a string after a certain number of words. Takes an optional argument of what should be used to notify that the string has been truncated, defaulting to ellipsis (...).
Truncates a string after a certain number of words. Takes an optional argument of what should be used to notify that the string has been truncated, defaulting to ellipsis (...).
def words(self, num, truncate=None, html=False): """ Truncates a string after a certain number of words. Takes an optional argument of what should be used to notify that the string has been truncated, defaulting to ellipsis (...). """ length = int(num) if html: ...
[ "def", "words", "(", "self", ",", "num", ",", "truncate", "=", "None", ",", "html", "=", "False", ")", ":", "length", "=", "int", "(", "num", ")", "if", "html", ":", "return", "self", ".", "_truncate_html", "(", "length", ",", "truncate", ",", "sel...
[ 136, 4 ]
[ 145, 49 ]
python
en
['en', 'error', 'th']
False
Truncator._text_words
(self, length, truncate)
Truncates a string after a certain number of words. Newlines in the string will be stripped.
Truncates a string after a certain number of words.
def _text_words(self, length, truncate): """ Truncates a string after a certain number of words. Newlines in the string will be stripped. """ words = self._wrapped.split() if len(words) > length: words = words[:length] return self.add_truncation_t...
[ "def", "_text_words", "(", "self", ",", "length", ",", "truncate", ")", ":", "words", "=", "self", ".", "_wrapped", ".", "split", "(", ")", "if", "len", "(", "words", ")", ">", "length", ":", "words", "=", "words", "[", ":", "length", "]", "return"...
[ 148, 4 ]
[ 158, 30 ]
python
en
['en', 'error', 'th']
False
Truncator._truncate_html
(self, length, truncate, text, truncate_len, words)
Truncates HTML to a certain number of chars (not counting tags and comments), or, if words is True, then to a certain number of words. Closes opened tags if they were correctly closed in the given HTML. Newlines in the HTML are preserved.
Truncates HTML to a certain number of chars (not counting tags and comments), or, if words is True, then to a certain number of words. Closes opened tags if they were correctly closed in the given HTML.
def _truncate_html(self, length, truncate, text, truncate_len, words): """ Truncates HTML to a certain number of chars (not counting tags and comments), or, if words is True, then to a certain number of words. Closes opened tags if they were correctly closed in the given HTML. N...
[ "def", "_truncate_html", "(", "self", ",", "length", ",", "truncate", ",", "text", ",", "truncate_len", ",", "words", ")", ":", "if", "words", "and", "length", "<=", "0", ":", "return", "''", "html4_singlets", "=", "(", "'br'", ",", "'col'", ",", "'lin...
[ 160, 4 ]
[ 230, 18 ]
python
en
['en', 'error', 'th']
False
Feed.feed_extra_kwargs
(self, obj)
Return an extra keyword arguments dictionary that is used when initializing the feed generator.
Return an extra keyword arguments dictionary that is used when initializing the feed generator.
def feed_extra_kwargs(self, obj): """ Return an extra keyword arguments dictionary that is used when initializing the feed generator. """ return {}
[ "def", "feed_extra_kwargs", "(", "self", ",", "obj", ")", ":", "return", "{", "}" ]
[ 95, 4 ]
[ 100, 17 ]
python
en
['en', 'error', 'th']
False
Feed.item_extra_kwargs
(self, item)
Return an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator.
Return an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator.
def item_extra_kwargs(self, item): """ Return an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator. """ return {}
[ "def", "item_extra_kwargs", "(", "self", ",", "item", ")", ":", "return", "{", "}" ]
[ 102, 4 ]
[ 107, 17 ]
python
en
['en', 'error', 'th']
False
Feed.get_context_data
(self, **kwargs)
Return a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used. Default implementation preserves the old behavior of using {'obj': item, 'site': current_site} as the context.
Return a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used.
def get_context_data(self, **kwargs): """ Return a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used. Default implementation preserves the old behavior of using {'obj': item, 'site': current_site} as the context. ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "{", "'obj'", ":", "kwargs", ".", "get", "(", "'item'", ")", ",", "'site'", ":", "kwargs", ".", "get", "(", "'site'", ")", "}" ]
[ 112, 4 ]
[ 120, 70 ]
python
en
['en', 'error', 'th']
False
Feed.get_feed
(self, obj, request)
Return a feedgenerator.DefaultFeed object, fully populated, for this feed. Raise FeedDoesNotExist for invalid parameters.
Return a feedgenerator.DefaultFeed object, fully populated, for this feed. Raise FeedDoesNotExist for invalid parameters.
def get_feed(self, obj, request): """ Return a feedgenerator.DefaultFeed object, fully populated, for this feed. Raise FeedDoesNotExist for invalid parameters. """ current_site = get_current_site(request) link = self._get_dynamic_attr('link', obj) link = add_doma...
[ "def", "get_feed", "(", "self", ",", "obj", ",", "request", ")", ":", "current_site", "=", "get_current_site", "(", "request", ")", "link", "=", "self", ".", "_get_dynamic_attr", "(", "'link'", ",", "obj", ")", "link", "=", "add_domain", "(", "current_site...
[ 122, 4 ]
[ 218, 19 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.spatial_version
(self)
Determine the version of the PostGIS library.
Determine the version of the PostGIS library.
def spatial_version(self): """Determine the version of the PostGIS library.""" # Trying to get the PostGIS version because the function # signatures will depend on the version used. The cost # here is a database query to determine the version, which # can be mitigated by setting...
[ "def", "spatial_version", "(", "self", ")", ":", "# Trying to get the PostGIS version because the function", "# signatures will depend on the version used. The cost", "# here is a database query to determine the version, which", "# can be mitigated by setting `POSTGIS_VERSION` with a 3-tuple", ...
[ 159, 4 ]
[ 180, 22 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.check_aggregate_support
(self, aggregate)
Checks if the given aggregate name is supported (that is, if it's in `self.valid_aggregates`).
Checks if the given aggregate name is supported (that is, if it's in `self.valid_aggregates`).
def check_aggregate_support(self, aggregate): """ Checks if the given aggregate name is supported (that is, if it's in `self.valid_aggregates`). """ agg_name = aggregate.__class__.__name__ return agg_name in self.valid_aggregates
[ "def", "check_aggregate_support", "(", "self", ",", "aggregate", ")", ":", "agg_name", "=", "aggregate", ".", "__class__", ".", "__name__", "return", "agg_name", "in", "self", ".", "valid_aggregates" ]
[ 182, 4 ]
[ 188, 48 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.convert_extent
(self, box)
Returns a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)".
Returns a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)".
def convert_extent(self, box): """ Returns a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)". """ ll, ur = box[4:-1].split(',') xmin, ymin = map(float, l...
[ "def", "convert_extent", "(", "self", ",", "box", ")", ":", "ll", ",", "ur", "=", "box", "[", "4", ":", "-", "1", "]", ".", "split", "(", "','", ")", "xmin", ",", "ymin", "=", "map", "(", "float", ",", "ll", ".", "split", "(", ")", ")", "xm...
[ 190, 4 ]
[ 199, 39 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.convert_extent3d
(self, box3d)
Returns a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)".
Returns a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)".
def convert_extent3d(self, box3d): """ Returns a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)". """ ll, ur = box3d[6:-1].split(',') xmin, ...
[ "def", "convert_extent3d", "(", "self", ",", "box3d", ")", ":", "ll", ",", "ur", "=", "box3d", "[", "6", ":", "-", "1", "]", ".", "split", "(", "','", ")", "xmin", ",", "ymin", ",", "zmin", "=", "map", "(", "float", ",", "ll", ".", "split", "...
[ 201, 4 ]
[ 210, 51 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.convert_geom
(self, hex, geo_field)
Converts the geometry returned from PostGIS aggretates.
Converts the geometry returned from PostGIS aggretates.
def convert_geom(self, hex, geo_field): """ Converts the geometry returned from PostGIS aggretates. """ if hex: return Geometry(hex) else: return None
[ "def", "convert_geom", "(", "self", ",", "hex", ",", "geo_field", ")", ":", "if", "hex", ":", "return", "Geometry", "(", "hex", ")", "else", ":", "return", "None" ]
[ 212, 4 ]
[ 219, 23 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.geo_db_type
(self, f)
Return the database field type for the given geometry field. Typically this is `None` because geometry columns are added via the `AddGeometryColumn` stored procedure, unless the field has been specified to be of geography type instead.
Return the database field type for the given geometry field. Typically this is `None` because geometry columns are added via the `AddGeometryColumn` stored procedure, unless the field has been specified to be of geography type instead.
def geo_db_type(self, f): """ Return the database field type for the given geometry field. Typically this is `None` because geometry columns are added via the `AddGeometryColumn` stored procedure, unless the field has been specified to be of geography type instead. """ ...
[ "def", "geo_db_type", "(", "self", ",", "f", ")", ":", "if", "f", ".", "geography", ":", "if", "f", ".", "srid", "!=", "4326", ":", "raise", "NotImplementedError", "(", "'PostGIS only supports geography columns with an SRID of 4326.'", ")", "return", "'geography(%...
[ 221, 4 ]
[ 242, 23 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.get_distance
(self, f, dist_val, lookup_type)
Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. This is the most complex implementation of the spatial backends due to what is supported on geodetic geometry columns vs. what's available on projected geometry c...
Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type.
def get_distance(self, f, dist_val, lookup_type): """ Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. This is the most complex implementation of the spatial backends due to what is supported on geodetic geometry...
[ "def", "get_distance", "(", "self", ",", "f", ",", "dist_val", ",", "lookup_type", ")", ":", "# Getting the distance parameter and any options.", "if", "len", "(", "dist_val", ")", "==", "1", ":", "value", ",", "option", "=", "dist_val", "[", "0", "]", ",", ...
[ 244, 4 ]
[ 284, 31 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.get_geom_placeholder
(self, f, value)
Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call.
Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call.
def get_geom_placeholder(self, f, value): """ Provides a proper substitution value for Geometries that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call. """ if value is None or value.srid == f.srid: ...
[ "def", "get_geom_placeholder", "(", "self", ",", "f", ",", "value", ")", ":", "if", "value", "is", "None", "or", "value", ".", "srid", "==", "f", ".", "srid", ":", "placeholder", "=", "'%s'", "else", ":", "# Adding Transform() to the SQL placeholder.", "plac...
[ 286, 4 ]
[ 304, 26 ]
python
en
['en', 'error', 'th']
False
PostGISOperations._get_postgis_func
(self, func)
Helper routine for calling PostGIS functions and returning their result.
Helper routine for calling PostGIS functions and returning their result.
def _get_postgis_func(self, func): """ Helper routine for calling PostGIS functions and returning their result. """ # Close out the connection. See #9437. with self.connection.temporary_connection() as cursor: cursor.execute('SELECT %s()' % func) return c...
[ "def", "_get_postgis_func", "(", "self", ",", "func", ")", ":", "# Close out the connection. See #9437.", "with", "self", ".", "connection", ".", "temporary_connection", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'SELECT %s()'", "%", "func", ...
[ 306, 4 ]
[ 313, 39 ]
python
en
['en', 'error', 'th']
False