input
stringlengths
11
7.65k
target
stringlengths
22
8.26k
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): """Cast raw string to appropriate type.""" return decode(value)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): """Convert value back to string for saving.""" if value is None: return "" return str(value)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): return DeprecatedValue()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): return DeprecatedValue()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, optional=False, choices=None): self._required = not optional self._choices = choices
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value).strip() validators.validate_required(value, self._required) if not value: return None validators.validate_choice(value, self._choices) return value
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): if value is None: return "" return encode(value)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, optional=False, choices=None): self._required = not optional self._choices = None # Choices doesn't make sense for secrets
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): if value is not None and display: return "********" return super().serialize(value, display)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__( self, minimum=None, maximum=None, choices=None, optional=False ): self._required = not optional self._minimum = minimum self._maximum = maximum self._choices = choices
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value) validators.validate_required(value, self._required) if not value: return None value = int(value) validators.validate_choice(value, self._choices) validators.validate_minimum(value, self._minimum) vali...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, optional=False): self._required = not optional
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value) validators.validate_required(value, self._required) if not value: return None if value.lower() in self.true_values: return True elif value.lower() in self.false_values: return False ra...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): if value is True: return "true" elif value in (False, None): return "false" else: raise ValueError(f"{value!r} is not a boolean")
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value) if "\n" in value: values = re.split(r"\s*\n\s*", value) else: values = re.split(r"\s*,\s*", value) values = tuple(v.strip() for v in values if v.strip()) validators.validate_required(values, self._require...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): if not value: return "" return "\n " + "\n ".join(encode(v) for v in value if v)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value) validators.validate_choice(value.lower(), log.COLORS) return value.lower()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): if value.lower() in log.COLORS: return encode(value.lower()) return ""
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value) validators.validate_choice(value.lower(), self.levels.keys()) return self.levels.get(value.lower())
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize(self, value, display=False): lookup = {v: k for k, v in self.levels.items()} if value in lookup: return encode(lookup[value]) return ""
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value, display=False): value = decode(value).strip() validators.validate_required(value, self._required) if not value: return None socket_path = path.get_unix_socket_path(value) if socket_path is not None: path_str = Path(not self._r...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, choices=None, optional=False): super().__init__( minimum=0, maximum=2 ** 16 - 1, choices=choices, optional=optional )
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __new__(cls, original, expanded): return super().__new__(cls, expanded)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, original, expanded): self.original = original
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def deserialize(self, value): value = decode(value).strip() expanded = path.expand_path(value) validators.validate_required(value, self._required) validators.validate_required(expanded, self._required) if not value or expanded is None: return None return _Expa...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, msg): super(TransactionError, self).__init__(msg)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, branch, package): Base.__init__(self) self.branch = branch self.package = package self.sp_obj = None
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, filename, errors): """ :param filename: The name of the transaction file being replayed :param errors: a list of error classes or a string with an error description """ # store args in case someone wants to read them from a caught exception self.filena...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def parse(self): f = tempfile.NamedTemporaryFile(delete=True) cmd_str = "curl http://pkgs.fedoraproject.org/cgit/rpms/%s.git/plain/%s.spec > %s" runCommand(cmd_str % (self.package, self.package, f.name)) self.sp_obj = SpecParser(f.name) if not self.sp_obj.parse(): self.err = self.sp_obj.getError() f.clo...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, filename, msg): super(IncompatibleTransactionVersionError, self).__init__(filename, msg)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getProvides(self): """Fetch a spec file from pkgdb and get provides from all its [sub]packages""" if self.sp_obj == None: return {} return self.sp_obj.getProvides()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _check_version(version, filename): major, minor = version.split('.') try: major = int(major) except ValueError as e: raise TransactionReplayError( filename, _('Invalid major version "{major}", number expected.').format(major=major) ) try: int...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def getPackageCommits(self): if self.sp_obj == None: return "" return self.sp_obj.getMacro("commit")
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def serialize_transaction(transaction): """ Serializes a transaction to a data structure that is equivalent to the stored JSON format. :param transaction: the transaction to serialize (an instance of dnf.db.history.TransactionWrapper) """ data = { "version": VERSION, } rpms = [] ...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__( self, base, filename="", data=None, ignore_extras=False, ignore_installed=False, skip_unavailable=False ): """ :param base: the dnf base :param filename: the filename to load the transaction from (conflicts with the 'data'...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _load_from_file(self, fn): self._filename = fn with open(fn, "r") as f: try: replay_data = json.load(f) except json.decoder.JSONDecodeError as e: raise TransactionReplayError(fn, str(e) + ".") try: self._load_from_data(repl...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _load_from_data(self, data): self._replay_data = data self._verify_toplevel_json(self._replay_data) self._rpms = self._replay_data.get("rpms", []) self._assert_type(self._rpms, list, "rpms", "array") self._groups = self._replay_data.get("groups", []) self._assert_ty...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _raise_or_warn(self, warn_only, msg): if warn_only: self._warnings.append(msg) else: raise TransactionError(msg)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _assert_type(self, value, t, id, expected): if not isinstance(value, t): raise TransactionError(_('Unexpected type of "{id}", {exp} expected.').format(id=id, exp=expected))
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _verify_toplevel_json(self, replay_data): fn = self._filename if "version" not in replay_data: raise TransactionReplayError(fn, _('Missing key "{key}".'.format(key="version"))) self._assert_type(replay_data["version"], str, "version", "string") _check_version(replay_da...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _replay_pkg_action(self, pkg_data): try: action = pkg_data["action"] nevra = pkg_data["nevra"] repo_id = pkg_data["repo_id"] reason = libdnf.transaction.StringToTransactionItemReason(pkg_data["reason"]) except KeyError as e: raise Transacti...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _create_swdb_group(self, group_id, pkg_types, pkgs): comps_group = self._base.comps._group_by_id(group_id) if not comps_group: self._raise_or_warn(self._skip_unavailable, _("Group id '%s' is not available.") % group_id) return None swdb_group = self._base.history.gro...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _swdb_group_install(self, group_id, pkg_types, pkgs): swdb_group = self._create_swdb_group(group_id, pkg_types, pkgs) if swdb_group is not None: self._base.history.group.install(swdb_group)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _swdb_group_upgrade(self, group_id, pkg_types, pkgs): if not self._base.history.group.get(group_id): self._raise_or_warn( self._ignore_installed, _("Group id '%s' is not installed.") % group_id) return swdb_group = self._create_swdb_group(group_id, pkg_types, pkgs) ...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _swdb_group_remove(self, group_id, pkg_types, pkgs): if not self._base.history.group.get(group_id): self._raise_or_warn(self._ignore_installed, _("Group id '%s' is not installed.") % group_id) return swdb_group = self._create_swdb_group(group_id, pkg_types, pkgs) if...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _create_swdb_environment(self, env_id, pkg_types, groups): comps_env = self._base.comps._environment_by_id(env_id) if not comps_env: self._raise_or_warn(self._skip_unavailable, _("Environment id '%s' is not available.") % env_id) return None swdb_env = self._base.his...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _swdb_environment_install(self, env_id, pkg_types, groups): swdb_env = self._create_swdb_environment(env_id, pkg_types, groups) if swdb_env is not None: self._base.history.env.install(swdb_env)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _swdb_environment_upgrade(self, env_id, pkg_types, groups): if not self._base.history.env.get(env_id): self._raise_or_warn(self._ignore_installed,_("Environment id '%s' is not installed.") % env_id) return swdb_env = self._create_swdb_environment(env_id, pkg_types, groups) ...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _swdb_environment_remove(self, env_id, pkg_types, groups): if not self._base.history.env.get(env_id): self._raise_or_warn(self._ignore_installed, _("Environment id '%s' is not installed.") % env_id) return swdb_env = self._create_swdb_environment(env_id, pkg_types, groups) ...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def get_data(self): """ :returns: the loaded data of the transaction """ return self._replay_data
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def get_warnings(self): """ :returns: an array of warnings gathered during the transaction replay """ return self._warnings
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def run(self): """ Replays the transaction. """ fn = self._filename errors = [] for pkg_data in self._rpms: try: self._replay_pkg_action(pkg_data) except TransactionError as e: errors.append(e) for group_d...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def has_ext_modules(self): return True
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, host, loginUser, debug = False, trace = False, log=None, port=22, pexpectObject=None): self.pexpect = pexpect if not pexpectObject else pexpectObject self.debug = debug self.trace = trace self.host = host self._port = port self._connection = None ...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def finalize_options(self): ret = InstallCommandBase.finalize_options(self) self.install_headers = os.path.join(self.install_purelib, 'tensorflow', 'include') return ret
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __del__(self): self.closeCliConnectionTo()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def initialize_options(self): self.install_dir = None self.force = 0 self.outfiles = []
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def showOutputOnScreen(self): self.debug = True self.trace = True self._log = None self._setupLog()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def finalize_options(self): self.set_undefined_options('install', ('install_headers', 'install_dir'), ('force', 'force'))
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def connectWithSsh(self): self._debugLog("Establishing connection to " + self.host) self._connection = self.pexpect.spawn( 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no %s@%s -p %d' % (self._loginUser.username, self.host, self._port)) if self._...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def mkdir_and_copy_file(self, header): install_dir = os.path.join(self.install_dir, os.path.dirname(header)) # Get rid of some extra intervening directories so we can have fewer # directories for -I install_dir = re.sub('/google/protobuf_archive/src', '', install_dir) # Copy eigen code into tensorf...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def resetLoggingTo(self, log): self._connection.logfile = log
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def run(self): hdrs = self.distribution.headers if not hdrs: return self.mkpath(self.install_dir) for header in hdrs: (out, _) = self.mkdir_and_copy_file(header) self.outfiles.append(out)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def write(self, s): sys.stdout.buffer.write(s)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def get_inputs(self): return self.distribution.headers or []
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def flush(self): sys.stdout.flush()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def get_outputs(self): return self.outfiles
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def loginSsh(self): self._setupLog() self._debugLog("Login in as "+self._loginUser.username) try: self._loginUser.sendPassword() return True except Exception as e: self.forceCloseCliConnectionTo() raise Exception('Exception ('+str(e)+') '+...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def find_files(pattern, root): """Return all the files matching pattern below root dir.""" for path, _, files in os.walk(root): for filename in fnmatch.filter(files, pattern): yield os.path.join(path, filename)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _exit_modes_beyond(self, thisMode): if not self.modeList: return while len(self.modeList) > thisMode + 1: self.modeList.pop().exit()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def exitMode(self, mode): if mode in self.modeList: self.modeList.remove(mode)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def check_prereq(self, prereqMode = 0): self._exit_modes_beyond(prereqMode) if len(self.modeList) <= prereqMode: raise Exception("Attempted to enter menu when prerequist mode was not entered, expected: %d" % prereqMode)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def execute_as(self, user): self.check_prereq(self.LOGGED_IN) self._exit_modes_beyond(self.LOGGED_IN) user.commandLine(self) user.login() self.modeList.append(user) return user
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def closeCliConnectionTo(self): if self._connection == None: return self._exit_modes_beyond(-1) self.modeList = [] self._debugLog("Exited all modes.") self.forceCloseCliConnectionTo()
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def forceCloseCliConnectionTo(self): self.modeList = None if self._connection: self._debugLog("Closing connection.") self._connection.close() self._connection = None
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _debugLog(self, message): if self.debug: print(message)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _resetExpect(self): self.previousExpectLine = "" if self._connection is not None and isinstance(self._connection.buffer, str): self.previousExpectLine = self._connection.buffer self._connection.buffer = ""
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def _lastExpect(self): constructLine = self.previousExpectLine if self._connection is not None and isinstance(self._connection.before, str): constructLine += self._connection.before if self._connection is not None and isinstance(self._connection.after, str): constructLine...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def send(self, command): if self._bufferedCommands is None: self._bufferedCommands = command else: self._bufferedCommands += "\n" + command
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def flush(self): if self._bufferedCommands is None: return self._connection.sendline(str(self._bufferedCommands)) self._bufferedCommands = None
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def buffering(self): return self._bufferedMode
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def bufferedMode(self, mode = True): if mode is None: self.flush() self._bufferedMode = mode
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def create_node(self, *args, **kwargs): nbparam = len(args) + len(kwargs) assert nbparam in (0, len(Fields)), \ "Bad argument number for {}: {}, expecting {}".\ format(Name, nbparam, len(Fields)) self._fields = Fields self._attributes = Attributes for argn...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def parse(*args, **kwargs): return ast_to_gast(_ast.parse(*args, **kwargs))
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def literal_eval(node_or_string): if isinstance(node_or_string, AST): node_or_string = gast_to_ast(node_or_string) return _ast.literal_eval(node_or_string)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def get_dpo_proto(addr): if ip_address(addr).version == 6: return DpoProto.DPO_PROTO_IP6 else: return DpoProto.DPO_PROTO_IP4
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, addr): self.addr = addr self.ip_addr = ip_address(text_type(self.addr))
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def encode(self): if self.version == 6: return {'ip6': self.ip_addr} else: return {'ip4': self.ip_addr}
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def version(self): return self.ip_addr.version
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def address(self): return self.addr
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def length(self): return self.ip_addr.max_prefixlen
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def bytes(self): return self.ip_addr.packed
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __eq__(self, other): if isinstance(other, self.__class__): return self.ip_addr == other.ip_addr elif hasattr(other, "ip4") and hasattr(other, "ip6"): # vl_api_address_union_t if 4 == self.version: return self.ip_addr == other.ip4 else: ...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __ne__(self, other): return not (self == other)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __str__(self): return str(self.ip_addr)
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __init__(self, saddr, gaddr, glen): self.saddr = saddr self.gaddr = gaddr self.glen = glen if ip_address(self.saddr).version != \ ip_address(self.gaddr).version: raise ValueError('Source and group addresses must be of the ' 'same ad...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def encode(self): return { 'af': ip_address(self.gaddr).vapi_af, 'grp_address': { ip_address(self.gaddr).vapi_af_name: self.gaddr }, 'src_address': { ip_address(self.saddr).vapi_af_name: self.saddr }, 'grp_ad...
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def length(self): return self.glen
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def version(self): return ip_address(self.gaddr).version
def __init__(self, x=0.0, y=0.0): self.x = x self.y = y
def __str__(self): return "(%s,%s)/%d" % (self.saddr, self.gaddr, self.glen)