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
TestInspectView.test_title_present
(self)
The page title should appear three times. Once in the header, and two times in the field listing (as the actual title and as the draft title)
The page title should appear three times. Once in the header, and two times in the field listing (as the actual title and as the draft title)
def test_title_present(self): """ The page title should appear three times. Once in the header, and two times in the field listing (as the actual title and as the draft title) """ response = self.get(4) self.assertContains(response, 'Christmas', 3)
[ "def", "test_title_present", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", "4", ")", "self", ".", "assertContains", "(", "response", ",", "'Christmas'", ",", "3", ")" ]
[ 124, 4 ]
[ 130, 53 ]
python
en
['en', 'error', 'th']
False
TestInspectView.test_manytomany_output
(self)
Because ManyToMany fields are output InspectView by default, the `categories` for the event should output as a comma separated list once populated.
Because ManyToMany fields are output InspectView by default, the `categories` for the event should output as a comma separated list once populated.
def test_manytomany_output(self): """ Because ManyToMany fields are output InspectView by default, the `categories` for the event should output as a comma separated list once populated. """ eventpage = EventPage.objects.get(pk=4) free_category = EventCategory.obje...
[ "def", "test_manytomany_output", "(", "self", ")", ":", "eventpage", "=", "EventPage", ".", "objects", ".", "get", "(", "pk", "=", "4", ")", "free_category", "=", "EventCategory", ".", "objects", ".", "create", "(", "name", "=", "'Free'", ")", "child_frien...
[ 132, 4 ]
[ 144, 81 ]
python
en
['en', 'error', 'th']
False
TestInspectView.test_false_values_displayed
(self)
Boolean fields with False values should display False, rather than the value of `get_empty_value_display()`. For this page, those should be `locked`, `expired` and `has_unpublished_changes`
Boolean fields with False values should display False, rather than the value of `get_empty_value_display()`. For this page, those should be `locked`, `expired` and `has_unpublished_changes`
def test_false_values_displayed(self): """ Boolean fields with False values should display False, rather than the value of `get_empty_value_display()`. For this page, those should be `locked`, `expired` and `has_unpublished_changes` """ response = self.get(4) self...
[ "def", "test_false_values_displayed", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", "4", ")", "self", ".", "assertContains", "(", "response", ",", "'<dd>False</dd>'", ",", "count", "=", "3", ",", "html", "=", "True", ")" ]
[ 146, 4 ]
[ 153, 75 ]
python
en
['en', 'error', 'th']
False
TestInspectView.test_location_present
(self)
The location should appear once, in the field listing
The location should appear once, in the field listing
def test_location_present(self): """ The location should appear once, in the field listing """ response = self.get(4) self.assertContains(response, 'The North Pole', 1)
[ "def", "test_location_present", "(", "self", ")", ":", "response", "=", "self", ".", "get", "(", "4", ")", "self", ".", "assertContains", "(", "response", ",", "'The North Pole'", ",", "1", ")" ]
[ 155, 4 ]
[ 160, 58 ]
python
en
['en', 'error', 'th']
False
TestInspectView.test_short_description_is_used_as_field_label
(self)
A custom field has been added to the inspect view's `inspect_view_fields` and since this field has a `short_description` we expect it to be used as the field's label, and not use the name of the function.
A custom field has been added to the inspect view's `inspect_view_fields` and since this field has a `short_description` we expect it to be used as the field's label, and not use the name of the function.
def test_short_description_is_used_as_field_label(self): """ A custom field has been added to the inspect view's `inspect_view_fields` and since this field has a `short_description` we expect it to be used as the field's label, and not use the name of the function. """ re...
[ "def", "test_short_description_is_used_as_field_label", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "'/admin/modeladmintest/author/inspect/1/'", ")", "self", ".", "assertContains", "(", "response", ",", "'Birth information'", ")", "...
[ 166, 4 ]
[ 174, 63 ]
python
en
['en', 'error', 'th']
False
PrettyHelpFormatter._format_option_strings
(self, option, mvarfmt=' <{}>', optsep=', ')
Return a comma-separated list of option strings and metavars. :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') :param mvarfmt: metavar format string :param optsep: separator
Return a comma-separated list of option strings and metavars.
def _format_option_strings(self, option, mvarfmt=' <{}>', optsep=', '): """ Return a comma-separated list of option strings and metavars. :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') :param mvarfmt: metavar format string :param optsep: separator ...
[ "def", "_format_option_strings", "(", "self", ",", "option", ",", "mvarfmt", "=", "' <{}>'", ",", "optsep", "=", "', '", ")", ":", "opts", "=", "[", "]", "if", "option", ".", "_short_opts", ":", "opts", ".", "append", "(", "option", ".", "_short_opts", ...
[ 37, 4 ]
[ 58, 28 ]
python
en
['en', 'error', 'th']
False
PrettyHelpFormatter.format_usage
(self, usage)
Ensure there is only one newline between usage and the first heading if there is no description.
Ensure there is only one newline between usage and the first heading if there is no description.
def format_usage(self, usage): """ Ensure there is only one newline between usage and the first heading if there is no description. """ msg = '\nUsage: {}\n'.format( self.indent_lines(textwrap.dedent(usage), " ")) return msg
[ "def", "format_usage", "(", "self", ",", "usage", ")", ":", "msg", "=", "'\\nUsage: {}\\n'", ".", "format", "(", "self", ".", "indent_lines", "(", "textwrap", ".", "dedent", "(", "usage", ")", ",", "\" \"", ")", ")", "return", "msg" ]
[ 65, 4 ]
[ 72, 18 ]
python
en
['en', 'error', 'th']
False
CustomOptionParser.insert_option_group
(self, idx, *args, **kwargs)
Insert an OptionGroup at a given position.
Insert an OptionGroup at a given position.
def insert_option_group(self, idx, *args, **kwargs): """Insert an OptionGroup at a given position.""" group = self.add_option_group(*args, **kwargs) self.option_groups.pop() self.option_groups.insert(idx, group) return group
[ "def", "insert_option_group", "(", "self", ",", "idx", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "group", "=", "self", ".", "add_option_group", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "option_groups", ".", "pop", "(", ...
[ 137, 4 ]
[ 144, 20 ]
python
en
['en', 'en', 'en']
True
CustomOptionParser.option_list_all
(self)
Get a list of all options, including those in option groups.
Get a list of all options, including those in option groups.
def option_list_all(self): """Get a list of all options, including those in option groups.""" res = self.option_list[:] for i in self.option_groups: res.extend(i.option_list) return res
[ "def", "option_list_all", "(", "self", ")", ":", "res", "=", "self", ".", "option_list", "[", ":", "]", "for", "i", "in", "self", ".", "option_groups", ":", "res", ".", "extend", "(", "i", ".", "option_list", ")", "return", "res" ]
[ 147, 4 ]
[ 153, 18 ]
python
en
['en', 'en', 'en']
True
ConfigOptionParser._update_defaults
(self, defaults)
Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).
Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).
def _update_defaults(self, defaults): """Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).""" # Accumulate complex default state. self.values = optparse.Values(self.defaults) ...
[ "def", "_update_defaults", "(", "self", ",", "defaults", ")", ":", "# Accumulate complex default state.", "self", ".", "values", "=", "optparse", ".", "Values", "(", "self", ".", "defaults", ")", "late_eval", "=", "set", "(", ")", "# Then set the options with thos...
[ 200, 4 ]
[ 259, 23 ]
python
en
['en', 'en', 'en']
True
ConfigOptionParser.get_default_values
(self)
Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.
Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.
def get_default_values(self): """Overriding to make updating the defaults after instantiation of the option parser possible, _update_defaults() does the dirty work.""" if not self.process_default_values: # Old, pre-Optik 1.5 behaviour. return optparse.Values(self.defaults...
[ "def", "get_default_values", "(", "self", ")", ":", "if", "not", "self", ".", "process_default_values", ":", "# Old, pre-Optik 1.5 behaviour.", "return", "optparse", ".", "Values", "(", "self", ".", "defaults", ")", "# Load the configuration, or error out in case of an er...
[ 261, 4 ]
[ 280, 40 ]
python
en
['en', 'en', 'en']
True
PluginFileInjector.inventory_as_dict
(self, inventory_source, private_data_dir)
Default implementation of inventory plugin file contents. There are some valid cases when all parameters can be obtained from the environment variables, example "plugin: linode" is valid ideally, however, some options should be filled from the inventory source data
Default implementation of inventory plugin file contents. There are some valid cases when all parameters can be obtained from the environment variables, example "plugin: linode" is valid ideally, however, some options should be filled from the inventory source data
def inventory_as_dict(self, inventory_source, private_data_dir): """Default implementation of inventory plugin file contents. There are some valid cases when all parameters can be obtained from the environment variables, example "plugin: linode" is valid ideally, however, some options sh...
[ "def", "inventory_as_dict", "(", "self", ",", "inventory_source", ",", "private_data_dir", ")", ":", "if", "self", ".", "plugin_name", "is", "None", ":", "raise", "NotImplementedError", "(", "'At minimum the plugin name is needed for inventory plugin use.'", ")", "proper_...
[ 18, 4 ]
[ 27, 38 ]
python
en
['en', 'en', 'en']
True
process_gcm_data
(gdir, filesuffix='', prcp=None, temp=None, year_range=('1961', '1990'), scale_stddev=True, time_unit=None, calendar=None, source='')
Applies the anomaly method to GCM climate data This function can be applied to any GCM data, if it is provided in a suitable :py:class:`xarray.DataArray`. See Parameter description for format details. For CESM-LME a specific function :py:func:`tasks.process_cesm_data` is available which does the ...
Applies the anomaly method to GCM climate data
def process_gcm_data(gdir, filesuffix='', prcp=None, temp=None, year_range=('1961', '1990'), scale_stddev=True, time_unit=None, calendar=None, source=''): """ Applies the anomaly method to GCM climate data This function can be applied to any GCM data, if it is provided...
[ "def", "process_gcm_data", "(", "gdir", ",", "filesuffix", "=", "''", ",", "prcp", "=", "None", ",", "temp", "=", "None", ",", "year_range", "=", "(", "'1961'", ",", "'1990'", ")", ",", "scale_stddev", "=", "True", ",", "time_unit", "=", "None", ",", ...
[ 23, 0 ]
[ 168, 62 ]
python
en
['en', 'en', 'en']
True
process_cesm_data
(gdir, filesuffix='', fpath_temp=None, fpath_precc=None, fpath_precl=None, **kwargs)
Processes and writes CESM climate data for this glacier. This function is made for interpolating the Community Earth System Model Last Millennium Ensemble (CESM-LME) climate simulations, from Otto-Bliesner et al. (2016), to the high-resolution CL2 climatologies (provided with OGGM) and writes everythin...
Processes and writes CESM climate data for this glacier.
def process_cesm_data(gdir, filesuffix='', fpath_temp=None, fpath_precc=None, fpath_precl=None, **kwargs): """Processes and writes CESM climate data for this glacier. This function is made for interpolating the Community Earth System Model Last Millennium Ensemble (CESM-LME) climate s...
[ "def", "process_cesm_data", "(", "gdir", ",", "filesuffix", "=", "''", ",", "fpath_temp", "=", "None", ",", "fpath_precc", "=", "None", ",", "fpath_precl", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# CESM temperature and precipitation data", "if", "fpat...
[ 172, 0 ]
[ 267, 70 ]
python
en
['en', 'en', 'en']
True
process_cmip5_data
(*args, **kwargs)
Renamed to process_cmip_data.
Renamed to process_cmip_data.
def process_cmip5_data(*args, **kwargs): """Renamed to process_cmip_data. """ warnings.warn('The task `process_cmip5_data` is deprecated and renamed ' 'to `process_cmip_data`.', FutureWarning) process_cmip_data(*args, **kwargs)
[ "def", "process_cmip5_data", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "'The task `process_cmip5_data` is deprecated and renamed '", "'to `process_cmip_data`.'", ",", "FutureWarning", ")", "process_cmip_data", "(", "*", "args", ...
[ 271, 0 ]
[ 276, 38 ]
python
en
['en', 'en', 'sw']
True
process_cmip_data
(gdir, filesuffix='', fpath_temp=None, fpath_precip=None, **kwargs)
Read, process and store the CMIP5 and CMIP6 climate data for this glacier. It stores the data in a format that can be used by the OGGM mass balance model and in the glacier directory. Currently, this function is built for the CMIP5 and CMIP6 projection simulations that are on the OGGM servers. Pa...
Read, process and store the CMIP5 and CMIP6 climate data for this glacier.
def process_cmip_data(gdir, filesuffix='', fpath_temp=None, fpath_precip=None, **kwargs): """Read, process and store the CMIP5 and CMIP6 climate data for this glacier. It stores the data in a format that can be used by the OGGM mass balance model and in the glacier directory. Cur...
[ "def", "process_cmip_data", "(", "gdir", ",", "filesuffix", "=", "''", ",", "fpath_temp", "=", "None", ",", "fpath_precip", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Get the path of GCM temperature & precipitation data", "if", "fpath_temp", "is", "None", ...
[ 280, 0 ]
[ 341, 49 ]
python
en
['en', 'en', 'en']
True
process_lmr_data
(gdir, fpath_temp=None, fpath_precip=None, year_range=('1951', '1980'), filesuffix='', **kwargs)
Read, process and store the Last Millennium Reanalysis (LMR) data for this glacier. LMR data: https://atmos.washington.edu/~hakim/lmr/LMRv2/ LMR data is annualised in anomaly format relative to 1951-1980. We create synthetic timeseries from the reference data. It stores the data in a format that can ...
Read, process and store the Last Millennium Reanalysis (LMR) data for this glacier.
def process_lmr_data(gdir, fpath_temp=None, fpath_precip=None, year_range=('1951', '1980'), filesuffix='', **kwargs): """Read, process and store the Last Millennium Reanalysis (LMR) data for this glacier. LMR data: https://atmos.washington.edu/~hakim/lmr/LMRv2/ LMR data is annualised ...
[ "def", "process_lmr_data", "(", "gdir", ",", "fpath_temp", "=", "None", ",", "fpath_precip", "=", "None", ",", "year_range", "=", "(", "'1951'", ",", "'1980'", ")", ",", "filesuffix", "=", "''", ",", "*", "*", "kwargs", ")", ":", "# Get the path of GCM tem...
[ 345, 0 ]
[ 438, 44 ]
python
en
['en', 'en', 'en']
True
memorized_timedelta
(seconds)
Create only one instance of each distinct timedelta
Create only one instance of each distinct timedelta
def memorized_timedelta(seconds): '''Create only one instance of each distinct timedelta''' try: return _timedelta_cache[seconds] except KeyError: delta = timedelta(seconds=seconds) _timedelta_cache[seconds] = delta return delta
[ "def", "memorized_timedelta", "(", "seconds", ")", ":", "try", ":", "return", "_timedelta_cache", "[", "seconds", "]", "except", "KeyError", ":", "delta", "=", "timedelta", "(", "seconds", "=", "seconds", ")", "_timedelta_cache", "[", "seconds", "]", "=", "d...
[ 17, 0 ]
[ 24, 20 ]
python
en
['en', 'en', 'en']
True
memorized_datetime
(seconds)
Create only one instance of each distinct datetime
Create only one instance of each distinct datetime
def memorized_datetime(seconds): '''Create only one instance of each distinct datetime''' try: return _datetime_cache[seconds] except KeyError: # NB. We can't just do datetime.utcfromtimestamp(seconds) as this # fails with negative values under Windows (Bug #90096) dt = _epoc...
[ "def", "memorized_datetime", "(", "seconds", ")", ":", "try", ":", "return", "_datetime_cache", "[", "seconds", "]", "except", "KeyError", ":", "# NB. We can't just do datetime.utcfromtimestamp(seconds) as this", "# fails with negative values under Windows (Bug #90096)", "dt", ...
[ 30, 0 ]
[ 39, 17 ]
python
en
['en', 'en', 'en']
True
memorized_ttinfo
(*args)
Create only one instance of each distinct tuple
Create only one instance of each distinct tuple
def memorized_ttinfo(*args): '''Create only one instance of each distinct tuple''' try: return _ttinfo_cache[args] except KeyError: ttinfo = ( memorized_timedelta(args[0]), memorized_timedelta(args[1]), args[2] ) _ttinfo_cache[args] = ttinf...
[ "def", "memorized_ttinfo", "(", "*", "args", ")", ":", "try", ":", "return", "_ttinfo_cache", "[", "args", "]", "except", "KeyError", ":", "ttinfo", "=", "(", "memorized_timedelta", "(", "args", "[", "0", "]", ")", ",", "memorized_timedelta", "(", "args", ...
[ 44, 0 ]
[ 55, 21 ]
python
en
['en', 'en', 'en']
True
_to_seconds
(td)
Convert a timedelta to seconds
Convert a timedelta to seconds
def _to_seconds(td): '''Convert a timedelta to seconds''' return td.seconds + td.days * 24 * 60 * 60
[ "def", "_to_seconds", "(", "td", ")", ":", "return", "td", ".", "seconds", "+", "td", ".", "days", "*", "24", "*", "60", "*", "60" ]
[ 60, 0 ]
[ 62, 46 ]
python
en
['en', 'en', 'en']
True
unpickler
(zone, utcoffset=None, dstoffset=None, tzname=None)
Factory function for unpickling pytz tzinfo instances. This is shared for both StaticTzInfo and DstTzInfo instances, because database changes could cause a zones implementation to switch between these two base classes and we can't break pickles on a pytz version upgrade.
Factory function for unpickling pytz tzinfo instances.
def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None): """Factory function for unpickling pytz tzinfo instances. This is shared for both StaticTzInfo and DstTzInfo instances, because database changes could cause a zones implementation to switch between these two base classes and we can't bre...
[ "def", "unpickler", "(", "zone", ",", "utcoffset", "=", "None", ",", "dstoffset", "=", "None", ",", "tzname", "=", "None", ")", ":", "# Raises a KeyError if zone no longer exists, which should never happen", "# and would be a bug.", "tz", "=", "pytz", ".", "timezone",...
[ 528, 0 ]
[ 576, 27 ]
python
en
['en', 'fr', 'en']
True
StaticTzInfo.fromutc
(self, dt)
See datetime.tzinfo.fromutc
See datetime.tzinfo.fromutc
def fromutc(self, dt): '''See datetime.tzinfo.fromutc''' if dt.tzinfo is not None and dt.tzinfo is not self: raise ValueError('fromutc: dt.tzinfo is not self') return (dt + self._utcoffset).replace(tzinfo=self)
[ "def", "fromutc", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", "and", "dt", ".", "tzinfo", "is", "not", "self", ":", "raise", "ValueError", "(", "'fromutc: dt.tzinfo is not self'", ")", "return", "(", "dt", "+", "se...
[ 81, 4 ]
[ 85, 58 ]
python
en
['en', 'en', 'de']
False
StaticTzInfo.utcoffset
(self, dt, is_dst=None)
See datetime.tzinfo.utcoffset is_dst is ignored for StaticTzInfo, and exists only to retain compatibility with DstTzInfo.
See datetime.tzinfo.utcoffset
def utcoffset(self, dt, is_dst=None): '''See datetime.tzinfo.utcoffset is_dst is ignored for StaticTzInfo, and exists only to retain compatibility with DstTzInfo. ''' return self._utcoffset
[ "def", "utcoffset", "(", "self", ",", "dt", ",", "is_dst", "=", "None", ")", ":", "return", "self", ".", "_utcoffset" ]
[ 87, 4 ]
[ 93, 30 ]
python
de
['en', 'ny', 'de']
False
StaticTzInfo.dst
(self, dt, is_dst=None)
See datetime.tzinfo.dst is_dst is ignored for StaticTzInfo, and exists only to retain compatibility with DstTzInfo.
See datetime.tzinfo.dst
def dst(self, dt, is_dst=None): '''See datetime.tzinfo.dst is_dst is ignored for StaticTzInfo, and exists only to retain compatibility with DstTzInfo. ''' return _notime
[ "def", "dst", "(", "self", ",", "dt", ",", "is_dst", "=", "None", ")", ":", "return", "_notime" ]
[ 95, 4 ]
[ 101, 22 ]
python
en
['en', 'en', 'de']
False
StaticTzInfo.tzname
(self, dt, is_dst=None)
See datetime.tzinfo.tzname is_dst is ignored for StaticTzInfo, and exists only to retain compatibility with DstTzInfo.
See datetime.tzinfo.tzname
def tzname(self, dt, is_dst=None): '''See datetime.tzinfo.tzname is_dst is ignored for StaticTzInfo, and exists only to retain compatibility with DstTzInfo. ''' return self._tzname
[ "def", "tzname", "(", "self", ",", "dt", ",", "is_dst", "=", "None", ")", ":", "return", "self", ".", "_tzname" ]
[ 103, 4 ]
[ 109, 27 ]
python
de
['de', 'en', 'de']
False
StaticTzInfo.localize
(self, dt, is_dst=False)
Convert naive time to local time
Convert naive time to local time
def localize(self, dt, is_dst=False): '''Convert naive time to local time''' if dt.tzinfo is not None: raise ValueError('Not naive datetime (tzinfo is already set)') return dt.replace(tzinfo=self)
[ "def", "localize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", ":", "raise", "ValueError", "(", "'Not naive datetime (tzinfo is already set)'", ")", "return", "dt", ".", "replace", "(", "tz...
[ 111, 4 ]
[ 115, 38 ]
python
en
['en', 'en', 'en']
True
StaticTzInfo.normalize
(self, dt, is_dst=False)
Correct the timezone information on the given datetime. This is normally a no-op, as StaticTzInfo timezones never have ambiguous cases to correct: >>> from pytz import timezone >>> gmt = timezone('GMT') >>> isinstance(gmt, StaticTzInfo) True >>> dt = datetime(20...
Correct the timezone information on the given datetime.
def normalize(self, dt, is_dst=False): '''Correct the timezone information on the given datetime. This is normally a no-op, as StaticTzInfo timezones never have ambiguous cases to correct: >>> from pytz import timezone >>> gmt = timezone('GMT') >>> isinstance(gmt, Stati...
[ "def", "normalize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "self", ":", "return", "dt", "if", "dt", ".", "tzinfo", "is", "None", ":", "raise", "ValueError", "(", "'Naive time - no tzinfo set'", "...
[ 117, 4 ]
[ 144, 34 ]
python
en
['en', 'en', 'en']
True
DstTzInfo.fromutc
(self, dt)
See datetime.tzinfo.fromutc
See datetime.tzinfo.fromutc
def fromutc(self, dt): '''See datetime.tzinfo.fromutc''' if (dt.tzinfo is not None and getattr(dt.tzinfo, '_tzinfos', None) is not self._tzinfos): raise ValueError('fromutc: dt.tzinfo is not self') dt = dt.replace(tzinfo=None) idx = max(0, bisect_right(self._u...
[ "def", "fromutc", "(", "self", ",", "dt", ")", ":", "if", "(", "dt", ".", "tzinfo", "is", "not", "None", "and", "getattr", "(", "dt", ".", "tzinfo", ",", "'_tzinfos'", ",", "None", ")", "is", "not", "self", ".", "_tzinfos", ")", ":", "raise", "Va...
[ 192, 4 ]
[ 200, 63 ]
python
en
['en', 'en', 'de']
False
DstTzInfo.normalize
(self, dt)
Correct the timezone information on the given datetime If date arithmetic crosses DST boundaries, the tzinfo is not magically adjusted. This method normalizes the tzinfo to the correct one. To test, first we need to do some setup >>> from pytz import timezone >>> utc =...
Correct the timezone information on the given datetime
def normalize(self, dt): '''Correct the timezone information on the given datetime If date arithmetic crosses DST boundaries, the tzinfo is not magically adjusted. This method normalizes the tzinfo to the correct one. To test, first we need to do some setup >>> from py...
[ "def", "normalize", "(", "self", ",", "dt", ")", ":", "if", "dt", ".", "tzinfo", "is", "None", ":", "raise", "ValueError", "(", "'Naive time - no tzinfo set'", ")", "# Convert dt in localtime to UTC", "offset", "=", "dt", ".", "tzinfo", ".", "_utcoffset", "dt"...
[ 202, 4 ]
[ 255, 31 ]
python
en
['en', 'en', 'en']
True
DstTzInfo.localize
(self, dt, is_dst=False)
Convert naive time to local time. This method should be used to construct localtimes, rather than passing a tzinfo argument to a datetime constructor. is_dst is used to determine the correct timezone in the ambigous period at the end of daylight saving time. >>> from pytz impo...
Convert naive time to local time.
def localize(self, dt, is_dst=False): '''Convert naive time to local time. This method should be used to construct localtimes, rather than passing a tzinfo argument to a datetime constructor. is_dst is used to determine the correct timezone in the ambigous period at the end of ...
[ "def", "localize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", ":", "raise", "ValueError", "(", "'Not naive datetime (tzinfo is already set)'", ")", "# Find the two best possibilities.", "possible_...
[ 257, 4 ]
[ 393, 51 ]
python
en
['en', 'en', 'en']
True
DstTzInfo.utcoffset
(self, dt, is_dst=None)
See datetime.tzinfo.utcoffset The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> ambiguous = datetime(2009, 10, 31, 23, 30) >>> str(tz.utcoffset(ambiguous, is_dst=False)) ...
See datetime.tzinfo.utcoffset
def utcoffset(self, dt, is_dst=None): '''See datetime.tzinfo.utcoffset The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> ambiguous = datetime(2009, 10, 31, 23, 30) ...
[ "def", "utcoffset", "(", "self", ",", "dt", ",", "is_dst", "=", "None", ")", ":", "if", "dt", "is", "None", ":", "return", "None", "elif", "dt", ".", "tzinfo", "is", "not", "self", ":", "dt", "=", "self", ".", "localize", "(", "dt", ",", "is_dst"...
[ 395, 4 ]
[ 424, 34 ]
python
de
['en', 'ny', 'de']
False
DstTzInfo.dst
(self, dt, is_dst=None)
See datetime.tzinfo.dst The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> normal = datetime(2009, 9, 1) >>> str(tz.dst(normal)) '1:00:00' >>> str(tz.dst(...
See datetime.tzinfo.dst
def dst(self, dt, is_dst=None): '''See datetime.tzinfo.dst The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> normal = datetime(2009, 9, 1) >>> str(tz.dst(normal)...
[ "def", "dst", "(", "self", ",", "dt", ",", "is_dst", "=", "None", ")", ":", "if", "dt", "is", "None", ":", "return", "None", "elif", "dt", ".", "tzinfo", "is", "not", "self", ":", "dt", "=", "self", ".", "localize", "(", "dt", ",", "is_dst", ")...
[ 426, 4 ]
[ 463, 28 ]
python
en
['en', 'en', 'de']
False
DstTzInfo.tzname
(self, dt, is_dst=None)
See datetime.tzinfo.tzname The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> normal = datetime(2009, 9, 1) >>> tz.tzname(normal) 'NDT' >>> tz.tzname(norm...
See datetime.tzinfo.tzname
def tzname(self, dt, is_dst=None): '''See datetime.tzinfo.tzname The is_dst parameter may be used to remove ambiguity during DST transitions. >>> from pytz import timezone >>> tz = timezone('America/St_Johns') >>> normal = datetime(2009, 9, 1) >>> tz.tzname(no...
[ "def", "tzname", "(", "self", ",", "dt", ",", "is_dst", "=", "None", ")", ":", "if", "dt", "is", "None", ":", "return", "self", ".", "zone", "elif", "dt", ".", "tzinfo", "is", "not", "self", ":", "dt", "=", "self", ".", "localize", "(", "dt", "...
[ 465, 4 ]
[ 501, 31 ]
python
de
['de', 'en', 'de']
False
Controller._check_action
(self, action, active_actions)
Compare (and update) controller's state with the set of active actions. Args: action: Action to check active_actions: Set of all active actions
Compare (and update) controller's state with the set of active actions.
def _check_action(self, action, active_actions): """Compare (and update) controller's state with the set of active actions. Args: action: Action to check active_actions: Set of all active actions """ assert isinstance(action, football_action_set.CoreAction) if not action.is_in_actionset...
[ "def", "_check_action", "(", "self", ",", "action", ",", "active_actions", ")", ":", "assert", "isinstance", "(", "action", ",", "football_action_set", ".", "CoreAction", ")", "if", "not", "action", ".", "is_in_actionset", "(", "self", ".", "_env_config", ")",...
[ 32, 2 ]
[ 50, 32 ]
python
en
['en', 'en', 'en']
True
Controller._check_direction
(self, action, state)
Compare (and update) controller's direction with the current direction. Args: action: Action to check state: Current state of the action being checked
Compare (and update) controller's direction with the current direction.
def _check_direction(self, action, state): """Compare (and update) controller's direction with the current direction. Args: action: Action to check state: Current state of the action being checked """ assert isinstance(action, football_action_set.CoreAction) if not action.is_in_actionse...
[ "def", "_check_direction", "(", "self", ",", "action", ",", "state", ")", ":", "assert", "isinstance", "(", "action", ",", "football_action_set", ".", "CoreAction", ")", "if", "not", "action", ".", "is_in_actionset", "(", "self", ".", "_env_config", ")", ":"...
[ 52, 2 ]
[ 65, 38 ]
python
en
['en', 'en', 'en']
True
Controller.get_env_action
(self, left, right, top, bottom, active_actions)
For a given controller's state generate next environment action. Args: action: Action to check state: Current state of the action being checked
For a given controller's state generate next environment action.
def get_env_action(self, left, right, top, bottom, active_actions): """For a given controller's state generate next environment action. Args: action: Action to check state: Current state of the action being checked """ self._current_direction = football_action_set.action_idle self._chec...
[ "def", "get_env_action", "(", "self", ",", "left", ",", "right", ",", "top", ",", "bottom", ",", "active_actions", ")", ":", "self", ".", "_current_direction", "=", "football_action_set", ".", "action_idle", "self", ".", "_check_direction", "(", "football_action...
[ 67, 2 ]
[ 111, 28 ]
python
en
['en', 'en', 'en']
True
Engine.get_default
()
When only one DjangoTemplates backend is configured, returns it. Raises ImproperlyConfigured otherwise. This is required for preserving historical APIs that rely on a globally available, implicitly configured engine such as: >>> from django.template import Context, Template ...
When only one DjangoTemplates backend is configured, returns it.
def get_default(): """ When only one DjangoTemplates backend is configured, returns it. Raises ImproperlyConfigured otherwise. This is required for preserving historical APIs that rely on a globally available, implicitly configured engine such as: >>> from django.templ...
[ "def", "get_default", "(", ")", ":", "# Since Engine is imported in django.template and since", "# DjangoTemplates is a wrapper around this Engine class,", "# local imports are required to avoid import loops.", "from", "django", ".", "template", "import", "engines", "from", "django", ...
[ 55, 4 ]
[ 86, 50 ]
python
en
['en', 'error', 'th']
False
Engine.from_string
(self, template_code)
Returns a compiled Template object for the given template code, handling template inheritance recursively.
Returns a compiled Template object for the given template code, handling template inheritance recursively.
def from_string(self, template_code): """ Returns a compiled Template object for the given template code, handling template inheritance recursively. """ return Template(template_code, engine=self)
[ "def", "from_string", "(", "self", ",", "template_code", ")", ":", "return", "Template", "(", "template_code", ",", "engine", "=", "self", ")" ]
[ 149, 4 ]
[ 154, 51 ]
python
en
['en', 'error', 'th']
False
Engine.get_template
(self, template_name)
Returns a compiled Template object for the given template name, handling template inheritance recursively.
Returns a compiled Template object for the given template name, handling template inheritance recursively.
def get_template(self, template_name): """ Returns a compiled Template object for the given template name, handling template inheritance recursively. """ template, origin = self.find_template(template_name) if not hasattr(template, 'render'): # template needs ...
[ "def", "get_template", "(", "self", ",", "template_name", ")", ":", "template", ",", "origin", "=", "self", ".", "find_template", "(", "template_name", ")", "if", "not", "hasattr", "(", "template", ",", "'render'", ")", ":", "# template needs to be compiled", ...
[ 156, 4 ]
[ 165, 23 ]
python
en
['en', 'error', 'th']
False
Engine.render_to_string
(self, template_name, context=None)
Render the template specified by template_name with the given context. For use in Django's test suite.
Render the template specified by template_name with the given context. For use in Django's test suite.
def render_to_string(self, template_name, context=None): """ Render the template specified by template_name with the given context. For use in Django's test suite. """ if isinstance(template_name, (list, tuple)): t = self.select_template(template_name) else: ...
[ "def", "render_to_string", "(", "self", ",", "template_name", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "template_name", ",", "(", "list", ",", "tuple", ")", ")", ":", "t", "=", "self", ".", "select_template", "(", "template_name", ...
[ 167, 4 ]
[ 181, 45 ]
python
en
['en', 'error', 'th']
False
Engine.select_template
(self, template_name_list)
Given a list of template names, returns the first that can be loaded.
Given a list of template names, returns the first that can be loaded.
def select_template(self, template_name_list): """ Given a list of template names, returns the first that can be loaded. """ if not template_name_list: raise TemplateDoesNotExist("No template names provided") not_found = [] for template_name in template_name_l...
[ "def", "select_template", "(", "self", ",", "template_name_list", ")", ":", "if", "not", "template_name_list", ":", "raise", "TemplateDoesNotExist", "(", "\"No template names provided\"", ")", "not_found", "=", "[", "]", "for", "template_name", "in", "template_name_li...
[ 183, 4 ]
[ 198, 56 ]
python
en
['en', 'error', 'th']
False
install._called_from_setup
(run_frame)
Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might...
Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any other way, the immediate caller *might...
def _called_from_setup(run_frame): """ Attempt to detect whether run() was called from setup() or by another command. If called by setup(), the parent caller will be the 'run_command' method in 'distutils.dist', and *its* caller will be the 'run_commands' method. If called any ...
[ "def", "_called_from_setup", "(", "run_frame", ")", ":", "if", "run_frame", "is", "None", ":", "msg", "=", "\"Call stack not available. bdist_* commands may fail.\"", "warnings", ".", "warn", "(", "msg", ")", "if", "platform", ".", "python_implementation", "(", ")",...
[ 69, 4 ]
[ 93, 9 ]
python
en
['en', 'error', 'th']
False
render_icon
(icon, **kwargs)
Render a Bootstrap glyphicon icon.
Render a Bootstrap glyphicon icon.
def render_icon(icon, **kwargs): """Render a Bootstrap glyphicon icon.""" attrs = {"class": add_css_class("glyphicon glyphicon-{icon}".format(icon=icon), kwargs.get("extra_classes", ""))} title = kwargs.get("title") if title: attrs["title"] = title return render_tag("span", attrs=attrs)
[ "def", "render_icon", "(", "icon", ",", "*", "*", "kwargs", ")", ":", "attrs", "=", "{", "\"class\"", ":", "add_css_class", "(", "\"glyphicon glyphicon-{icon}\"", ".", "format", "(", "icon", "=", "icon", ")", ",", "kwargs", ".", "get", "(", "\"extra_classe...
[ 7, 0 ]
[ 13, 42 ]
python
en
['en', 'it', 'en']
True
render_alert
(content, alert_type=None, dismissable=True)
Render a Bootstrap alert.
Render a Bootstrap alert.
def render_alert(content, alert_type=None, dismissable=True): """Render a Bootstrap alert.""" button = "" if not alert_type: alert_type = "info" css_classes = ["alert", "alert-" + text_value(alert_type)] if dismissable: css_classes.append("alert-dismissable") button = '<butto...
[ "def", "render_alert", "(", "content", ",", "alert_type", "=", "None", ",", "dismissable", "=", "True", ")", ":", "button", "=", "\"\"", "if", "not", "alert_type", ":", "alert_type", "=", "\"info\"", "css_classes", "=", "[", "\"alert\"", ",", "\"alert-\"", ...
[ 16, 0 ]
[ 30, 5 ]
python
en
['en', 'lb', 'en']
True
TestScenarioExecutor.test_timers
(self)
general executor supports only simplified form of think-time
general executor supports only simplified form of think-time
def test_timers(self): """ general executor supports only simplified form of think-time """ with open(os.path.join(RESOURCES_DIR, "yaml/timers.yml")) as config_file: config = yaml.full_load(config_file.read()) self.configure(config) timers = [request.get_think_time() for req...
[ "def", "test_timers", "(", "self", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "RESOURCES_DIR", ",", "\"yaml/timers.yml\"", ")", ")", "as", "config_file", ":", "config", "=", "yaml", ".", "full_load", "(", "config_file", ".", "rea...
[ 255, 4 ]
[ 262, 62 ]
python
en
['en', 'en', 'en']
True
mask_comments
(input)
Mask the quoted strings so we skip braces inside quoted strings.
Mask the quoted strings so we skip braces inside quoted strings.
def mask_comments(input): """Mask the quoted strings so we skip braces inside quoted strings.""" search_re = re.compile(r"(.*?)(#)(.*)") return [search_re.sub(comment_replace, line) for line in input]
[ "def", "mask_comments", "(", "input", ")", ":", "search_re", "=", "re", ".", "compile", "(", "r\"(.*?)(#)(.*)\"", ")", "return", "[", "search_re", ".", "sub", "(", "comment_replace", ",", "line", ")", "for", "line", "in", "input", "]" ]
[ 29, 0 ]
[ 32, 67 ]
python
en
['en', 'en', 'en']
True
mask_quotes
(input)
Mask the quoted strings so we skip braces inside quoted strings.
Mask the quoted strings so we skip braces inside quoted strings.
def mask_quotes(input): """Mask the quoted strings so we skip braces inside quoted strings.""" search_re = re.compile(r"(.*?)" + QUOTE_RE_STR) return [search_re.sub(quote_replace, line) for line in input]
[ "def", "mask_quotes", "(", "input", ")", ":", "search_re", "=", "re", ".", "compile", "(", "r\"(.*?)\"", "+", "QUOTE_RE_STR", ")", "return", "[", "search_re", ".", "sub", "(", "quote_replace", ",", "line", ")", "for", "line", "in", "input", "]" ]
[ 44, 0 ]
[ 47, 65 ]
python
en
['en', 'en', 'en']
True
split_double_braces
(input)
Masks out the quotes and comments, and then splits appropriate lines (lines that matche the double_*_brace re's above) before indenting them below. These are used to split lines which have multiple braces on them, so that the indentation looks prettier when all laid out (e.g. closing braces make a nice diago...
Masks out the quotes and comments, and then splits appropriate lines (lines that matche the double_*_brace re's above) before indenting them below.
def split_double_braces(input): """Masks out the quotes and comments, and then splits appropriate lines (lines that matche the double_*_brace re's above) before indenting them below. These are used to split lines which have multiple braces on them, so that the indentation looks prettier when all laid out (...
[ "def", "split_double_braces", "(", "input", ")", ":", "double_open_brace_re", "=", "re", ".", "compile", "(", "r\"(.*?[\\[\\{\\(,])(\\s*)([\\[\\{\\(])\"", ")", "double_close_brace_re", "=", "re", ".", "compile", "(", "r\"(.*?[\\]\\}\\)],?)(\\s*)([\\]\\}\\)])\"", ")", "mas...
[ 65, 0 ]
[ 83, 17 ]
python
en
['en', 'en', 'en']
True
count_braces
(line)
keeps track of the number of braces on a given line and returns the result. It starts at zero and subtracts for closed braces, and adds for open braces.
keeps track of the number of braces on a given line and returns the result.
def count_braces(line): """keeps track of the number of braces on a given line and returns the result. It starts at zero and subtracts for closed braces, and adds for open braces. """ open_braces = ["[", "(", "{"] close_braces = ["]", ")", "}"] closing_prefix_re = re.compile(r"(.*?[^\s\]\}\)]+.*?)(...
[ "def", "count_braces", "(", "line", ")", ":", "open_braces", "=", "[", "\"[\"", ",", "\"(\"", ",", "\"{\"", "]", "close_braces", "=", "[", "\"]\"", ",", "\")\"", ",", "\"}\"", "]", "closing_prefix_re", "=", "re", ".", "compile", "(", "r\"(.*?[^\\s\\]\\}\\)...
[ 86, 0 ]
[ 115, 23 ]
python
en
['en', 'en', 'en']
True
prettyprint_input
(lines)
Does the main work of indenting the input based on the brace counts.
Does the main work of indenting the input based on the brace counts.
def prettyprint_input(lines): """Does the main work of indenting the input based on the brace counts.""" indent = 0 basic_offset = 2 for line in lines: if COMMENT_RE.match(line): print(line) else: line = line.strip("\r\n\t ") # Otherwise doesn't strip \r on Unix....
[ "def", "prettyprint_input", "(", "lines", ")", ":", "indent", "=", "0", "basic_offset", "=", "2", "for", "line", "in", "lines", ":", "if", "COMMENT_RE", ".", "match", "(", "line", ")", ":", "print", "(", "line", ")", "else", ":", "line", "=", "line",...
[ 118, 0 ]
[ 139, 25 ]
python
en
['en', 'en', 'en']
True
swappable_dependency
(value)
Turns a setting value into a dependency.
Turns a setting value into a dependency.
def swappable_dependency(value): """ Turns a setting value into a dependency. """ return SwappableTuple((value.split(".", 1)[0], "__first__"), value)
[ "def", "swappable_dependency", "(", "value", ")", ":", "return", "SwappableTuple", "(", "(", "value", ".", "split", "(", "\".\"", ",", "1", ")", "[", "0", "]", ",", "\"__first__\"", ")", ",", "value", ")" ]
[ 193, 0 ]
[ 197, 71 ]
python
en
['en', 'error', 'th']
False
SphericalMercator.px_to_ll
(self,px,zoom)
Convert pixel postion to LatLong (EPSG:4326)
Convert pixel postion to LatLong (EPSG:4326)
def px_to_ll(self,px,zoom): """ Convert pixel postion to LatLong (EPSG:4326) """ # TODO - more graceful handling of indexing error e = self.zc[zoom] f = (px[0] - e[0])/self.Bc[zoom] g = (px[1] - e[1])/-self.Cc[zoom] h = self.RAD_TO_DEG * ( 2 * math.atan(math.exp(g)) - 0.5...
[ "def", "px_to_ll", "(", "self", ",", "px", ",", "zoom", ")", ":", "# TODO - more graceful handling of indexing error", "e", "=", "self", ".", "zc", "[", "zoom", "]", "f", "=", "(", "px", "[", "0", "]", "-", "e", "[", "0", "]", ")", "/", "self", "."...
[ 120, 4 ]
[ 127, 20 ]
python
en
['en', 'jv', 'en']
True
SphericalMercator.xyz_to_envelope
(self,x,y,zoom, tms_style=False, count=1)
Convert XYZ to mapnik.Envelope
Convert XYZ to mapnik.Envelope
def xyz_to_envelope(self,x,y,zoom, tms_style=False, count=1): """ Convert XYZ to mapnik.Envelope """ # flip y to match TMS spec if tms_style: y = (2**zoom-1) - y ll = (x * self.size,(y + count) * self.size) ur = ((x + count) * self.size, y * self.size) minx,mi...
[ "def", "xyz_to_envelope", "(", "self", ",", "x", ",", "y", ",", "zoom", ",", "tms_style", "=", "False", ",", "count", "=", "1", ")", ":", "# flip y to match TMS spec", "if", "tms_style", ":", "y", "=", "(", "2", "**", "zoom", "-", "1", ")", "-", "y...
[ 129, 4 ]
[ 140, 18 ]
python
en
['en', 'hu', 'it']
False
Server.msg
(self,message)
WSGI apps must not print to stdout.
WSGI apps must not print to stdout.
def msg(self,message): """ WSGI apps must not print to stdout. """ self._log.debug(message)
[ "def", "msg", "(", "self", ",", "message", ")", ":", "self", ".", "_log", ".", "debug", "(", "message", ")" ]
[ 250, 4 ]
[ 253, 32 ]
python
en
['en', 'en', 'en']
True
Server.__call__
(self, environ, start_response)
WSGI request handler
WSGI request handler
def __call__(self, environ, start_response): """ WSGI request handler """ response_status = "200 OK" mime_type = 'text/html' fmt = 'png' if not self._locked: path_info = environ['PATH_INFO'] qs = environ['QUERY_STRING'] zoom,x,y = None,None...
[ "def", "__call__", "(", "self", ",", "environ", ",", "start_response", ")", ":", "response_status", "=", "\"200 OK\"", "mime_type", "=", "'text/html'", "fmt", "=", "'png'", "if", "not", "self", ".", "_locked", ":", "path_info", "=", "environ", "[", "'PATH_IN...
[ 369, 4 ]
[ 439, 22 ]
python
de
['sv', 'de', 'en']
False
display_list
(values: List[str], display_limit: int)
Given a list of values, return a string nicely formatting those values, summarizing when you have more than `display_limit`. Eg, for a `display_limit` of 3 we get the following possible cases: Jessica Jessica and Waseem Jessica, Waseem, and Tim Jessica, Waseem, Tim, and 1 other Jessica...
Given a list of values, return a string nicely formatting those values, summarizing when you have more than `display_limit`. Eg, for a `display_limit` of 3 we get the following possible cases:
def display_list(values: List[str], display_limit: int) -> str: """ Given a list of values, return a string nicely formatting those values, summarizing when you have more than `display_limit`. Eg, for a `display_limit` of 3 we get the following possible cases: Jessica Jessica and Waseem Jes...
[ "def", "display_list", "(", "values", ":", "List", "[", "str", "]", ",", "display_limit", ":", "int", ")", "->", "str", ":", "if", "len", "(", "values", ")", "==", "1", ":", "# One value, show it.", "display_string", "=", "f\"{values[0]}\"", "elif", "len",...
[ 40, 0 ]
[ 64, 25 ]
python
en
['en', 'error', 'th']
False
render_markdown_path
( markdown_file_path: str, context: Mapping[str, Any] = {}, pure_markdown: bool = False )
Given a path to a Markdown file, return the rendered HTML. Note that this assumes that any HTML in the Markdown file is trusted; it is intended to be used for documentation, not user data.
Given a path to a Markdown file, return the rendered HTML.
def render_markdown_path( markdown_file_path: str, context: Mapping[str, Any] = {}, pure_markdown: bool = False ) -> str: """Given a path to a Markdown file, return the rendered HTML. Note that this assumes that any HTML in the Markdown file is trusted; it is intended to be used for documentation, not ...
[ "def", "render_markdown_path", "(", "markdown_file_path", ":", "str", ",", "context", ":", "Mapping", "[", "str", ",", "Any", "]", "=", "{", "}", ",", "pure_markdown", ":", "bool", "=", "False", ")", "->", "str", ":", "# We set this global hackishly", "from"...
[ 83, 0 ]
[ 174, 35 ]
python
en
['en', 'en', 'en']
True
RequirementTracker.add
(self, req)
Add an InstallRequirement to build tracking.
Add an InstallRequirement to build tracking.
def add(self, req): # type: (InstallRequirement) -> None """Add an InstallRequirement to build tracking. """ assert req.link # Get the file to write information about this requirement. entry_path = self._entry_path(req.link) # Try reading from the file. If it ex...
[ "def", "add", "(", "self", ",", "req", ")", ":", "# type: (InstallRequirement) -> None", "assert", "req", ".", "link", "# Get the file to write information about this requirement.", "entry_path", "=", "self", ".", "_entry_path", "(", "req", ".", "link", ")", "# Try re...
[ 93, 4 ]
[ 124, 69 ]
python
en
['en', 'en', 'en']
True
RequirementTracker.remove
(self, req)
Remove an InstallRequirement from build tracking.
Remove an InstallRequirement from build tracking.
def remove(self, req): # type: (InstallRequirement) -> None """Remove an InstallRequirement from build tracking. """ assert req.link # Delete the created file and the corresponding entries. os.unlink(self._entry_path(req.link)) self._entries.remove(req) ...
[ "def", "remove", "(", "self", ",", "req", ")", ":", "# type: (InstallRequirement) -> None", "assert", "req", ".", "link", "# Delete the created file and the corresponding entries.", "os", ".", "unlink", "(", "self", ".", "_entry_path", "(", "req", ".", "link", ")", ...
[ 126, 4 ]
[ 136, 73 ]
python
en
['en', 'en', 'en']
True
get_supported_platform
()
Return this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of macOS that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of macOS that we are *running*. To allow...
Return this platform's maximum compatible version.
def get_supported_platform(): """Return this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of macOS that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of m...
[ "def", "get_supported_platform", "(", ")", ":", "plat", "=", "get_build_platform", "(", ")", "m", "=", "macosVersionString", ".", "match", "(", "plat", ")", "if", "m", "is", "not", "None", "and", "sys", ".", "platform", "==", "\"darwin\"", ":", "try", ":...
[ 160, 0 ]
[ 181, 15 ]
python
en
['en', 'la', 'en']
True
register_loader_type
(loader_type, provider_factory)
Register `provider_factory` to make providers for `loader_type` `loader_type` is the type or class of a PEP 302 ``module.__loader__``, and `provider_factory` is a function that, passed a *module* object, returns an ``IResourceProvider`` for that module.
Register `provider_factory` to make providers for `loader_type`
def register_loader_type(loader_type, provider_factory): """Register `provider_factory` to make providers for `loader_type` `loader_type` is the type or class of a PEP 302 ``module.__loader__``, and `provider_factory` is a function that, passed a *module* object, returns an ``IResourceProvider`` for th...
[ "def", "register_loader_type", "(", "loader_type", ",", "provider_factory", ")", ":", "_provider_factories", "[", "loader_type", "]", "=", "provider_factory" ]
[ 327, 0 ]
[ 334, 55 ]
python
en
['en', 'no', 'en']
True
get_provider
(moduleOrReq)
Return an IResourceProvider for the named module or requirement
Return an IResourceProvider for the named module or requirement
def get_provider(moduleOrReq): """Return an IResourceProvider for the named module or requirement""" if isinstance(moduleOrReq, Requirement): return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] try: module = sys.modules[moduleOrReq] except KeyError: __import__(mo...
[ "def", "get_provider", "(", "moduleOrReq", ")", ":", "if", "isinstance", "(", "moduleOrReq", ",", "Requirement", ")", ":", "return", "working_set", ".", "find", "(", "moduleOrReq", ")", "or", "require", "(", "str", "(", "moduleOrReq", ")", ")", "[", "0", ...
[ 337, 0 ]
[ 347, 61 ]
python
en
['en', 'en', 'en']
True
get_build_platform
()
Return this platform's string for platform-specific distributions XXX Currently this is the same as ``distutils.util.get_platform()``, but it needs some hacks for Linux and macOS.
Return this platform's string for platform-specific distributions
def get_build_platform(): """Return this platform's string for platform-specific distributions XXX Currently this is the same as ``distutils.util.get_platform()``, but it needs some hacks for Linux and macOS. """ from sysconfig import get_platform plat = get_platform() if sys.platform == "...
[ "def", "get_build_platform", "(", ")", ":", "from", "sysconfig", "import", "get_platform", "plat", "=", "get_platform", "(", ")", "if", "sys", ".", "platform", "==", "\"darwin\"", "and", "not", "plat", ".", "startswith", "(", "'macosx-'", ")", ":", "try", ...
[ 370, 0 ]
[ 391, 15 ]
python
en
['en', 'da', 'en']
True
compatible_platforms
(provided, required)
Can code for the `provided` platform run on the `required` platform? Returns true if either platform is ``None``, or the platforms are equal. XXX Needs compatibility checks for Linux and other unixy OSes.
Can code for the `provided` platform run on the `required` platform?
def compatible_platforms(provided, required): """Can code for the `provided` platform run on the `required` platform? Returns true if either platform is ``None``, or the platforms are equal. XXX Needs compatibility checks for Linux and other unixy OSes. """ if provided is None or required is None ...
[ "def", "compatible_platforms", "(", "provided", ",", "required", ")", ":", "if", "provided", "is", "None", "or", "required", "is", "None", "or", "provided", "==", "required", ":", "# easy case", "return", "True", "# macOS special cases", "reqMac", "=", "macosVer...
[ 400, 0 ]
[ 443, 16 ]
python
en
['en', 'en', 'en']
True
run_script
(dist_spec, script_name)
Locate distribution `dist_spec` and run its `script_name` script
Locate distribution `dist_spec` and run its `script_name` script
def run_script(dist_spec, script_name): """Locate distribution `dist_spec` and run its `script_name` script""" ns = sys._getframe(1).f_globals name = ns['__name__'] ns.clear() ns['__name__'] = name require(dist_spec)[0].run_script(script_name, ns)
[ "def", "run_script", "(", "dist_spec", ",", "script_name", ")", ":", "ns", "=", "sys", ".", "_getframe", "(", "1", ")", ".", "f_globals", "name", "=", "ns", "[", "'__name__'", "]", "ns", ".", "clear", "(", ")", "ns", "[", "'__name__'", "]", "=", "n...
[ 446, 0 ]
[ 452, 53 ]
python
en
['en', 'co', 'en']
True
get_distribution
(dist)
Return a current distribution object for a Requirement or string
Return a current distribution object for a Requirement or string
def get_distribution(dist): """Return a current distribution object for a Requirement or string""" if isinstance(dist, str): dist = Requirement.parse(dist) if isinstance(dist, Requirement): dist = get_provider(dist) if not isinstance(dist, Distribution): raise TypeError("Expected...
[ "def", "get_distribution", "(", "dist", ")", ":", "if", "isinstance", "(", "dist", ",", "str", ")", ":", "dist", "=", "Requirement", ".", "parse", "(", "dist", ")", "if", "isinstance", "(", "dist", ",", "Requirement", ")", ":", "dist", "=", "get_provid...
[ 459, 0 ]
[ 467, 15 ]
python
en
['en', 'en', 'en']
True
load_entry_point
(dist, group, name)
Return `name` entry point of `group` for `dist` or raise ImportError
Return `name` entry point of `group` for `dist` or raise ImportError
def load_entry_point(dist, group, name): """Return `name` entry point of `group` for `dist` or raise ImportError""" return get_distribution(dist).load_entry_point(group, name)
[ "def", "load_entry_point", "(", "dist", ",", "group", ",", "name", ")", ":", "return", "get_distribution", "(", "dist", ")", ".", "load_entry_point", "(", "group", ",", "name", ")" ]
[ 470, 0 ]
[ 472, 63 ]
python
en
['en', 'en', 'en']
True
get_entry_map
(dist, group=None)
Return the entry point map for `group`, or the full entry map
Return the entry point map for `group`, or the full entry map
def get_entry_map(dist, group=None): """Return the entry point map for `group`, or the full entry map""" return get_distribution(dist).get_entry_map(group)
[ "def", "get_entry_map", "(", "dist", ",", "group", "=", "None", ")", ":", "return", "get_distribution", "(", "dist", ")", ".", "get_entry_map", "(", "group", ")" ]
[ 475, 0 ]
[ 477, 54 ]
python
en
['en', 'en', 'en']
True
get_entry_info
(dist, group, name)
Return the EntryPoint object for `group`+`name`, or ``None``
Return the EntryPoint object for `group`+`name`, or ``None``
def get_entry_info(dist, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return get_distribution(dist).get_entry_info(group, name)
[ "def", "get_entry_info", "(", "dist", ",", "group", ",", "name", ")", ":", "return", "get_distribution", "(", "dist", ")", ".", "get_entry_info", "(", "group", ",", "name", ")" ]
[ 480, 0 ]
[ 482, 61 ]
python
en
['en', 'en', 'en']
True
get_default_cache
()
Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs".
Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs".
def get_default_cache(): """ Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs". """ return ( os.environ.get('PYTHON_EGG_CACHE') or appdirs.user_cache_dir(appname='Python-Eggs') )
[ "def", "get_default_cache", "(", ")", ":", "return", "(", "os", ".", "environ", ".", "get", "(", "'PYTHON_EGG_CACHE'", ")", "or", "appdirs", ".", "user_cache_dir", "(", "appname", "=", "'Python-Eggs'", ")", ")" ]
[ 1289, 0 ]
[ 1298, 5 ]
python
en
['en', 'error', 'th']
False
safe_name
(name)
Convert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'.
Convert an arbitrary string to a standard distribution name
def safe_name(name): """Convert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. """ return re.sub('[^A-Za-z0-9.]+', '-', name)
[ "def", "safe_name", "(", "name", ")", ":", "return", "re", ".", "sub", "(", "'[^A-Za-z0-9.]+'", ",", "'-'", ",", "name", ")" ]
[ 1301, 0 ]
[ 1306, 46 ]
python
en
['en', 'en', 'en']
True
safe_version
(version)
Convert an arbitrary string to a standard version string
Convert an arbitrary string to a standard version string
def safe_version(version): """ Convert an arbitrary string to a standard version string """ try: # normalize the version return str(packaging.version.Version(version)) except packaging.version.InvalidVersion: version = version.replace(' ', '.') return re.sub('[^A-Za-z...
[ "def", "safe_version", "(", "version", ")", ":", "try", ":", "# normalize the version", "return", "str", "(", "packaging", ".", "version", ".", "Version", "(", "version", ")", ")", "except", "packaging", ".", "version", ".", "InvalidVersion", ":", "version", ...
[ 1309, 0 ]
[ 1318, 53 ]
python
en
['en', 'error', 'th']
False
safe_extra
(extra)
Convert an arbitrary string to a standard 'extra' name Any runs of non-alphanumeric characters are replaced with a single '_', and the result is always lowercased.
Convert an arbitrary string to a standard 'extra' name
def safe_extra(extra): """Convert an arbitrary string to a standard 'extra' name Any runs of non-alphanumeric characters are replaced with a single '_', and the result is always lowercased. """ return re.sub('[^A-Za-z0-9.-]+', '_', extra).lower()
[ "def", "safe_extra", "(", "extra", ")", ":", "return", "re", ".", "sub", "(", "'[^A-Za-z0-9.-]+'", ",", "'_'", ",", "extra", ")", ".", "lower", "(", ")" ]
[ 1321, 0 ]
[ 1327, 56 ]
python
en
['en', 'en', 'en']
True
to_filename
(name)
Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'.
Convert a project or version name to its filename-escaped form
def to_filename(name): """Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. """ return name.replace('-', '_')
[ "def", "to_filename", "(", "name", ")", ":", "return", "name", ".", "replace", "(", "'-'", ",", "'_'", ")" ]
[ 1330, 0 ]
[ 1335, 33 ]
python
en
['en', 'en', 'en']
True
invalid_marker
(text)
Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise.
Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise.
def invalid_marker(text): """ Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise. """ try: evaluate_marker(text) except SyntaxError as e: e.filename = None e.lineno = None return e return False
[ "def", "invalid_marker", "(", "text", ")", ":", "try", ":", "evaluate_marker", "(", "text", ")", "except", "SyntaxError", "as", "e", ":", "e", ".", "filename", "=", "None", "e", ".", "lineno", "=", "None", "return", "e", "return", "False" ]
[ 1338, 0 ]
[ 1349, 16 ]
python
en
['en', 'error', 'th']
False
evaluate_marker
(text, extra=None)
Evaluate a PEP 508 environment marker. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. This implementation uses the 'pyparsing' module.
Evaluate a PEP 508 environment marker. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid.
def evaluate_marker(text, extra=None): """ Evaluate a PEP 508 environment marker. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. This implementation uses the 'pyparsing' module. """ try: marker = packaging.markers.Marker(te...
[ "def", "evaluate_marker", "(", "text", ",", "extra", "=", "None", ")", ":", "try", ":", "marker", "=", "packaging", ".", "markers", ".", "Marker", "(", "text", ")", "return", "marker", ".", "evaluate", "(", ")", "except", "packaging", ".", "markers", "...
[ 1352, 0 ]
[ 1364, 35 ]
python
en
['en', 'error', 'th']
False
_parents
(path)
yield all parents of path including path
yield all parents of path including path
def _parents(path): """ yield all parents of path including path """ last = None while path != last: yield path last = path path, _ = os.path.split(path)
[ "def", "_parents", "(", "path", ")", ":", "last", "=", "None", "while", "path", "!=", "last", ":", "yield", "path", "last", "=", "path", "path", ",", "_", "=", "os", ".", "path", ".", "split", "(", "path", ")" ]
[ 1561, 0 ]
[ 1569, 37 ]
python
en
['en', 'error', 'th']
False
register_finder
(importer_type, distribution_finder)
Register `distribution_finder` to find distributions in sys.path items `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `distribution_finder` is a callable that, passed a path item and the importer instance, yields ``Distribution`` instances found on that path i...
Register `distribution_finder` to find distributions in sys.path items
def register_finder(importer_type, distribution_finder): """Register `distribution_finder` to find distributions in sys.path items `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `distribution_finder` is a callable that, passed a path item and the importer inst...
[ "def", "register_finder", "(", "importer_type", ",", "distribution_finder", ")", ":", "_distribution_finders", "[", "importer_type", "]", "=", "distribution_finder" ]
[ 1948, 0 ]
[ 1955, 62 ]
python
en
['en', 'en', 'en']
True
find_distributions
(path_item, only=False)
Yield distributions accessible via `path_item`
Yield distributions accessible via `path_item`
def find_distributions(path_item, only=False): """Yield distributions accessible via `path_item`""" importer = get_importer(path_item) finder = _find_adapter(_distribution_finders, importer) return finder(importer, path_item, only)
[ "def", "find_distributions", "(", "path_item", ",", "only", "=", "False", ")", ":", "importer", "=", "get_importer", "(", "path_item", ")", "finder", "=", "_find_adapter", "(", "_distribution_finders", ",", "importer", ")", "return", "finder", "(", "importer", ...
[ 1958, 0 ]
[ 1962, 44 ]
python
en
['en', 'en', 'en']
True
find_eggs_in_zip
(importer, path_item, only=False)
Find eggs in zip files; possibly multiple nested eggs.
Find eggs in zip files; possibly multiple nested eggs.
def find_eggs_in_zip(importer, path_item, only=False): """ Find eggs in zip files; possibly multiple nested eggs. """ if importer.archive.endswith('.whl'): # wheels are not supported with this finder # they don't have PKG-INFO metadata, and won't ever contain eggs return meta...
[ "def", "find_eggs_in_zip", "(", "importer", ",", "path_item", ",", "only", "=", "False", ")", ":", "if", "importer", ".", "archive", ".", "endswith", "(", "'.whl'", ")", ":", "# wheels are not supported with this finder", "# they don't have PKG-INFO metadata, and won't ...
[ 1965, 0 ]
[ 1989, 73 ]
python
en
['en', 'error', 'th']
False
_by_version_descending
(names)
Given a list of filenames, return them in descending order by version number. >>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg' >>> _by_version_descending(names) ['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar'] >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg'...
Given a list of filenames, return them in descending order by version number.
def _by_version_descending(names): """ Given a list of filenames, return them in descending order by version number. >>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg' >>> _by_version_descending(names) ['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar'] >>> names = 'Setup...
[ "def", "_by_version_descending", "(", "names", ")", ":", "def", "_by_version", "(", "name", ")", ":", "\"\"\"\n Parse each component of the filename\n \"\"\"", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "name", ")", "parts", "=...
[ 2002, 0 ]
[ 2025, 55 ]
python
en
['en', 'error', 'th']
False
find_on_path
(importer, path_item, only=False)
Yield distributions accessible on a sys.path directory
Yield distributions accessible on a sys.path directory
def find_on_path(importer, path_item, only=False): """Yield distributions accessible on a sys.path directory""" path_item = _normalize_cached(path_item) if _is_unpacked_egg(path_item): yield Distribution.from_filename( path_item, metadata=PathMetadata( path_item, os.path...
[ "def", "find_on_path", "(", "importer", ",", "path_item", ",", "only", "=", "False", ")", ":", "path_item", "=", "_normalize_cached", "(", "path_item", ")", "if", "_is_unpacked_egg", "(", "path_item", ")", ":", "yield", "Distribution", ".", "from_filename", "(...
[ 2028, 0 ]
[ 2060, 22 ]
python
en
['en', 'en', 'en']
True
dist_factory
(path_item, entry, only)
Return a dist_factory for the given entry.
Return a dist_factory for the given entry.
def dist_factory(path_item, entry, only): """Return a dist_factory for the given entry.""" lower = entry.lower() is_egg_info = lower.endswith('.egg-info') is_dist_info = ( lower.endswith('.dist-info') and os.path.isdir(os.path.join(path_item, entry)) ) is_meta = is_egg_info or is...
[ "def", "dist_factory", "(", "path_item", ",", "entry", ",", "only", ")", ":", "lower", "=", "entry", ".", "lower", "(", ")", "is_egg_info", "=", "lower", ".", "endswith", "(", "'.egg-info'", ")", "is_dist_info", "=", "(", "lower", ".", "endswith", "(", ...
[ 2063, 0 ]
[ 2080, 5 ]
python
en
['en', 'en', 'en']
True
safe_listdir
(path)
Attempt to list contents of path, but suppress some exceptions.
Attempt to list contents of path, but suppress some exceptions.
def safe_listdir(path): """ Attempt to list contents of path, but suppress some exceptions. """ try: return os.listdir(path) except (PermissionError, NotADirectoryError): pass except OSError as e: # Ignore the directory if does not exist, not a directory or # perm...
[ "def", "safe_listdir", "(", "path", ")", ":", "try", ":", "return", "os", ".", "listdir", "(", "path", ")", "except", "(", "PermissionError", ",", "NotADirectoryError", ")", ":", "pass", "except", "OSError", "as", "e", ":", "# Ignore the directory if does not ...
[ 2098, 0 ]
[ 2111, 13 ]
python
en
['en', 'error', 'th']
False
non_empty_lines
(path)
Yield non-empty lines from file at path
Yield non-empty lines from file at path
def non_empty_lines(path): """ Yield non-empty lines from file at path """ with open(path) as f: for line in f: line = line.strip() if line: yield line
[ "def", "non_empty_lines", "(", "path", ")", ":", "with", "open", "(", "path", ")", "as", "f", ":", "for", "line", "in", "f", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "line", ":", "yield", "line" ]
[ 2129, 0 ]
[ 2137, 26 ]
python
en
['en', 'error', 'th']
False
resolve_egg_link
(path)
Given a path to an .egg-link, resolve distributions present in the referenced path.
Given a path to an .egg-link, resolve distributions present in the referenced path.
def resolve_egg_link(path): """ Given a path to an .egg-link, resolve distributions present in the referenced path. """ referenced_paths = non_empty_lines(path) resolved_paths = ( os.path.join(os.path.dirname(path), ref) for ref in referenced_paths ) dist_groups = map(fin...
[ "def", "resolve_egg_link", "(", "path", ")", ":", "referenced_paths", "=", "non_empty_lines", "(", "path", ")", "resolved_paths", "=", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "path", ")", ",", "ref", ")", "for"...
[ 2140, 0 ]
[ 2151, 32 ]
python
en
['en', 'error', 'th']
False
register_namespace_handler
(importer_type, namespace_handler)
Register `namespace_handler` to declare namespace packages `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `namespace_handler` is a callable like this:: def namespace_handler(importer, path_entry, moduleName, module): # return a path_entry to use f...
Register `namespace_handler` to declare namespace packages
def register_namespace_handler(importer_type, namespace_handler): """Register `namespace_handler` to declare namespace packages `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `namespace_handler` is a callable like this:: def namespace_handler(importer, pa...
[ "def", "register_namespace_handler", "(", "importer_type", ",", "namespace_handler", ")", ":", "_namespace_handlers", "[", "importer_type", "]", "=", "namespace_handler" ]
[ 2163, 0 ]
[ 2178, 58 ]
python
en
['it', 'en', 'en']
True
_handle_ns
(packageName, path_item)
Ensure that named package includes a subpath of path_item (if needed)
Ensure that named package includes a subpath of path_item (if needed)
def _handle_ns(packageName, path_item): """Ensure that named package includes a subpath of path_item (if needed)""" importer = get_importer(path_item) if importer is None: return None # use find_spec (PEP 451) and fall-back to find_module (PEP 302) try: loader = importer.find_spec(...
[ "def", "_handle_ns", "(", "packageName", ",", "path_item", ")", ":", "importer", "=", "get_importer", "(", "path_item", ")", "if", "importer", "is", "None", ":", "return", "None", "# use find_spec (PEP 451) and fall-back to find_module (PEP 302)", "try", ":", "loader"...
[ 2181, 0 ]
[ 2213, 18 ]
python
en
['en', 'en', 'en']
True
_rebuild_mod_path
(orig_path, package_name, module)
Rebuild module.__path__ ensuring that all entries are ordered corresponding to their sys.path order
Rebuild module.__path__ ensuring that all entries are ordered corresponding to their sys.path order
def _rebuild_mod_path(orig_path, package_name, module): """ Rebuild module.__path__ ensuring that all entries are ordered corresponding to their sys.path order """ sys_path = [_normalize_cached(p) for p in sys.path] def safe_sys_path_index(entry): """ Workaround for #520 and #51...
[ "def", "_rebuild_mod_path", "(", "orig_path", ",", "package_name", ",", "module", ")", ":", "sys_path", "=", "[", "_normalize_cached", "(", "p", ")", "for", "p", "in", "sys", ".", "path", "]", "def", "safe_sys_path_index", "(", "entry", ")", ":", "\"\"\"\n...
[ 2216, 0 ]
[ 2247, 34 ]
python
en
['en', 'error', 'th']
False
declare_namespace
(packageName)
Declare that package 'packageName' is a namespace package
Declare that package 'packageName' is a namespace package
def declare_namespace(packageName): """Declare that package 'packageName' is a namespace package""" _imp.acquire_lock() try: if packageName in _namespace_packages: return path = sys.path parent, _, _ = packageName.rpartition('.') if parent: declare_...
[ "def", "declare_namespace", "(", "packageName", ")", ":", "_imp", ".", "acquire_lock", "(", ")", "try", ":", "if", "packageName", "in", "_namespace_packages", ":", "return", "path", "=", "sys", ".", "path", "parent", ",", "_", ",", "_", "=", "packageName",...
[ 2250, 0 ]
[ 2281, 27 ]
python
en
['en', 'en', 'en']
True
fixup_namespace_packages
(path_item, parent=None)
Ensure that previously-declared namespace packages include path_item
Ensure that previously-declared namespace packages include path_item
def fixup_namespace_packages(path_item, parent=None): """Ensure that previously-declared namespace packages include path_item""" _imp.acquire_lock() try: for package in _namespace_packages.get(parent, ()): subpath = _handle_ns(package, path_item) if subpath: f...
[ "def", "fixup_namespace_packages", "(", "path_item", ",", "parent", "=", "None", ")", ":", "_imp", ".", "acquire_lock", "(", ")", "try", ":", "for", "package", "in", "_namespace_packages", ".", "get", "(", "parent", ",", "(", ")", ")", ":", "subpath", "=...
[ 2284, 0 ]
[ 2293, 27 ]
python
en
['en', 'en', 'en']
True
file_ns_handler
(importer, path_item, packageName, module)
Compute an ns-package subpath for a filesystem or zipfile importer
Compute an ns-package subpath for a filesystem or zipfile importer
def file_ns_handler(importer, path_item, packageName, module): """Compute an ns-package subpath for a filesystem or zipfile importer""" subpath = os.path.join(path_item, packageName.split('.')[-1]) normalized = _normalize_cached(subpath) for item in module.__path__: if _normalize_cached(item) =...
[ "def", "file_ns_handler", "(", "importer", ",", "path_item", ",", "packageName", ",", "module", ")", ":", "subpath", "=", "os", ".", "path", ".", "join", "(", "path_item", ",", "packageName", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", ")", "n...
[ 2296, 0 ]
[ 2306, 22 ]
python
en
['en', 'en', 'en']
True
normalize_path
(filename)
Normalize a file/dir name for comparison purposes
Normalize a file/dir name for comparison purposes
def normalize_path(filename): """Normalize a file/dir name for comparison purposes""" return os.path.normcase(os.path.realpath(os.path.normpath( _cygwin_patch(filename))))
[ "def", "normalize_path", "(", "filename", ")", ":", "return", "os", ".", "path", ".", "normcase", "(", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "normpath", "(", "_cygwin_patch", "(", "filename", ")", ")", ")", ")" ]
[ 2323, 0 ]
[ 2326, 34 ]
python
en
['en', 'it', 'en']
True
_cygwin_patch
(filename)
Contrary to POSIX 2008, on Cygwin, getcwd (3) contains symlink components. Using os.path.abspath() works around this limitation. A fix in os.getcwd() would probably better, in Cygwin even more so, except that this seems to be by design...
Contrary to POSIX 2008, on Cygwin, getcwd (3) contains symlink components. Using os.path.abspath() works around this limitation. A fix in os.getcwd() would probably better, in Cygwin even more so, except that this seems to be by design...
def _cygwin_patch(filename): # pragma: nocover """ Contrary to POSIX 2008, on Cygwin, getcwd (3) contains symlink components. Using os.path.abspath() works around this limitation. A fix in os.getcwd() would probably better, in Cygwin even more so, except that this seems to be by design... "...
[ "def", "_cygwin_patch", "(", "filename", ")", ":", "# pragma: nocover", "return", "os", ".", "path", ".", "abspath", "(", "filename", ")", "if", "sys", ".", "platform", "==", "'cygwin'", "else", "filename" ]
[ 2329, 0 ]
[ 2337, 78 ]
python
en
['en', 'error', 'th']
False
_is_egg_path
(path)
Determine if given path appears to be an egg.
Determine if given path appears to be an egg.
def _is_egg_path(path): """ Determine if given path appears to be an egg. """ return _is_zip_egg(path) or _is_unpacked_egg(path)
[ "def", "_is_egg_path", "(", "path", ")", ":", "return", "_is_zip_egg", "(", "path", ")", "or", "_is_unpacked_egg", "(", "path", ")" ]
[ 2348, 0 ]
[ 2352, 54 ]
python
en
['en', 'error', 'th']
False
_is_unpacked_egg
(path)
Determine if given path appears to be an unpacked egg.
Determine if given path appears to be an unpacked egg.
def _is_unpacked_egg(path): """ Determine if given path appears to be an unpacked egg. """ return ( path.lower().endswith('.egg') and os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO')) )
[ "def", "_is_unpacked_egg", "(", "path", ")", ":", "return", "(", "path", ".", "lower", "(", ")", ".", "endswith", "(", "'.egg'", ")", "and", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "path", ",", "'EGG-INFO'", ",",...
[ 2363, 0 ]
[ 2370, 5 ]
python
en
['en', 'error', 'th']
False
yield_lines
(strs)
Yield non-empty/non-comment lines of a string or sequence
Yield non-empty/non-comment lines of a string or sequence
def yield_lines(strs): """Yield non-empty/non-comment lines of a string or sequence""" if isinstance(strs, str): for s in strs.splitlines(): s = s.strip() # skip blank lines/comments if s and not s.startswith('#'): yield s else: for ss in s...
[ "def", "yield_lines", "(", "strs", ")", ":", "if", "isinstance", "(", "strs", ",", "str", ")", ":", "for", "s", "in", "strs", ".", "splitlines", "(", ")", ":", "s", "=", "s", ".", "strip", "(", ")", "# skip blank lines/comments", "if", "s", "and", ...
[ 2381, 0 ]
[ 2392, 23 ]
python
en
['en', 'en', 'en']
True
_version_from_file
(lines)
Given an iterable of lines from a Metadata file, return the value of the Version field, if present, or None otherwise.
Given an iterable of lines from a Metadata file, return the value of the Version field, if present, or None otherwise.
def _version_from_file(lines): """ Given an iterable of lines from a Metadata file, return the value of the Version field, if present, or None otherwise. """ def is_version_line(line): return line.lower().startswith('version:') version_lines = filter(is_version_line, lines) line = ne...
[ "def", "_version_from_file", "(", "lines", ")", ":", "def", "is_version_line", "(", "line", ")", ":", "return", "line", ".", "lower", "(", ")", ".", "startswith", "(", "'version:'", ")", "version_lines", "=", "filter", "(", "is_version_line", ",", "lines", ...
[ 2542, 0 ]
[ 2552, 46 ]
python
en
['en', 'error', 'th']
False
_parsed_pkg_info
(self)
Parse and cache metadata
Parse and cache metadata
def _parsed_pkg_info(self): """Parse and cache metadata""" try: return self._pkg_info except AttributeError: metadata = self.get_metadata(self.PKG_INFO) self._pkg_info = email.parser.Parser().parsestr(metadata) return self._pkg_info
[ "def", "_parsed_pkg_info", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_pkg_info", "except", "AttributeError", ":", "metadata", "=", "self", ".", "get_metadata", "(", "self", ".", "PKG_INFO", ")", "self", ".", "_pkg_info", "=", "email", ".",...
[ 2999, 4 ]
[ 3006, 33 ]
python
en
['en', 'la', 'en']
True