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
annotation.get_selection_names
(self, index=None)
return the names of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
return the names of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
def get_selection_names(self, index=None): """ return the names of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;) """ if index is None: ...
[ "def", "get_selection_names", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "else", ":", "final_ind", "=", "index", "names", "=...
[ 847, 4 ]
[ 861, 21 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_attribute
(self, attribute)
return the keyword values of the selected annotations The attribute here is a property tagged to a feature via the description column in the annotation.
return the keyword values of the selected annotations The attribute here is a property tagged to a feature via the description column in the annotation.
def get_selection_attribute(self, attribute): """ return the keyword values of the selected annotations The attribute here is a property tagged to a feature via the description column in the annotation. """ sel = self.get_selection() keywordvals = [] ...
[ "def", "get_selection_attribute", "(", "self", ",", "attribute", ")", ":", "sel", "=", "self", ".", "get_selection", "(", ")", "keywordvals", "=", "[", "]", "for", "region", "in", "sel", ":", "if", "attribute", "in", "region", ".", "desc", ":", "keywordv...
[ 863, 4 ]
[ 879, 40 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_types
(self, index=None)
return the types of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
return the types of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
def get_selection_types(self, index=None): """ return the types of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;) """ if index is None: ...
[ "def", "get_selection_types", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "else", ":", "final_ind", "=", "index", "types", "=...
[ 881, 4 ]
[ 895, 21 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_chrids
(self, index=None)
return the chrids of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
return the chrids of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
def get_selection_chrids(self, index=None): """ return the chrids of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;) """ if index is None: ...
[ "def", "get_selection_chrids", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "else", ":", "final_ind", "=", "index", "chrids", ...
[ 897, 4 ]
[ 911, 22 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_starts
(self, index=None)
return the start positions of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the start position selection. This should be used mostly internally ;)
return the start positions of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the start position selection. This should be used mostly internally ;)
def get_selection_starts(self, index=None): """ return the start positions of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the start position selection. This should be used mostly internally ;) """ if index is No...
[ "def", "get_selection_starts", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "else", ":", "final_ind", "=", "index", "starts", ...
[ 913, 4 ]
[ 927, 22 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_stops
(self, index=None)
return the stop positions of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the stop position selection. This should be used mostly internally ;)
return the stop positions of the selected annotations
def get_selection_stops(self, index=None): """ return the stop positions of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the stop position selection. This should be used mostly internally ;) """ if index is None:...
[ "def", "get_selection_stops", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "else", ":", "final_ind", "=", "index", "stops", "=...
[ 929, 4 ]
[ 944, 21 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_strands
(self, index=None)
return the strands of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
return the strands of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;)
def get_selection_strands(self, index=None): """ return the strands of the selected annotations The keyword arg 'index' allows a specific index to be supplied. for the chrid position selection. This should be used mostly internally ;) """ if index is None: ...
[ "def", "get_selection_strands", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "else", ":", "final_ind", "=", "index", "strands", ...
[ 946, 4 ]
[ 960, 23 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_lengths
(self)
return the lengths of the selected annotations
return the lengths of the selected annotations
def get_selection_lengths(self): """ return the lengths of the selected annotations """ final_ind = self.get_selection(return_indexes=True) return(1+(self.get_selection_stops(final_ind)-self.get_selection_starts(final_ind)))
[ "def", "get_selection_lengths", "(", "self", ")", ":", "final_ind", "=", "self", ".", "get_selection", "(", "return_indexes", "=", "True", ")", "return", "(", "1", "+", "(", "self", ".", "get_selection_stops", "(", "final_ind", ")", "-", "self", ".", "get_...
[ 962, 4 ]
[ 968, 92 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_sum_length
(self)
return the sum of the lengths of the selected annotations
return the sum of the lengths of the selected annotations
def get_selection_sum_length(self): """ return the sum of the lengths of the selected annotations """ return(self.get_selection_lengths().sum())
[ "def", "get_selection_sum_length", "(", "self", ")", ":", "return", "(", "self", ".", "get_selection_lengths", "(", ")", ".", "sum", "(", ")", ")" ]
[ 970, 4 ]
[ 974, 50 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_mean_length
(self)
return the mean of the lengths of the selected annotations
return the mean of the lengths of the selected annotations
def get_selection_mean_length(self): """ return the mean of the lengths of the selected annotations """ return(self.get_selection_lengths().mean())
[ "def", "get_selection_mean_length", "(", "self", ")", ":", "return", "(", "self", ".", "get_selection_lengths", "(", ")", ".", "mean", "(", ")", ")" ]
[ 976, 4 ]
[ 980, 51 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_median_length
(self)
return the median of the lengths of the selected annotations
return the median of the lengths of the selected annotations
def get_selection_median_length(self): """ return the median of the lengths of the selected annotations """ return(numpy.median(self.get_selection_lengths()))
[ "def", "get_selection_median_length", "(", "self", ")", ":", "return", "(", "numpy", ".", "median", "(", "self", ".", "get_selection_lengths", "(", ")", ")", ")" ]
[ 982, 4 ]
[ 986, 58 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_stddev_length
(self)
return the unbiassed standard deviation of the lengths of the selected annotations. Here we correct numpys typical standard deviation routine to make it an unbiased estimator, according to GURLAND, J. & TRIPATHI, R. C. 1971. "Simple Approximation for Unbiased Estimation of S...
return the unbiassed standard deviation of the lengths of the selected annotations. Here we correct numpys typical standard deviation routine to make it an unbiased estimator, according to GURLAND, J. & TRIPATHI, R. C. 1971. "Simple Approximation for Unbiased Estimation of S...
def get_selection_stddev_length(self): """ return the unbiassed standard deviation of the lengths of the selected annotations. Here we correct numpys typical standard deviation routine to make it an unbiased estimator, according to GURLAND, J. & TRIPATHI, R. C. 1971. ...
[ "def", "get_selection_stddev_length", "(", "self", ")", ":", "return", "(", "self", ".", "get_selection_lengths", "(", ")", ".", "std", "(", "ddof", "=", "1", ")", "*", "(", "1.0", "+", "(", "1.0", "/", "(", "4.0", "*", "(", "len", "(", "self", "."...
[ 988, 4 ]
[ 1002, 73 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_stderr_length
(self)
return the unbiassed standard error on the mean of the lengths of the selected annotations.
return the unbiassed standard error on the mean of the lengths of the selected annotations.
def get_selection_stderr_length(self): """ return the unbiassed standard error on the mean of the lengths of the selected annotations.""" return(self.get_selection_stddev_length()/len(self.get_selection_lengths()))
[ "def", "get_selection_stderr_length", "(", "self", ")", ":", "return", "(", "self", ".", "get_selection_stddev_length", "(", ")", "/", "len", "(", "self", ".", "get_selection_lengths", "(", ")", ")", ")" ]
[ 1004, 4 ]
[ 1009, 84 ]
python
en
['en', 'en', 'en']
True
annotation.get_selection_lengthstats
(self)
return the lengths of the selected annotations
return the lengths of the selected annotations
def get_selection_lengthstats(self): """ return the lengths of the selected annotations """ return(self.get_selection_mean_lengths(), self.get_selection_median_lengths(), self.get_selection_stddev_lengths(), self.get_selection_stderr_lengths())
[ "def", "get_selection_lengthstats", "(", "self", ")", ":", "return", "(", "self", ".", "get_selection_mean_lengths", "(", ")", ",", "self", ".", "get_selection_median_lengths", "(", ")", ",", "self", ".", "get_selection_stddev_lengths", "(", ")", ",", "self", "....
[ 1011, 4 ]
[ 1018, 51 ]
python
en
['en', 'en', 'en']
True
annotation.get_features
(self)
get the list of features found in the annotation
get the list of features found in the annotation
def get_features(self): """ get the list of features found in the annotation """ return(self._featurelist)
[ "def", "get_features", "(", "self", ")", ":", "return", "(", "self", ".", "_featurelist", ")" ]
[ 1020, 4 ]
[ 1024, 33 ]
python
en
['en', 'en', 'en']
True
annotation.get_chromosomes
(self)
get the list of chromosomes in the whole annotation
get the list of chromosomes in the whole annotation
def get_chromosomes(self): """ get the list of chromosomes in the whole annotation """ return(sorted(self._chrid_dic.keys()))
[ "def", "get_chromosomes", "(", "self", ")", ":", "return", "(", "sorted", "(", "self", ".", "_chrid_dic", ".", "keys", "(", ")", ")", ")" ]
[ 1026, 4 ]
[ 1030, 46 ]
python
en
['en', 'en', 'en']
True
annotation.get_gene_length_bp
(self, feature="exons", inc_UTRs=True, ret_type="dict")
return the bp length of all exons and UTRs in each gene Note that region, name and attribute selections are preserved
return the bp length of all exons and UTRs in each gene Note that region, name and attribute selections are preserved
def get_gene_length_bp(self, feature="exons", inc_UTRs=True, ret_type="dict"): """ return the bp length of all exons and UTRs in each gene Note that region, name and attribute selections are preserved """ allowed_ret_types=["dict","structure...
[ "def", "get_gene_length_bp", "(", "self", ",", "feature", "=", "\"exons\"", ",", "inc_UTRs", "=", "True", ",", "ret_type", "=", "\"dict\"", ")", ":", "allowed_ret_types", "=", "[", "\"dict\"", ",", "\"structured_array\"", "]", "if", "ret_type", "not", "in", ...
[ 1032, 4 ]
[ 1098, 29 ]
python
en
['en', 'no', 'en']
True
annotation.write
(self, filename, fmt="gff3", regions_to_write=None, append=False, compress=True, verbose=False)
write the existing annotation, inc. selections, to a file The fmt option will determine the file format. Options are 'gff3', 'gtf' or bed6
write the existing annotation, inc. selections, to a file The fmt option will determine the file format. Options are 'gff3', 'gtf' or bed6
def write(self, filename, fmt="gff3", regions_to_write=None, append=False, compress=True, verbose=False): """ write the existing annotation, inc. selections, to a file The fmt option will determine the file format. Options are 'gff3', 'gtf' or bed6 """ ...
[ "def", "write", "(", "self", ",", "filename", ",", "fmt", "=", "\"gff3\"", ",", "regions_to_write", "=", "None", ",", "append", "=", "False", ",", "compress", "=", "True", ",", "verbose", "=", "False", ")", ":", "if", "regions_to_write", "is", "None", ...
[ 1126, 4 ]
[ 1159, 24 ]
python
en
['en', 'en', 'en']
True
samefile
(p1, p2)
Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist.
Determine if two paths reference the same file.
def samefile(p1, p2): """ Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. """ both_exist = os.path.exists(p1) and os.path.exists(p2) use_samefile = hasattr(os.path, 'samefile') and both_exist i...
[ "def", "samefile", "(", "p1", ",", "p2", ")", ":", "both_exist", "=", "os", ".", "path", ".", "exists", "(", "p1", ")", "and", "os", ".", "path", ".", "exists", "(", "p2", ")", "use_samefile", "=", "hasattr", "(", "os", ".", "path", ",", "'samefi...
[ 77, 0 ]
[ 90, 29 ]
python
en
['en', 'error', 'th']
False
get_site_dirs
()
Return a list of 'site' dirs
Return a list of 'site' dirs
def get_site_dirs(): """ Return a list of 'site' dirs """ sitedirs = [] # start with PYTHONPATH sitedirs.extend(_pythonpath()) prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) for prefix in prefixes: if prefix: ...
[ "def", "get_site_dirs", "(", ")", ":", "sitedirs", "=", "[", "]", "# start with PYTHONPATH", "sitedirs", ".", "extend", "(", "_pythonpath", "(", ")", ")", "prefixes", "=", "[", "sys", ".", "prefix", "]", "if", "sys", ".", "exec_prefix", "!=", "sys", ".",...
[ 1348, 0 ]
[ 1410, 19 ]
python
en
['en', 'error', 'th']
False
expand_paths
(inputs)
Yield sys.path directories that might contain "old-style" packages
Yield sys.path directories that might contain "old-style" packages
def expand_paths(inputs): """Yield sys.path directories that might contain "old-style" packages""" seen = {} for dirname in inputs: dirname = normalize_path(dirname) if dirname in seen: continue seen[dirname] = 1 if not os.path.isdir(dirname): conti...
[ "def", "expand_paths", "(", "inputs", ")", ":", "seen", "=", "{", "}", "for", "dirname", "in", "inputs", ":", "dirname", "=", "normalize_path", "(", "dirname", ")", "if", "dirname", "in", "seen", ":", "continue", "seen", "[", "dirname", "]", "=", "1", ...
[ 1413, 0 ]
[ 1451, 52 ]
python
en
['en', 'en', 'en']
True
extract_wininst_cfg
(dist_filename)
Extract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None
Extract configuration data from a bdist_wininst .exe
def extract_wininst_cfg(dist_filename): """Extract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None """ f = open(dist_filename, 'rb') try: endrec = zipfile._EndRecData(f) if endrec is None: return None prepended = (end...
[ "def", "extract_wininst_cfg", "(", "dist_filename", ")", ":", "f", "=", "open", "(", "dist_filename", ",", "'rb'", ")", "try", ":", "endrec", "=", "zipfile", ".", "_EndRecData", "(", "f", ")", "if", "endrec", "is", "None", ":", "return", "None", "prepend...
[ 1454, 0 ]
[ 1492, 17 ]
python
en
['en', 'en', 'en']
True
get_exe_prefixes
(exe_filename)
Get exe->egg path translations for a given .exe file
Get exe->egg path translations for a given .exe file
def get_exe_prefixes(exe_filename): """Get exe->egg path translations for a given .exe file""" prefixes = [ ('PURELIB/', ''), ('PLATLIB/pywin32_system32', ''), ('PLATLIB/', ''), ('SCRIPTS/', 'EGG-INFO/scripts/'), ('DATA/lib/site-packages', ''), ] z = zipfile.ZipF...
[ "def", "get_exe_prefixes", "(", "exe_filename", ")", ":", "prefixes", "=", "[", "(", "'PURELIB/'", ",", "''", ")", ",", "(", "'PLATLIB/pywin32_system32'", ",", "''", ")", ",", "(", "'PLATLIB/'", ",", "''", ")", ",", "(", "'SCRIPTS/'", ",", "'EGG-INFO/scrip...
[ 1495, 0 ]
[ 1529, 19 ]
python
en
['en', 'en', 'en']
True
_first_line_re
()
Return a regular expression based on first_line_re suitable for matching strings.
Return a regular expression based on first_line_re suitable for matching strings.
def _first_line_re(): """ Return a regular expression based on first_line_re suitable for matching strings. """ if isinstance(first_line_re.pattern, str): return first_line_re # first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern. return re.compile(first_line_re.pattern.d...
[ "def", "_first_line_re", "(", ")", ":", "if", "isinstance", "(", "first_line_re", ".", "pattern", ",", "str", ")", ":", "return", "first_line_re", "# first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.", "return", "re", ".", "compile", "(", "first_line_re", ...
[ 1666, 0 ]
[ 1675, 53 ]
python
en
['en', 'error', 'th']
False
update_dist_caches
(dist_path, fix_zipimporter_caches)
Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be clear...
Fix any globally cached `dist_path` related data
def update_dist_caches(dist_path, fix_zipimporter_caches): """ Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data fro...
[ "def", "update_dist_caches", "(", "dist_path", ",", "fix_zipimporter_caches", ")", ":", "# There are several other known sources of stale zipimport.zipimporter", "# instances that we do not clear here, but might if ever given a reason to", "# do so:", "# * Global setuptools pkg_resources.worki...
[ 1687, 0 ]
[ 1766, 67 ]
python
en
['en', 'error', 'th']
False
_collect_zipimporter_cache_entries
(normalized_path, cache)
Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zi...
Return zipimporter cache entry keys related to a given normalized path.
def _collect_zipimporter_cache_entries(normalized_path, cache): """ Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any su...
[ "def", "_collect_zipimporter_cache_entries", "(", "normalized_path", ",", "cache", ")", ":", "result", "=", "[", "]", "prefix_len", "=", "len", "(", "normalized_path", ")", "for", "p", "in", "cache", ":", "np", "=", "normalize_path", "(", "p", ")", "if", "...
[ 1769, 0 ]
[ 1786, 17 ]
python
en
['en', 'error', 'th']
False
_update_zipimporter_cache
(normalized_path, cache, updater=None)
Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry key and the original entry (after already removing the entry from the ca...
Update zipimporter cache data for a given normalized path.
def _update_zipimporter_cache(normalized_path, cache, updater=None): """ Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry ...
[ "def", "_update_zipimporter_cache", "(", "normalized_path", ",", "cache", ",", "updater", "=", "None", ")", ":", "for", "p", "in", "_collect_zipimporter_cache_entries", "(", "normalized_path", ",", "cache", ")", ":", "# N.B. pypy's custom zipimport._zip_directory_cache im...
[ 1789, 0 ]
[ 1818, 32 ]
python
en
['en', 'error', 'th']
False
is_python
(text, filename='<string>')
Is this string a valid Python script?
Is this string a valid Python script?
def is_python(text, filename='<string>'): "Is this string a valid Python script?" try: compile(text, filename, 'exec') except (SyntaxError, TypeError): return False else: return True
[ "def", "is_python", "(", "text", ",", "filename", "=", "'<string>'", ")", ":", "try", ":", "compile", "(", "text", ",", "filename", ",", "'exec'", ")", "except", "(", "SyntaxError", ",", "TypeError", ")", ":", "return", "False", "else", ":", "return", ...
[ 1866, 0 ]
[ 1873, 19 ]
python
en
['en', 'en', 'en']
True
is_sh
(executable)
Determine if the specified executable is a .sh (contains a #! line)
Determine if the specified executable is a .sh (contains a #! line)
def is_sh(executable): """Determine if the specified executable is a .sh (contains a #! line)""" try: with io.open(executable, encoding='latin-1') as fp: magic = fp.read(2) except (OSError, IOError): return executable return magic == '#!'
[ "def", "is_sh", "(", "executable", ")", ":", "try", ":", "with", "io", ".", "open", "(", "executable", ",", "encoding", "=", "'latin-1'", ")", "as", "fp", ":", "magic", "=", "fp", ".", "read", "(", "2", ")", "except", "(", "OSError", ",", "IOError"...
[ 1876, 0 ]
[ 1883, 24 ]
python
en
['en', 'en', 'en']
True
nt_quote_arg
(arg)
Quote a command line argument according to Windows parsing rules
Quote a command line argument according to Windows parsing rules
def nt_quote_arg(arg): """Quote a command line argument according to Windows parsing rules""" return subprocess.list2cmdline([arg])
[ "def", "nt_quote_arg", "(", "arg", ")", ":", "return", "subprocess", ".", "list2cmdline", "(", "[", "arg", "]", ")" ]
[ 1886, 0 ]
[ 1888, 41 ]
python
en
['en', 'en', 'en']
True
is_python_script
(script_text, filename)
Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ if filename.endswith('.py') or filename.endswith('.pyw'): return True # extension says it's Python if is_python(script_text, filename): return True # it's syntac...
[ "def", "is_python_script", "(", "script_text", ",", "filename", ")", ":", "if", "filename", ".", "endswith", "(", "'.py'", ")", "or", "filename", ".", "endswith", "(", "'.pyw'", ")", ":", "return", "True", "# extension says it's Python", "if", "is_python", "("...
[ 1891, 0 ]
[ 1902, 16 ]
python
en
['en', 'en', 'en']
True
get_win_launcher
(type)
Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string.
Load the Windows launcher (executable) suitable for launching a script.
def get_win_launcher(type): """ Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. """ launcher_fn = '%s.exe' % type if is_64bit(): launcher_fn = launcher_fn.replace(".", "-64.") ...
[ "def", "get_win_launcher", "(", "type", ")", ":", "launcher_fn", "=", "'%s.exe'", "%", "type", "if", "is_64bit", "(", ")", ":", "launcher_fn", "=", "launcher_fn", ".", "replace", "(", "\".\"", ",", "\"-64.\"", ")", "else", ":", "launcher_fn", "=", "launche...
[ 2229, 0 ]
[ 2242, 53 ]
python
en
['en', 'error', 'th']
False
easy_install._render_version
()
Render the Setuptools version and installation details, then exit.
Render the Setuptools version and installation details, then exit.
def _render_version(): """ Render the Setuptools version and installation details, then exit. """ ver = '{}.{}'.format(*sys.version_info) dist = get_distribution('setuptools') tmpl = 'setuptools {dist.version} from {dist.location} (Python {ver})' print(tmpl.format...
[ "def", "_render_version", "(", ")", ":", "ver", "=", "'{}.{}'", ".", "format", "(", "*", "sys", ".", "version_info", ")", "dist", "=", "get_distribution", "(", "'setuptools'", ")", "tmpl", "=", "'setuptools {dist.version} from {dist.location} (Python {ver})'", "prin...
[ 218, 4 ]
[ 226, 26 ]
python
en
['en', 'error', 'th']
False
easy_install._fix_install_dir_for_user_site
(self)
Fix the install_dir if "--user" was used.
Fix the install_dir if "--user" was used.
def _fix_install_dir_for_user_site(self): """ Fix the install_dir if "--user" was used. """ if not self.user or not site.ENABLE_USER_SITE: return self.create_home_path() if self.install_userbase is None: msg = "User base directory is not specified...
[ "def", "_fix_install_dir_for_user_site", "(", "self", ")", ":", "if", "not", "self", ".", "user", "or", "not", "site", ".", "ENABLE_USER_SITE", ":", "return", "self", ".", "create_home_path", "(", ")", "if", "self", ".", "install_userbase", "is", "None", ":"...
[ 355, 4 ]
[ 368, 39 ]
python
en
['en', 'error', 'th']
False
easy_install.expand_basedirs
(self)
Calls `os.path.expanduser` on install_base, install_platbase and root.
Calls `os.path.expanduser` on install_base, install_platbase and root.
def expand_basedirs(self): """Calls `os.path.expanduser` on install_base, install_platbase and root.""" self._expand_attrs(['install_base', 'install_platbase', 'root'])
[ "def", "expand_basedirs", "(", "self", ")", ":", "self", ".", "_expand_attrs", "(", "[", "'install_base'", ",", "'install_platbase'", ",", "'root'", "]", ")" ]
[ 379, 4 ]
[ 382, 72 ]
python
en
['en', 'en', 'en']
True
easy_install.expand_dirs
(self)
Calls `os.path.expanduser` on install dirs.
Calls `os.path.expanduser` on install dirs.
def expand_dirs(self): """Calls `os.path.expanduser` on install dirs.""" dirs = [ 'install_purelib', 'install_platlib', 'install_lib', 'install_headers', 'install_scripts', 'install_data', ] self._expand_attrs(dirs)
[ "def", "expand_dirs", "(", "self", ")", ":", "dirs", "=", "[", "'install_purelib'", ",", "'install_platlib'", ",", "'install_lib'", ",", "'install_headers'", ",", "'install_scripts'", ",", "'install_data'", ",", "]", "self", ".", "_expand_attrs", "(", "dirs", ")...
[ 384, 4 ]
[ 394, 32 ]
python
en
['en', 'en', 'en']
True
easy_install.pseudo_tempname
(self)
Return a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo.
Return a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo.
def pseudo_tempname(self): """Return a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo. """ try: pid = os.getpid() except Exception: ...
[ "def", "pseudo_tempname", "(", "self", ")", ":", "try", ":", "pid", "=", "os", ".", "getpid", "(", ")", "except", "Exception", ":", "pid", "=", "random", ".", "randint", "(", "0", ",", "sys", ".", "maxsize", ")", "return", "os", ".", "path", ".", ...
[ 425, 4 ]
[ 434, 75 ]
python
en
['en', 'en', 'en']
True
easy_install.check_site_dir
(self)
Verify that self.install_dir is .pth-capable dir, if needed
Verify that self.install_dir is .pth-capable dir, if needed
def check_site_dir(self): """Verify that self.install_dir is .pth-capable dir, if needed""" instdir = normalize_path(self.install_dir) pth_file = os.path.join(instdir, 'easy-install.pth') if not os.path.exists(instdir): try: os.makedirs(instdir) ...
[ "def", "check_site_dir", "(", "self", ")", ":", "instdir", "=", "normalize_path", "(", "self", ".", "install_dir", ")", "pth_file", "=", "os", ".", "path", ".", "join", "(", "instdir", ",", "'easy-install.pth'", ")", "if", "not", "os", ".", "path", ".", ...
[ 439, 4 ]
[ 482, 34 ]
python
en
['en', 'en', 'en']
True
easy_install.check_pth_processing
(self)
Empirically verify whether .pth files are supported in inst. dir
Empirically verify whether .pth files are supported in inst. dir
def check_pth_processing(self): """Empirically verify whether .pth files are supported in inst. dir""" instdir = self.install_dir log.info("Checking .pth file support in %s", instdir) pth_file = self.pseudo_tempname() + ".pth" ok_file = pth_file + '.ok' ok_exists = os.pat...
[ "def", "check_pth_processing", "(", "self", ")", ":", "instdir", "=", "self", ".", "install_dir", "log", ".", "info", "(", "\"Checking .pth file support in %s\"", ",", "instdir", ")", "pth_file", "=", "self", ".", "pseudo_tempname", "(", ")", "+", "\".pth\"", ...
[ 529, 4 ]
[ 586, 20 ]
python
en
['en', 'en', 'en']
True
easy_install.install_egg_scripts
(self, dist)
Write all the scripts for `dist`, unless scripts are excluded
Write all the scripts for `dist`, unless scripts are excluded
def install_egg_scripts(self, dist): """Write all the scripts for `dist`, unless scripts are excluded""" if not self.exclude_scripts and dist.metadata_isdir('scripts'): for script_name in dist.metadata_listdir('scripts'): if dist.metadata_isdir('scripts/' + script_name): ...
[ "def", "install_egg_scripts", "(", "self", ",", "dist", ")", ":", "if", "not", "self", ".", "exclude_scripts", "and", "dist", ".", "metadata_isdir", "(", "'scripts'", ")", ":", "for", "script_name", "in", "dist", ".", "metadata_listdir", "(", "'scripts'", ")...
[ 588, 4 ]
[ 600, 42 ]
python
en
['en', 'en', 'en']
True
easy_install.select_scheme
(self, name)
Sets the install directories by applying the install schemes.
Sets the install directories by applying the install schemes.
def select_scheme(self, name): """Sets the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! scheme = INSTALL_SCHEMES[name] for key in SCHEME_KEYS: attrname = 'install_' + key if getattr(self, attrname) ...
[ "def", "select_scheme", "(", "self", ",", "name", ")", ":", "# it's the caller's problem if they supply a bad name!", "scheme", "=", "INSTALL_SCHEMES", "[", "name", "]", "for", "key", "in", "SCHEME_KEYS", ":", "attrname", "=", "'install_'", "+", "key", "if", "geta...
[ 706, 4 ]
[ 713, 52 ]
python
en
['en', 'en', 'en']
True
easy_install.install_script
(self, dist, script_name, script_text, dev_path=None)
Generate a legacy script wrapper and install it
Generate a legacy script wrapper and install it
def install_script(self, dist, script_name, script_text, dev_path=None): """Generate a legacy script wrapper and install it""" spec = str(dist.as_requirement()) is_script = is_python_script(script_text, script_name) if is_script: body = self._load_template(dev_path) % locals...
[ "def", "install_script", "(", "self", ",", "dist", ",", "script_name", ",", "script_text", ",", "dev_path", "=", "None", ")", ":", "spec", "=", "str", "(", "dist", ".", "as_requirement", "(", ")", ")", "is_script", "=", "is_python_script", "(", "script_tex...
[ 792, 4 ]
[ 800, 67 ]
python
en
['en', 'en', 'en']
True
easy_install._load_template
(dev_path)
There are a couple of template scripts in the package. This function loads one of them and prepares it for use.
There are a couple of template scripts in the package. This function loads one of them and prepares it for use.
def _load_template(dev_path): """ There are a couple of template scripts in the package. This function loads one of them and prepares it for use. """ # See https://github.com/pypa/setuptools/issues/134 for info # on script file naming and downstream issues with SVR4 ...
[ "def", "_load_template", "(", "dev_path", ")", ":", "# See https://github.com/pypa/setuptools/issues/134 for info", "# on script file naming and downstream issues with SVR4", "name", "=", "'script.tmpl'", "if", "dev_path", ":", "name", "=", "name", ".", "replace", "(", "'.tmp...
[ 803, 4 ]
[ 815, 40 ]
python
en
['en', 'error', 'th']
False
easy_install.write_script
(self, script_name, contents, mode="t", blockers=())
Write an executable file to the scripts directory
Write an executable file to the scripts directory
def write_script(self, script_name, contents, mode="t", blockers=()): """Write an executable file to the scripts directory""" self.delete_blockers( # clean up old .py/.pyw w/o a script [os.path.join(self.script_dir, x) for x in blockers] ) log.info("Installing %s script to %...
[ "def", "write_script", "(", "self", ",", "script_name", ",", "contents", ",", "mode", "=", "\"t\"", ",", "blockers", "=", "(", ")", ")", ":", "self", ".", "delete_blockers", "(", "# clean up old .py/.pyw w/o a script", "[", "os", ".", "path", ".", "join", ...
[ 817, 4 ]
[ 835, 35 ]
python
en
['en', 'en', 'en']
True
easy_install.exe_to_egg
(self, dist_filename, egg_tmp)
Extract a bdist_wininst to the directories an egg would use
Extract a bdist_wininst to the directories an egg would use
def exe_to_egg(self, dist_filename, egg_tmp): """Extract a bdist_wininst to the directories an egg would use""" # Check for .pth file and set up prefix translations prefixes = get_exe_prefixes(dist_filename) to_compile = [] native_libs = [] top_level = {} def pro...
[ "def", "exe_to_egg", "(", "self", ",", "dist_filename", ",", "egg_tmp", ")", ":", "# Check for .pth file and set up prefix translations", "prefixes", "=", "get_exe_prefixes", "(", "dist_filename", ")", "to_compile", "=", "[", "]", "native_libs", "=", "[", "]", "top_...
[ 988, 4 ]
[ 1039, 29 ]
python
en
['en', 'en', 'en']
True
easy_install.installation_report
(self, req, dist, what="Installed")
Helpful installation message for display to package users
Helpful installation message for display to package users
def installation_report(self, req, dist, what="Installed"): """Helpful installation message for display to package users""" msg = "\n%(what)s %(eggloc)s%(extras)s" if self.multi_version and not self.no_report: msg += '\n' + self.__mv_warning if self.install_dir not in map...
[ "def", "installation_report", "(", "self", ",", "req", ",", "dist", ",", "what", "=", "\"Installed\"", ")", ":", "msg", "=", "\"\\n%(what)s %(eggloc)s%(extras)s\"", "if", "self", ".", "multi_version", "and", "not", "self", ".", "no_report", ":", "msg", "+=", ...
[ 1087, 4 ]
[ 1099, 29 ]
python
en
['en', 'en', 'en']
True
easy_install._set_fetcher_options
(self, base)
When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well.
When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well.
def _set_fetcher_options(self, base): """ When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well. ...
[ "def", "_set_fetcher_options", "(", "self", ",", "base", ")", ":", "# find the fetch options from easy_install and write them out", "# to the setup.cfg file.", "ei_opts", "=", "self", ".", "distribution", ".", "get_option_dict", "(", "'easy_install'", ")", ".", "copy", "(...
[ 1163, 4 ]
[ 1184, 50 ]
python
en
['en', 'error', 'th']
False
easy_install.create_home_path
(self)
Create directories under ~.
Create directories under ~.
def create_home_path(self): """Create directories under ~.""" if not self.user: return home = convert_path(os.path.expanduser("~")) for name, path in self.config_vars.items(): if path.startswith(home) and not os.path.isdir(path): self.debug_print("...
[ "def", "create_home_path", "(", "self", ")", ":", "if", "not", "self", ".", "user", ":", "return", "home", "=", "convert_path", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ")", "for", "name", ",", "path", "in", "self", ".", "config_...
[ 1298, 4 ]
[ 1306, 40 ]
python
de
['de', 'de', 'en']
True
PthDistributions.save
(self)
Write changed .pth file back to disk
Write changed .pth file back to disk
def save(self): """Write changed .pth file back to disk""" if not self.dirty: return rel_paths = list(map(self.make_relative, self.paths)) if rel_paths: log.debug("Saving %s", self.filename) lines = self._wrap_lines(rel_paths) data = '\n'....
[ "def", "save", "(", "self", ")", ":", "if", "not", "self", ".", "dirty", ":", "return", "rel_paths", "=", "list", "(", "map", "(", "self", ".", "make_relative", ",", "self", ".", "paths", ")", ")", "if", "rel_paths", ":", "log", ".", "debug", "(", ...
[ 1577, 4 ]
[ 1597, 26 ]
python
en
['en', 'en', 'en']
True
PthDistributions.add
(self, dist)
Add `dist` to the distribution map
Add `dist` to the distribution map
def add(self, dist): """Add `dist` to the distribution map""" new_path = ( dist.location not in self.paths and ( dist.location not in self.sitedirs or # account for '.' being in PYTHONPATH dist.location == os.getcwd() ) ) ...
[ "def", "add", "(", "self", ",", "dist", ")", ":", "new_path", "=", "(", "dist", ".", "location", "not", "in", "self", ".", "paths", "and", "(", "dist", ".", "location", "not", "in", "self", ".", "sitedirs", "or", "# account for '.' being in PYTHONPATH", ...
[ 1603, 4 ]
[ 1615, 35 ]
python
en
['en', 'en', 'en']
True
PthDistributions.remove
(self, dist)
Remove `dist` from the distribution map
Remove `dist` from the distribution map
def remove(self, dist): """Remove `dist` from the distribution map""" while dist.location in self.paths: self.paths.remove(dist.location) self.dirty = True Environment.remove(self, dist)
[ "def", "remove", "(", "self", ",", "dist", ")", ":", "while", "dist", ".", "location", "in", "self", ".", "paths", ":", "self", ".", "paths", ".", "remove", "(", "dist", ".", "location", ")", "self", ".", "dirty", "=", "True", "Environment", ".", "...
[ 1617, 4 ]
[ 1622, 38 ]
python
en
['en', 'en', 'en']
True
CommandSpec.best
(cls)
Choose the best CommandSpec class based on environmental conditions.
Choose the best CommandSpec class based on environmental conditions.
def best(cls): """ Choose the best CommandSpec class based on environmental conditions. """ return cls
[ "def", "best", "(", "cls", ")", ":", "return", "cls" ]
[ 1931, 4 ]
[ 1935, 18 ]
python
en
['en', 'error', 'th']
False
CommandSpec.from_param
(cls, param)
Construct a CommandSpec from a parameter to build_scripts, which may be None.
Construct a CommandSpec from a parameter to build_scripts, which may be None.
def from_param(cls, param): """ Construct a CommandSpec from a parameter to build_scripts, which may be None. """ if isinstance(param, cls): return param if isinstance(param, list): return cls(param) if param is None: return cls...
[ "def", "from_param", "(", "cls", ",", "param", ")", ":", "if", "isinstance", "(", "param", ",", "cls", ")", ":", "return", "param", "if", "isinstance", "(", "param", ",", "list", ")", ":", "return", "cls", "(", "param", ")", "if", "param", "is", "N...
[ 1943, 4 ]
[ 1955, 37 ]
python
en
['en', 'error', 'th']
False
CommandSpec.from_string
(cls, string)
Construct a command spec from a simple string representing a command line parseable by shlex.split.
Construct a command spec from a simple string representing a command line parseable by shlex.split.
def from_string(cls, string): """ Construct a command spec from a simple string representing a command line parseable by shlex.split. """ items = shlex.split(string, **cls.split_args) return cls(items)
[ "def", "from_string", "(", "cls", ",", "string", ")", ":", "items", "=", "shlex", ".", "split", "(", "string", ",", "*", "*", "cls", ".", "split_args", ")", "return", "cls", "(", "items", ")" ]
[ 1962, 4 ]
[ 1968, 25 ]
python
en
['en', 'error', 'th']
False
CommandSpec._extract_options
(orig_script)
Extract any options from the first line of the script.
Extract any options from the first line of the script.
def _extract_options(orig_script): """ Extract any options from the first line of the script. """ first = (orig_script + '\n').splitlines()[0] match = _first_line_re().match(first) options = match.group(1) or '' if match else '' return options.strip()
[ "def", "_extract_options", "(", "orig_script", ")", ":", "first", "=", "(", "orig_script", "+", "'\\n'", ")", ".", "splitlines", "(", ")", "[", "0", "]", "match", "=", "_first_line_re", "(", ")", ".", "match", "(", "first", ")", "options", "=", "match"...
[ 1977, 4 ]
[ 1984, 30 ]
python
en
['en', 'error', 'th']
False
ScriptWriter.get_args
(cls, dist, header=None)
Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points.
Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points.
def get_args(cls, dist, header=None): """ Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. """ if header is None: header = cls.get_header() spec = str(dist.as_requirement()) for type_ in 'console',...
[ "def", "get_args", "(", "cls", ",", "dist", ",", "header", "=", "None", ")", ":", "if", "header", "is", "None", ":", "header", "=", "cls", ".", "get_header", "(", ")", "spec", "=", "str", "(", "dist", ".", "as_requirement", "(", ")", ")", "for", ...
[ 2073, 4 ]
[ 2088, 29 ]
python
en
['en', 'error', 'th']
False
ScriptWriter._ensure_safe_name
(name)
Prevent paths in *_scripts entry point names.
Prevent paths in *_scripts entry point names.
def _ensure_safe_name(name): """ Prevent paths in *_scripts entry point names. """ has_path_sep = re.search(r'[\\/]', name) if has_path_sep: raise ValueError("Path separators not allowed in script names")
[ "def", "_ensure_safe_name", "(", "name", ")", ":", "has_path_sep", "=", "re", ".", "search", "(", "r'[\\\\/]'", ",", "name", ")", "if", "has_path_sep", ":", "raise", "ValueError", "(", "\"Path separators not allowed in script names\"", ")" ]
[ 2091, 4 ]
[ 2097, 75 ]
python
en
['en', 'error', 'th']
False
ScriptWriter.best
(cls)
Select the best ScriptWriter for this environment.
Select the best ScriptWriter for this environment.
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
[ "def", "best", "(", "cls", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", "or", "(", "os", ".", "name", "==", "'java'", "and", "os", ".", "_name", "==", "'nt'", ")", ":", "return", "WindowsScriptWriter", ".", "best", "(", ")", "else", ":"...
[ 2106, 4 ]
[ 2113, 22 ]
python
en
['en', 'error', 'th']
False
ScriptWriter.get_header
(cls, script_text="", executable=None)
Create a #! line, getting options (if any) from script_text
Create a #! line, getting options (if any) from script_text
def get_header(cls, script_text="", executable=None): """Create a #! line, getting options (if any) from script_text""" cmd = cls.command_spec_class.best().from_param(executable) cmd.install_options(script_text) return cmd.as_header()
[ "def", "get_header", "(", "cls", ",", "script_text", "=", "\"\"", ",", "executable", "=", "None", ")", ":", "cmd", "=", "cls", ".", "command_spec_class", ".", "best", "(", ")", ".", "from_param", "(", "executable", ")", "cmd", ".", "install_options", "("...
[ 2121, 4 ]
[ 2125, 30 ]
python
en
['en', 'en', 'en']
True
WindowsScriptWriter.best
(cls)
Select the best ScriptWriter suitable for Windows
Select the best ScriptWriter suitable for Windows
def best(cls): """ Select the best ScriptWriter suitable for Windows """ writer_lookup = dict( executable=WindowsExecutableLauncherWriter, natural=cls, ) # for compatibility, use the executable launcher by default launcher = os.environ.get(...
[ "def", "best", "(", "cls", ")", ":", "writer_lookup", "=", "dict", "(", "executable", "=", "WindowsExecutableLauncherWriter", ",", "natural", "=", "cls", ",", ")", "# for compatibility, use the executable launcher by default", "launcher", "=", "os", ".", "environ", ...
[ 2138, 4 ]
[ 2148, 38 ]
python
en
['en', 'error', 'th']
False
WindowsScriptWriter._get_script_args
(cls, type_, name, header, script_text)
For Windows, add a .py extension
For Windows, add a .py extension
def _get_script_args(cls, type_, name, header, script_text): "For Windows, add a .py extension" ext = dict(console='.pya', gui='.pyw')[type_] if ext not in os.environ['PATHEXT'].lower().split(';'): msg = ( "{ext} not listed in PATHEXT; scripts will not be " ...
[ "def", "_get_script_args", "(", "cls", ",", "type_", ",", "name", ",", "header", ",", "script_text", ")", ":", "ext", "=", "dict", "(", "console", "=", "'.pya'", ",", "gui", "=", "'.pyw'", ")", "[", "type_", "]", "if", "ext", "not", "in", "os", "."...
[ 2151, 4 ]
[ 2164, 61 ]
python
en
['en', 'en', 'en']
True
WindowsScriptWriter._adjust_header
(cls, type_, orig_header)
Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is).
Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is).
def _adjust_header(cls, type_, orig_header): """ Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). """ pattern = 'pythonw.exe' repl = 'python.exe' if type_ == 'gui': pattern, repl = repl, p...
[ "def", "_adjust_header", "(", "cls", ",", "type_", ",", "orig_header", ")", ":", "pattern", "=", "'pythonw.exe'", "repl", "=", "'python.exe'", "if", "type_", "==", "'gui'", ":", "pattern", ",", "repl", "=", "repl", ",", "pattern", "pattern_ob", "=", "re", ...
[ 2167, 4 ]
[ 2178, 73 ]
python
en
['en', 'error', 'th']
False
WindowsScriptWriter._use_header
(new_header)
Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system.
Should _adjust_header use the replaced header?
def _use_header(new_header): """ Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. """ clean_header = new_header[2:-1].strip('"') ...
[ "def", "_use_header", "(", "new_header", ")", ":", "clean_header", "=", "new_header", "[", "2", ":", "-", "1", "]", ".", "strip", "(", "'\"'", ")", "return", "sys", ".", "platform", "!=", "'win32'", "or", "find_executable", "(", "clean_header", ")" ]
[ 2181, 4 ]
[ 2190, 71 ]
python
en
['en', 'error', 'th']
False
WindowsExecutableLauncherWriter._get_script_args
(cls, type_, name, header, script_text)
For Windows, add a .py extension and an .exe launcher
For Windows, add a .py extension and an .exe launcher
def _get_script_args(cls, type_, name, header, script_text): """ For Windows, add a .py extension and an .exe launcher """ if type_ == 'gui': launcher_type = 'gui' ext = '-script.pyw' old = ['.pyw'] else: launcher_type = 'cli' ...
[ "def", "_get_script_args", "(", "cls", ",", "type_", ",", "name", ",", "header", ",", "script_text", ")", ":", "if", "type_", "==", "'gui'", ":", "launcher_type", "=", "'gui'", "ext", "=", "'-script.pyw'", "old", "=", "[", "'.pyw'", "]", "else", ":", "...
[ 2195, 4 ]
[ 2221, 61 ]
python
en
['en', 'error', 'th']
False
setup
(set_prefix=True)
Configure the settings (this happens as a side effect of accessing the first setting), configure logging and populate the app registry. Set the thread-local urlresolvers script prefix if `set_prefix` is True.
Configure the settings (this happens as a side effect of accessing the first setting), configure logging and populate the app registry. Set the thread-local urlresolvers script prefix if `set_prefix` is True.
def setup(set_prefix=True): """ Configure the settings (this happens as a side effect of accessing the first setting), configure logging and populate the app registry. Set the thread-local urlresolvers script prefix if `set_prefix` is True. """ from django.apps import apps from django.conf i...
[ "def", "setup", "(", "set_prefix", "=", "True", ")", ":", "from", "django", ".", "apps", "import", "apps", "from", "django", ".", "conf", "import", "settings", "from", "django", ".", "urls", "import", "set_script_prefix", "from", "django", ".", "utils", "....
[ 9, 0 ]
[ 26, 42 ]
python
en
['en', 'error', 'th']
False
get_chooser_js_data
()
construct context variables needed by the chooser JS
construct context variables needed by the chooser JS
def get_chooser_js_data(): """construct context variables needed by the chooser JS""" return { 'step': 'chooser', 'error_label': _("Server Error"), 'error_message': _("Report this error to your webmaster with the following information:"), 'tag_autocomplete_url': reverse('wagtaila...
[ "def", "get_chooser_js_data", "(", ")", ":", "return", "{", "'step'", ":", "'chooser'", ",", "'error_label'", ":", "_", "(", "\"Server Error\"", ")", ",", "'error_message'", ":", "_", "(", "\"Report this error to your webmaster with the following information:\"", ")", ...
[ 24, 0 ]
[ 31, 5 ]
python
en
['en', 'en', 'en']
True
get_image_result_data
(image)
helper function: given an image, return the json data to pass back to the image chooser panel
helper function: given an image, return the json data to pass back to the image chooser panel
def get_image_result_data(image): """ helper function: given an image, return the json data to pass back to the image chooser panel """ preview_image = image.get_rendition('max-165x165') return { 'id': image.id, 'edit_link': reverse('wagtailimages:edit', args=(image.id,)), ...
[ "def", "get_image_result_data", "(", "image", ")", ":", "preview_image", "=", "image", ".", "get_rendition", "(", "'max-165x165'", ")", "return", "{", "'id'", ":", "image", ".", "id", ",", "'edit_link'", ":", "reverse", "(", "'wagtailimages:edit'", ",", "args"...
[ 34, 0 ]
[ 50, 5 ]
python
en
['en', 'error', 'th']
False
get_chooser_context
(request)
Helper function to return common template context variables for the main chooser view
Helper function to return common template context variables for the main chooser view
def get_chooser_context(request): """Helper function to return common template context variables for the main chooser view""" collections = permission_policy.collections_user_has_permission_for( request.user, 'choose' ) if len(collections) < 2: collections = None return { '...
[ "def", "get_chooser_context", "(", "request", ")", ":", "collections", "=", "permission_policy", ".", "collections_user_has_permission_for", "(", "request", ".", "user", ",", "'choose'", ")", "if", "len", "(", "collections", ")", "<", "2", ":", "collections", "=...
[ 53, 0 ]
[ 69, 5 ]
python
en
['en', 'en', 'en']
True
RequestException.__init__
(self, *args, **kwargs)
Initialize RequestException with `request` and `response` objects.
Initialize RequestException with `request` and `response` objects.
def __init__(self, *args, **kwargs): """Initialize RequestException with `request` and `response` objects.""" response = kwargs.pop('response', None) self.response = response self.request = kwargs.pop('request', None) if (response is not None and not self.request and ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "kwargs", ".", "pop", "(", "'response'", ",", "None", ")", "self", ".", "response", "=", "response", "self", ".", "request", "=", "kwargs", ".", "...
[ 16, 4 ]
[ 24, 63 ]
python
en
['en', 'en', 'en']
True
_check_link_requires_python
( link, # type: Link version_info, # type: Tuple[int, int, int] ignore_requires_python=False, # type: bool )
Return whether the given Python version is compatible with a link's "Requires-Python" value. :param version_info: A 3-tuple of ints representing the Python major-minor-micro version to check. :param ignore_requires_python: Whether to ignore the "Requires-Python" value if the given Pyth...
Return whether the given Python version is compatible with a link's "Requires-Python" value.
def _check_link_requires_python( link, # type: Link version_info, # type: Tuple[int, int, int] ignore_requires_python=False, # type: bool ): # type: (...) -> bool """ Return whether the given Python version is compatible with a link's "Requires-Python" value. :param version_info: A 3...
[ "def", "_check_link_requires_python", "(", "link", ",", "# type: Link", "version_info", ",", "# type: Tuple[int, int, int]", "ignore_requires_python", "=", "False", ",", "# type: bool", ")", ":", "# type: (...) -> bool", "try", ":", "is_compatible", "=", "check_requires_pyt...
[ 59, 0 ]
[ 99, 15 ]
python
en
['en', 'error', 'th']
False
filter_unallowed_hashes
( candidates, # type: List[InstallationCandidate] hashes, # type: Hashes project_name, # type: str )
Filter out candidates whose hashes aren't allowed, and return a new list of candidates. If at least one candidate has an allowed hash, then all candidates with either an allowed hash or no hash specified are returned. Otherwise, the given candidates are returned. Including the candidates wit...
Filter out candidates whose hashes aren't allowed, and return a new list of candidates.
def filter_unallowed_hashes( candidates, # type: List[InstallationCandidate] hashes, # type: Hashes project_name, # type: str ): # type: (...) -> List[InstallationCandidate] """ Filter out candidates whose hashes aren't allowed, and return a new list of candidates. If at leas...
[ "def", "filter_unallowed_hashes", "(", "candidates", ",", "# type: List[InstallationCandidate]", "hashes", ",", "# type: Hashes", "project_name", ",", "# type: str", ")", ":", "# type: (...) -> List[InstallationCandidate]", "if", "not", "hashes", ":", "logger", ".", "debug"...
[ 243, 0 ]
[ 315, 19 ]
python
en
['en', 'error', 'th']
False
_find_name_version_sep
(fragment, canonical_name)
Find the separator's index based on the package's canonical name. :param fragment: A <package>+<version> filename "fragment" (stem) or egg fragment. :param canonical_name: The package's canonical name. This function is needed since the canonicalized name does not necessarily have the same leng...
Find the separator's index based on the package's canonical name.
def _find_name_version_sep(fragment, canonical_name): # type: (str, str) -> int """Find the separator's index based on the package's canonical name. :param fragment: A <package>+<version> filename "fragment" (stem) or egg fragment. :param canonical_name: The package's canonical name. This ...
[ "def", "_find_name_version_sep", "(", "fragment", ",", "canonical_name", ")", ":", "# type: (str, str) -> int", "# Project name and version must be separated by one single dash. Find all", "# occurrences of dashes; if the string in front of it matches the canonical", "# name, this is the one s...
[ 971, 0 ]
[ 995, 77 ]
python
en
['en', 'en', 'en']
True
_extract_version_from_fragment
(fragment, canonical_name)
Parse the version string from a <package>+<version> filename "fragment" (stem) or egg fragment. :param fragment: The string to parse. E.g. foo-2.1 :param canonical_name: The canonicalized name of the package this belongs to.
Parse the version string from a <package>+<version> filename "fragment" (stem) or egg fragment.
def _extract_version_from_fragment(fragment, canonical_name): # type: (str, str) -> Optional[str] """Parse the version string from a <package>+<version> filename "fragment" (stem) or egg fragment. :param fragment: The string to parse. E.g. foo-2.1 :param canonical_name: The canonicalized name of th...
[ "def", "_extract_version_from_fragment", "(", "fragment", ",", "canonical_name", ")", ":", "# type: (str, str) -> Optional[str]", "try", ":", "version_start", "=", "_find_name_version_sep", "(", "fragment", ",", "canonical_name", ")", "+", "1", "except", "ValueError", "...
[ 998, 0 ]
[ 1014, 18 ]
python
en
['en', 'en', 'en']
True
LinkEvaluator.__init__
( self, project_name, # type: str canonical_name, # type: str formats, # type: FrozenSet[str] target_python, # type: TargetPython allow_yanked, # type: bool ignore_requires_python=None, # type: Optional[bool] )
:param project_name: The user supplied package name. :param canonical_name: The canonical package name. :param formats: The formats allowed for this package. Should be a set with 'binary' or 'source' or both in it. :param target_python: The target Python interpreter to use w...
:param project_name: The user supplied package name. :param canonical_name: The canonical package name. :param formats: The formats allowed for this package. Should be a set with 'binary' or 'source' or both in it. :param target_python: The target Python interpreter to use w...
def __init__( self, project_name, # type: str canonical_name, # type: str formats, # type: FrozenSet[str] target_python, # type: TargetPython allow_yanked, # type: bool ignore_requires_python=None, # type: Optional[bool] ): # type: (....
[ "def", "__init__", "(", "self", ",", "project_name", ",", "# type: str", "canonical_name", ",", "# type: str", "formats", ",", "# type: FrozenSet[str]", "target_python", ",", "# type: TargetPython", "allow_yanked", ",", "# type: bool", "ignore_requires_python", "=", "None...
[ 114, 4 ]
[ 150, 40 ]
python
en
['en', 'error', 'th']
False
LinkEvaluator.evaluate_link
(self, link)
Determine whether a link is a candidate for installation. :return: A tuple (is_candidate, result), where `result` is (1) a version string if `is_candidate` is True, and (2) if `is_candidate` is False, an optional string to log the reason the link fails to qualify. ...
Determine whether a link is a candidate for installation.
def evaluate_link(self, link): # type: (Link) -> Tuple[bool, Optional[Text]] """ Determine whether a link is a candidate for installation. :return: A tuple (is_candidate, result), where `result` is (1) a version string if `is_candidate` is True, and (2) if `is_ca...
[ "def", "evaluate_link", "(", "self", ",", "link", ")", ":", "# type: (Link) -> Tuple[bool, Optional[Text]]", "version", "=", "None", "if", "link", ".", "is_yanked", "and", "not", "self", ".", "_allow_yanked", ":", "reason", "=", "link", ".", "yanked_reason", "or...
[ 152, 4 ]
[ 240, 30 ]
python
en
['en', 'error', 'th']
False
CandidatePreferences.__init__
( self, prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool )
:param allow_all_prereleases: Whether to allow all pre-releases.
:param allow_all_prereleases: Whether to allow all pre-releases.
def __init__( self, prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool ): # type: (...) -> None """ :param allow_all_prereleases: Whether to allow all pre-releases. """ self.allow_all_prereleases = allow_all_prereleases ...
[ "def", "__init__", "(", "self", ",", "prefer_binary", "=", "False", ",", "# type: bool", "allow_all_prereleases", "=", "False", ",", "# type: bool", ")", ":", "# type: (...) -> None", "self", ".", "allow_all_prereleases", "=", "allow_all_prereleases", "self", ".", "...
[ 325, 4 ]
[ 335, 42 ]
python
en
['en', 'error', 'th']
False
BestCandidateResult.__init__
( self, candidates, # type: List[InstallationCandidate] applicable_candidates, # type: List[InstallationCandidate] best_candidate, # type: Optional[InstallationCandidate] )
:param candidates: A sequence of all available candidates found. :param applicable_candidates: The applicable candidates. :param best_candidate: The most preferred candidate found, or None if no applicable candidates were found.
:param candidates: A sequence of all available candidates found. :param applicable_candidates: The applicable candidates. :param best_candidate: The most preferred candidate found, or None if no applicable candidates were found.
def __init__( self, candidates, # type: List[InstallationCandidate] applicable_candidates, # type: List[InstallationCandidate] best_candidate, # type: Optional[InstallationCandidate] ): # type: (...) -> None """ :param candidates: A sequen...
[ "def", "__init__", "(", "self", ",", "candidates", ",", "# type: List[InstallationCandidate]", "applicable_candidates", ",", "# type: List[InstallationCandidate]", "best_candidate", ",", "# type: Optional[InstallationCandidate]", ")", ":", "# type: (...) -> None", "assert", "set"...
[ 345, 4 ]
[ 368, 44 ]
python
en
['en', 'error', 'th']
False
BestCandidateResult.iter_all
(self)
Iterate through all candidates.
Iterate through all candidates.
def iter_all(self): # type: () -> Iterable[InstallationCandidate] """Iterate through all candidates. """ return iter(self._candidates)
[ "def", "iter_all", "(", "self", ")", ":", "# type: () -> Iterable[InstallationCandidate]", "return", "iter", "(", "self", ".", "_candidates", ")" ]
[ 370, 4 ]
[ 374, 37 ]
python
en
['en', 'en', 'en']
True
BestCandidateResult.iter_applicable
(self)
Iterate through the applicable candidates.
Iterate through the applicable candidates.
def iter_applicable(self): # type: () -> Iterable[InstallationCandidate] """Iterate through the applicable candidates. """ return iter(self._applicable_candidates)
[ "def", "iter_applicable", "(", "self", ")", ":", "# type: () -> Iterable[InstallationCandidate]", "return", "iter", "(", "self", ".", "_applicable_candidates", ")" ]
[ 376, 4 ]
[ 380, 48 ]
python
en
['en', 'en', 'en']
True
CandidateEvaluator.create
( cls, project_name, # type: str target_python=None, # type: Optional[TargetPython] prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # typ...
Create a CandidateEvaluator object. :param target_python: The target Python interpreter to use when checking compatibility. If None (the default), a TargetPython object will be constructed from the running Python. :param specifier: An optional object implementing `filter` ...
Create a CandidateEvaluator object.
def create( cls, project_name, # type: str target_python=None, # type: Optional[TargetPython] prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, ...
[ "def", "create", "(", "cls", ",", "project_name", ",", "# type: str", "target_python", "=", "None", ",", "# type: Optional[TargetPython]", "prefer_binary", "=", "False", ",", "# type: bool", "allow_all_prereleases", "=", "False", ",", "# type: bool", "specifier", "=",...
[ 391, 4 ]
[ 425, 9 ]
python
en
['pt', 'en', 'en']
True
CandidateEvaluator.__init__
( self, project_name, # type: str supported_tags, # type: List[Tag] specifier, # type: specifiers.BaseSpecifier prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool hashes=None, # type: Optional[Ha...
:param supported_tags: The PEP 425 tags supported by the target Python in order of preference (most preferred first).
:param supported_tags: The PEP 425 tags supported by the target Python in order of preference (most preferred first).
def __init__( self, project_name, # type: str supported_tags, # type: List[Tag] specifier, # type: specifiers.BaseSpecifier prefer_binary=False, # type: bool allow_all_prereleases=False, # type: bool hashes=None, # type:...
[ "def", "__init__", "(", "self", ",", "project_name", ",", "# type: str", "supported_tags", ",", "# type: List[Tag]", "specifier", ",", "# type: specifiers.BaseSpecifier", "prefer_binary", "=", "False", ",", "# type: bool", "allow_all_prereleases", "=", "False", ",", "# ...
[ 427, 4 ]
[ 446, 45 ]
python
en
['en', 'error', 'th']
False
CandidateEvaluator.get_applicable_candidates
( self, candidates, # type: List[InstallationCandidate] )
Return the applicable candidates from a list of candidates.
Return the applicable candidates from a list of candidates.
def get_applicable_candidates( self, candidates, # type: List[InstallationCandidate] ): # type: (...) -> List[InstallationCandidate] """ Return the applicable candidates from a list of candidates. """ # Using None infers from the specifier instead. al...
[ "def", "get_applicable_candidates", "(", "self", ",", "candidates", ",", "# type: List[InstallationCandidate]", ")", ":", "# type: (...) -> List[InstallationCandidate]", "# Using None infers from the specifier instead.", "allow_prereleases", "=", "self", ".", "_allow_all_prereleases"...
[ 448, 4 ]
[ 484, 73 ]
python
en
['en', 'error', 'th']
False
CandidateEvaluator._sort_key
(self, candidate)
Function to pass as the `key` argument to a call to sorted() to sort InstallationCandidates by preference. Returns a tuple such that tuples sorting as greater using Python's default comparison operator are more preferred. The preference is as follows: First and foremo...
Function to pass as the `key` argument to a call to sorted() to sort InstallationCandidates by preference.
def _sort_key(self, candidate): # type: (InstallationCandidate) -> CandidateSortingKey """ Function to pass as the `key` argument to a call to sorted() to sort InstallationCandidates by preference. Returns a tuple such that tuples sorting as greater using Python's defaul...
[ "def", "_sort_key", "(", "self", ",", "candidate", ")", ":", "# type: (InstallationCandidate) -> CandidateSortingKey", "valid_tags", "=", "self", ".", "_supported_tags", "support_num", "=", "len", "(", "valid_tags", ")", "build_tag", "=", "(", ")", "# type: BuildTag",...
[ 486, 4 ]
[ 544, 9 ]
python
en
['en', 'error', 'th']
False
CandidateEvaluator.sort_best_candidate
( self, candidates, # type: List[InstallationCandidate] )
Return the best candidate per the instance's sort order, or None if no candidate is acceptable.
Return the best candidate per the instance's sort order, or None if no candidate is acceptable.
def sort_best_candidate( self, candidates, # type: List[InstallationCandidate] ): # type: (...) -> Optional[InstallationCandidate] """ Return the best candidate per the instance's sort order, or None if no candidate is acceptable. """ if not candida...
[ "def", "sort_best_candidate", "(", "self", ",", "candidates", ",", "# type: List[InstallationCandidate]", ")", ":", "# type: (...) -> Optional[InstallationCandidate]", "if", "not", "candidates", ":", "return", "None", "best_candidate", "=", "max", "(", "candidates", ",", ...
[ 546, 4 ]
[ 558, 29 ]
python
en
['en', 'error', 'th']
False
CandidateEvaluator.compute_best_candidate
( self, candidates, # type: List[InstallationCandidate] )
Compute and return a `BestCandidateResult` instance.
Compute and return a `BestCandidateResult` instance.
def compute_best_candidate( self, candidates, # type: List[InstallationCandidate] ): # type: (...) -> BestCandidateResult """ Compute and return a `BestCandidateResult` instance. """ applicable_candidates = self.get_applicable_candidates(candidates) ...
[ "def", "compute_best_candidate", "(", "self", ",", "candidates", ",", "# type: List[InstallationCandidate]", ")", ":", "# type: (...) -> BestCandidateResult", "applicable_candidates", "=", "self", ".", "get_applicable_candidates", "(", "candidates", ")", "best_candidate", "="...
[ 560, 4 ]
[ 576, 9 ]
python
en
['en', 'error', 'th']
False
PackageFinder.__init__
( self, link_collector, # type: LinkCollector target_python, # type: TargetPython allow_yanked, # type: bool format_control=None, # type: Optional[FormatControl] candidate_prefs=None, # type: CandidatePreferences ignore_requires_pytho...
This constructor is primarily meant to be used by the create() class method and from tests. :param format_control: A FormatControl object, used to control the selection of source packages / binary packages when consulting the index and links. :param candidate_pr...
This constructor is primarily meant to be used by the create() class method and from tests.
def __init__( self, link_collector, # type: LinkCollector target_python, # type: TargetPython allow_yanked, # type: bool format_control=None, # type: Optional[FormatControl] candidate_prefs=None, # type: CandidatePreferences ignore_re...
[ "def", "__init__", "(", "self", ",", "link_collector", ",", "# type: LinkCollector", "target_python", ",", "# type: TargetPython", "allow_yanked", ",", "# type: bool", "format_control", "=", "None", ",", "# type: Optional[FormatControl]", "candidate_prefs", "=", "None", "...
[ 586, 4 ]
[ 620, 34 ]
python
en
['en', 'error', 'th']
False
PackageFinder.create
( cls, link_collector, # type: LinkCollector selection_prefs, # type: SelectionPreferences target_python=None, # type: Optional[TargetPython] )
Create a PackageFinder. :param selection_prefs: The candidate selection preferences, as a SelectionPreferences object. :param target_python: The target Python interpreter to use when checking compatibility. If None (the default), a TargetPython object will be constru...
Create a PackageFinder.
def create( cls, link_collector, # type: LinkCollector selection_prefs, # type: SelectionPreferences target_python=None, # type: Optional[TargetPython] ): # type: (...) -> PackageFinder """Create a PackageFinder. :param selection_prefs: The candidat...
[ "def", "create", "(", "cls", ",", "link_collector", ",", "# type: LinkCollector", "selection_prefs", ",", "# type: SelectionPreferences", "target_python", "=", "None", ",", "# type: Optional[TargetPython]", ")", ":", "# type: (...) -> PackageFinder", "if", "target_python", ...
[ 627, 4 ]
[ 657, 9 ]
python
en
['en', 'af', 'en']
True
PackageFinder._sort_links
(self, links)
Returns elements of links in order, non-egg links first, egg links second, while eliminating duplicates
Returns elements of links in order, non-egg links first, egg links second, while eliminating duplicates
def _sort_links(self, links): # type: (Iterable[Link]) -> List[Link] """ Returns elements of links in order, non-egg links first, egg links second, while eliminating duplicates """ eggs, no_eggs = [], [] seen = set() # type: Set[Link] for link in links: ...
[ "def", "_sort_links", "(", "self", ",", "links", ")", ":", "# type: (Iterable[Link]) -> List[Link]", "eggs", ",", "no_eggs", "=", "[", "]", ",", "[", "]", "seen", "=", "set", "(", ")", "# type: Set[Link]", "for", "link", "in", "links", ":", "if", "link", ...
[ 722, 4 ]
[ 737, 29 ]
python
en
['en', 'error', 'th']
False
PackageFinder.get_install_candidate
(self, link_evaluator, link)
If the link is a candidate for install, convert it to an InstallationCandidate and return it. Otherwise, return None.
If the link is a candidate for install, convert it to an InstallationCandidate and return it. Otherwise, return None.
def get_install_candidate(self, link_evaluator, link): # type: (LinkEvaluator, Link) -> Optional[InstallationCandidate] """ If the link is a candidate for install, convert it to an InstallationCandidate and return it. Otherwise, return None. """ is_candidate, result = lin...
[ "def", "get_install_candidate", "(", "self", ",", "link_evaluator", ",", "link", ")", ":", "# type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]", "is_candidate", ",", "result", "=", "link_evaluator", ".", "evaluate_link", "(", "link", ")", "if", "not", "is_...
[ 750, 4 ]
[ 768, 9 ]
python
en
['en', 'error', 'th']
False
PackageFinder.evaluate_links
(self, link_evaluator, links)
Convert links that are candidates to InstallationCandidate objects.
Convert links that are candidates to InstallationCandidate objects.
def evaluate_links(self, link_evaluator, links): # type: (LinkEvaluator, Iterable[Link]) -> List[InstallationCandidate] """ Convert links that are candidates to InstallationCandidate objects. """ candidates = [] for link in self._sort_links(links): candidate =...
[ "def", "evaluate_links", "(", "self", ",", "link_evaluator", ",", "links", ")", ":", "# type: (LinkEvaluator, Iterable[Link]) -> List[InstallationCandidate]", "candidates", "=", "[", "]", "for", "link", "in", "self", ".", "_sort_links", "(", "links", ")", ":", "cand...
[ 770, 4 ]
[ 781, 25 ]
python
en
['en', 'error', 'th']
False
PackageFinder.find_all_candidates
(self, project_name)
Find all available InstallationCandidate for project_name This checks index_urls and find_links. All versions found are returned as an InstallationCandidate list. See LinkEvaluator.evaluate_link() for details on which files are accepted.
Find all available InstallationCandidate for project_name
def find_all_candidates(self, project_name): # type: (str) -> List[InstallationCandidate] """Find all available InstallationCandidate for project_name This checks index_urls and find_links. All versions found are returned as an InstallationCandidate list. See LinkEvaluator.eval...
[ "def", "find_all_candidates", "(", "self", ",", "project_name", ")", ":", "# type: (str) -> List[InstallationCandidate]", "collected_links", "=", "self", ".", "_link_collector", ".", "collect_links", "(", "project_name", ")", "link_evaluator", "=", "self", ".", "make_li...
[ 803, 4 ]
[ 844, 66 ]
python
en
['en', 'en', 'en']
True
PackageFinder.make_candidate_evaluator
( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] )
Create a CandidateEvaluator object to use.
Create a CandidateEvaluator object to use.
def make_candidate_evaluator( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> CandidateEvaluator """Create a CandidateEvaluator object to use. """ ...
[ "def", "make_candidate_evaluator", "(", "self", ",", "project_name", ",", "# type: str", "specifier", "=", "None", ",", "# type: Optional[specifiers.BaseSpecifier]", "hashes", "=", "None", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> CandidateEvaluator", "ca...
[ 846, 4 ]
[ 863, 9 ]
python
en
['en', 'en', 'en']
True
PackageFinder.find_best_candidate
( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] )
Find matches for the given project and specifier. :param specifier: An optional object implementing `filter` (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable versions. :return: A `BestCandidateResult` instance.
Find matches for the given project and specifier.
def find_best_candidate( self, project_name, # type: str specifier=None, # type: Optional[specifiers.BaseSpecifier] hashes=None, # type: Optional[Hashes] ): # type: (...) -> BestCandidateResult """Find matches for the given project and specifier. ...
[ "def", "find_best_candidate", "(", "self", ",", "project_name", ",", "# type: str", "specifier", "=", "None", ",", "# type: Optional[specifiers.BaseSpecifier]", "hashes", "=", "None", ",", "# type: Optional[Hashes]", ")", ":", "# type: (...) -> BestCandidateResult", "candid...
[ 866, 4 ]
[ 887, 69 ]
python
en
['en', 'en', 'en']
True
PackageFinder.find_requirement
(self, req, upgrade)
Try to find a Link matching req Expects req, an InstallRequirement and upgrade, a boolean Returns a InstallationCandidate if found, Raises DistributionNotFound or BestVersionAlreadyInstalled otherwise
Try to find a Link matching req
def find_requirement(self, req, upgrade): # type: (InstallRequirement, bool) -> Optional[InstallationCandidate] """Try to find a Link matching req Expects req, an InstallRequirement and upgrade, a boolean Returns a InstallationCandidate if found, Raises DistributionNotFound or B...
[ "def", "find_requirement", "(", "self", ",", "req", ",", "upgrade", ")", ":", "# type: (InstallRequirement, bool) -> Optional[InstallationCandidate]", "hashes", "=", "req", ".", "hashes", "(", "trust_internet", "=", "False", ")", "best_candidate_result", "=", "self", ...
[ 889, 4 ]
[ 968, 29 ]
python
en
['en', 'en', 'en']
True
unpackb
(packed, **kwargs)
Unpack an object from `packed`. Raises ``ExtraData`` when *packed* contains extra bytes. Raises ``ValueError`` when *packed* is incomplete. Raises ``FormatError`` when *packed* is not valid msgpack. Raises ``StackError`` when *packed* contains too nested. Other exceptions can be raised during ...
Unpack an object from `packed`.
def unpackb(packed, **kwargs): """ Unpack an object from `packed`. Raises ``ExtraData`` when *packed* contains extra bytes. Raises ``ValueError`` when *packed* is incomplete. Raises ``FormatError`` when *packed* is not valid msgpack. Raises ``StackError`` when *packed* contains too nested. ...
[ "def", "unpackb", "(", "packed", ",", "*", "*", "kwargs", ")", ":", "unpacker", "=", "Unpacker", "(", "None", ",", "max_buffer_size", "=", "len", "(", "packed", ")", ",", "*", "*", "kwargs", ")", "unpacker", ".", "feed", "(", "packed", ")", "try", ...
[ 113, 0 ]
[ 137, 14 ]
python
en
['en', 'error', 'th']
False
Unpacker._consume
(self)
Gets rid of the used parts of the buffer.
Gets rid of the used parts of the buffer.
def _consume(self): """ Gets rid of the used parts of the buffer. """ self._stream_offset += self._buff_i - self._buf_checkpoint self._buf_checkpoint = self._buff_i
[ "def", "_consume", "(", "self", ")", ":", "self", ".", "_stream_offset", "+=", "self", ".", "_buff_i", "-", "self", ".", "_buf_checkpoint", "self", ".", "_buf_checkpoint", "=", "self", ".", "_buff_i" ]
[ 355, 4 ]
[ 358, 43 ]
python
en
['en', 'en', 'en']
True
Packer.bytes
(self)
Return internal buffer contents as bytes object
Return internal buffer contents as bytes object
def bytes(self): """Return internal buffer contents as bytes object""" return self._buffer.getvalue()
[ "def", "bytes", "(", "self", ")", ":", "return", "self", ".", "_buffer", ".", "getvalue", "(", ")" ]
[ 1046, 4 ]
[ 1048, 38 ]
python
en
['en', 'lb', 'en']
True
Packer.reset
(self)
Reset internal buffer. This method is useful only when autoreset=False.
Reset internal buffer.
def reset(self): """Reset internal buffer. This method is useful only when autoreset=False. """ self._buffer = StringIO()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_buffer", "=", "StringIO", "(", ")" ]
[ 1050, 4 ]
[ 1055, 33 ]
python
en
['en', 'lb', 'en']
True
Packer.getbuffer
(self)
Return view of internal buffer.
Return view of internal buffer.
def getbuffer(self): """Return view of internal buffer.""" if USING_STRINGBUILDER or PY2: return memoryview(self.bytes()) else: return self._buffer.getbuffer()
[ "def", "getbuffer", "(", "self", ")", ":", "if", "USING_STRINGBUILDER", "or", "PY2", ":", "return", "memoryview", "(", "self", ".", "bytes", "(", ")", ")", "else", ":", "return", "self", ".", "_buffer", ".", "getbuffer", "(", ")" ]
[ 1057, 4 ]
[ 1062, 43 ]
python
en
['en', 'lb', 'en']
True
test_create_project_copy_from
(run_module, admin_user, organization, silence_warning)
Test the copy_from functionality
Test the copy_from functionality
def test_create_project_copy_from(run_module, admin_user, organization, silence_warning): ''' Test the copy_from functionality''' result = run_module( 'project', dict(name='foo', organization=organization.name, scm_type='git', scm_url='https://foo.invalid', wait=False, scm_update_cache_timeout=5...
[ "def", "test_create_project_copy_from", "(", "run_module", ",", "admin_user", ",", "organization", ",", "silence_warning", ")", ":", "result", "=", "run_module", "(", "'project'", ",", "dict", "(", "name", "=", "'foo'", ",", "organization", "=", "organization", ...
[ 29, 0 ]
[ 49, 103 ]
python
en
['en', 'en', 'en']
True