text
stringlengths
81
112k
Returns a C{WORD} from a given offset. @type offset: int @param offset: The offset to get the C{WORD} from. @rtype: L{WORD} @return: The L{WORD} obtained at the given offset. def getWordAtOffset(self, offset): """ Returns a C{WORD} from a given offset....
Returns a C{QWORD} from a given RVA. @type rva: int @param rva: The RVA to get the C{QWORD} from. @rtype: L{QWORD} @return: The L{QWORD} obtained at the given RVA. def getQwordAtRva(self, rva): """ Returns a C{QWORD} from a given RVA. ...
Returns a C{QWORD} from a given offset. @type offset: int @param offset: The offset to get the C{QWORD} from. @rtype: L{QWORD} @return: The L{QWORD} obtained at the given offset. def getQwordAtOffset(self, offset): """ Returns a C{QWORD} from a given o...
Gets binary data at a given RVA. @type rva: int @param rva: The RVA to get the data from. @type size: int @param size: The size of the data to be obtained. @rtype: str @return: The data obtained at the given RVA. def getDataAtRva(self, rva, si...
Gets binary data at a given offset. @type offset: int @param offset: The offset to get the data from. @type size: int @param size: The size of the data to be obtained. @rtype: str @return: The data obtained at the given offset. def getDataAtOff...
Returns a L{String} object from a given RVA. @type rva: int @param rva: The RVA to get the string from. @rtype: L{String} @return: A new L{String} object from the given RVA. def readStringAtRva(self, rva): """ Returns a L{String} object from a given RV...
Determines if the current L{PE} instance is an Executable file. @rtype: bool @return: C{True} if the current L{PE} instance is an Executable file. Otherwise, returns C{False}. def isExe(self): """ Determines if the current L{PE} instance is an Executable file. ...
Determines if the current L{PE} instance is a Dynamic Link Library file. @rtype: bool @return: C{True} if the current L{PE} instance is a DLL. Otherwise, returns C{False}. def isDll(self): """ Determines if the current L{PE} instance is a Dynamic Link Library file. ...
Determines if the current L{PE} instance is a driver (.sys) file. @rtype: bool @return: C{True} if the current L{PE} instance is a driver. Otherwise, returns C{False}. def isDriver(self): """ Determines if the current L{PE} instance is a driver (.sys) file. @rt...
Determines if the current L{PE} instance is a PE32 file. @rtype: bool @return: C{True} if the current L{PE} instance is a PE32 file. Otherwise, returns C{False}. def isPe32(self): """ Determines if the current L{PE} instance is a PE32 file. @rtype: bool ...
Determines if the current L{PE} instance is a PE64 file. @rtype: bool @return: C{True} if the current L{PE} instance is a PE64 file. Otherwise, returns C{False}. def isPe64(self): """ Determines if the current L{PE} instance is a PE64 file. @rtype: bool ...
Determines if the current L{PE} instance is bounded, i.e. has a C{BOUND_IMPORT_DIRECTORY}. @rtype: bool @return: Returns C{True} if the current L{PE} instance is bounded. Otherwise, returns C{False}. def isPeBounded(self): """ Determines if the current L{PE} instance is bounded...
Determines if the current L{PE} instance has the NXCOMPAT (Compatible with Data Execution Prevention) flag enabled. @see: U{http://msdn.microsoft.com/en-us/library/ms235442.aspx} @rtype: bool @return: Returns C{True} if the current L{PE} instance has the NXCOMPAT flag enabled. Otherwise, return...
Determines if the current L{PE} instance has CFG (Control Flow Guard) flag enabled. @see: U{http://blogs.msdn.com/b/vcblog/archive/2014/12/08/visual-studio-2015-preview-work-in-progress-security-feature.aspx} @see: U{https://msdn.microsoft.com/en-us/library/dn919635%%28v=vs.140%%29.aspx} @rtype...
Determines if the current L{PE} instance has the DYNAMICBASE (Use address space layout randomization) flag enabled. @see: U{http://msdn.microsoft.com/en-us/library/bb384887.aspx} @rtype: bool @return: Returns C{True} if the current L{PE} instance has the DYNAMICBASE flag enabled. Otherwise, ret...
Determines if the current L{PE} instance has the SAFESEH (Image has Safe Exception Handlers) flag enabled. @see: U{http://msdn.microsoft.com/en-us/library/9a89h429.aspx} @rtype: bool @return: Returns C{True} if the current L{PE} instance has the SAFESEH flag enabled. Returns C{False} if SAFESEH...
Parses all the directories in the L{PE} instance. @type dataDirectoryInstance: L{DataDirectory} @param dataDirectoryInstance: A L{DataDirectory} object with the directories data. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32...
Parses the C{IMAGE_RESOURCE_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_RESOURCE_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_RESOURCE_DIRECTORY} directory. @type magic: int @param magic...
Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type magic: int @param ma...
Parses the delay imports directory. @type rva: int @param rva: The RVA where the delay imports directory starts. @type size: int @param size: The size of the delay imports directory. @type magic: int @param magic: (Optional) The type of PE. Thi...
Parses the bound import directory. @type rva: int @param rva: The RVA where the bound import directory starts. @type size: int @param size: The size of the bound import directory. @type magic: int @param magic: (Optional) The type of PE. This v...
Parses IMAGE_LOAD_CONFIG_DIRECTORY. @type rva: int @param rva: The RVA where the IMAGE_LOAD_CONFIG_DIRECTORY starts. @type size: int @param size: The size of the IMAGE_LOAD_CONFIG_DIRECTORY. @type magic: int @param magic: (Optional) The type of...
Parses the TLS directory. @type rva: int @param rva: The RVA where the TLS directory starts. @type size: int @param size: The size of the TLS directory. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32...
Parses the relocation directory. @type rva: int @param rva: The RVA where the relocation directory starts. @type size: int @param size: The size of the relocation directory. @type magic: int @param magic: (Optional) The type of PE. This value c...
Parses the C{IMAGE_EXPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{IMAGE_EXPORT_DIRECTORY} directory. @type magic: int @param m...
Parses the C{IMAGE_DEBUG_DIRECTORY} directory. @see: U{http://msdn.microsoft.com/es-es/library/windows/desktop/ms680307(v=vs.85).aspx} @type rva: int @param rva: The RVA where the C{IMAGE_DEBUG_DIRECTORY} directory starts. @type size: int @param size: The size ...
Parses the C{IMAGE_IMPORT_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_IMPORT_DIRECTORY} directory starts. @type size: int @param size: The size of the C{IMAGE_IMPORT_DIRECTORY} directory. @type magic: int @param m...
Parses the NET directory. @see: U{http://www.ntcore.com/files/dotnetformat.htm} @type rva: int @param rva: The RVA where the NET directory starts. @type size: int @param size: The size of the NET directory. @type magic: int @param magic...
Returns a new L{DosHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{DosHeader} object. @rtype: L{DosHeader} @return: A new L{DosHeader} object. def parse(readDataInstance): """ ...
Returns a new L{NtHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{NtHeaders} object. @rtype: L{NtHeaders} @return: A new L{NtHeaders} object. def parse(readDataInstance): """ ...
Returns a new L{FileHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{FileHeader} object. @rtype: L{FileHeader} @return: A new L{ReadData} object. def parse(readDataInstance): """ ...
Returns a new L{OptionalHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{OptionalHeader} object. @rtype: L{OptionalHeader} @return: A new L{OptionalHeader} object. def parse(readDataInstance...
Returns a new L{SectionHeader} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeader} object. @rtype: L{SectionHeader} @return: A new L{SectionHeader} object. def parse(readDataInstance): ...
Returns a new L{SectionHeaders} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{SectionHeaders} object. @type numberOfSectionHeaders: int @param numberOfSectionHeaders: The number of L{SectionHeader...
Returns a new L{Sections} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with data to be parsed as a L{Sections} object. @type sectionHeadersInstance: instance @param sectionHeadersInstance: The L{SectionHeaders} instance with ...
Get addresses across both subchains based on the filter criteria passed in Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'pubkeyhex': '0123456...'}, ..., ] Dicts may also contain WIF and privkeyhex if wallet_obj has private ...
Hit /derive to register new unused_addresses on a subchain_index and verify them client-side Returns a list of dicts of the following form: [ {'address': '1abc123...', 'path': 'm/0/9', 'public': '0123456...'}, ..., ] def register_unused_addresses(wallet_obj, subchain_index,...
Offline-enabled mechanism to dump addresses def dump_all_keys_or_addrs(wallet_obj): ''' Offline-enabled mechanism to dump addresses ''' print_traversal_warning() puts('\nDo you understand this warning?') if not confirm(user_prompt=DEFAULT_PROMPT, default=False): puts(colored.red('Dump...
Works for both public key only or private key access def dump_selected_keys_or_addrs(wallet_obj, used=None, zero_balance=None): ''' Works for both public key only or private key access ''' if wallet_obj.private_key: content_str = 'private keys' else: content_str = 'addresses' i...
Offline-enabled mechanism to dump everything def dump_private_keys_or_addrs_chooser(wallet_obj): ''' Offline-enabled mechanism to dump everything ''' if wallet_obj.private_key: puts('Which private keys and addresses do you want?') else: puts('Which addresses do you want?') with...
Loaded on bootup (and stays in while loop until quitting) def wallet_home(wallet_obj): ''' Loaded on bootup (and stays in while loop until quitting) ''' mpub = wallet_obj.serialize_b58(private=False) if wallet_obj.private_key is None: print_pubwallet_notice(mpub=mpub) else: pri...
Solves the GFL for a fixed value of lambda. def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' if self.penalty == 'dp': return self.solve_dp(lam) if self.penalty == 'gfl': return self.solve_gfl(lam) if self.penalty == 'gamlasso': ...
Solves the Graph-fused double Pareto (non-convex, local optima only) def solve_dp(self, lam): '''Solves the Graph-fused double Pareto (non-convex, local optima only)''' cur_converge = self.converge+1 step = 0 # Get an initial estimate using the GFL self.solve_gfl(lam) be...
Solves the Graph-fused gamma lasso via POSE (Taddy, 2013) def solve_gamlasso(self, lam): '''Solves the Graph-fused gamma lasso via POSE (Taddy, 2013)''' weights = lam / (1 + self.gamma * np.abs(self.beta[self.trails[::2]] - self.beta[self.trails[1::2]])) s = self.solve_gfl(u) self.steps...
Follows the solution path to find the best lambda value. def solution_path(self, min_lambda, max_lambda, lambda_bins, verbose=0): '''Follows the solution path to find the best lambda value.''' lambda_grid = np.exp(np.linspace(np.log(max_lambda), np.log(min_lambda), lambda_bins)) aic_trace = np....
Generate sequences. def main(): """ Generate sequences.""" parser = OptionParser(conflict_handler="resolve") parser.add_option('--humanTRA', '--human_T_alpha', action='store_true', dest='humanTRA', default=False, help='use default human TRA model (T cell alpha chain)') parser.add_option('--humanTRB',...
Netmiko is being used to push set commands. def _send_merge_commands(self, config, file_config): """ Netmiko is being used to push set commands. """ if self.loaded is False: if self._save_backup() is False: raise MergeConfigException('Error while storing back...
Netmiko is being used to obtain config diffs because pan-python doesn't support the needed command. def compare_config(self): """ Netmiko is being used to obtain config diffs because pan-python doesn't support the needed command. """ if self.ssh_connection is False: ...
Netmiko is being used to commit the configuration because it takes a better care of results compared to pan-python. def commit_config(self): """ Netmiko is being used to commit the configuration because it takes a better care of results compared to pan-python. """ if sel...
Netmiko is being used to commit the rollback configuration because it takes a better care of results compared to pan-python. def rollback(self): """ Netmiko is being used to commit the rollback configuration because it takes a better care of results compared to pan-python. """ ...
Return LLDP neighbors details. def get_lldp_neighbors(self): """Return LLDP neighbors details.""" neighbors = {} cmd = '<show><lldp><neighbors>all</neighbors></lldp></show>' try: self.device.op(cmd=cmd) lldp_table_xml = xmltodict.parse(self.device.xml_root()) ...
Return route details to a specific destination, learned from a certain protocol. def get_route_to(self, destination='', protocol=''): """Return route details to a specific destination, learned from a certain protocol.""" # Note, it should be possible to query the FIB: # "<show><routing><fib></...
Return IP interface data. def get_interfaces_ip(self): '''Return IP interface data.''' def extract_ip_info(parsed_intf_dict): ''' IPv4: - Primary IP is in the '<ip>' tag. If no v4 is configured the return value is 'N/A'. - Secondary IP's are in '<add...
Return a refined CSG. To each polygon, a middle point is added to each edge and to the center of the polygon def refine(self): """ Return a refined CSG. To each polygon, a middle point is added to each edge and to the center of the polygon """ newCSG = CSG() fo...
Translate Geometry. disp: displacement (array of floats) def translate(self, disp): """ Translate Geometry. disp: displacement (array of floats) """ d = Vector(disp[0], disp[1], disp[2]) for poly in self.polygons: for v in poly.vertices: ...
Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees def rotate(self, axis, angleDeg): """ Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees """ ax = Vector(a...
Return list of vertices, polygons (cells), and the total number of vertex indices in the polygon connectivity list (count). def toVerticesAndPolygons(self): """ Return list of vertices, polygons (cells), and the total number of vertex indices in the polygon connectivity list ...
Save polygons in VTK file. def saveVTK(self, filename): """ Save polygons in VTK file. """ with open(filename, 'w') as f: f.write('# vtk DataFile Version 3.0\n') f.write('pycsg output\n') f.write('ASCII\n') f.write('DATASET POLYDATA\n') ...
Return a new CSG solid representing space in either this solid or in the solid `csg`. Neither this solid nor the solid `csg` are modified.:: A.union(B) +-------+ +-------+ | | | | | A | | | ...
Return a new CSG solid with solid and empty space switched. This solid is not modified. def inverse(self): """ Return a new CSG solid with solid and empty space switched. This solid is not modified. """ csg = self.clone() map(lambda p: p.flip(), csg.polygons) ...
Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( ...
Returns a sphere. Kwargs: center (list): Center of sphere, default [0, 0, 0]. radius (float): Radius of sphere, default 1.0. slices (int): Number of slices, default 16. stacks (int...
Returns a cylinder. Kwargs: start (list): Start of cylinder, default [0, -1, 0]. end (list): End of cylinder, default [0, 1, 0]. radius (float): Radius of cylinder, default 1.0. sl...
Returns a cone. Kwargs: start (list): Start of cone, default [0, -1, 0]. end (list): End of cone, default [0, 1, 0]. radius (float): Maximum radius of cone at start, default 1.0. s...
Load the nbt file at the specified location. By default, the function will figure out by itself if the file is gzipped before loading it. You can pass a boolean to the `gzipped` keyword only argument to specify explicitly whether the file is compressed or not. You can also use the `byteorder` keyw...
Load nbt file from a file-like object. The `buff` argument can be either a standard `io.BufferedReader` for uncompressed nbt or a `gzip.GzipFile` for gzipped nbt data. def from_buffer(cls, buff, byteorder='big'): """Load nbt file from a file-like object. The `buff` argument can ...
Read, parse and return the file at the specified location. The `gzipped` argument is used to indicate if the specified file is gzipped. The `byteorder` argument lets you specify whether the file is big-endian or little-endian. def load(cls, filename, gzipped, byteorder='big'): """...
Write the file at the specified location. The `gzipped` keyword only argument indicates if the file should be gzipped. The `byteorder` keyword only argument lets you specify whether the file should be big-endian or little-endian. If the method is called without any argument, it w...
Change method return value from raw API output to collection of models def return_collection(collection_type): """Change method return value from raw API output to collection of models """ def outer_func(func): @functools.wraps(func) def inner_func(self, *pargs, **kwargs): resul...
Update related objects when the Stop is updated def post_save_stop(sender, instance, **kwargs): '''Update related objects when the Stop is updated''' from multigtfs.models.trip import Trip trip_ids = instance.stoptime_set.filter( trip__shape=None).values_list('trip_id', flat=True).distinct() fo...
Handle actions that need to be done with every response I'm not sure what these session_ops are actually used for yet, seems to be a way to tell the client to do *something* if needed. def _do_post_request_tasks(self, response_data): """Handle actions that need to be done with every response ...
Build a function to do an API request "We have to go deeper" or "It's functions all the way down!" def _build_request(self, method, url, params=None): """Build a function to do an API request "We have to go deeper" or "It's functions all the way down!" """ full_params = self._...
Build a URL for a API method request def _build_request_url(self, secure, api_method): """Build a URL for a API method request """ if secure: proto = ANDROID_MANGA.PROTOCOL_SECURE else: proto = ANDROID_MANGA.PROTOCOL_INSECURE req_url = ANDROID_MANGA.API_U...
Login using email/username and password, used to get the auth token @param str account @param str password @param str hash_id (optional) def cr_login(self, response): """ Login using email/username and password, used to get the auth token @param str account @pa...
Handle data loaded from database. def from_db_value(self, value, expression, connection, context): '''Handle data loaded from database.''' if value is None: return value return self.parse_seconds(value)
Handle data from serialization and form clean() methods. def to_python(self, value): '''Handle data from serialization and form clean() methods.''' if isinstance(value, Seconds): return value if value in self.empty_values: return None return self.parse_seconds(va...
Parse string into Seconds instances. Handled formats: HH:MM:SS HH:MM SS def parse_seconds(value): ''' Parse string into Seconds instances. Handled formats: HH:MM:SS HH:MM SS ''' svalue = str(value) colons = svalue...
Prepare value for database storage. def get_prep_value(self, value): '''Prepare value for database storage.''' if isinstance(value, Seconds): return value.seconds elif value: return self.parse_seconds(value).seconds else: return None
Returns the positions and colors of all intervals inside the colorbar. def calculate_colorbar(self): """ Returns the positions and colors of all intervals inside the colorbar. """ self._base._process_values() self._base._find_range() X, Y = self._base._mesh() C =...
Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string. def calculate_ticks(self): """ Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string. """ curr...
CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page def get_media_formats(self, media_id): """CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video ...
Parse a literal nbt string and return the resulting tag. def parse_nbt(literal): """Parse a literal nbt string and return the resulting tag.""" parser = Parser(tokenize(literal)) tag = parser.parse() cursor = parser.token_span[1] leftover = literal[cursor:] if leftover.strip(): parser....
Match and yield all the tokens of the input string. def tokenize(string): """Match and yield all the tokens of the input string.""" for match in TOKENS_REGEX.finditer(string): yield Token(match.lastgroup, match.group().strip(), match.span())
Move to the next token in the token stream. def next(self): """Move to the next token in the token stream.""" self.current_token = next(self.token_stream, None) if self.current_token is None: self.token_span = self.token_span[1], self.token_span[1] raise self.error('Unex...
Parse and return an nbt literal from the token stream. def parse(self): """Parse and return an nbt literal from the token stream.""" token_type = self.current_token.type.lower() handler = getattr(self, f'parse_{token_type}', None) if handler is None: raise self.error(f'Inval...
Parse a number from the token stream. def parse_number(self): """Parse a number from the token stream.""" value = self.current_token.value suffix = value[-1].lower() try: if suffix in NUMBER_SUFFIXES: return NUMBER_SUFFIXES[suffix](value[:-1]) re...
Parse a regular unquoted string from the token stream. def parse_string(self): """Parse a regular unquoted string from the token stream.""" aliased_value = LITERAL_ALIASES.get(self.current_token.value.lower()) if aliased_value is not None: return aliased_value return String(...
Yield the item tokens in a comma-separated tag collection. def collect_tokens_until(self, token_type): """Yield the item tokens in a comma-separated tag collection.""" self.next() if self.current_token.type == token_type: return while True: yield self.current_to...
Parse a compound from the token stream. def parse_compound(self): """Parse a compound from the token stream.""" compound_tag = Compound() for token in self.collect_tokens_until('CLOSE_COMPOUND'): item_key = token.value if token.type not in ('NUMBER', 'STRING', 'QUOTED_S...
Parse and yield array items from the token stream. def array_items(self, number_type, *, number_suffix=''): """Parse and yield array items from the token stream.""" for token in self.collect_tokens_until('CLOSE_BRACKET'): is_number = token.type == 'NUMBER' value = token.value.lo...
Parse a list from the token stream. def parse_list(self): """Parse a list from the token stream.""" try: return List([self.parse() for _ in self.collect_tokens_until('CLOSE_BRACKET')]) except IncompatibleItemType as exc: raise self.error(f'Item {...
Return the unquoted value of a quoted string. def unquote_string(self, string): """Return the unquoted value of a quoted string.""" value = string[1:-1] forbidden_sequences = {ESCAPE_SUBS[STRING_QUOTES[string[0]]]} valid_sequences = set(ESCAPE_SEQUENCES) - forbidden_sequences ...
Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text. def opener_from_zipfile(zipfile): """ Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text. ...
Write CSV row data which may include text. def write_text_rows(writer, rows): '''Write CSV row data which may include text.''' for row in rows: try: writer.writerow(row) except UnicodeEncodeError: # Python 2 csv does badly with unicode outside of ASCII new_ro...
Serialize an nbt tag to its literal representation. def serialize_tag(tag, *, indent=None, compact=False, quote=None): """Serialize an nbt tag to its literal representation.""" serializer = Serializer(indent=indent, compact=compact, quote=quote) return serializer.serialize(tag)
Increase the level of indentation by one. def depth(self): """Increase the level of indentation by one.""" if self.indentation is None: yield else: previous = self.previous_indent self.previous_indent = self.indent self.indent += self.indentation ...
Return whether the specified tag should be expanded. def should_expand(self, tag): """Return whether the specified tag should be expanded.""" return self.indentation is not None and tag and ( not self.previous_indent or ( tag.serializer == 'list' and tag.subt...
Return the escaped literal representation of an nbt string. def escape_string(self, string): """Return the escaped literal representation of an nbt string.""" if self.quote: quote = self.quote else: found = QUOTE_REGEX.search(string) quote = STRING_QUOTES[fou...
Escape the compound key if it can't be represented unquoted. def stringify_compound_key(self, key): """Escape the compound key if it can't be represented unquoted.""" if UNQUOTED_COMPOUND_KEY.match(key): return key return self.escape_string(key)
Return the literal representation of a tag. def serialize(self, tag): """Return the literal representation of a tag.""" handler = getattr(self, f'serialize_{tag.serializer}', None) if handler is None: raise TypeError(f'Can\'t serialize {type(tag)!r} instance') return handler...