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
read_32
(fobj, start_length, size)
Read a 32bit RGB icon resource. Seems to be either uncompressed or an RLE packbits-like scheme.
Read a 32bit RGB icon resource. Seems to be either uncompressed or an RLE packbits-like scheme.
def read_32(fobj, start_length, size): """ Read a 32bit RGB icon resource. Seems to be either uncompressed or an RLE packbits-like scheme. """ (start, length) = start_length fobj.seek(start) pixel_size = (size[0] * size[2], size[1] * size[2]) sizesq = pixel_size[0] * pixel_size[1] i...
[ "def", "read_32", "(", "fobj", ",", "start_length", ",", "size", ")", ":", "(", "start", ",", "length", ")", "=", "start_length", "fobj", ".", "seek", "(", "start", ")", "pixel_size", "=", "(", "size", "[", "0", "]", "*", "size", "[", "2", "]", "...
[ 49, 0 ]
[ 88, 22 ]
python
en
['en', 'error', 'th']
False
_save
(im, fp, filename)
Saves the image as a series of PNG files, that are then converted to a .icns file using the macOS command line utility 'iconutil'. macOS only.
Saves the image as a series of PNG files, that are then converted to a .icns file using the macOS command line utility 'iconutil'.
def _save(im, fp, filename): """ Saves the image as a series of PNG files, that are then converted to a .icns file using the macOS command line utility 'iconutil'. macOS only. """ if hasattr(fp, "flush"): fp.flush() # create the temporary set of pngs with tempfile.Temporary...
[ "def", "_save", "(", "im", ",", "fp", ",", "filename", ")", ":", "if", "hasattr", "(", "fp", ",", "\"flush\"", ")", ":", "fp", ".", "flush", "(", ")", "# create the temporary set of pngs", "with", "tempfile", ".", "TemporaryDirectory", "(", "\".iconset\"", ...
[ 304, 0 ]
[ 357, 34 ]
python
en
['en', 'error', 'th']
False
IcnsFile.__init__
(self, fobj)
fobj is a file-like object as an icns resource
fobj is a file-like object as an icns resource
def __init__(self, fobj): """ fobj is a file-like object as an icns resource """ # signature : (start, length) self.dct = dct = {} self.fobj = fobj sig, filesize = nextheader(fobj) if sig != b"icns": raise SyntaxError("not an icns file") ...
[ "def", "__init__", "(", "self", ",", "fobj", ")", ":", "# signature : (start, length)", "self", ".", "dct", "=", "dct", "=", "{", "}", "self", ".", "fobj", "=", "fobj", "sig", ",", "filesize", "=", "nextheader", "(", "fobj", ")", "if", "sig", "!=", "...
[ 160, 4 ]
[ 179, 26 ]
python
en
['en', 'error', 'th']
False
IcnsFile.dataforsize
(self, size)
Get an icon resource as {channel: array}. Note that the arrays are bottom-up like windows bitmaps and will likely need to be flipped or transposed in some way.
Get an icon resource as {channel: array}. Note that the arrays are bottom-up like windows bitmaps and will likely need to be flipped or transposed in some way.
def dataforsize(self, size): """ Get an icon resource as {channel: array}. Note that the arrays are bottom-up like windows bitmaps and will likely need to be flipped or transposed in some way. """ dct = {} for code, reader in self.SIZES[size]: desc = ...
[ "def", "dataforsize", "(", "self", ",", "size", ")", ":", "dct", "=", "{", "}", "for", "code", ",", "reader", "in", "self", ".", "SIZES", "[", "size", "]", ":", "desc", "=", "self", ".", "dct", ".", "get", "(", "code", ")", "if", "desc", "is", ...
[ 196, 4 ]
[ 207, 18 ]
python
en
['en', 'error', 'th']
False
no_install_setup_requires
()
Temporarily disable installing setup_requires Under PEP 517, the backend reports build dependencies to the frontend, and the frontend is responsible for ensuring they're installed. So setuptools (acting as a backend) should not try to install them.
Temporarily disable installing setup_requires
def no_install_setup_requires(): """Temporarily disable installing setup_requires Under PEP 517, the backend reports build dependencies to the frontend, and the frontend is responsible for ensuring they're installed. So setuptools (acting as a backend) should not try to install them. """ orig =...
[ "def", "no_install_setup_requires", "(", ")", ":", "orig", "=", "setuptools", ".", "_install_setup_requires", "setuptools", ".", "_install_setup_requires", "=", "lambda", "attrs", ":", "None", "try", ":", "yield", "finally", ":", "setuptools", ".", "_install_setup_r...
[ 78, 0 ]
[ 90, 49 ]
python
en
['en', 'en', 'en']
True
Distribution.patch
(cls)
Replace distutils.dist.Distribution with this class for the duration of this context.
Replace distutils.dist.Distribution with this class for the duration of this context.
def patch(cls): """ Replace distutils.dist.Distribution with this class for the duration of this context. """ orig = distutils.core.Distribution distutils.core.Distribution = cls try: yield finally: distutils.core.Distributi...
[ "def", "patch", "(", "cls", ")", ":", "orig", "=", "distutils", ".", "core", ".", "Distribution", "distutils", ".", "core", ".", "Distribution", "=", "cls", "try", ":", "yield", "finally", ":", "distutils", ".", "core", ".", "Distribution", "=", "orig" ]
[ 63, 4 ]
[ 74, 46 ]
python
en
['en', 'error', 'th']
False
MLP.__init__
(self, name, output_dim, hidden_sizes, hidden_nonlinearity, output_nonlinearity, hidden_W_init=L.XavierUniformInitializer(), hidden_b_init=tf.zeros_initializer(), output_W_init=L.XavierUniformInitializer(), output_b_init=tf.zeros_initializer(), input_var=None, input_la...
:param dropout_ph: None if no dropout should be used. Else a scalar placeholder that determines the prob of dropping a node. Remember to set placeholder to Zero during test / eval
:param dropout_ph: None if no dropout should be used. Else a scalar placeholder that determines the prob of dropping a node. Remember to set placeholder to Zero during test / eval
def __init__(self, name, output_dim, hidden_sizes, hidden_nonlinearity, output_nonlinearity, hidden_W_init=L.XavierUniformInitializer(), hidden_b_init=tf.zeros_initializer(), output_W_init=L.XavierUniformInitializer(), output_b_init=tf.zeros_initializer(), input_var=No...
[ "def", "__init__", "(", "self", ",", "name", ",", "output_dim", ",", "hidden_sizes", ",", "hidden_nonlinearity", ",", "output_nonlinearity", ",", "hidden_W_init", "=", "L", ".", "XavierUniformInitializer", "(", ")", ",", "hidden_b_init", "=", "tf", ".", "zeros_i...
[ 14, 4 ]
[ 68, 47 ]
python
en
['en', 'error', 'th']
False
create_main_parser
()
Creates and returns the main parser for pip's CLI
Creates and returns the main parser for pip's CLI
def create_main_parser(): # type: () -> ConfigOptionParser """Creates and returns the main parser for pip's CLI """ parser_kw = { 'usage': '\n%prog <command> [options]', 'add_help_option': False, 'formatter': UpdatingDefaultsHelpFormatter(), 'name': 'global', 'pr...
[ "def", "create_main_parser", "(", ")", ":", "# type: () -> ConfigOptionParser", "parser_kw", "=", "{", "'usage'", ":", "'\\n%prog <command> [options]'", ",", "'add_help_option'", ":", "False", ",", "'formatter'", ":", "UpdatingDefaultsHelpFormatter", "(", ")", ",", "'na...
[ 20, 0 ]
[ 52, 17 ]
python
en
['en', 'en', 'en']
True
api_opbeat_webhook
( request: HttpRequest, user_profile: UserProfile, payload: Dict[str, Any] = REQ(argument_type="body"), )
This uses the subject name from opbeat to make the subject, and the summary from Opbeat as the message body, with details about the object mentioned.
This uses the subject name from opbeat to make the subject, and the summary from Opbeat as the message body, with details about the object mentioned.
def api_opbeat_webhook( request: HttpRequest, user_profile: UserProfile, payload: Dict[str, Any] = REQ(argument_type="body"), ) -> HttpResponse: """ This uses the subject name from opbeat to make the subject, and the summary from Opbeat as the message body, with details about the object ment...
[ "def", "api_opbeat_webhook", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "payload", ":", "Dict", "[", "str", ",", "Any", "]", "=", "REQ", "(", "argument_type", "=", "\"body\"", ")", ",", ")", "->", "HttpResponse", ":",...
[ 100, 0 ]
[ 116, 25 ]
python
en
['en', 'error', 'th']
False
WhereNode.split_having
(self, negated=False)
Returns two possibly None nodes: one for those parts of self that should be included in the WHERE clause and one for those parts of self that must be included in the HAVING clause.
Returns two possibly None nodes: one for those parts of self that should be included in the WHERE clause and one for those parts of self that must be included in the HAVING clause.
def split_having(self, negated=False): """ Returns two possibly None nodes: one for those parts of self that should be included in the WHERE clause and one for those parts of self that must be included in the HAVING clause. """ if not self.contains_aggregate: ...
[ "def", "split_having", "(", "self", ",", "negated", "=", "False", ")", ":", "if", "not", "self", ".", "contains_aggregate", ":", "return", "self", ",", "None", "in_negated", "=", "negated", "^", "self", ".", "negated", "# If the effective connector is OR and thi...
[ 29, 4 ]
[ 60, 38 ]
python
en
['en', 'error', 'th']
False
WhereNode.as_sql
(self, compiler, connection)
Returns the SQL version of the where clause and the value to be substituted in. Returns '', [] if this node matches everything, None, [] if this node is empty, and raises EmptyResultSet if this node can't match anything.
Returns the SQL version of the where clause and the value to be substituted in. Returns '', [] if this node matches everything, None, [] if this node is empty, and raises EmptyResultSet if this node can't match anything.
def as_sql(self, compiler, connection): """ Returns the SQL version of the where clause and the value to be substituted in. Returns '', [] if this node matches everything, None, [] if this node is empty, and raises EmptyResultSet if this node can't match anything. """ ...
[ "def", "as_sql", "(", "self", ",", "compiler", ",", "connection", ")", ":", "result", "=", "[", "]", "result_params", "=", "[", "]", "if", "self", ".", "connector", "==", "AND", ":", "full_needed", ",", "empty_needed", "=", "len", "(", "self", ".", "...
[ 62, 4 ]
[ 112, 40 ]
python
en
['en', 'error', 'th']
False
WhereNode.relabel_aliases
(self, change_map)
Relabels the alias values of any children. 'change_map' is a dictionary mapping old (current) alias values to the new values.
Relabels the alias values of any children. 'change_map' is a dictionary mapping old (current) alias values to the new values.
def relabel_aliases(self, change_map): """ Relabels the alias values of any children. 'change_map' is a dictionary mapping old (current) alias values to the new values. """ for pos, child in enumerate(self.children): if hasattr(child, 'relabel_aliases'): ...
[ "def", "relabel_aliases", "(", "self", ",", "change_map", ")", ":", "for", "pos", ",", "child", "in", "enumerate", "(", "self", ".", "children", ")", ":", "if", "hasattr", "(", "child", ",", "'relabel_aliases'", ")", ":", "# For example another WhereNode", "...
[ 127, 4 ]
[ 137, 70 ]
python
en
['en', 'error', 'th']
False
WhereNode.clone
(self)
Creates a clone of the tree. Must only be called on root nodes (nodes with empty subtree_parents). Childs must be either (Contraint, lookup, value) tuples, or objects supporting .clone().
Creates a clone of the tree. Must only be called on root nodes (nodes with empty subtree_parents). Childs must be either (Contraint, lookup, value) tuples, or objects supporting .clone().
def clone(self): """ Creates a clone of the tree. Must only be called on root nodes (nodes with empty subtree_parents). Childs must be either (Contraint, lookup, value) tuples, or objects supporting .clone(). """ clone = self.__class__._new_instance( children=...
[ "def", "clone", "(", "self", ")", ":", "clone", "=", "self", ".", "__class__", ".", "_new_instance", "(", "children", "=", "[", "]", ",", "connector", "=", "self", ".", "connector", ",", "negated", "=", "self", ".", "negated", ")", "for", "child", "i...
[ 139, 4 ]
[ 152, 20 ]
python
en
['en', 'error', 'th']
False
xframe_options_deny
(view_func)
Modifies a view function so its response has the X-Frame-Options HTTP header set to 'DENY' as long as the response doesn't already have that header set. e.g. @xframe_options_deny def some_view(request): ...
Modifies a view function so its response has the X-Frame-Options HTTP header set to 'DENY' as long as the response doesn't already have that header set.
def xframe_options_deny(view_func): """ Modifies a view function so its response has the X-Frame-Options HTTP header set to 'DENY' as long as the response doesn't already have that header set. e.g. @xframe_options_deny def some_view(request): ... """ def wrapped_view(*args,...
[ "def", "xframe_options_deny", "(", "view_func", ")", ":", "def", "wrapped_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "view_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "resp", ".", "get", "(", "'X-Frame-O...
[ 5, 0 ]
[ 22, 78 ]
python
en
['en', 'error', 'th']
False
xframe_options_sameorigin
(view_func)
Modifies a view function so its response has the X-Frame-Options HTTP header set to 'SAMEORIGIN' as long as the response doesn't already have that header set. e.g. @xframe_options_sameorigin def some_view(request): ...
Modifies a view function so its response has the X-Frame-Options HTTP header set to 'SAMEORIGIN' as long as the response doesn't already have that header set.
def xframe_options_sameorigin(view_func): """ Modifies a view function so its response has the X-Frame-Options HTTP header set to 'SAMEORIGIN' as long as the response doesn't already have that header set. e.g. @xframe_options_sameorigin def some_view(request): ... """ def w...
[ "def", "xframe_options_sameorigin", "(", "view_func", ")", ":", "def", "wrapped_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "view_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "resp", ".", "get", "(", "'X-F...
[ 25, 0 ]
[ 42, 78 ]
python
en
['en', 'error', 'th']
False
xframe_options_exempt
(view_func)
Modifies a view function by setting a response variable that instructs XFrameOptionsMiddleware to NOT set the X-Frame-Options HTTP header. e.g. @xframe_options_exempt def some_view(request): ...
Modifies a view function by setting a response variable that instructs XFrameOptionsMiddleware to NOT set the X-Frame-Options HTTP header.
def xframe_options_exempt(view_func): """ Modifies a view function by setting a response variable that instructs XFrameOptionsMiddleware to NOT set the X-Frame-Options HTTP header. e.g. @xframe_options_exempt def some_view(request): ... """ def wrapped_view(*args, **kwargs): ...
[ "def", "xframe_options_exempt", "(", "view_func", ")", ":", "def", "wrapped_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "view_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", "resp", ".", "xframe_options_exempt", "=", ...
[ 45, 0 ]
[ 60, 78 ]
python
en
['en', 'error', 'th']
False
GDALBand._flush
(self)
Call the flush method on the Band's parent raster and force a refresh of the statistics attribute when requested the next time.
Call the flush method on the Band's parent raster and force a refresh of the statistics attribute when requested the next time.
def _flush(self): """ Call the flush method on the Band's parent raster and force a refresh of the statistics attribute when requested the next time. """ self.source._flush() self._stats_refresh = True
[ "def", "_flush", "(", "self", ")", ":", "self", ".", "source", ".", "_flush", "(", ")", "self", ".", "_stats_refresh", "=", "True" ]
[ 21, 4 ]
[ 27, 34 ]
python
en
['en', 'error', 'th']
False
GDALBand.description
(self)
Returns the description string of the band.
Returns the description string of the band.
def description(self): """ Returns the description string of the band. """ return force_text(capi.get_band_description(self._ptr))
[ "def", "description", "(", "self", ")", ":", "return", "force_text", "(", "capi", ".", "get_band_description", "(", "self", ".", "_ptr", ")", ")" ]
[ 30, 4 ]
[ 34, 63 ]
python
en
['en', 'error', 'th']
False
GDALBand.width
(self)
Width (X axis) in pixels of the band.
Width (X axis) in pixels of the band.
def width(self): """ Width (X axis) in pixels of the band. """ return capi.get_band_xsize(self._ptr)
[ "def", "width", "(", "self", ")", ":", "return", "capi", ".", "get_band_xsize", "(", "self", ".", "_ptr", ")" ]
[ 37, 4 ]
[ 41, 45 ]
python
en
['en', 'error', 'th']
False
GDALBand.height
(self)
Height (Y axis) in pixels of the band.
Height (Y axis) in pixels of the band.
def height(self): """ Height (Y axis) in pixels of the band. """ return capi.get_band_ysize(self._ptr)
[ "def", "height", "(", "self", ")", ":", "return", "capi", ".", "get_band_ysize", "(", "self", ".", "_ptr", ")" ]
[ 44, 4 ]
[ 48, 45 ]
python
en
['en', 'error', 'th']
False
GDALBand.pixel_count
(self)
Returns the total number of pixels in this band.
Returns the total number of pixels in this band.
def pixel_count(self): """ Returns the total number of pixels in this band. """ return self.width * self.height
[ "def", "pixel_count", "(", "self", ")", ":", "return", "self", ".", "width", "*", "self", ".", "height" ]
[ 51, 4 ]
[ 55, 39 ]
python
en
['en', 'error', 'th']
False
GDALBand.statistics
(self, refresh=False, approximate=False)
Compute statistics on the pixel values of this band. The return value is a tuple with the following structure: (minimum, maximum, mean, standard deviation). If approximate=True, the statistics may be computed based on overviews or a subset of image tiles. If refresh=T...
Compute statistics on the pixel values of this band.
def statistics(self, refresh=False, approximate=False): """ Compute statistics on the pixel values of this band. The return value is a tuple with the following structure: (minimum, maximum, mean, standard deviation). If approximate=True, the statistics may be computed based on ...
[ "def", "statistics", "(", "self", ",", "refresh", "=", "False", ",", "approximate", "=", "False", ")", ":", "# Prepare array with arguments for capi function", "smin", ",", "smax", ",", "smean", ",", "sstd", "=", "c_double", "(", ")", ",", "c_double", "(", "...
[ 59, 4 ]
[ 103, 21 ]
python
en
['en', 'error', 'th']
False
GDALBand.min
(self)
Return the minimum pixel value for this band.
Return the minimum pixel value for this band.
def min(self): """ Return the minimum pixel value for this band. """ return self.statistics()[0]
[ "def", "min", "(", "self", ")", ":", "return", "self", ".", "statistics", "(", ")", "[", "0", "]" ]
[ 106, 4 ]
[ 110, 35 ]
python
en
['en', 'error', 'th']
False
GDALBand.max
(self)
Return the maximum pixel value for this band.
Return the maximum pixel value for this band.
def max(self): """ Return the maximum pixel value for this band. """ return self.statistics()[1]
[ "def", "max", "(", "self", ")", ":", "return", "self", ".", "statistics", "(", ")", "[", "1", "]" ]
[ 113, 4 ]
[ 117, 35 ]
python
en
['en', 'error', 'th']
False
GDALBand.mean
(self)
Return the mean of all pixel values of this band.
Return the mean of all pixel values of this band.
def mean(self): """ Return the mean of all pixel values of this band. """ return self.statistics()[2]
[ "def", "mean", "(", "self", ")", ":", "return", "self", ".", "statistics", "(", ")", "[", "2", "]" ]
[ 120, 4 ]
[ 124, 35 ]
python
en
['en', 'error', 'th']
False
GDALBand.std
(self)
Return the standard deviation of all pixel values of this band.
Return the standard deviation of all pixel values of this band.
def std(self): """ Return the standard deviation of all pixel values of this band. """ return self.statistics()[3]
[ "def", "std", "(", "self", ")", ":", "return", "self", ".", "statistics", "(", ")", "[", "3", "]" ]
[ 127, 4 ]
[ 131, 35 ]
python
en
['en', 'error', 'th']
False
GDALBand.nodata_value
(self)
Returns the nodata value for this band, or None if it isn't set.
Returns the nodata value for this band, or None if it isn't set.
def nodata_value(self): """ Returns the nodata value for this band, or None if it isn't set. """ # Get value and nodata exists flag nodata_exists = c_int() value = capi.get_band_nodata_value(self._ptr, nodata_exists) if not nodata_exists: value = None ...
[ "def", "nodata_value", "(", "self", ")", ":", "# Get value and nodata exists flag", "nodata_exists", "=", "c_int", "(", ")", "value", "=", "capi", ".", "get_band_nodata_value", "(", "self", ".", "_ptr", ",", "nodata_exists", ")", "if", "not", "nodata_exists", ":...
[ 134, 4 ]
[ 146, 20 ]
python
en
['en', 'error', 'th']
False
GDALBand.nodata_value
(self, value)
Sets the nodata value for this band.
Sets the nodata value for this band.
def nodata_value(self, value): """ Sets the nodata value for this band. """ if value is None: if not capi.delete_band_nodata_value: raise ValueError('GDAL >= 2.1 required to delete nodata values.') capi.delete_band_nodata_value(self._ptr) e...
[ "def", "nodata_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "if", "not", "capi", ".", "delete_band_nodata_value", ":", "raise", "ValueError", "(", "'GDAL >= 2.1 required to delete nodata values.'", ")", "capi", ".", "delete_band_n...
[ 149, 4 ]
[ 161, 21 ]
python
en
['en', 'error', 'th']
False
GDALBand.datatype
(self, as_string=False)
Returns the GDAL Pixel Datatype for this band.
Returns the GDAL Pixel Datatype for this band.
def datatype(self, as_string=False): """ Returns the GDAL Pixel Datatype for this band. """ dtype = capi.get_band_datatype(self._ptr) if as_string: dtype = GDAL_PIXEL_TYPES[dtype] return dtype
[ "def", "datatype", "(", "self", ",", "as_string", "=", "False", ")", ":", "dtype", "=", "capi", ".", "get_band_datatype", "(", "self", ".", "_ptr", ")", "if", "as_string", ":", "dtype", "=", "GDAL_PIXEL_TYPES", "[", "dtype", "]", "return", "dtype" ]
[ 163, 4 ]
[ 170, 20 ]
python
en
['en', 'error', 'th']
False
GDALBand.data
(self, data=None, offset=None, size=None, shape=None, as_memoryview=False)
Reads or writes pixel values for this band. Blocks of data can be accessed by specifying the width, height and offset of the desired block. The same specification can be used to update parts of a raster by providing an array of values. Allowed input data types are bytes, memory...
Reads or writes pixel values for this band. Blocks of data can be accessed by specifying the width, height and offset of the desired block. The same specification can be used to update parts of a raster by providing an array of values.
def data(self, data=None, offset=None, size=None, shape=None, as_memoryview=False): """ Reads or writes pixel values for this band. Blocks of data can be accessed by specifying the width, height and offset of the desired block. The same specification can be used to update parts o...
[ "def", "data", "(", "self", ",", "data", "=", "None", ",", "offset", "=", "None", ",", "size", "=", "None", ",", "shape", "=", "None", ",", "as_memoryview", "=", "False", ")", ":", "if", "not", "offset", ":", "offset", "=", "(", "0", ",", "0", ...
[ 172, 4 ]
[ 231, 25 ]
python
en
['en', 'error', 'th']
False
set_logging_config
(logging_level='INFO', future=False)
Set the global logger parameters. Logging levels: DEBUG Print detailed information, typically of interest only when diagnosing problems. INFO Print confirmation that things are working as expected, e.g. when each task is run correctly (this is the default). WARNING ...
Set the global logger parameters.
def set_logging_config(logging_level='INFO', future=False): """Set the global logger parameters. Logging levels: DEBUG Print detailed information, typically of interest only when diagnosing problems. INFO Print confirmation that things are working as expected, e.g. when ...
[ "def", "set_logging_config", "(", "logging_level", "=", "'INFO'", ",", "future", "=", "False", ")", ":", "# Add a custom level - just for us", "logging", ".", "addLevelName", "(", "45", ",", "'WORKFLOW'", ")", "def", "workflow", "(", "self", ",", "message", ",",...
[ 309, 0 ]
[ 392, 62 ]
python
en
['en', 'en', 'en']
True
initialize_minimal
(file=None, logging_level='INFO', params=None, future=False)
Same as initialise() but without requiring any download of data. This is useful for "flowline only" OGGM applications Parameters ---------- file : str path to the configuration file (default: OGGM params.cfg) logging_level : str set a logging level. See :func:`set_logging_config` f...
Same as initialise() but without requiring any download of data.
def initialize_minimal(file=None, logging_level='INFO', params=None, future=False): """Same as initialise() but without requiring any download of data. This is useful for "flowline only" OGGM applications Parameters ---------- file : str path to the configuration fil...
[ "def", "initialize_minimal", "(", "file", "=", "None", ",", "logging_level", "=", "'INFO'", ",", "params", "=", "None", ",", "future", "=", "False", ")", ":", "global", "IS_INITIALIZED", "global", "PARAMS", "global", "PATHS", "set_logging_config", "(", "loggin...
[ 395, 0 ]
[ 606, 25 ]
python
en
['en', 'en', 'en']
True
initialize
(file=None, logging_level='INFO', params=None, future=False)
Read the configuration file containing the run's parameters. This should be the first call, before using any of the other OGGM modules for most (all?) OGGM simulations. Parameters ---------- file : str path to the configuration file (default: OGGM params.cfg) logging_level : str ...
Read the configuration file containing the run's parameters.
def initialize(file=None, logging_level='INFO', params=None, future=False): """Read the configuration file containing the run's parameters. This should be the first call, before using any of the other OGGM modules for most (all?) OGGM simulations. Parameters ---------- file : str path ...
[ "def", "initialize", "(", "file", "=", "None", ",", "logging_level", "=", "'INFO'", ",", "params", "=", "None", ",", "future", "=", "False", ")", ":", "global", "PARAMS", "global", "DATA", "initialize_minimal", "(", "file", "=", "file", ",", "logging_level...
[ 609, 0 ]
[ 666, 24 ]
python
en
['en', 'en', 'en']
True
oggm_static_paths
()
Initialise the OGGM paths from the config file.
Initialise the OGGM paths from the config file.
def oggm_static_paths(): """Initialise the OGGM paths from the config file.""" global PATHS, PARAMS # See if the file is there, if not create it if not os.path.exists(CONFIG_FILE): dldir = os.path.join(os.path.expanduser('~'), 'OGGM') config = ConfigObj() config['dl_cache_dir']...
[ "def", "oggm_static_paths", "(", ")", ":", "global", "PATHS", ",", "PARAMS", "# See if the file is there, if not create it", "if", "not", "os", ".", "path", ".", "exists", "(", "CONFIG_FILE", ")", ":", "dldir", "=", "os", ".", "path", ".", "join", "(", "os",...
[ 669, 0 ]
[ 730, 46 ]
python
en
['en', 'en', 'en']
True
get_lru_handler
(tmpdir=None, maxsize=None, ending='.tif')
LRU handler for a given temporary directory (singleton). Parameters ---------- tmpdir : str path to the temporary directory to handle. Default is ``cfg.PATHS['tmp_dir']``. maxsize : int the max number of files to keep in the directory ending : str consider only the f...
LRU handler for a given temporary directory (singleton).
def get_lru_handler(tmpdir=None, maxsize=None, ending='.tif'): """LRU handler for a given temporary directory (singleton). Parameters ---------- tmpdir : str path to the temporary directory to handle. Default is ``cfg.PATHS['tmp_dir']``. maxsize : int the max number of files...
[ "def", "get_lru_handler", "(", "tmpdir", "=", "None", ",", "maxsize", "=", "None", ",", "ending", "=", "'.tif'", ")", ":", "global", "LRUHANDLERS", "# see if we're set up", "if", "tmpdir", "is", "None", ":", "tmpdir", "=", "PATHS", "[", "'tmp_dir'", "]", "...
[ 737, 0 ]
[ 777, 18 ]
python
en
['en', 'en', 'en']
True
set_intersects_db
(path_or_gdf=None)
Set the glacier intersection database for OGGM to use. It is now set automatically by the :func:`oggm.workflow.init_glacier_directories` task, but setting it manually can be useful for a slightly faster run initialization. See :func:`oggm.utils.get_rgi_intersects_region_file` for how to obtain suc...
Set the glacier intersection database for OGGM to use.
def set_intersects_db(path_or_gdf=None): """Set the glacier intersection database for OGGM to use. It is now set automatically by the :func:`oggm.workflow.init_glacier_directories` task, but setting it manually can be useful for a slightly faster run initialization. See :func:`oggm.utils.get_rgi_i...
[ "def", "set_intersects_db", "(", "path_or_gdf", "=", "None", ")", ":", "global", "PARAMS", "PARAMS", ".", "do_log", "=", "False", "if", "PARAMS", "[", "'use_intersects'", "]", "and", "path_or_gdf", "is", "not", "None", ":", "if", "isinstance", "(", "path_or_...
[ 780, 0 ]
[ 806, 24 ]
python
en
['en', 'en', 'en']
True
reset_working_dir
()
Deletes the content of the working directory. Careful: cannot be undone!
Deletes the content of the working directory. Careful: cannot be undone!
def reset_working_dir(): """Deletes the content of the working directory. Careful: cannot be undone! """ if PATHS['working_dir']: if os.path.exists(PATHS['working_dir']): shutil.rmtree(PATHS['working_dir']) os.makedirs(PATHS['working_dir'])
[ "def", "reset_working_dir", "(", ")", ":", "if", "PATHS", "[", "'working_dir'", "]", ":", "if", "os", ".", "path", ".", "exists", "(", "PATHS", "[", "'working_dir'", "]", ")", ":", "shutil", ".", "rmtree", "(", "PATHS", "[", "'working_dir'", "]", ")", ...
[ 809, 0 ]
[ 815, 41 ]
python
en
['en', 'en', 'en']
True
pack_config
()
Pack the entire configuration in one pickleable dict.
Pack the entire configuration in one pickleable dict.
def pack_config(): """Pack the entire configuration in one pickleable dict.""" return { 'IS_INITIALIZED': IS_INITIALIZED, 'PARAMS': PARAMS, 'PATHS': PATHS, 'LRUHANDLERS': LRUHANDLERS, 'DATA': DATA, 'BASENAMES': dict(BASENAMES), 'DL_VERIFIED': DL_VERIFIED,...
[ "def", "pack_config", "(", ")", ":", "return", "{", "'IS_INITIALIZED'", ":", "IS_INITIALIZED", ",", "'PARAMS'", ":", "PARAMS", ",", "'PATHS'", ":", "PATHS", ",", "'LRUHANDLERS'", ":", "LRUHANDLERS", ",", "'DATA'", ":", "DATA", ",", "'BASENAMES'", ":", "dict"...
[ 818, 0 ]
[ 830, 5 ]
python
en
['en', 'en', 'en']
True
unpack_config
(cfg_dict)
Unpack and apply the config packed via pack_config.
Unpack and apply the config packed via pack_config.
def unpack_config(cfg_dict): """Unpack and apply the config packed via pack_config.""" global IS_INITIALIZED, PARAMS, PATHS, BASENAMES, LRUHANDLERS, DATA global DL_VERIFIED, DEM_SOURCE_TABLE IS_INITIALIZED = cfg_dict['IS_INITIALIZED'] PARAMS = cfg_dict['PARAMS'] PATHS = cfg_dict['PATHS'] L...
[ "def", "unpack_config", "(", "cfg_dict", ")", ":", "global", "IS_INITIALIZED", ",", "PARAMS", ",", "PATHS", ",", "BASENAMES", ",", "LRUHANDLERS", ",", "DATA", "global", "DL_VERIFIED", ",", "DEM_SOURCE_TABLE", "IS_INITIALIZED", "=", "cfg_dict", "[", "'IS_INITIALIZE...
[ 833, 0 ]
[ 851, 68 ]
python
en
['en', 'en', 'en']
True
set_manager
(manager)
Sets a multiprocessing manager to use for shared dicts
Sets a multiprocessing manager to use for shared dicts
def set_manager(manager): """Sets a multiprocessing manager to use for shared dicts""" global DL_VERIFIED, DEM_SOURCE_TABLE, DATA if manager: new_dict = manager.dict() new_dict.update(DL_VERIFIED) DL_VERIFIED = new_dict new_dict = manager.dict() new_dict.update(DEM...
[ "def", "set_manager", "(", "manager", ")", ":", "global", "DL_VERIFIED", ",", "DEM_SOURCE_TABLE", ",", "DATA", "if", "manager", ":", "new_dict", "=", "manager", ".", "dict", "(", ")", "new_dict", ".", "update", "(", "DL_VERIFIED", ")", "DL_VERIFIED", "=", ...
[ 854, 0 ]
[ 874, 25 ]
python
en
['en', 'en', 'en']
True
add_to_basenames
(basename, filename, docstr='')
Add an entry to the list of BASENAMES. BASENAMES are access keys to files available at the gdir level. Parameters ---------- basename : str the key (e.g. 'dem', 'model_flowlines') filename : str the associated filename (e.g. 'dem.tif', 'model_flowlines.pkl') docstr : str ...
Add an entry to the list of BASENAMES.
def add_to_basenames(basename, filename, docstr=''): """Add an entry to the list of BASENAMES. BASENAMES are access keys to files available at the gdir level. Parameters ---------- basename : str the key (e.g. 'dem', 'model_flowlines') filename : str the associated filename (e....
[ "def", "add_to_basenames", "(", "basename", ",", "filename", ",", "docstr", "=", "''", ")", ":", "global", "BASENAMES", "if", "'.'", "not", "in", "filename", ":", "raise", "ValueError", "(", "'The filename needs a proper file suffix!'", ")", "BASENAMES", "[", "b...
[ 877, 0 ]
[ 894, 44 ]
python
en
['en', 'en', 'en']
True
DocumentedDict.info_str
(self, key)
Info string for the documentation.
Info string for the documentation.
def info_str(self, key): """Info string for the documentation.""" return ' {}'.format(self[key]) + '\n' + ' ' + self._doc[key]
[ "def", "info_str", "(", "self", ",", "key", ")", ":", "return", "' {}'", ".", "format", "(", "self", "[", "key", "]", ")", "+", "'\\n'", "+", "' '", "+", "self", ".", "_doc", "[", "key", "]" ]
[ 75, 4 ]
[ 77, 78 ]
python
en
['en', 'en', 'en']
True
DocumentedDict.doc_str
(self, key)
Info string for the documentation.
Info string for the documentation.
def doc_str(self, key): """Info string for the documentation.""" return ' {}'.format(self[key]) + '\n' + ' ' + \ self._doc[key]
[ "def", "doc_str", "(", "self", ",", "key", ")", ":", "return", "' {}'", ".", "format", "(", "self", "[", "key", "]", ")", "+", "'\\n'", "+", "' '", "+", "self", ".", "_doc", "[", "key", "]" ]
[ 79, 4 ]
[ 82, 29 ]
python
en
['en', 'en', 'en']
True
TestJinjaEscaping.test_block_render_result_is_safe
(self)
Ensure that any results of template rendering in block.render are marked safe so that they don't get double-escaped when inserted into a parent template (#2541)
Ensure that any results of template rendering in block.render are marked safe so that they don't get double-escaped when inserted into a parent template (#2541)
def test_block_render_result_is_safe(self): """ Ensure that any results of template rendering in block.render are marked safe so that they don't get double-escaped when inserted into a parent template (#2541) """ stream_block = blocks.StreamBlock([ ('paragraph', block...
[ "def", "test_block_render_result_is_safe", "(", "self", ")", ":", "stream_block", "=", "blocks", ".", "StreamBlock", "(", "[", "(", "'paragraph'", ",", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/jinja2/paragraph.html'", ")", ")", "]", ")", "stream...
[ 63, 4 ]
[ 80, 51 ]
python
en
['en', 'error', 'th']
False
TestJinjaEscaping.test_rich_text_is_safe
(self)
Ensure that RichText values are marked safe so that they don't get double-escaped when inserted into a parent template (#2542)
Ensure that RichText values are marked safe so that they don't get double-escaped when inserted into a parent template (#2542)
def test_rich_text_is_safe(self): """ Ensure that RichText values are marked safe so that they don't get double-escaped when inserted into a parent template (#2542) """ stream_block = blocks.StreamBlock([ ('paragraph', blocks.RichTextBlock(template='tests/jinja2/rich_...
[ "def", "test_rich_text_is_safe", "(", "self", ")", ":", "stream_block", "=", "blocks", ".", "StreamBlock", "(", "[", "(", "'paragraph'", ",", "blocks", ".", "RichTextBlock", "(", "template", "=", "'tests/jinja2/rich_text.html'", ")", ")", "]", ")", "stream_value...
[ 82, 4 ]
[ 98, 89 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_tag_with_boundblock
(self)
The include_block tag should be able to render a BoundBlock's template while keeping the parent template's context
The include_block tag should be able to render a BoundBlock's template while keeping the parent template's context
def test_include_block_tag_with_boundblock(self): """ The include_block tag should be able to render a BoundBlock's template while keeping the parent template's context """ block = blocks.CharBlock(template='tests/jinja2/heading_block.html') bound_block = block.bind('bonj...
[ "def", "test_include_block_tag_with_boundblock", "(", "self", ")", ":", "block", "=", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/jinja2/heading_block.html'", ")", "bound_block", "=", "block", ".", "bind", "(", "'bonjour'", ")", "result", "=", "rende...
[ 102, 4 ]
[ 114, 72 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_tag_with_structvalue
(self)
The include_block tag should be able to render a StructValue's template while keeping the parent template's context
The include_block tag should be able to render a StructValue's template while keeping the parent template's context
def test_include_block_tag_with_structvalue(self): """ The include_block tag should be able to render a StructValue's template while keeping the parent template's context """ block = SectionBlock() struct_value = block.to_python({'title': 'Bonjour', 'body': 'monde <i>ital...
[ "def", "test_include_block_tag_with_structvalue", "(", "self", ")", ":", "block", "=", "SectionBlock", "(", ")", "struct_value", "=", "block", ".", "to_python", "(", "{", "'title'", ":", "'Bonjour'", ",", "'body'", ":", "'monde <i>italique</i>'", "}", ")", "resu...
[ 116, 4 ]
[ 132, 9 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_tag_with_streamvalue
(self)
The include_block tag should be able to render a StreamValue's template while keeping the parent template's context
The include_block tag should be able to render a StreamValue's template while keeping the parent template's context
def test_include_block_tag_with_streamvalue(self): """ The include_block tag should be able to render a StreamValue's template while keeping the parent template's context """ block = blocks.StreamBlock([ ('heading', blocks.CharBlock(template='tests/jinja2/heading_bloc...
[ "def", "test_include_block_tag_with_streamvalue", "(", "self", ")", ":", "block", "=", "blocks", ".", "StreamBlock", "(", "[", "(", "'heading'", ",", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/jinja2/heading_block.html'", ")", ")", ",", "(", "'par...
[ 134, 4 ]
[ 153, 96 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_tag_with_plain_value
(self)
The include_block tag should be able to render a value without a render_as_block method by just rendering it as a string
The include_block tag should be able to render a value without a render_as_block method by just rendering it as a string
def test_include_block_tag_with_plain_value(self): """ The include_block tag should be able to render a value without a render_as_block method by just rendering it as a string """ result = render_to_string('tests/jinja2/include_block_test.html', { 'test_block': 42, ...
[ "def", "test_include_block_tag_with_plain_value", "(", "self", ")", ":", "result", "=", "render_to_string", "(", "'tests/jinja2/include_block_test.html'", ",", "{", "'test_block'", ":", "42", ",", "}", ")", "self", ".", "assertIn", "(", "'<body>42</body>'", ",", "re...
[ 155, 4 ]
[ 164, 48 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_tag_with_filtered_value
(self)
The block parameter on include_block tag should support complex values including filters, e.g. {% include_block foo|default:123 %}
The block parameter on include_block tag should support complex values including filters, e.g. {% include_block foo|default:123 %}
def test_include_block_tag_with_filtered_value(self): """ The block parameter on include_block tag should support complex values including filters, e.g. {% include_block foo|default:123 %} """ block = blocks.CharBlock(template='tests/jinja2/heading_block.html') bound_bloc...
[ "def", "test_include_block_tag_with_filtered_value", "(", "self", ")", ":", "block", "=", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/jinja2/heading_block.html'", ")", "bound_block", "=", "block", ".", "bind", "(", "'bonjour'", ")", "result", "=", "r...
[ 166, 4 ]
[ 184, 49 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_tag_with_additional_variable
(self)
The include_block tag should be able to pass local variables from parent context to the child context
The include_block tag should be able to pass local variables from parent context to the child context
def test_include_block_tag_with_additional_variable(self): """ The include_block tag should be able to pass local variables from parent context to the child context """ block = blocks.CharBlock(template='tests/blocks/heading_block.html') bound_block = block.bind('bonjour'...
[ "def", "test_include_block_tag_with_additional_variable", "(", "self", ")", ":", "block", "=", "blocks", ".", "CharBlock", "(", "template", "=", "'tests/blocks/heading_block.html'", ")", "bound_block", "=", "block", ".", "bind", "(", "'bonjour'", ")", "result", "=",...
[ 186, 4 ]
[ 197, 80 ]
python
en
['en', 'error', 'th']
False
TestIncludeBlockTag.test_include_block_html_escaping
(self)
Output of include_block should be escaped as per Django autoescaping rules
Output of include_block should be escaped as per Django autoescaping rules
def test_include_block_html_escaping(self): """ Output of include_block should be escaped as per Django autoescaping rules """ block = blocks.CharBlock() bound_block = block.bind(block.to_python('some <em>evil</em> HTML')) result = render_to_string('tests/jinja2/include_...
[ "def", "test_include_block_html_escaping", "(", "self", ")", ":", "block", "=", "blocks", ".", "CharBlock", "(", ")", "bound_block", "=", "block", ".", "bind", "(", "block", ".", "to_python", "(", "'some <em>evil</em> HTML'", ")", ")", "result", "=", "render_t...
[ 199, 4 ]
[ 245, 69 ]
python
en
['en', 'error', 'th']
False
build_ext.check_extensions_list
(self, extensions)
Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here. ...
Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here.
def check_extensions_list(self, extensions): """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which ...
[ "def", "check_extensions_list", "(", "self", ",", "extensions", ")", ":", "if", "not", "isinstance", "(", "extensions", ",", "list", ")", ":", "raise", "DistutilsSetupError", "(", "\"'ext_modules' option must be a list of Extension instances\"", ")", "for", "i", ",", ...
[ 342, 4 ]
[ 418, 31 ]
python
en
['en', 'en', 'en']
True
build_ext.swig_sources
(self, sources, extension)
Walk the list of source files in 'sources', looking for SWIG interface (.i) files. Run SWIG on all that are found, and return a modified 'sources' list with SWIG source files replaced by the generated C (or C++) files.
Walk the list of source files in 'sources', looking for SWIG interface (.i) files. Run SWIG on all that are found, and return a modified 'sources' list with SWIG source files replaced by the generated C (or C++) files.
def swig_sources(self, sources, extension): """Walk the list of source files in 'sources', looking for SWIG interface (.i) files. Run SWIG on all that are found, and return a modified 'sources' list with SWIG source files replaced by the generated C (or C++) files. """ n...
[ "def", "swig_sources", "(", "self", ",", "sources", ",", "extension", ")", ":", "new_sources", "=", "[", "]", "swig_sources", "=", "[", "]", "swig_targets", "=", "{", "}", "# XXX this drops generated C/C++ files into the source tree, which", "# is fine for developers wh...
[ 562, 4 ]
[ 614, 26 ]
python
en
['en', 'en', 'en']
True
build_ext.find_swig
(self)
Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows.
Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows.
def find_swig(self): """Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. """ if os.name == "posix": return "swig" elif os.name == "nt": # Look for SWIG in its standar...
[ "def", "find_swig", "(", "self", ")", ":", "if", "os", ".", "name", "==", "\"posix\"", ":", "return", "\"swig\"", "elif", "os", ".", "name", "==", "\"nt\"", ":", "# Look for SWIG in its standard installation directory on", "# Windows (or so I presume!). If we find it t...
[ 616, 4 ]
[ 636, 47 ]
python
en
['en', 'en', 'en']
True
build_ext.get_ext_fullpath
(self, ext_name)
Returns the path of the filename for a given extension. The file is located in `build_lib` or directly in the package (inplace option).
Returns the path of the filename for a given extension.
def get_ext_fullpath(self, ext_name): """Returns the path of the filename for a given extension. The file is located in `build_lib` or directly in the package (inplace option). """ fullname = self.get_ext_fullname(ext_name) modpath = fullname.split('.') filename ...
[ "def", "get_ext_fullpath", "(", "self", ",", "ext_name", ")", ":", "fullname", "=", "self", ".", "get_ext_fullname", "(", "ext_name", ")", "modpath", "=", "fullname", ".", "split", "(", "'.'", ")", "filename", "=", "self", ".", "get_ext_filename", "(", "mo...
[ 640, 4 ]
[ 665, 50 ]
python
en
['en', 'en', 'en']
True
build_ext.get_ext_fullname
(self, ext_name)
Returns the fullname of a given extension name. Adds the `package.` prefix
Returns the fullname of a given extension name.
def get_ext_fullname(self, ext_name): """Returns the fullname of a given extension name. Adds the `package.` prefix""" if self.package is None: return ext_name else: return self.package + '.' + ext_name
[ "def", "get_ext_fullname", "(", "self", ",", "ext_name", ")", ":", "if", "self", ".", "package", "is", "None", ":", "return", "ext_name", "else", ":", "return", "self", ".", "package", "+", "'.'", "+", "ext_name" ]
[ 667, 4 ]
[ 674, 48 ]
python
en
['en', 'en', 'en']
True
build_ext.get_ext_filename
(self, ext_name)
r"""Convert the name of an extension (eg. "foo.bar") into the name of the file from which it will be loaded (eg. "foo/bar.so", or "foo\bar.pyd").
r"""Convert the name of an extension (eg. "foo.bar") into the name of the file from which it will be loaded (eg. "foo/bar.so", or "foo\bar.pyd").
def get_ext_filename(self, ext_name): r"""Convert the name of an extension (eg. "foo.bar") into the name of the file from which it will be loaded (eg. "foo/bar.so", or "foo\bar.pyd"). """ from distutils.sysconfig import get_config_var ext_path = ext_name.split('.') ...
[ "def", "get_ext_filename", "(", "self", ",", "ext_name", ")", ":", "from", "distutils", ".", "sysconfig", "import", "get_config_var", "ext_path", "=", "ext_name", ".", "split", "(", "'.'", ")", "ext_suffix", "=", "get_config_var", "(", "'EXT_SUFFIX'", ")", "re...
[ 676, 4 ]
[ 684, 51 ]
python
en
['en', 'en', 'en']
True
build_ext.get_export_symbols
(self, ext)
Return the list of symbols that a shared extension has to export. This either uses 'ext.export_symbols' or, if it's not provided, "PyInit_" + module_name. Only relevant on Windows, where the .pyd file (DLL) must export the module "PyInit_" function.
Return the list of symbols that a shared extension has to export. This either uses 'ext.export_symbols' or, if it's not provided, "PyInit_" + module_name. Only relevant on Windows, where the .pyd file (DLL) must export the module "PyInit_" function.
def get_export_symbols(self, ext): """Return the list of symbols that a shared extension has to export. This either uses 'ext.export_symbols' or, if it's not provided, "PyInit_" + module_name. Only relevant on Windows, where the .pyd file (DLL) must export the module "PyInit_" function...
[ "def", "get_export_symbols", "(", "self", ",", "ext", ")", ":", "suffix", "=", "'_'", "+", "ext", ".", "name", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "try", ":", "# Unicode module name support as defined in PEP-489", "# https://www.python.org/dev/pep...
[ 686, 4 ]
[ 703, 33 ]
python
en
['en', 'en', 'en']
True
build_ext.get_libraries
(self, ext)
Return the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll).
Return the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll).
def get_libraries(self, ext): """Return the list of libraries to link against when building a shared extension. On most platforms, this is just 'ext.libraries'; on Windows, we add the Python library (eg. python20.dll). """ # The python library is always needed on Windows. For M...
[ "def", "get_libraries", "(", "self", ",", "ext", ")", ":", "# The python library is always needed on Windows. For MSVC, this", "# is redundant, since the library is mentioned in a pragma in", "# pyconfig.h that MSVC groks. The other Windows compilers all seem", "# to need it mentioned explic...
[ 705, 4 ]
[ 754, 53 ]
python
en
['en', 'en', 'en']
True
MigrationLoader.migrations_module
(cls, app_label)
Return the path to the migrations module for the specified app_label and a boolean indicating if the module is specified in settings.MIGRATION_MODULE.
Return the path to the migrations module for the specified app_label and a boolean indicating if the module is specified in settings.MIGRATION_MODULE.
def migrations_module(cls, app_label): """ Return the path to the migrations module for the specified app_label and a boolean indicating if the module is specified in settings.MIGRATION_MODULE. """ if app_label in settings.MIGRATION_MODULES: return settings.MI...
[ "def", "migrations_module", "(", "cls", ",", "app_label", ")", ":", "if", "app_label", "in", "settings", ".", "MIGRATION_MODULES", ":", "return", "settings", ".", "MIGRATION_MODULES", "[", "app_label", "]", ",", "True", "else", ":", "app_package_name", "=", "a...
[ 54, 4 ]
[ 64, 78 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.load_disk
(self)
Loads the migrations from all INSTALLED_APPS from disk.
Loads the migrations from all INSTALLED_APPS from disk.
def load_disk(self): """ Loads the migrations from all INSTALLED_APPS from disk. """ self.disk_migrations = {} self.unmigrated_apps = set() self.migrated_apps = set() for app_config in apps.get_app_configs(): # Get the migrations module directory ...
[ "def", "load_disk", "(", "self", ")", ":", "self", ".", "disk_migrations", "=", "{", "}", "self", ".", "unmigrated_apps", "=", "set", "(", ")", "self", ".", "migrated_apps", "=", "set", "(", ")", "for", "app_config", "in", "apps", ".", "get_app_configs",...
[ 66, 4 ]
[ 121, 17 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.get_migration
(self, app_label, name_prefix)
Gets the migration exactly named, or raises `graph.NodeNotFoundError`
Gets the migration exactly named, or raises `graph.NodeNotFoundError`
def get_migration(self, app_label, name_prefix): "Gets the migration exactly named, or raises `graph.NodeNotFoundError`" return self.graph.nodes[app_label, name_prefix]
[ "def", "get_migration", "(", "self", ",", "app_label", ",", "name_prefix", ")", ":", "return", "self", ".", "graph", ".", "nodes", "[", "app_label", ",", "name_prefix", "]" ]
[ 123, 4 ]
[ 125, 55 ]
python
en
['en', 'en', 'en']
True
MigrationLoader.get_migration_by_prefix
(self, app_label, name_prefix)
Returns the migration(s) which match the given app label and name _prefix_
Returns the migration(s) which match the given app label and name _prefix_
def get_migration_by_prefix(self, app_label, name_prefix): "Returns the migration(s) which match the given app label and name _prefix_" # Do the search results = [] for migration_app_label, migration_name in self.disk_migrations: if migration_app_label == app_label and migrat...
[ "def", "get_migration_by_prefix", "(", "self", ",", "app_label", ",", "name_prefix", ")", ":", "# Do the search", "results", "=", "[", "]", "for", "migration_app_label", ",", "migration_name", "in", "self", ".", "disk_migrations", ":", "if", "migration_app_label", ...
[ 127, 4 ]
[ 141, 51 ]
python
en
['en', 'en', 'en']
True
MigrationLoader.add_internal_dependencies
(self, key, migration)
Internal dependencies need to be added first to ensure `__first__` dependencies find the correct root node.
Internal dependencies need to be added first to ensure `__first__` dependencies find the correct root node.
def add_internal_dependencies(self, key, migration): """ Internal dependencies need to be added first to ensure `__first__` dependencies find the correct root node. """ for parent in migration.dependencies: if parent[0] != key[0] or parent[1] == '__first__': ...
[ "def", "add_internal_dependencies", "(", "self", ",", "key", ",", "migration", ")", ":", "for", "parent", "in", "migration", ".", "dependencies", ":", "if", "parent", "[", "0", "]", "!=", "key", "[", "0", "]", "or", "parent", "[", "1", "]", "==", "'_...
[ 171, 4 ]
[ 180, 83 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.build_graph
(self)
Builds a migration dependency graph using both the disk and database. You'll need to rebuild the graph if you apply migrations. This isn't usually a problem as generally migration stuff runs in a one-shot process.
Builds a migration dependency graph using both the disk and database. You'll need to rebuild the graph if you apply migrations. This isn't usually a problem as generally migration stuff runs in a one-shot process.
def build_graph(self): """ Builds a migration dependency graph using both the disk and database. You'll need to rebuild the graph if you apply migrations. This isn't usually a problem as generally migration stuff runs in a one-shot process. """ # Load disk data se...
[ "def", "build_graph", "(", "self", ")", ":", "# Load disk data", "self", ".", "load_disk", "(", ")", "# Load database data", "if", "self", ".", "connection", "is", "None", ":", "self", ".", "applied_migrations", "=", "set", "(", ")", "else", ":", "recorder",...
[ 195, 4 ]
[ 273, 21 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.check_consistent_history
(self, connection)
Raise InconsistentMigrationHistory if any applied migrations have unapplied dependencies.
Raise InconsistentMigrationHistory if any applied migrations have unapplied dependencies.
def check_consistent_history(self, connection): """ Raise InconsistentMigrationHistory if any applied migrations have unapplied dependencies. """ recorder = MigrationRecorder(connection) applied = recorder.applied_migrations() for migration in applied: ...
[ "def", "check_consistent_history", "(", "self", ",", "connection", ")", ":", "recorder", "=", "MigrationRecorder", "(", "connection", ")", "applied", "=", "recorder", ".", "applied_migrations", "(", ")", "for", "migration", "in", "applied", ":", "# If the migratio...
[ 275, 4 ]
[ 299, 21 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.detect_conflicts
(self)
Looks through the loaded graph and detects any conflicts - apps with more than one leaf migration. Returns a dict of the app labels that conflict with the migration names that conflict.
Looks through the loaded graph and detects any conflicts - apps with more than one leaf migration. Returns a dict of the app labels that conflict with the migration names that conflict.
def detect_conflicts(self): """ Looks through the loaded graph and detects any conflicts - apps with more than one leaf migration. Returns a dict of the app labels that conflict with the migration names that conflict. """ seen_apps = {} conflicting_apps = set() ...
[ "def", "detect_conflicts", "(", "self", ")", ":", "seen_apps", "=", "{", "}", "conflicting_apps", "=", "set", "(", ")", "for", "app_label", ",", "migration_name", "in", "self", ".", "graph", ".", "leaf_nodes", "(", ")", ":", "if", "app_label", "in", "see...
[ 301, 4 ]
[ 313, 82 ]
python
en
['en', 'error', 'th']
False
MigrationLoader.project_state
(self, nodes=None, at_end=True)
Returns a ProjectState object representing the most recent state that the migrations we loaded represent. See graph.make_state for the meaning of "nodes" and "at_end"
Returns a ProjectState object representing the most recent state that the migrations we loaded represent.
def project_state(self, nodes=None, at_end=True): """ Returns a ProjectState object representing the most recent state that the migrations we loaded represent. See graph.make_state for the meaning of "nodes" and "at_end" """ return self.graph.make_state(nodes=nodes, at_e...
[ "def", "project_state", "(", "self", ",", "nodes", "=", "None", ",", "at_end", "=", "True", ")", ":", "return", "self", ".", "graph", ".", "make_state", "(", "nodes", "=", "nodes", ",", "at_end", "=", "at_end", ",", "real_apps", "=", "list", "(", "se...
[ 315, 4 ]
[ 322, 102 ]
python
en
['en', 'error', 'th']
False
import_finder_class
(dotted_path)
Imports a finder class from a dotted path. If the dotted path points to a module, that module is imported and its "embed_finder_class" class returned. If not, this will assume the dotted path points to directly a class and will attempt to import that instead.
Imports a finder class from a dotted path. If the dotted path points to a module, that module is imported and its "embed_finder_class" class returned.
def import_finder_class(dotted_path): """ Imports a finder class from a dotted path. If the dotted path points to a module, that module is imported and its "embed_finder_class" class returned. If not, this will assume the dotted path points to directly a class and will attempt to import that instea...
[ "def", "import_finder_class", "(", "dotted_path", ")", ":", "try", ":", "finder_module", "=", "import_module", "(", "dotted_path", ")", "return", "finder_module", ".", "embed_finder_class", "except", "ImportError", "as", "e", ":", "try", ":", "return", "import_str...
[ 6, 0 ]
[ 21, 36 ]
python
en
['en', 'error', 'th']
False
IFDRational.__init__
(self, value, denominator=1)
:param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator
:param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator
def __init__(self, value, denominator=1): """ :param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator """ if isinstance(value, IFDRational): self._numerator = value.numerator ...
[ "def", "__init__", "(", "self", ",", "value", ",", "denominator", "=", "1", ")", ":", "if", "isinstance", "(", "value", ",", "IFDRational", ")", ":", "self", ".", "_numerator", "=", "value", ".", "numerator", "self", ".", "_denominator", "=", "value", ...
[ 301, 4 ]
[ 325, 52 ]
python
en
['en', 'error', 'th']
False
IFDRational.limit_rational
(self, max_denominator)
:param max_denominator: Integer, the maximum denominator value :returns: Tuple of (numerator, denominator)
def limit_rational(self, max_denominator): """ :param max_denominator: Integer, the maximum denominator value :returns: Tuple of (numerator, denominator) """ if self.denominator == 0: return (self.numerator, self.denominator) f = self._val.limit_denominator...
[ "def", "limit_rational", "(", "self", ",", "max_denominator", ")", ":", "if", "self", ".", "denominator", "==", "0", ":", "return", "(", "self", ".", "numerator", ",", "self", ".", "denominator", ")", "f", "=", "self", ".", "_val", ".", "limit_denominato...
[ 335, 4 ]
[ 346, 43 ]
python
en
['en', 'error', 'th']
False
ImageFileDirectory_v2.__init__
(self, ifh=b"II\052\0\0\0\0\0", prefix=None)
Initialize an ImageFileDirectory. To construct an ImageFileDirectory from a real file, pass the 8-byte magic header to the constructor. To only set the endianness, pass it as the 'prefix' keyword argument. :param ifh: One of the accepted magic headers (cf. PREFIXES); also sets ...
Initialize an ImageFileDirectory.
def __init__(self, ifh=b"II\052\0\0\0\0\0", prefix=None): """Initialize an ImageFileDirectory. To construct an ImageFileDirectory from a real file, pass the 8-byte magic header to the constructor. To only set the endianness, pass it as the 'prefix' keyword argument. :param ifh...
[ "def", "__init__", "(", "self", ",", "ifh", "=", "b\"II\\052\\0\\0\\0\\0\\0\"", ",", "prefix", "=", "None", ")", ":", "if", "ifh", "[", ":", "4", "]", "not", "in", "PREFIXES", ":", "raise", "SyntaxError", "(", "f\"not a TIFF file (header {repr(ifh)} not valid)\"...
[ 456, 4 ]
[ 480, 32 ]
python
en
['en', 'en', 'en']
True
ImageFileDirectory_v2.named
(self)
:returns: dict of name|key: value Returns the complete tag dictionary, with named tags where possible.
:returns: dict of name|key: value
def named(self): """ :returns: dict of name|key: value Returns the complete tag dictionary, with named tags where possible. """ return {TiffTags.lookup(code).name: value for code, value in self.items()}
[ "def", "named", "(", "self", ")", ":", "return", "{", "TiffTags", ".", "lookup", "(", "code", ")", ".", "name", ":", "value", "for", "code", ",", "value", "in", "self", ".", "items", "(", ")", "}" ]
[ 501, 4 ]
[ 507, 82 ]
python
en
['en', 'error', 'th']
False
ImageFileDirectory_v1.from_v2
(cls, original)
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1`
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance.
def from_v2(cls, original): """Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFi...
[ "def", "from_v2", "(", "cls", ",", "original", ")", ":", "ifd", "=", "cls", "(", "prefix", "=", "original", ".", "prefix", ")", "ifd", ".", "_tagdata", "=", "original", ".", "_tagdata", "ifd", ".", "tagtype", "=", "original", ".", "tagtype", "ifd", "...
[ 922, 4 ]
[ 937, 18 ]
python
en
['en', 'lb', 'en']
False
ImageFileDirectory_v1.to_v2
(self)
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2`
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance.
def to_v2(self): """Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory...
[ "def", "to_v2", "(", "self", ")", ":", "ifd", "=", "ImageFileDirectory_v2", "(", "prefix", "=", "self", ".", "prefix", ")", "ifd", ".", "_tagdata", "=", "dict", "(", "self", ".", "_tagdata", ")", "ifd", ".", "tagtype", "=", "dict", "(", "self", ".", ...
[ 939, 4 ]
[ 954, 18 ]
python
en
['en', 'lb', 'en']
False
TiffImageFile.__init__
(self, fp=None, filename=None)
Image file directory (tag dictionary)
Image file directory (tag dictionary)
def __init__(self, fp=None, filename=None): self.tag_v2 = None """ Image file directory (tag dictionary) """ self.tag = None """ Legacy tag entries """ super().__init__(fp, filename)
[ "def", "__init__", "(", "self", ",", "fp", "=", "None", ",", "filename", "=", "None", ")", ":", "self", ".", "tag_v2", "=", "None", "self", ".", "tag", "=", "None", "\"\"\" Legacy tag entries \"\"\"", "super", "(", ")", ".", "__init__", "(", "fp", ",",...
[ 996, 4 ]
[ 1003, 38 ]
python
it
['it', 'en', 'it']
True
TiffImageFile._open
(self)
Open the first image in a TIFF file
Open the first image in a TIFF file
def _open(self): """Open the first image in a TIFF file""" # Header ifh = self.fp.read(8) self.tag_v2 = ImageFileDirectory_v2(ifh) # legacy IFD entries will be filled in later self.ifd = None # setup frame pointers self.__first = self.__next = self.tag...
[ "def", "_open", "(", "self", ")", ":", "# Header", "ifh", "=", "self", ".", "fp", ".", "read", "(", "8", ")", "self", ".", "tag_v2", "=", "ImageFileDirectory_v2", "(", "ifh", ")", "# legacy IFD entries will be filled in later", "self", ".", "ifd", "=", "No...
[ 1005, 4 ]
[ 1028, 21 ]
python
en
['en', 'en', 'en']
True
TiffImageFile.seek
(self, frame)
Select a given frame as current image
Select a given frame as current image
def seek(self, frame): """Select a given frame as current image""" if not self._seek_check(frame): return self._seek(frame) # Create a new core image object on second and # subsequent frames in the image. Image may be # different size/mode. Image._deco...
[ "def", "seek", "(", "self", ",", "frame", ")", ":", "if", "not", "self", ".", "_seek_check", "(", "frame", ")", ":", "return", "self", ".", "_seek", "(", "frame", ")", "# Create a new core image object on second and", "# subsequent frames in the image. Image may be"...
[ 1040, 4 ]
[ 1049, 54 ]
python
en
['en', 'en', 'en']
True
TiffImageFile.tell
(self)
Return the current frame number
Return the current frame number
def tell(self): """Return the current frame number""" return self.__frame
[ "def", "tell", "(", "self", ")", ":", "return", "self", ".", "__frame" ]
[ 1080, 4 ]
[ 1082, 27 ]
python
en
['en', 'da', 'en']
True
TiffImageFile._load_libtiff
(self)
Overload method triggered when we detect a compressed tiff Calls out to libtiff
Overload method triggered when we detect a compressed tiff Calls out to libtiff
def _load_libtiff(self): """Overload method triggered when we detect a compressed tiff Calls out to libtiff""" Image.Image.load(self) self.load_prepare() if not len(self.tile) == 1: raise OSError("Not exactly one tile") # (self._compression, (extents tuple...
[ "def", "_load_libtiff", "(", "self", ")", ":", "Image", ".", "Image", ".", "load", "(", "self", ")", "self", ".", "load_prepare", "(", ")", "if", "not", "len", "(", "self", ".", "tile", ")", "==", "1", ":", "raise", "OSError", "(", "\"Not exactly one...
[ 1109, 4 ]
[ 1192, 37 ]
python
en
['en', 'en', 'en']
True
TiffImageFile._setup
(self)
Setup this image object based on current tags
Setup this image object based on current tags
def _setup(self): """Setup this image object based on current tags""" if 0xBC01 in self.tag_v2: raise OSError("Windows Media Photo files not yet supported") # extract relevant tags self._compression = COMPRESSION_INFO[self.tag_v2.get(COMPRESSION, 1)] self._planar_co...
[ "def", "_setup", "(", "self", ")", ":", "if", "0xBC01", "in", "self", ".", "tag_v2", ":", "raise", "OSError", "(", "\"Windows Media Photo files not yet supported\"", ")", "# extract relevant tags", "self", ".", "_compression", "=", "COMPRESSION_INFO", "[", "self", ...
[ 1194, 4 ]
[ 1384, 56 ]
python
en
['en', 'en', 'en']
True
set_cores
(cores=0)
set the number of cores to use. 0 = autodetect
set the number of cores to use. 0 = autodetect
def set_cores(cores=0): """ set the number of cores to use. 0 = autodetect """ global pool if not cores: cores = cpu_count() pool = Pool(cores)
[ "def", "set_cores", "(", "cores", "=", "0", ")", ":", "global", "pool", "if", "not", "cores", ":", "cores", "=", "cpu_count", "(", ")", "pool", "=", "Pool", "(", "cores", ")" ]
[ 28, 0 ]
[ 35, 22 ]
python
en
['en', 'error', 'th']
False
setup_bd
(client, conn_mgr)
Instantiates port_vlan_mapping table entry setting bd == 0 for untagged packets on ifindex 1.
Instantiates port_vlan_mapping table entry setting bd == 0 for untagged packets on ifindex 1.
def setup_bd(client, conn_mgr): """ Instantiates port_vlan_mapping table entry setting bd == 0 for untagged packets on ifindex 1. """ sess_hdl = conn_mgr.client_init(16) dev_tgt = DevTarget_t(0, hex_to_i16(0xffff)) ifindices = [1, 2] for ifindex in ifindices: action_spec = dc_se...
[ "def", "setup_bd", "(", "client", ",", "conn_mgr", ")", ":", "sess_hdl", "=", "conn_mgr", ".", "client_init", "(", "16", ")", "dev_tgt", "=", "DevTarget_t", "(", "0", ",", "hex_to_i16", "(", "0xffff", ")", ")", "ifindices", "=", "[", "1", ",", "2", "...
[ 66, 0 ]
[ 109, 52 ]
python
en
['en', 'error', 'th']
False
OpenflowEnabledP4Switch.start
( self, controllers )
Start up a new P4 switch
Start up a new P4 switch
def start( self, controllers ): "Start up a new P4 switch" print "Starting P4 switch", self.name args = [self.sw_path] args.extend(['--of-ip', parser_args.controller_ip]) args.extend(['--no-veth']) args.extend(['-t']) for intf in self.intfs.values(): i...
[ "def", "start", "(", "self", ",", "controllers", ")", ":", "print", "\"Starting P4 switch\"", ",", "self", ".", "name", "args", "=", "[", "self", ".", "sw_path", "]", "args", ".", "extend", "(", "[", "'--of-ip'", ",", "parser_args", ".", "controller_ip", ...
[ 139, 4 ]
[ 157, 39 ]
python
en
['en', 'en', 'en']
True
inject_into_urllib3
()
Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.
Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.
def inject_into_urllib3(): "Monkey-patch urllib3 with PyOpenSSL-backed SSL-support." _validate_dependencies_met() util.SSLContext = PyOpenSSLContext util.ssl_.SSLContext = PyOpenSSLContext util.HAS_SNI = HAS_SNI util.ssl_.HAS_SNI = HAS_SNI util.IS_PYOPENSSL = True util.ssl_.IS_PYOPENSS...
[ "def", "inject_into_urllib3", "(", ")", ":", "_validate_dependencies_met", "(", ")", "util", ".", "SSLContext", "=", "PyOpenSSLContext", "util", ".", "ssl_", ".", "SSLContext", "=", "PyOpenSSLContext", "util", ".", "HAS_SNI", "=", "HAS_SNI", "util", ".", "ssl_",...
[ 118, 0 ]
[ 128, 33 ]
python
en
['en', 'en', 'en']
True
extract_from_urllib3
()
Undo monkey-patching by :func:`inject_into_urllib3`.
Undo monkey-patching by :func:`inject_into_urllib3`.
def extract_from_urllib3(): "Undo monkey-patching by :func:`inject_into_urllib3`." util.SSLContext = orig_util_SSLContext util.ssl_.SSLContext = orig_util_SSLContext util.HAS_SNI = orig_util_HAS_SNI util.ssl_.HAS_SNI = orig_util_HAS_SNI util.IS_PYOPENSSL = False util.ssl_.IS_PYOPENSSL = Fal...
[ "def", "extract_from_urllib3", "(", ")", ":", "util", ".", "SSLContext", "=", "orig_util_SSLContext", "util", ".", "ssl_", ".", "SSLContext", "=", "orig_util_SSLContext", "util", ".", "HAS_SNI", "=", "orig_util_HAS_SNI", "util", ".", "ssl_", ".", "HAS_SNI", "=",...
[ 131, 0 ]
[ 139, 34 ]
python
en
['en', 'ny', 'sw']
False
_validate_dependencies_met
()
Verifies that PyOpenSSL's package-level dependencies have been met. Throws `ImportError` if they are not met.
Verifies that PyOpenSSL's package-level dependencies have been met. Throws `ImportError` if they are not met.
def _validate_dependencies_met(): """ Verifies that PyOpenSSL's package-level dependencies have been met. Throws `ImportError` if they are not met. """ # Method added in `cryptography==1.1`; not available in older versions from cryptography.x509.extensions import Extensions if getattr(Exten...
[ "def", "_validate_dependencies_met", "(", ")", ":", "# Method added in `cryptography==1.1`; not available in older versions", "from", "cryptography", ".", "x509", ".", "extensions", "import", "Extensions", "if", "getattr", "(", "Extensions", ",", "\"get_extension_for_class\"", ...
[ 142, 0 ]
[ 165, 9 ]
python
en
['en', 'error', 'th']
False
_dnsname_to_stdlib
(name)
Converts a dNSName SubjectAlternativeName field to the form used by the standard library on the given Python version. Cryptography produces a dNSName as a unicode string that was idna-decoded from ASCII bytes. We need to idna-encode that string to get it back, and then on Python 3 we also need to ...
Converts a dNSName SubjectAlternativeName field to the form used by the standard library on the given Python version.
def _dnsname_to_stdlib(name): """ Converts a dNSName SubjectAlternativeName field to the form used by the standard library on the given Python version. Cryptography produces a dNSName as a unicode string that was idna-decoded from ASCII bytes. We need to idna-encode that string to get it back, and ...
[ "def", "_dnsname_to_stdlib", "(", "name", ")", ":", "def", "idna_encode", "(", "name", ")", ":", "\"\"\"\n Borrowed wholesale from the Python Cryptography Project. It turns out\n that we can't just safely call `idna.encode`: it can explode for\n wildcard names. This avoi...
[ 168, 0 ]
[ 208, 15 ]
python
en
['en', 'error', 'th']
False
get_subj_alt_name
(peer_cert)
Given an PyOpenSSL certificate, provides all the subject alternative names.
Given an PyOpenSSL certificate, provides all the subject alternative names.
def get_subj_alt_name(peer_cert): """ Given an PyOpenSSL certificate, provides all the subject alternative names. """ # Pass the cert to cryptography, which has much better APIs for this. if hasattr(peer_cert, "to_cryptography"): cert = peer_cert.to_cryptography() else: # This is...
[ "def", "get_subj_alt_name", "(", "peer_cert", ")", ":", "# Pass the cert to cryptography, which has much better APIs for this.", "if", "hasattr", "(", "peer_cert", ",", "\"to_cryptography\"", ")", ":", "cert", "=", "peer_cert", ".", "to_cryptography", "(", ")", "else", ...
[ 211, 0 ]
[ 262, 16 ]
python
en
['en', 'error', 'th']
False
get_object_or_400
(klass, *args, **kwargs)
Return a single object from the given model or queryset based on the query params, otherwise raise an exception that will return in a 400 response.
Return a single object from the given model or queryset based on the query params, otherwise raise an exception that will return in a 400 response.
def get_object_or_400(klass, *args, **kwargs): """ Return a single object from the given model or queryset based on the query params, otherwise raise an exception that will return in a 400 response. """ from django.shortcuts import _get_queryset queryset = _get_queryset(klass) try: ...
[ "def", "get_object_or_400", "(", "klass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "django", ".", "shortcuts", "import", "_get_queryset", "queryset", "=", "_get_queryset", "(", "klass", ")", "try", ":", "return", "queryset", ".", "get",...
[ 92, 0 ]
[ 105, 33 ]
python
en
['en', 'error', 'th']
False
camelcase_to_underscore
(s)
Convert CamelCase names to lowercase_with_underscore.
Convert CamelCase names to lowercase_with_underscore.
def camelcase_to_underscore(s): """ Convert CamelCase names to lowercase_with_underscore. """ s = re.sub(r'(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', s) return s.lower().strip('_')
[ "def", "camelcase_to_underscore", "(", "s", ")", ":", "s", "=", "re", ".", "sub", "(", "r'(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))'", ",", "'_\\\\1'", ",", "s", ")", "return", "s", ".", "lower", "(", ")", ".", "strip", "(", "'_'", ")" ]
[ 130, 0 ]
[ 135, 31 ]
python
en
['en', 'error', 'th']
False
underscore_to_camelcase
(s)
Convert lowercase_with_underscore names to CamelCase.
Convert lowercase_with_underscore names to CamelCase.
def underscore_to_camelcase(s): """ Convert lowercase_with_underscore names to CamelCase. """ return ''.join(x.capitalize() or '_' for x in s.split('_'))
[ "def", "underscore_to_camelcase", "(", "s", ")", ":", "return", "''", ".", "join", "(", "x", ".", "capitalize", "(", ")", "or", "'_'", "for", "x", "in", "s", ".", "split", "(", "'_'", ")", ")" ]
[ 138, 0 ]
[ 142, 63 ]
python
en
['en', 'error', 'th']
False
memoize
(ttl=60, cache_key=None, track_function=False, cache=None)
Decorator to wrap a function and cache its result.
Decorator to wrap a function and cache its result.
def memoize(ttl=60, cache_key=None, track_function=False, cache=None): """ Decorator to wrap a function and cache its result. """ if cache_key and track_function: raise IllegalArgumentError("Can not specify cache_key when track_function is True") cache = cache or get_memoize_cache() def...
[ "def", "memoize", "(", "ttl", "=", "60", ",", "cache_key", "=", "None", ",", "track_function", "=", "False", ",", "cache", "=", "None", ")", ":", "if", "cache_key", "and", "track_function", ":", "raise", "IllegalArgumentError", "(", "\"Can not specify cache_ke...
[ 166, 0 ]
[ 198, 28 ]
python
en
['en', 'error', 'th']
False
get_ansible_version
()
Return Ansible version installed. Ansible path needs to be provided to account for custom virtual environments
Return Ansible version installed. Ansible path needs to be provided to account for custom virtual environments
def get_ansible_version(): """ Return Ansible version installed. Ansible path needs to be provided to account for custom virtual environments """ try: proc = subprocess.Popen(['ansible', '--version'], stdout=subprocess.PIPE) result = smart_str(proc.communicate()[0]) return re...
[ "def", "get_ansible_version", "(", ")", ":", "try", ":", "proc", "=", "subprocess", ".", "Popen", "(", "[", "'ansible'", ",", "'--version'", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "result", "=", "smart_str", "(", "proc", ".", "communica...
[ 214, 0 ]
[ 224, 24 ]
python
en
['en', 'error', 'th']
False
get_awx_version
()
Return AWX version as reported by setuptools.
Return AWX version as reported by setuptools.
def get_awx_version(): """ Return AWX version as reported by setuptools. """ from awx import __version__ try: import pkg_resources return pkg_resources.require('awx')[0].version except Exception: return __version__
[ "def", "get_awx_version", "(", ")", ":", "from", "awx", "import", "__version__", "try", ":", "import", "pkg_resources", "return", "pkg_resources", ".", "require", "(", "'awx'", ")", "[", "0", "]", ".", "version", "except", "Exception", ":", "return", "__vers...
[ 227, 0 ]
[ 238, 26 ]
python
en
['en', 'error', 'th']
False
update_scm_url
(scm_type, url, username=True, password=True, check_special_cases=True, scp_format=False)
Update the given SCM URL to add/replace/remove the username/password. When username/password is True, preserve existing username/password, when False (None, '', etc.), remove any existing username/password, otherwise replace username/password. Also validates the given URL.
Update the given SCM URL to add/replace/remove the username/password. When username/password is True, preserve existing username/password, when False (None, '', etc.), remove any existing username/password, otherwise replace username/password. Also validates the given URL.
def update_scm_url(scm_type, url, username=True, password=True, check_special_cases=True, scp_format=False): """ Update the given SCM URL to add/replace/remove the username/password. When username/password is True, preserve existing username/password, when False (None, '', etc.), remove any existing use...
[ "def", "update_scm_url", "(", "scm_type", ",", "url", ",", "username", "=", "True", ",", "password", "=", "True", ",", "check_special_cases", "=", "True", ",", "scp_format", "=", "False", ")", ":", "# Handle all of the URL formats supported by the SCM systems:", "# ...
[ 250, 0 ]
[ 346, 18 ]
python
en
['en', 'error', 'th']
False
model_instance_diff
(old, new, serializer_mapping=None)
Calculate the differences between two model instances. One of the instances may be None (i.e., a newly created model or deleted model). This will cause all fields with a value to have changed (from None). serializer_mapping are used to determine read-only fields. When provided, read-only fields will no...
Calculate the differences between two model instances. One of the instances may be None (i.e., a newly created model or deleted model). This will cause all fields with a value to have changed (from None). serializer_mapping are used to determine read-only fields. When provided, read-only fields will no...
def model_instance_diff(old, new, serializer_mapping=None): """ Calculate the differences between two model instances. One of the instances may be None (i.e., a newly created model or deleted model). This will cause all fields with a value to have changed (from None). serializer_mapping are used to dete...
[ "def", "model_instance_diff", "(", "old", ",", "new", ",", "serializer_mapping", "=", "None", ")", ":", "from", "django", ".", "db", ".", "models", "import", "Model", "if", "not", "(", "old", "is", "None", "or", "isinstance", "(", "old", ",", "Model", ...
[ 392, 0 ]
[ 422, 15 ]
python
en
['en', 'error', 'th']
False
model_to_dict
(obj, serializer_mapping=None)
Serialize a model instance to a dictionary as best as possible serializer_mapping are used to determine read-only fields. When provided, read-only fields will not be included in the resulting dictionary
Serialize a model instance to a dictionary as best as possible serializer_mapping are used to determine read-only fields. When provided, read-only fields will not be included in the resulting dictionary
def model_to_dict(obj, serializer_mapping=None): """ Serialize a model instance to a dictionary as best as possible serializer_mapping are used to determine read-only fields. When provided, read-only fields will not be included in the resulting dictionary """ password_fields = set(getattr(type(o...
[ "def", "model_to_dict", "(", "obj", ",", "serializer_mapping", "=", "None", ")", ":", "password_fields", "=", "set", "(", "getattr", "(", "type", "(", "obj", ")", ",", "'PASSWORD_FIELDS'", ",", "[", "]", ")", ")", "|", "set", "(", "[", "'password'", "]...
[ 425, 0 ]
[ 438, 17 ]
python
en
['en', 'error', 'th']
False
copy_model_by_class
(obj1, Class2, fields, kwargs)
Creates a new unsaved object of type Class2 using the fields from obj1 values in kwargs can override obj1
Creates a new unsaved object of type Class2 using the fields from obj1 values in kwargs can override obj1
def copy_model_by_class(obj1, Class2, fields, kwargs): """ Creates a new unsaved object of type Class2 using the fields from obj1 values in kwargs can override obj1 """ create_kwargs = {} for field_name in fields: descriptor = getattr(Class2, field_name) if isinstance(descriptor,...
[ "def", "copy_model_by_class", "(", "obj1", ",", "Class2", ",", "fields", ",", "kwargs", ")", ":", "create_kwargs", "=", "{", "}", "for", "field_name", "in", "fields", ":", "descriptor", "=", "getattr", "(", "Class2", ",", "field_name", ")", "if", "isinstan...
[ 476, 0 ]
[ 526, 31 ]
python
en
['en', 'error', 'th']
False