id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
171,652
import importlib import os import sys import warnings import pywintypes import win32api import win32con import win32service import winerror error = RuntimeError def LocateSpecificServiceExe(serviceName): # Return the .exe name of any service. hkey = win32api.RegOpenKey( win32con.HKEY_LOCAL_MACHINE, ...
Utility function allowing services to process the command line. Allows standard commands such as 'start', 'stop', 'debug', 'install' etc. Install supports 'standard' command line options prefixed with '--', such as --username, --password, etc. In addition, the function allows custom command line options to be handled b...
171,653
import warnings import os import sys import regutil import win32api import win32con def CheckRegisteredExe(exename): try: os.stat( win32api.RegQueryValue( regutil.GetRootKey(), regutil.GetAppPathsKey() + "\\" + exename ) ) # except SystemError: except...
null
171,654
import time import win32pdh def find_pdh_counter_localized_name(english_name, machine_name=None): if not counter_english_map: import win32api import win32con counter_reg_value = win32api.RegQueryValueEx( win32con.HKEY_PERFORMANCE_DATA, "Counter 009" ) counter_list...
Find performance attributes by (case insensitive) instance name. Given a process name, return a list with the requested attributes. Most useful for returning a tuple of PIDs given a process name.
171,655
import time import win32pdh def find_pdh_counter_localized_name(english_name, machine_name=None): if not counter_english_map: import win32api import win32con counter_reg_value = win32api.RegQueryValueEx( win32con.HKEY_PERFORMANCE_DATA, "Counter 009" ) counter_list...
null
171,656
import time import win32pdh def BrowseCallBackDemo(counters): ## BrowseCounters can now return multiple counter paths for counter in counters: ( machine, object, instance, parentInstance, index, counterName, ) = win32pdh.Par...
null
171,657
def HRESULT_FROM_WIN32(scode): return -2147024896 | (scode & 65535)
null
171,658
def SUCCEEDED(Status): return (Status) >= 0
null
171,659
def FAILED(Status): return Status < 0
null
171,660
def SCODE_CODE(sc): return (sc) & 65535
null
171,661
def HRESULT_FACILITY(hr): return ((hr) >> 16) & 8191
null
171,662
def SCODE_FACILITY(sc): return ((sc) >> 16) & 8191
null
171,663
def HRESULT_SEVERITY(hr): return ((hr) >> 31) & 1
null
171,664
def SCODE_SEVERITY(sc): return ((sc) >> 31) & 1
null
171,665
FACILITY_NT_BIT = 268435456 def HRESULT_FROM_NT(x): return x | FACILITY_NT_BIT
null
171,666
def GetScode(hr): return hr
null
171,667
def ResultFromScode(sc): return sc
null
171,668
import pywintypes from ntsecuritycon import FILE_READ_DATA, FILE_WRITE_DATA def CTL_CODE(DeviceType, Function, Method, Access): return (DeviceType << 16) | (Access << 14) | (Function << 2) | Method
null
171,669
import pywintypes from ntsecuritycon import FILE_READ_DATA, FILE_WRITE_DATA def DEVICE_TYPE_FROM_CTL_CODE(ctrlCode): return (ctrlCode & 0xFFFF0000) >> 16
null
171,670
import glob import optparse import os import struct import sys from win32api import BeginUpdateResource, EndUpdateResource, UpdateResource def VS_VERSION_INFO(maj, min, sub, build, sdata, vdata, debug=0, is_dll=1): def stamp(pathname, options): # For some reason, the API functions report success if the file is ope...
null
171,671
def SEC_SUCCESS(Status): return (Status) >= 0
null
171,672
def GET_ALG_CLASS(x): return x & (7 << 13)
null
171,673
def GET_ALG_TYPE(x): return x & (15 << 9)
null
171,674
def GET_ALG_SID(x): return x & (511)
null
171,675
CRYPT_SUCCEED = 1 def RCRYPT_SUCCEEDED(rt): return (rt) == CRYPT_SUCCEED
null
171,676
CRYPT_FAILED = 0 def RCRYPT_FAILED(rt): return (rt) == CRYPT_FAILED
null
171,677
CERT_ENCODING_TYPE_MASK = 0x0000FFFF def GET_CERT_ENCODING_TYPE(X): return X & CERT_ENCODING_TYPE_MASK
null
171,678
CMSG_ENCODING_TYPE_MASK = -65536 def GET_CMSG_ENCODING_TYPE(X): return X & CMSG_ENCODING_TYPE_MASK
null
171,679
def INDEXTOOVERLAYMASK(i): return i << 8
null
171,680
def INDEXTOSTATEIMAGEMASK(i): return i << 12
null
171,681
import importlib.machinery import importlib.util import os import sys def __import_pywin32_system_module__(modname, globs): # This has been through a number of iterations. The problem: how to # locate pywintypesXX.dll when it may be in a number of places, and how # to avoid ever loading it twice. This pr...
null
171,682
import os import shutil import sys import winreg import win32api def _docopy(src, dest): orig_src = src if not os.path.isfile(src): src = os.path.join(os.path.split(sys.argv[0])[0], src) print( "Can not find %s or %s to copy" % (os.path.abspath(orig_src), os.path.abspath(...
null
171,683
import sys import win32api import win32con import win32pdhutil def killProcName(procname): # Change suggested by Dan Knierim, who found that this performed a # "refresh", allowing us to kill processes created since this was run # for the first time. try: win32pdhutil.GetPerformanceAttributes("P...
null
171,684
import sys import win32ras class ConnectionError(Exception): pass The provided code snippet includes necessary dependencies for implementing the `Connect` function. Write a Python function `def Connect(rasEntryName, numRetries=5)` to solve the following problem: Make a connection to the specified RAS entry. Return...
Make a connection to the specified RAS entry. Returns a tuple of (bool, handle) on success. - bool is 1 if a new connection was established, or 0 is a connection already existed. - handle is a RAS HANDLE that can be passed to Disconnect() to end the connection. Raises a ConnectionError if the connection could not be es...
171,685
import sys import win32ras class ConnectionError(Exception): pass def Disconnect(handle): if type(handle) == type(""): # have they passed a connection name? for info in win32ras.EnumConnections(): if info[1].lower() == handle.lower(): handle = info[0] break ...
null
171,686
import sys import win32ras usage = """rasutil.py - Utilities for using RAS Usage: rasutil [-r retryCount] [-c rasname] [-d rasname] -r retryCount - Number of times to retry the RAS connection -c rasname - Connect to the phonebook entry specified by rasname -d rasname - Disconnect from the phonebook entry specif...
null
171,687
import sys def LocatePath(fileName, searchPaths): """Like LocateFileName, but returns a directory only.""" import os return os.path.abspath(os.path.split(LocateFileName(fileName, searchPaths))[0]) The provided code snippet includes necessary dependencies for implementing the `LocateOptionalPath` function....
Like LocatePath, but returns None if the user cancels.
171,688
import sys def LocateFileName(fileNamesString, searchPaths): """Locate a file name, anywhere on the search path. If the file can not be located, prompt the user to find it for us (using a common OpenFile dialog) Raises KeyboardInterrupt if the user cancels. """ import os import regutil ...
Like LocateFileName, but returns None if the user cancels.
171,689
class error(Exception): pass import sys def FindPackagePath(packageName, knownFileName, searchPaths): """Find a package. Given a ni style package name, check the package is registered. First place looked is the registry for an existing entry. Then the searchPaths are searched. """ import o...
Find and Register a package. Assumes the core registry setup correctly. In addition, if the location located by the package is already in the **core** path, then an entry is registered, but no path. (no other paths are checked, as the application whose path was used may later be uninstalled. This should not happen with...
171,690
class error(Exception): pass import sys def FindAppPath(appName, knownFileName, searchPaths): """Find an application. First place looked is the registry for an existing entry. Then the searchPaths are searched. """ # Look in the first path. import os import regutil regPath = reguti...
Find and Register a package. Assumes the core registry setup correctly.
171,691
import sys def LocateFileName(fileNamesString, searchPaths): """Locate a file name, anywhere on the search path. If the file can not be located, prompt the user to find it for us (using a common OpenFile dialog) Raises KeyboardInterrupt if the user cancels. """ import os import regutil ...
Setup the core Python information in the registry. This function makes no assumptions about the current state of sys.path. After this function has completed, you should have access to the standard Python library, and the standard Win32 extensions
171,692
import sys def IsDebug(): """Return "_d" if we're running a debug version. This is to be used within DLL names when locating them. """ import importlib.machinery return "_d" if "_d.pyd" in importlib.machinery.EXTENSION_SUFFIXES else "" def QuotedFileName(fname): """Given a filename, return a qu...
Registers key parts of the Python installation with the Windows Shell. Assumes a valid, minimal Python installation exists (ie, SetupCore() has been previously successfully run)
171,693
import fnmatch import getopt import os import string import sys import win32api import win32con import win32file import wincerapi class InvalidUsage(Exception): pass def isdir(name, local=1): try: attr = GetFileAttributes(name, local) return attr & win32con.FILE_ATTRIBUTE_DIRECTORY except wi...
copy src [src ...], dest Copy files to/from the CE device
171,694
import fnmatch import getopt import os import string import sys import win32api import win32con import win32file import wincerapi class InvalidUsage(Exception): pass def BuildFileList(spec, local, recurse, filter, filter_args, recursed_path=""): files = [] if isdir(spec, local): path = spec ...
dir directory_name ... Perform a directory listing on the remote device
171,695
import fnmatch import getopt import os import string import sys import win32api import win32con import win32file import wincerapi import pywin.dialogs.status import win32ui The provided code snippet includes necessary dependencies for implementing the `run` function. Write a Python function `def run(args)` to solve th...
run program [args] Starts the specified program on the remote device.
171,696
import fnmatch import getopt import os import string import sys import win32api import win32con import win32file import wincerapi def print_error(api_exc, msg): hr, fn, errmsg = api_exc print("%s - %s(%d)" % (msg, errmsg, hr)) import pywin.dialogs.status import win32ui The provided code snippet includes necess...
delete file, ... Delete one or more remote files
171,697
import fnmatch import getopt import os import string import sys import win32api import win32con import win32file import wincerapi import pywin.dialogs.status import win32ui def DumpCommands(): print("%-10s - %s" % ("Command", "Description")) print("%-10s - %s" % ("-------", "-----------")) for name, item i...
null
171,698
import os import time import win32api import win32evtlog def BackupClearLog(logType): datePrefix = time.strftime("%Y%m%d", time.localtime(time.time())) fileExists = 1 retry = 0 while fileExists: if retry == 0: index = "" else: index = "-%d" % retry try: ...
null
171,699
import string import time import traceback import pythoncom import win32com.client import win32com.client.gencache import win32con constants = win32com.client.constants def VssLog(project, linePrefix="", noLabels=5, maxItems=150): lines = [] num = 0 labelNum = 0 for i in project.GetVersions(constants.V...
null
171,700
import os import string import sys import bulkstamp import vssutil import win32api def BrandProject( vssProjectName, descFile, stampPath, filesToSubstitute, buildDesc=None, auto=0, bRebrand=0, ): # vssProjectName -- The name of the VSS project to brand. # descFile -- A test file con...
null
171,701
import os import string import sys import bulkstamp import vssutil import win32api def usage(msg): print(msg) print( """\ %s Usage: %s [options] vssProject descFile stampPath Automatically brand a VSS project with an automatically incremented build number, and stamp DLL/EXE files with the build number...
null
171,702
from collections import namedtuple from tornado import web, gen from jupyter_server.transutils import _i18n from jupyter_server.utils import ( ensure_async ) from jupyter_server.base.handlers import path_regex, FilesRedirectHandler from jupyter_server.extension.handler import ( ExtensionHandlerMixin, Extens...
null
171,705
import sys The provided code snippet includes necessary dependencies for implementing the `shim_notebook` function. Write a Python function `def shim_notebook()` to solve the following problem: Define in sys.module the needed notebook packages that should be fullfilled by their corresponding and backwards-compatible j...
Define in sys.module the needed notebook packages that should be fullfilled by their corresponding and backwards-compatible jupyter-server packages. TODO Can we lazy load these loadings? Note: We could a custom module loader to achieve similar functionality. The logic thar conditional loading seems to be more complicat...
171,708
import os import platform import pprint import sys import subprocess from ipython_genutils import py3compat, encoding import nbclassic from nbclassic import _version def pkg_info(pkg_path): """Return dict describing the context of this package Parameters ---------- pkg_path : str path containing ...
Return useful information about the system as a dict.
171,709
import os import io import tarfile import nbformat The provided code snippet includes necessary dependencies for implementing the `_jupyter_bundlerextension_paths` function. Write a Python function `def _jupyter_bundlerextension_paths()` to solve the following problem: Metadata for notebook bundlerextension Here is t...
Metadata for notebook bundlerextension
171,710
import os import io import tarfile import nbformat The provided code snippet includes necessary dependencies for implementing the `bundle` function. Write a Python function `def bundle(handler, model)` to solve the following problem: Create a compressed tarball containing the notebook document. Parameters ---------- h...
Create a compressed tarball containing the notebook document. Parameters ---------- handler : tornado.web.RequestHandler Handler that serviced the bundle request model : dict Notebook model from the configured ContentManager
171,712
import os import io import zipfile import nbclassic.bundler.tools as tools The provided code snippet includes necessary dependencies for implementing the `_jupyter_bundlerextension_paths` function. Write a Python function `def _jupyter_bundlerextension_paths()` to solve the following problem: Metadata for notebook bun...
Metadata for notebook bundlerextension
171,713
import os import io import zipfile import nbclassic.bundler.tools as tools The provided code snippet includes necessary dependencies for implementing the `bundle` function. Write a Python function `def bundle(handler, model)` to solve the following problem: Create a zip file containing the original notebook and files ...
Create a zip file containing the original notebook and files referenced from it. Retain the referenced files in paths relative to the nbclassic. Return the zip as a file download. Assumes the notebook and other files are all on local disk. Parameters ---------- handler : tornado.web.RequestHandler Handler that serviced...
171,714
import asyncio import inspect import concurrent.futures from nbclassic import nbclassic_path from traitlets.utils.importstring import import_item from tornado import web, gen from jupyter_server.utils import url2path from jupyter_server.base.handlers import JupyterHandler from jupyter_server.services.config import Conf...
Like tornado's deprecated gen.maybe_future but more compatible with asyncio for recent versions of tornado
171,715
import sys import os from ..extensions import BaseExtensionApp, _get_config_dir, GREEN_ENABLED, RED_DISABLED from .._version import __version__ from nbclassic.config_manager import BaseJSONConfigManager from jupyter_core.paths import jupyter_config_path from traitlets.utils.importstring import import_item from traitlet...
Enables bundlers defined in a Python package. Returns whether each bundle defined in the packaged was enabled or not. Parameters ---------- module : str Importable Python module exposing the magic-named `_jupyter_bundlerextension_paths` function user : bool [default: True] Whether to enable in the user's nbconfig direc...
171,716
import sys import os from ..extensions import BaseExtensionApp, _get_config_dir, GREEN_ENABLED, RED_DISABLED from .._version import __version__ from nbclassic.config_manager import BaseJSONConfigManager from jupyter_core.paths import jupyter_config_path from traitlets.utils.importstring import import_item from traitlet...
Disables bundlers defined in a Python package. Returns whether each bundle defined in the packaged was enabled or not. Parameters ---------- module : str Importable Python module exposing the magic-named `_jupyter_bundlerextension_paths` function user : bool [default: True] Whether to enable in the user's nbconfig dire...
171,717
import os import shutil import sys import tarfile import zipfile from os.path import basename, join as pjoin, normpath from urllib.parse import urlparse from urllib.request import urlretrieve from jupyter_core.paths import ( jupyter_data_dir, jupyter_config_path, jupyter_path, SYSTEM_JUPYTER_PATH, ENV_JUPYTER_P...
Check whether nbextension files have been installed Returns True if all files are found, False if any are missing. Parameters ---------- files : list(paths) a list of relative paths within nbextensions. user : bool [default: False] Whether to check the user's .jupyter/nbextensions directory. Otherwise check a system-wi...
171,718
import os import shutil import sys import tarfile import zipfile from os.path import basename, join as pjoin, normpath from urllib.parse import urlparse from urllib.request import urlretrieve from jupyter_core.paths import ( jupyter_data_dir, jupyter_config_path, jupyter_path, SYSTEM_JUPYTER_PATH, ENV_JUPYTER_P...
Install an nbextension bundled in a Python package. Returns a list of installed/updated directories. See install_nbextension for parameter information.
171,719
import os import shutil import sys import tarfile import zipfile from os.path import basename, join as pjoin, normpath from urllib.parse import urlparse from urllib.request import urlretrieve from jupyter_core.paths import ( jupyter_data_dir, jupyter_config_path, jupyter_path, SYSTEM_JUPYTER_PATH, ENV_JUPYTER_P...
Remove nbextension files from the first location they are found. Returns True if files were removed, False otherwise.
171,723
import os import shutil import sys import tarfile import zipfile from os.path import basename, join as pjoin, normpath from urllib.parse import urlparse from urllib.request import urlretrieve from jupyter_core.paths import ( jupyter_data_dir, jupyter_config_path, jupyter_path, SYSTEM_JUPYTER_PATH, ENV_JUPYTER_P...
Disable an nbextension from the first config location where it is enabled. Returns True if it changed any config, False otherwise.
171,726
import warnings The provided code snippet includes necessary dependencies for implementing the `parameterized` function. Write a Python function `def parameterized(*params)` to solve the following problem: Decorator to create parameterized rules. Parameterized rule methods must be named starting with 'p_' and contain ...
Decorator to create parameterized rules. Parameterized rule methods must be named starting with 'p_' and contain 'xxx', and their docstrings may contain 'xxx' and 'yyy'. These will be replaced by the given parameter tuples. For example, ``p_xxx_rule()`` with docstring 'xxx_rule : yyy' when decorated with ``@parameteriz...
171,727
import warnings def _create_param_rules(cls, func): """ Create ply.yacc rules based on a parameterized rule function Generates new methods (one per each pair of parameters) based on the template rule function `func`, and attaches them to `cls`. The rule function's parameters must be accessible via its `...
Class decorator to generate rules from parameterized rule templates. See `parameterized` for more information on parameterized rules.
171,728
from . import c_ast def _extract_nested_case(case_node, stmts_list): """ Recursively extract consecutive Case statements that are made nested by the parser and add them to the stmts_list. """ if isinstance(case_node.stmts[0], (c_ast.Case, c_ast.Default)): stmts_list.append(case_node.stmts.po...
The 'case' statements in a 'switch' come out of parsing with one child node, so subsequent statements are just tucked to the parent Compound. Additionally, consecutive (fall-through) case statements come out messy. This is a peculiarity of the C grammar. The following: switch (myvar) { case 10: k = 10; p = k + 1; retur...
171,729
from . import c_ast def _fix_atomic_specifiers_once(decl): """ Performs one 'fix' round of atomic specifiers. Returns (modified_decl, found) where found is True iff a fix was made. """ parent = decl grandparent = None node = decl.type while node is not None: if isinstance(node, c...
Atomic specifiers like _Atomic(type) are unusually structured, conferring a qualifier upon the contained type. This function fixes a decl with atomic specifiers to have a sane AST structure, by removing spurious Typename->TypeDecl pairs and attaching the _Atomic qualifier in the right place.
171,730
import re import sys import types import copy import os import inspect def _funcs_to_names(funclist, namelist): result = [] for f, name in zip(funclist, namelist): if f and f[0]: result.append((name, f[1])) else: result.append(f) return result
null
171,731
import re import sys import types import copy import os import inspect def _names_to_funcs(namelist, fdict): result = [] for n in namelist: if n and n[0]: result.append((fdict[n[0]], n[1])) else: result.append(n) return result
null
171,732
import re import sys import types import copy import os import inspect def _statetoken(s, names): nonstate = 1 parts = s.split('_') for i, part in enumerate(parts[1:], 1): if part not in names and part != 'ANY': break if i > 1: states = tuple(parts[1:i]) else: s...
null
171,733
import re import sys import types import copy import os import inspect class PlyLogger(object): def __init__(self, f): self.f = f def critical(self, msg, *args, **kwargs): self.f.write((msg % args) + '\n') def warning(self, msg, *args, **kwargs): self.f.write('WARNING: ' + (msg % arg...
null
171,734
import re import sys import types import copy import os import inspect def runmain(lexer=None, data=None): if not data: try: filename = sys.argv[1] f = open(filename) data = f.read() f.close() except IndexError: sys.stdout.write('Reading f...
null
171,735
import re import sys import types import copy import os import inspect def _get_regex(func): return getattr(func, 'regex', func.__doc__) def TOKEN(r): def set_regex(f): if hasattr(r, '__call__'): f.regex = _get_regex(r) else: f.regex = r return f return set_r...
null
171,736
import os.path import shutil def get_source_range(lines, tag): srclines = enumerate(lines) start_tag = '#--! %s-start' % tag end_tag = '#--! %s-end' % tag for start_index, line in srclines: if line.strip().startswith(start_tag): break for end_index, line in srclines: i...
null
171,737
import os.path import shutil def filter_section(lines, tag): filtered_lines = [] include = True tag_text = '#--! %s' % tag for line in lines: if line.strip().startswith(tag_text): include = not include elif include: filtered_lines.append(line) return filtered...
null
171,738
import sys import re import copy import time import os.path The provided code snippet includes necessary dependencies for implementing the `t_CPP_WS` function. Write a Python function `def t_CPP_WS(t)` to solve the following problem: r'\s+ Here is the function: def t_CPP_WS(t): r'\s+' t.lexer.lineno += t.val...
r'\s+
171,739
import sys import re import copy import time import os.path The provided code snippet includes necessary dependencies for implementing the `CPP_INTEGER` function. Write a Python function `def CPP_INTEGER(t)` to solve the following problem: r'(((((0x)|(0X))[0-9a-fA-F]+)|(\d+))([uU][lL]|[lL][uU]|[uU]|[lL])?) Here is th...
r'(((((0x)|(0X))[0-9a-fA-F]+)|(\d+))([uU][lL]|[lL][uU]|[uU]|[lL])?)
171,740
import sys import re import copy import time import os.path The provided code snippet includes necessary dependencies for implementing the `t_CPP_STRING` function. Write a Python function `def t_CPP_STRING(t)` to solve the following problem: r'\"([^\\\n]|(\\(.|\n)))*?\" Here is the function: def t_CPP_STRING(t): ...
r'\"([^\\\n]|(\\(.|\n)))*?\"
171,741
import sys import re import copy import time import os.path The provided code snippet includes necessary dependencies for implementing the `t_CPP_CHAR` function. Write a Python function `def t_CPP_CHAR(t)` to solve the following problem: r'(L)?\'([^\\\n]|(\\(.|\n)))*?\ Here is the function: def t_CPP_CHAR(t): r'...
r'(L)?\'([^\\\n]|(\\(.|\n)))*?\
171,742
import sys import re import copy import time import os.path The provided code snippet includes necessary dependencies for implementing the `t_CPP_COMMENT1` function. Write a Python function `def t_CPP_COMMENT1(t)` to solve the following problem: r'(/\*(.|\n)*?\*/) Here is the function: def t_CPP_COMMENT1(t): r'(...
r'(/\*(.|\n)*?\*/)
171,743
import sys import re import copy import time import os.path The provided code snippet includes necessary dependencies for implementing the `t_CPP_COMMENT2` function. Write a Python function `def t_CPP_COMMENT2(t)` to solve the following problem: r'(//.*?(\n|$)) Here is the function: def t_CPP_COMMENT2(t): r'(//....
r'(//.*?(\n|$))
171,744
import sys import re import copy import time import os.path def t_error(t): t.type = t.value[0] t.value = t.value[0] t.lexer.skip(1) return t
null
171,745
import sys import re import copy import time import os.path _trigraph_pat = re.compile(r'''\?\?[=/\'\(\)\!<>\-]''') _trigraph_rep = { '=':'#', '/':'\\', "'":'^', '(':'[', ')':']', '!':'|', '<':'{', '>':'}', '-':'~' } def trigraph(input): return _trigraph_pat.sub(lambda g: _trigr...
null
171,746
import re import types import sys import os.path import inspect import base64 import warnings resultlimit = 40 def format_result(r): repr_str = repr(r) if '\n' in repr_str: repr_str = repr(repr_str) if len(repr_str) > resultlimit: repr_str = repr_str[:resultlimit] + ' ...' result = '<%s...
null
171,747
import re import types import sys import os.path import inspect import base64 import warnings def format_stack_entry(r): repr_str = repr(r) if '\n' in repr_str: repr_str = repr(repr_str) if len(repr_str) < 16: return repr_str else: return '<%s @ 0x%x>' % (type(r).__name__, id(r)...
null
171,748
import re import types import sys import os.path import inspect import base64 import warnings _token = None _warnmsg = '''PLY: Don't use global functions errok(), token(), and restart() in p_error(). Instead, invoke the methods on the associated parser instance: def p_error(p): ... # Use parser.erro...
null
171,749
import re import types import sys import os.path import inspect import base64 import warnings _errok = None _token = None _restart = None def errok(): def restart(): def call_errorfunc(errorfunc, token, parser): global _errok, _token, _restart _errok = parser.errok _token = parser.token _restart = pars...
null
171,750
import re import types import sys import os.path import inspect import base64 import warnings def rightmost_terminal(symbols, terminals): i = len(symbols) - 1 while i >= 0: if symbols[i] in terminals: return symbols[i] i -= 1 return None
null
171,751
import re import types import sys import os.path import inspect import base64 import warnings def traverse(x, N, stack, F, X, R, FP): stack.append(x) d = len(stack) N[x] = d F[x] = FP(x) # F(X) <- F'(x) rel = R(x) # Get y's related to x for y in rel: if N[y] == ...
null
171,752
import re import types import sys import os.path import inspect import base64 import warnings def parse_grammar(doc, file, line): grammar = [] # Split the doc string into lines pstrings = doc.splitlines() lastp = None dline = line for ps in pstrings: dline += 1 p = ps.split() ...
null
171,753
import re import types import sys import os.path import inspect import base64 import warnings __version__ = '3.10' yaccdebug = True debug_file = 'parser.out' tab_module = 'parsetab' if sys.version_info[0] < 3: string_types = basestring else: string_types = str class PlyLog...
null
171,754
The provided code snippet includes necessary dependencies for implementing the `t_COMMENT` function. Write a Python function `def t_COMMENT(t)` to solve the following problem: r'/\*(.|\n)*?\*/ Here is the function: def t_COMMENT(t): r'/\*(.|\n)*?\*/' t.lexer.lineno += t.value.count('\n') return t
r'/\*(.|\n)*?\*/
171,755
The provided code snippet includes necessary dependencies for implementing the `t_CPPCOMMENT` function. Write a Python function `def t_CPPCOMMENT(t)` to solve the following problem: r'//.*\n Here is the function: def t_CPPCOMMENT(t): r'//.*\n' t.lexer.lineno += 1 return t
r'//.*\n
171,756
import sys The provided code snippet includes necessary dependencies for implementing the `_repr` function. Write a Python function `def _repr(obj)` to solve the following problem: Get the representation of an object, with dedicated pprint-like format for lists. Here is the function: def _repr(obj): """ Get ...
Get the representation of an object, with dedicated pprint-like format for lists.
171,757
from dataclasses import dataclass from typing import Any, Optional from .exceptions import InvalidHash from .low_level import Type Any = object() Optional: _SpecialForm = ... The provided code snippet includes necessary dependencies for implementing the `_check_types` function. Write a Python function `def _check...
Check each ``name: (value, types)`` in *kw*. Returns a human-readable string of all violations or `None``.
171,758
from dataclasses import dataclass from typing import Any, Optional from .exceptions import InvalidHash from .low_level import Type def _decoded_str_len(l: int) -> int: """ Compute how long an encoded string of length *l* becomes. """ rem = l % 4 if rem == 3: last_group_len = 2 elif rem =...
Extract parameters from an encoded *hash*. :param str params: An encoded Argon2 hash string. :rtype: Parameters .. versionadded:: 18.2.0
171,759
import os from typing import Union from ._typing import Literal from ._utils import Parameters, _check_types, extract_parameters from .exceptions import InvalidHash from .low_level import Type, hash_secret, verify_secret from .profiles import RFC_9106_LOW_MEMORY Union: _SpecialForm = ... The provided code snippet inc...
Ensure *s* is a bytes string. Encode using *encoding* if it isn't.
171,760
import os from typing import Optional from ._password_hasher import ( DEFAULT_HASH_LENGTH, DEFAULT_MEMORY_COST, DEFAULT_PARALLELISM, DEFAULT_RANDOM_SALT_LENGTH, DEFAULT_TIME_COST, ) from ._typing import Literal from .low_level import Type, hash_secret, hash_secret_raw, verify_secret Optional: _Spec...
Legacy alias for :func:`hash_secret` with default parameters. .. deprecated:: 16.0.0 Use :class:`argon2.PasswordHasher` for passwords.
171,761
import os from typing import Optional from ._password_hasher import ( DEFAULT_HASH_LENGTH, DEFAULT_MEMORY_COST, DEFAULT_PARALLELISM, DEFAULT_RANDOM_SALT_LENGTH, DEFAULT_TIME_COST, ) from ._typing import Literal from .low_level import Type, hash_secret, hash_secret_raw, verify_secret Optional: _Spec...
Legacy alias for :func:`hash_secret_raw` with default parameters. .. deprecated:: 16.0.0 Use :class:`argon2.PasswordHasher` for passwords.