Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def _process_download(self, url): if self.platform_check and self._is_platform_dependent(url): info = None else: info = self.convert_url_to_download_info(url, self.project_name) logger.debug('process_download: %s -> %s...
[ "\n See if an URL is a suitable download for a project.\n\n If it is, register information in the result dictionary (for\n _get_project) about the specific version it's for.\n\n Note that the return value isn't actually used other than as a boolean\n value.\n " ]
Please provide a description of the function:def _should_queue(self, link, referrer, rel): scheme, netloc, path, _, _, _ = urlparse(link) if path.endswith(self.source_extensions + self.binary_extensions + self.excluded_extensions): result = False eli...
[ "\n Determine whether a link URL from a referring page and with a\n particular \"rel\" attribute should be queued for scraping.\n " ]
Please provide a description of the function:def _fetch(self): while True: url = self._to_fetch.get() try: if url: page = self.get_page(url) if page is None: # e.g. after an error continue ...
[ "\n Get a URL to fetch from the work queue, get the HTML page, examine its\n links for download candidates and candidates for further scraping.\n\n This is a handy method to run in a thread.\n " ]
Please provide a description of the function:def get_distribution_names(self): result = set() page = self.get_page(self.base_url) if not page: raise DistlibException('Unable to get %s' % self.base_url) for match in self._distname_re.finditer(page.data): r...
[ "\n Return all the distribution names known to this locator.\n " ]
Please provide a description of the function:def get_distribution_names(self): result = set() for root, dirs, files in os.walk(self.base_dir): for fn in files: if self.should_include(fn, root): fn = os.path.join(root, fn) url =...
[ "\n Return all the distribution names known to this locator.\n " ]
Please provide a description of the function:def get_distribution_names(self): result = set() for locator in self.locators: try: result |= locator.get_distribution_names() except NotImplementedError: pass return result
[ "\n Return all the distribution names known to this locator.\n " ]
Please provide a description of the function:def add_distribution(self, dist): logger.debug('adding distribution %s', dist) name = dist.key self.dists_by_name[name] = dist self.dists[(name, dist.version)] = dist for p in dist.provides: name, version = parse_n...
[ "\n Add a distribution to the finder. This will update internal information\n about who provides what.\n :param dist: The distribution to add.\n " ]
Please provide a description of the function:def remove_distribution(self, dist): logger.debug('removing distribution %s', dist) name = dist.key del self.dists_by_name[name] del self.dists[(name, dist.version)] for p in dist.provides: name, version = parse_na...
[ "\n Remove a distribution from the finder. This will update internal\n information about who provides what.\n :param dist: The distribution to remove.\n " ]
Please provide a description of the function:def get_matcher(self, reqt): try: matcher = self.scheme.matcher(reqt) except UnsupportedVersionError: # pragma: no cover # XXX compat-mode if cannot read the version name = reqt.split()[0] matcher = se...
[ "\n Get a version matcher for a requirement.\n :param reqt: The requirement\n :type reqt: str\n :return: A version matcher (an instance of\n :class:`distlib.version.Matcher`).\n " ]
Please provide a description of the function:def find_providers(self, reqt): matcher = self.get_matcher(reqt) name = matcher.key # case-insensitive result = set() provided = self.provided if name in provided: for version, provider in provided[name]: ...
[ "\n Find the distributions which can fulfill a requirement.\n\n :param reqt: The requirement.\n :type reqt: str\n :return: A set of distribution which can fulfill the requirement.\n " ]
Please provide a description of the function:def try_to_replace(self, provider, other, problems): rlist = self.reqts[other] unmatched = set() for s in rlist: matcher = self.get_matcher(s) if not matcher.match(provider.version): unmatched.add(s) ...
[ "\n Attempt to replace one provider with another. This is typically used\n when resolving dependencies from multiple sources, e.g. A requires\n (B >= 1.0) while C requires (B >= 1.1).\n\n For successful replacement, ``provider`` must meet all the requirements\n which ``other`` ful...
Please provide a description of the function:def find(self, requirement, meta_extras=None, prereleases=False): self.provided = {} self.dists = {} self.dists_by_name = {} self.reqts = {} meta_extras = set(meta_extras or []) if ':*:' in meta_extras: m...
[ "\n Find a distribution and all distributions it depends on.\n\n :param requirement: The requirement specifying the distribution to\n find, or a Distribution instance.\n :param meta_extras: A list of meta extras such as :test:, :build: and\n ...
Please provide a description of the function:def _read_incoming(self): fileno = self.proc.stdout.fileno() while 1: buf = b'' try: buf = os.read(fileno, 1024) except OSError as e: self._log(e, 'read') if not buf: ...
[ "Run in a thread to move output from a pipe to a queue." ]
Please provide a description of the function:def send(self, s): '''Send data to the subprocess' stdin. Returns the number of bytes written. ''' s = self._coerce_send_string(s) self._log(s, 'send') b = self._encoder.encode(s, final=False) if PY3: retu...
[]
Please provide a description of the function:def sendline(self, s=''): '''Wraps send(), sending string ``s`` to child process, with os.linesep automatically appended. Returns number of bytes written. ''' n = self.send(s) return n + self.send(self.linesep)
[]
Please provide a description of the function:def wait(self): '''Wait for the subprocess to finish. Returns the exit code. ''' status = self.proc.wait() if status >= 0: self.exitstatus = status self.signalstatus = None else: self.exitst...
[]
Please provide a description of the function:def kill(self, sig): '''Sends a Unix signal to the subprocess. Use constants from the :mod:`signal` module to specify which signal. ''' if sys.platform == 'win32': if sig in [signal.SIGINT, signal.CTRL_C_EVENT]: si...
[]
Please provide a description of the function:def mkdir_p(*args, **kwargs): try: return os.mkdir(*args, **kwargs) except OSError as exc: if exc.errno != errno.EEXIST: raise
[ "Like `mkdir`, but does not raise an exception if the\n directory already exists.\n " ]
Please provide a description of the function:def with_pattern(pattern, regex_group_count=None): def decorator(func): func.pattern = pattern func.regex_group_count = regex_group_count return func return decorator
[ "Attach a regular expression pattern matcher to a custom type converter\n function.\n\n This annotates the type converter with the :attr:`pattern` attribute.\n\n EXAMPLE:\n >>> import parse\n >>> @parse.with_pattern(r\"\\d+\")\n ... def parse_number(text):\n ... return int(t...
Please provide a description of the function:def int_convert(base): '''Convert a string to an integer. The string may start with a sign. It may be of a base other than 10. If may start with a base indicator, 0#nnnn, which we assume should override the specified base. It may also have other n...
[]
Please provide a description of the function:def date_convert(string, match, ymd=None, mdy=None, dmy=None, d_m_y=None, hms=None, am=None, tz=None, mm=None, dd=None): '''Convert the incoming string containing some date / time info into a datetime instance. ''' groups = match.groups() time_onl...
[]
Please provide a description of the function:def extract_format(format, extra_types): '''Pull apart the format [[fill]align][0][width][.precision][type] ''' fill = align = None if format[0] in '<>=^': align = format[0] format = format[1:] elif len(format) > 1 and format[1] in '<>=^':...
[]
Please provide a description of the function:def parse(format, string, extra_types=None, evaluate_result=True, case_sensitive=False): '''Using "format" attempt to pull values from "string". The format must match the string contents exactly. If the value you're looking for is instead just a part of the stri...
[]
Please provide a description of the function:def search(format, string, pos=0, endpos=None, extra_types=None, evaluate_result=True, case_sensitive=False): '''Search "string" for the first occurrence of "format". The format may occur anywhere within the string. If instead you wish for the format to ...
[]
Please provide a description of the function:def parse(self, string, evaluate_result=True): '''Match my format to the string exactly. Return a Result or Match instance or None if there's no match. ''' m = self._match_re.match(string) if m is None: return None ...
[]
Please provide a description of the function:def search(self, string, pos=0, endpos=None, evaluate_result=True): '''Search the string for my format. Optionally start the search at "pos" character index and limit the search to a maximum index of endpos - equivalent to search(string[:endp...
[]
Please provide a description of the function:def findall(self, string, pos=0, endpos=None, extra_types=None, evaluate_result=True): '''Search "string" for all occurrences of "format". Optionally start the search at "pos" character index and limit the search to a maximum index of endpos - equiva...
[]
Please provide a description of the function:def evaluate_result(self, m): '''Generate a Result instance for the given regex match object''' # ok, figure the fixed fields we've pulled out and type convert them fixed_fields = list(m.groups()) for n in self._fixed_fields: if n ...
[]
Please provide a description of the function:def install( ctx, state, **kwargs ): from ..core import do_install retcode = do_install( dev=state.installstate.dev, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror, system=state.system, ...
[ "Installs provided packages and adds them to Pipfile, or (if no packages are given), installs all packages from Pipfile." ]
Please provide a description of the function:def uninstall( ctx, state, all_dev=False, all=False, **kwargs ): from ..core import do_uninstall retcode = do_uninstall( packages=state.installstate.packages, editable_packages=state.installstate.editables, three=state...
[ "Un-installs a provided package and removes it from Pipfile." ]
Please provide a description of the function:def lock( ctx, state, **kwargs ): from ..core import ensure_project, do_init, do_lock # Ensure that virtualenv is available. ensure_project(three=state.three, python=state.python, pypi_mirror=state.pypi_mirror) if state.installstate.requirem...
[ "Generates Pipfile.lock." ]
Please provide a description of the function:def shell( state, fancy=False, shell_args=None, anyway=False, ): from ..core import load_dot_env, do_shell # Prevent user from activating nested environments. if "PIPENV_ACTIVE" in os.environ: # If PIPENV_ACTIVE is set, VIRTUAL_ENV s...
[ "Spawns a shell within the virtualenv." ]
Please provide a description of the function:def run(state, command, args): from ..core import do_run do_run( command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror )
[ "Spawns a command installed into the virtualenv." ]
Please provide a description of the function:def check( state, unused=False, style=False, ignore=None, args=None, **kwargs ): from ..core import do_check do_check( three=state.three, python=state.python, system=state.system, unused=unused, ig...
[ "Checks for security vulnerabilities and against PEP 508 markers provided in Pipfile." ]
Please provide a description of the function:def update( ctx, state, bare=False, dry_run=None, outdated=False, **kwargs ): from ..core import ( ensure_project, do_outdated, do_lock, do_sync, project, ) ensure_project(three=state.three, py...
[ "Runs lock, then sync." ]
Please provide a description of the function:def graph(bare=False, json=False, json_tree=False, reverse=False): from ..core import do_graph do_graph(bare=bare, json=json, json_tree=json_tree, reverse=reverse)
[ "Displays currently-installed dependency graph information." ]
Please provide a description of the function:def run_open(state, module, *args, **kwargs): from ..core import which, ensure_project, inline_activate_virtual_environment # Ensure that virtualenv is available. ensure_project( three=state.three, python=state.python, validate=False, pypi_m...
[ "View a given module in your editor.\n\n This uses the EDITOR environment variable. You can temporarily override it,\n for example:\n\n EDITOR=atom pipenv open requests\n " ]
Please provide a description of the function:def sync( ctx, state, bare=False, user=False, unused=False, **kwargs ): from ..core import do_sync retcode = do_sync( ctx=ctx, dev=state.installstate.dev, three=state.three, python=state.python, ba...
[ "Installs all packages specified in Pipfile.lock." ]
Please provide a description of the function:def clean(ctx, state, dry_run=False, bare=False, user=False): from ..core import do_clean do_clean(ctx=ctx, three=state.three, python=state.python, dry_run=dry_run, system=state.system)
[ "Uninstalls all packages not specified in Pipfile.lock." ]
Please provide a description of the function:def consumeNumberEntity(self, isHex): allowed = digits radix = 10 if isHex: allowed = hexDigits radix = 16 charStack = [] # Consume all the characters that are in range while making sure we #...
[ "This function returns either U+FFFD or the character based on the\n decimal or hexadecimal representation. It also discards \";\" if present.\n If not present self.tokenQueue.append({\"type\": tokenTypes[\"ParseError\"]}) is invoked.\n " ]
Please provide a description of the function:def emitCurrentToken(self): token = self.currentToken # Add token to the queue to be yielded if (token["type"] in tagTokenTypes): token["name"] = token["name"].translate(asciiUpper2Lower) if token["type"] == tokenTypes...
[ "This method is a generic handler for emitting the tags. It also sets\n the state to \"data\" because that's what's needed after a token has been\n emitted.\n " ]
Please provide a description of the function:def create_package_set_from_installed(**kwargs): # type: (**Any) -> Tuple[PackageSet, bool] # Default to using all packages installed on the system if kwargs == {}: kwargs = {"local_only": False, "skip": ()} package_set = {} problems = False...
[ "Converts a list of distributions into a PackageSet.\n " ]
Please provide a description of the function:def check_package_set(package_set, should_ignore=None): # type: (PackageSet, Optional[Callable[[str], bool]]) -> CheckResult if should_ignore is None: def should_ignore(name): return False missing = dict() conflicting = dict() f...
[ "Check if a package set is consistent\n\n If should_ignore is passed, it should be a callable that takes a\n package name and returns a boolean.\n " ]
Please provide a description of the function:def check_install_conflicts(to_install): # type: (List[InstallRequirement]) -> Tuple[PackageSet, CheckResult] # Start from the current state package_set, _ = create_package_set_from_installed() # Install packages would_be_installed = _simulate_instal...
[ "For checking if the dependency graph would be consistent after \\\n installing given requirements\n " ]
Please provide a description of the function:def _simulate_installation_of(to_install, package_set): # type: (List[InstallRequirement], PackageSet) -> Set[str] # Keep track of packages that were installed installed = set() # Modify it as installing requirement_set would (assuming no errors) f...
[ "Computes the version of packages after installing to_install.\n " ]
Please provide a description of the function:def filter_international_words(buf): filtered = bytearray() # This regex expression filters out only words that have at-least one # international character. The word may include one marker character at # the end. words = re.f...
[ "\n We define three types of bytes:\n alphabet: english alphabets [a-zA-Z]\n international: international characters [\\x80-\\xFF]\n marker: everything else [^a-zA-Z\\x80-\\xFF]\n\n The input buffer can be thought to contain a series of words delimited\n by markers. This fu...
Please provide a description of the function:def filter_with_english_letters(buf): filtered = bytearray() in_tag = False prev = 0 for curr in range(len(buf)): # Slice here to get bytes instead of an int with Python 3 buf_char = buf[curr:curr + 1] ...
[ "\n Returns a copy of ``buf`` that retains only the sequences of English\n alphabet and high byte characters that are not between <> characters.\n Also retains English alphabet and high byte characters immediately\n before occurrences of >.\n\n This filter can be applied to all sc...
Please provide a description of the function:def join_parsed_parts(self, drv, root, parts, drv2, root2, parts2): if root2: if not drv2 and drv: return drv, root2, [drv + root2] + parts2[1:] elif drv2: if drv2 == drv or self.casefold(drv2) == self.casefold...
[ "\n Join the two paths represented by the respective\n (drive, root, parts) tuples. Return a new (drive, root, parts) tuple.\n " ]
Please provide a description of the function:def select_from(self, parent_path): path_cls = type(parent_path) is_dir = path_cls.is_dir exists = path_cls.exists scandir = parent_path._accessor.scandir if not is_dir(parent_path): return iter([]) return ...
[ "Iterate over all child paths of `parent_path` matched by this\n selector. This can contain parent_path itself." ]
Please provide a description of the function:def as_posix(self): f = self._flavour return str(self).replace(f.sep, '/')
[ "Return the string representation of the path with forward (/)\n slashes." ]
Please provide a description of the function:def name(self): parts = self._parts if len(parts) == (1 if (self._drv or self._root) else 0): return '' return parts[-1]
[ "The final path component, if any." ]
Please provide a description of the function:def suffix(self): name = self.name i = name.rfind('.') if 0 < i < len(name) - 1: return name[i:] else: return ''
[ "The final component's last suffix, if any." ]
Please provide a description of the function:def suffixes(self): name = self.name if name.endswith('.'): return [] name = name.lstrip('.') return ['.' + suffix for suffix in name.split('.')[1:]]
[ "A list of the final component's suffixes, if any." ]
Please provide a description of the function:def stem(self): name = self.name i = name.rfind('.') if 0 < i < len(name) - 1: return name[:i] else: return name
[ "The final path component, minus its last suffix." ]
Please provide a description of the function:def with_name(self, name): if not self.name: raise ValueError("%r has an empty name" % (self,)) drv, root, parts = self._flavour.parse_parts((name,)) if (not name or name[-1] in [self._flavour.sep, self._flavour.altsep] ...
[ "Return a new path with the file name changed." ]
Please provide a description of the function:def with_suffix(self, suffix): # XXX if suffix is None, should the current suffix be removed? f = self._flavour if f.sep in suffix or f.altsep and f.altsep in suffix: raise ValueError("Invalid suffix %r" % (suffix)) if suf...
[ "Return a new path with the file suffix changed (or added, if\n none).\n " ]
Please provide a description of the function:def parts(self): # We cache the tuple to avoid building a new one each time .parts # is accessed. XXX is this necessary? try: return self._pparts except AttributeError: self._pparts = tuple(self._parts) ...
[ "An object providing sequence-like access to the\n components in the filesystem path." ]
Please provide a description of the function:def parent(self): drv = self._drv root = self._root parts = self._parts if len(parts) == 1 and (drv or root): return self return self._from_parsed_parts(drv, root, parts[:-1])
[ "The logical parent of the path." ]
Please provide a description of the function:def is_absolute(self): if not self._root: return False return not self._flavour.has_drv or bool(self._drv)
[ "True if the path is absolute (has both a root and, if applicable,\n a drive)." ]
Please provide a description of the function:def match(self, path_pattern): cf = self._flavour.casefold path_pattern = cf(path_pattern) drv, root, pat_parts = self._flavour.parse_parts((path_pattern,)) if not pat_parts: raise ValueError("empty pattern") if dr...
[ "\n Return True if this path matches the given pattern.\n " ]
Please provide a description of the function:def _raw_open(self, flags, mode=0o777): if self._closed: self._raise_closed() return self._accessor.open(self, flags, mode)
[ "\n Open the file pointed by this path and return a file descriptor,\n as os.open() does.\n " ]
Please provide a description of the function:def samefile(self, other_path): if hasattr(os.path, "samestat"): st = self.stat() try: other_st = other_path.stat() except AttributeError: other_st = os.stat(other_path) return o...
[ "Return whether other_path is the same or not as this file\n (as returned by os.path.samefile()).\n " ]
Please provide a description of the function:def iterdir(self): if self._closed: self._raise_closed() for name in self._accessor.listdir(self): if name in ('.', '..'): # Yielding a path object for these makes little sense continue ...
[ "Iterate over the files in this directory. Does not yield any\n result for the special paths '.' and '..'.\n " ]
Please provide a description of the function:def touch(self, mode=0o666, exist_ok=True): if self._closed: self._raise_closed() if exist_ok: # First try to bump modification time # Implementation note: GNU touch uses the UTIME_NOW option of # the u...
[ "\n Create this file with the given access mode, if it doesn't exist.\n " ]
Please provide a description of the function:def mkdir(self, mode=0o777, parents=False, exist_ok=False): if self._closed: self._raise_closed() def _try_func(): self._accessor.mkdir(self, mode) def _exc_func(exc): if not parents or self.parent == sel...
[ "\n Create a new directory at this given path.\n " ]
Please provide a description of the function:def chmod(self, mode): if self._closed: self._raise_closed() self._accessor.chmod(self, mode)
[ "\n Change the permissions of the path, like os.chmod().\n " ]
Please provide a description of the function:def lchmod(self, mode): if self._closed: self._raise_closed() self._accessor.lchmod(self, mode)
[ "\n Like chmod(), except if the path points to a symlink, the symlink's\n permissions are changed, rather than its target's.\n " ]
Please provide a description of the function:def unlink(self): if self._closed: self._raise_closed() self._accessor.unlink(self)
[ "\n Remove this file or link.\n If the path is a directory, use rmdir() instead.\n " ]
Please provide a description of the function:def rmdir(self): if self._closed: self._raise_closed() self._accessor.rmdir(self)
[ "\n Remove this directory. The directory must be empty.\n " ]
Please provide a description of the function:def lstat(self): if self._closed: self._raise_closed() return self._accessor.lstat(self)
[ "\n Like stat(), except if the path points to a symlink, the symlink's\n status information is returned, rather than its target's.\n " ]
Please provide a description of the function:def rename(self, target): if self._closed: self._raise_closed() self._accessor.rename(self, target)
[ "\n Rename this path to the given path.\n " ]
Please provide a description of the function:def replace(self, target): if sys.version_info < (3, 3): raise NotImplementedError("replace() is only available " "with Python 3.3 and later") if self._closed: self._raise_closed() ...
[ "\n Rename this path to the given path, clobbering the existing\n destination if it exists.\n " ]
Please provide a description of the function:def symlink_to(self, target, target_is_directory=False): if self._closed: self._raise_closed() self._accessor.symlink(target, self, target_is_directory)
[ "\n Make this path a symlink pointing to the given path.\n Note the order of arguments (self, target) is the reverse of\n os.symlink's.\n " ]
Please provide a description of the function:def exists(self): try: self.stat() except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise return False return True
[ "\n Whether this path exists.\n " ]
Please provide a description of the function:def is_dir(self): try: return S_ISDIR(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see https://bitb...
[ "\n Whether this path is a directory.\n " ]
Please provide a description of the function:def is_file(self): try: return S_ISREG(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see https://bit...
[ "\n Whether this path is a regular file (also True for symlinks pointing\n to regular files).\n " ]
Please provide a description of the function:def is_fifo(self): try: return S_ISFIFO(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see https://bi...
[ "\n Whether this path is a FIFO.\n " ]
Please provide a description of the function:def is_socket(self): try: return S_ISSOCK(self.stat().st_mode) except OSError as e: if e.errno not in (ENOENT, ENOTDIR): raise # Path doesn't exist or is a broken symlink # (see https://...
[ "\n Whether this path is a socket.\n " ]
Please provide a description of the function:def expanduser(self): if (not (self._drv or self._root) and self._parts and self._parts[0][:1] == '~'): homedir = self._flavour.gethomedir(self._parts[0][1:]) return self._from_parts([homedir] + self._parts[1:]) ...
[ " Return a new path with expanded ~ and ~user constructs\n (as returned by os.path.expanduser)\n " ]
Please provide a description of the function:def lookupEncoding(encoding): if isinstance(encoding, binary_type): try: encoding = encoding.decode("ascii") except UnicodeDecodeError: return None if encoding is not None: try: return webencodings.loo...
[ "Return the python codec name corresponding to an encoding or None if the\n string doesn't correspond to a valid encoding." ]
Please provide a description of the function:def openStream(self, source): # Already a file object if hasattr(source, 'read'): stream = source else: stream = StringIO(source) return stream
[ "Produces a file object from source.\n\n source can be either a file object, local filename or a string.\n\n " ]
Please provide a description of the function:def position(self): line, col = self._position(self.chunkOffset) return (line + 1, col)
[ "Returns (line, col) of the current position in the stream." ]
Please provide a description of the function:def char(self): # Read a new chunk from the input stream if necessary if self.chunkOffset >= self.chunkSize: if not self.readChunk(): return EOF chunkOffset = self.chunkOffset char = self.chunk[chunkOffset...
[ " Read one character from the stream or queue if available. Return\n EOF when EOF is reached.\n " ]
Please provide a description of the function:def charsUntil(self, characters, opposite=False): # Use a cache of regexps to find the required characters try: chars = charsUntilRegEx[(characters, opposite)] except KeyError: if __debug__: for c in c...
[ " Returns a string of characters from the stream up to but not\n including any character in 'characters' or EOF. 'characters' must be\n a container that supports the 'in' method and iteration over its\n characters.\n " ]
Please provide a description of the function:def openStream(self, source): # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) try: stream.seek(stream.tell()) except: # pylint:disable=ba...
[ "Produces a file object from source.\n\n source can be either a file object, local filename or a string.\n\n " ]
Please provide a description of the function:def detectEncodingMeta(self): buffer = self.rawStream.read(self.numBytesMeta) assert isinstance(buffer, bytes) parser = EncodingParser(buffer) self.rawStream.seek(0) encoding = parser.getEncoding() if encoding is not ...
[ "Report the encoding declared by the meta element\n " ]
Please provide a description of the function:def skip(self, chars=spaceCharactersBytes): p = self.position # use property for the error-checking while p < len(self): c = self[p:p + 1] if c not in chars: self._position = p ret...
[ "Skip past a list of characters" ]
Please provide a description of the function:def matchBytes(self, bytes): p = self.position data = self[p:p + len(bytes)] rv = data.startswith(bytes) if rv: self.position += len(bytes) return rv
[ "Look for a sequence of bytes at the start of a string. If the bytes\n are found return True and advance the position to the byte after the\n match. Otherwise return False and leave the position alone" ]
Please provide a description of the function:def jumpTo(self, bytes): newPosition = self[self.position:].find(bytes) if newPosition > -1: # XXX: This is ugly, but I can't see a nicer way to fix this. if self._position == -1: self._position = 0 ...
[ "Look for the next sequence of bytes matching a given sequence. If\n a match is found advance the position to the last byte of the match" ]
Please provide a description of the function:def getAttribute(self): data = self.data # Step 1 (skip chars) c = data.skip(spaceCharactersBytes | frozenset([b"/"])) assert c is None or len(c) == 1 # Step 2 if c in (b">", None): return None # St...
[ "Return a name,value pair for the next attribute in the stream,\n if one is found, or None" ]
Please provide a description of the function:def _build_backend(): ep = os.environ['PEP517_BUILD_BACKEND'] mod_path, _, obj_path = ep.partition(':') try: obj = import_module(mod_path) except ImportError: raise BackendUnavailable if obj_path: for path_part in obj_path.spl...
[ "Find and load the build backend" ]
Please provide a description of the function:def get_requires_for_build_wheel(config_settings): backend = _build_backend() try: hook = backend.get_requires_for_build_wheel except AttributeError: return [] else: return hook(config_settings)
[ "Invoke the optional get_requires_for_build_wheel hook\n\n Returns [] if the hook is not defined.\n " ]
Please provide a description of the function:def prepare_metadata_for_build_wheel(metadata_directory, config_settings): backend = _build_backend() try: hook = backend.prepare_metadata_for_build_wheel except AttributeError: return _get_wheel_metadata_from_wheel(backend, metadata_director...
[ "Invoke optional prepare_metadata_for_build_wheel\n\n Implements a fallback by building a wheel if the hook isn't defined.\n " ]
Please provide a description of the function:def _dist_info_files(whl_zip): res = [] for path in whl_zip.namelist(): m = re.match(r'[^/\\]+-[^/\\]+\.dist-info/', path) if m: res.append(path) if res: return res raise Exception("No .dist-info folder found in wheel"...
[ "Identify the .dist-info folder inside a wheel ZipFile." ]
Please provide a description of the function:def _get_wheel_metadata_from_wheel( backend, metadata_directory, config_settings): from zipfile import ZipFile whl_basename = backend.build_wheel(metadata_directory, config_settings) with open(os.path.join(metadata_directory, WHEEL_BUILT_MARKER), 'wb...
[ "Build a wheel and extract the metadata from it.\n\n Fallback for when the build backend does not\n define the 'get_wheel_metadata' hook.\n " ]
Please provide a description of the function:def _find_already_built_wheel(metadata_directory): if not metadata_directory: return None metadata_parent = os.path.dirname(metadata_directory) if not os.path.isfile(pjoin(metadata_parent, WHEEL_BUILT_MARKER)): return None whl_files = gl...
[ "Check for a wheel already built during the get_wheel_metadata hook.\n " ]
Please provide a description of the function:def build_wheel(wheel_directory, config_settings, metadata_directory=None): prebuilt_whl = _find_already_built_wheel(metadata_directory) if prebuilt_whl: shutil.copy2(prebuilt_whl, wheel_directory) return os.path.basename(prebuilt_whl) retur...
[ "Invoke the mandatory build_wheel hook.\n\n If a wheel was already built in the\n prepare_metadata_for_build_wheel fallback, this\n will copy it rather than rebuilding the wheel.\n " ]
Please provide a description of the function:def get_requires_for_build_sdist(config_settings): backend = _build_backend() try: hook = backend.get_requires_for_build_sdist except AttributeError: return [] else: return hook(config_settings)
[ "Invoke the optional get_requires_for_build_wheel hook\n\n Returns [] if the hook is not defined.\n " ]
Please provide a description of the function:def append(self, key, _item): # type: (Union[Key, str], Any) -> Table if not isinstance(_item, Item): _item = item(_item) self._value.append(key, _item) if isinstance(key, Key): key = key.key if key is not ...
[ "\n Appends a (key, item) to the table.\n " ]
Please provide a description of the function:def append(self, key, _item): # type: (Union[Key, str], Any) -> InlineTable if not isinstance(_item, Item): _item = item(_item) if not isinstance(_item, (Whitespace, Comment)): if not _item.trivia.indent and len(self._value)...
[ "\n Appends a (key, item) to the table.\n " ]