Search is not available for this dataset
text
stringlengths
75
104k
def write(self, filename = ""): """ Writes data from L{PE} object to a file. @rtype: str @return: The L{PE} stream data. @raise IOError: If the file could not be opened for write operations. """ file_data = str(self) if filename: try:...
def __write(self, thePath, theData): """ Write data to a file. @type thePath: str @param thePath: The file path. @type theData: str @param theData: The data to write. """ fd = open(thePath, "wb") fd.write(theData) fd.c...
def _updateDirectoriesData(self, peStr): """ Updates the data in every L{Directory} object. @type peStr: str @param peStr: C{str} representation of the L{PE} object. @rtype: str @return: A C{str} representation of the L{PE} object. """ da...
def _getPaddingDataToSectionOffset(self): """ Returns the data between the last section header and the begenning of data from the first section. @rtype: str @return: Data between last section header and the begenning of the first section. """ start = self._getPad...
def _getSignature(self, readDataInstance, dataDirectoryInstance): """ Returns the digital signature within a digital signed PE file. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} instance containing a PE file data. @type dataDirector...
def _getOverlay(self, readDataInstance, sectionHdrsInstance): """ Returns the overlay data from the PE file. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} instance containing the PE file data. @type sectionHdrsInstance: L{SectionHead...
def getOffsetFromRva(self, rva): """ Converts an offset to an RVA. @type rva: int @param rva: The RVA to be converted. @rtype: int @return: An integer value representing an offset in the PE file. """ offset = -1 s = self.getSectio...
def getRvaFromOffset(self, offset): """ Converts a RVA to an offset. @type offset: int @param offset: The offset value to be converted to RVA. @rtype: int @return: The RVA obtained from the given offset. """ rva = -1 s = self.getS...
def getSectionByOffset(self, offset): """ Given an offset in the file, tries to determine the section this offset belong to. @type offset: int @param offset: Offset value. @rtype: int @return: An index, starting at 0, that represents the section the give...
def getSectionIndexByName(self, name): """ Given a string representing a section name, tries to find the section index. @type name: str @param name: A section name. @rtype: int @return: The index, starting at 0, of the section. """ index = -1 ...
def getSectionByRva(self, rva): """ Given a RVA in the file, tries to determine the section this RVA belongs to. @type rva: int @param rva: RVA value. @rtype: int @return: An index, starting at 1, that represents the section the given RVA belongs to. ...
def _getPaddingToSectionOffset(self): """ Returns the offset to last section header present in the PE file. @rtype: int @return: The offset where the end of the last section header resides in the PE file. """ return len(str(self.dosHeader) + str(self.dosStub) + s...
def fullLoad(self): """Parse all the directories in the PE file.""" self._parseDirectories(self.ntHeaders.optionalHeader.dataDirectory, self.PE_TYPE)
def _internalParse(self, readDataInstance): """ Populates the attributes of the L{PE} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} instance with the data of a PE file. """ self.dosHeader = DosHeader.parse(readDataInstance) ...
def addSection(self, data, name =".pype32\x00", flags = 0x60000000): """ Adds a new section to the existing L{PE} instance. @type data: str @param data: The data to be added in the new section. @type name: str @param name: (Optional) The name for the new...
def extendSection(self, sectionIndex, data): """ Extends an existing section in the L{PE} instance. @type sectionIndex: int @param sectionIndex: The index for the section to be extended. @type data: str @param data: The data to include in the section. ...
def _fixPe(self): """ Fixes the necessary fields in the PE file instance in order to create a valid PE32. i.e. SizeOfImage. """ sizeOfImage = 0 for sh in self.sectionHeaders: sizeOfImage += sh.misc self.ntHeaders.optionaHeader.sizeoOfImage.value = self._sectio...
def _adjustFileAlignment(self, value, fileAlignment): """ Align a value to C{FileAligment}. @type value: int @param value: The value to align. @type fileAlignment: int @param fileAlignment: The value to be used to align the C{value} parameter. ...
def _adjustSectionAlignment(self, value, fileAlignment, sectionAlignment): """ Align a value to C{SectionAligment}. @type value: int @param value: The value to be aligned. @type fileAlignment: int @param fileAlignment: The value to be used as C{FileAlig...
def getDwordAtRva(self, rva): """ Returns a C{DWORD} from a given RVA. @type rva: int @param rva: The RVA to get the C{DWORD} from. @rtype: L{DWORD} @return: The L{DWORD} obtained at the given RVA. """ return datatypes.DWORD.parse(utils....
def getWordAtRva(self, rva): """ Returns a C{WORD} from a given RVA. @type rva: int @param rva: The RVA to get the C{WORD} from. @rtype: L{WORD} @return: The L{WORD} obtained at the given RVA. """ return datatypes.WORD.parse(utils.ReadDa...
def getDwordAtOffset(self, offset): """ Returns a C{DWORD} from a given offset. @type offset: int @param offset: The offset to get the C{DWORD} from. @rtype: L{DWORD} @return: The L{DWORD} obtained at the given offset. """ return datatyp...
def getWordAtOffset(self, offset): """ 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. """ return datatypes.WO...
def getQwordAtRva(self, rva): """ 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. """ return datatypes.QWORD.parse(utils....
def getQwordAtOffset(self, offset): """ 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. """ return datatyp...
def getDataAtRva(self, rva, size): """ 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 obt...
def getDataAtOffset(self, offset, size): """ 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 @ret...
def readStringAtRva(self, rva): """ 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. """ d = self.getDataAtRva(r...
def isExe(self): """ 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}. """ if not self.isDll() and not self.isDriver() and ( consts.IMAGE...
def isDll(self): """ 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}. """ if (consts.IMAGE_FILE_DLL & self.ntHeaders.fileHeader.characterist...
def isDriver(self): """ 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}. """ modules = [] imports = self.ntHeaders.optionalHeader.dataDi...
def isPe32(self): """ 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}. """ if self.ntHeaders.optionalHeader.magic.value == consts.PE32: re...
def isPe64(self): """ 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}. """ if self.ntHeaders.optionalHeader.magic.value == consts.PE64: re...
def isPeBounded(self): """ 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}. """ boundImportsDir = self.ntHeaders...
def isNXEnabled(self): """ 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 t...
def isCFGEnabled(self): """ 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/dn...
def isASLREnabled(self): """ 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...
def isSAFESEHEnabled(self): """ 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 S...
def _parseDirectories(self, dataDirectoryInstance, magic = consts.PE32): """ Parses all the directories in the L{PE} instance. @type dataDirectoryInstance: L{DataDirectory} @param dataDirectoryInstance: A L{DataDirectory} object with the directories data. @type ...
def _parseResourceDirectory(self, rva, size, magic = 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{IMAG...
def _parseExceptionDirectory(self, rva, size, magic = consts.PE32): """ 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{I...
def _parseDelayImportDirectory(self, rva, size, magic = consts.PE32): """ 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 directo...
def _parseBoundImportDirectory(self, rva, size, magic = consts.PE32): """ 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....
def _parseLoadConfigDirectory(self, rva, size, magic = consts.PE32): """ 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_...
def _parseTlsDirectory(self, rva, size, magic = consts.PE32): """ 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 ...
def _parseRelocsDirectory(self, rva, size, magic = 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. ...
def _parseExportDirectory(self, rva, size, magic = consts.PE32): """ 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{...
def _parseDebugDirectory(self, rva, size, magic = consts.PE32): """ 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_DIRECTOR...
def _parseImportDirectory(self, rva, size, magic = consts.PE32): """ 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{...
def _parseNetDirectory(self, rva, size, magic = consts.PE32): """ 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...
def parse(readDataInstance): """ 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} obje...
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{Op...
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{Secti...
def parse(readDataInstance, numberOfSectionHeaders): """ 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...
def parse(readDataInstance, sectionHeadersInstance): """ 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 ...
def get_addresses_on_both_chains(wallet_obj, used=None, zero_balance=None): ''' 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...'}, ...
def register_unused_addresses(wallet_obj, subchain_index, num_addrs=1): ''' 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 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 Cancelled!')) return mpub = wal...
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' if not USER_ONLINE: puts(colored.red('\nInterne...
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 indent(2): puts(colored.cyan('1: Acti...
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: print_bcwallet_basic_pub_opening(mpub=mpub) coin_symbol =...
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': return self.solve_gfl(lam) raise Exce...
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) beta2 = np.copy(self.beta) while cur_converge > self.converge an...
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.append(s) return self.beta
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.zeros(lambda_grid.shape) # The AIC score for each lambda v...
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', '--human_T_beta', ac...
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 backup ' ...
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: self._open_ssh() self.ssh_device.exit_config_mode() diff = self.ssh_device.send_comm...
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 self.loaded: if self.ssh_connection is False: self._open_ssh() try: self...
def rollback(self): """ Netmiko is being used to commit the rollback configuration because it takes a better care of results compared to pan-python. """ if self.changed: rollback_cmd = '<load><config><from>{0}</from></config></load>'.format(self.backup_file) ...
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()) lldp_table_json = jso...
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></fib></routing></show>" # To add informations to this getter routes...
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 '<addr>'. If no secondaries, thi...
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() for poly in self.polygons: verts = poly.vertices numVerts = len(verts) if numVerts ...
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: v.pos = v.pos.plus(d)
def rotate(self, axis, angleDeg): """ Rotate geometry. axis: axis of rotation (array of floats) angleDeg: rotation angle in degrees """ ax = Vector(axis[0], axis[1], axis[2]).unit() cosAngle = math.cos(math.pi * angleDeg / 180.) sinAngle = math.sin(m...
def toVerticesAndPolygons(self): """ Return list of vertices, polygons (cells), and the total number of vertex indices in the polygon connectivity list (count). """ offset = 1.234567890 verts = [] polys = [] vertexIndexMap = {} count = 0 ...
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') verts, ce...
def union(self, csg): """ 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) +-------+ +-------+ | | | | ...
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) return csg
def cube(cls, center=[0,0,0], radius=[1,1,1]): """ 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. ...
def sphere(cls, **kwargs): """ 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. ...
def cylinder(cls, **kwargs): """ 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...
def cone(cls, **kwargs): """ 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....
def load(filename, *, gzipped=None, byteorder='big'): """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...
def from_buffer(cls, buff, byteorder='big'): """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. """ self = cls.parse(buff, byteorder) self.filen...
def load(cls, filename, gzipped, byteorder='big'): """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 save(self, filename=None, *, gzipped=None, byteorder=None): """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 ...
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): result = func(self, *pargs, **kwargs) return list(map(collection_...
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() for trip in Trip.objects.filter(id__in=trip_ids): ...
def _do_post_request_tasks(self, response_data): """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. """ try: sess_ops = response_d...
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._get_base_params() if params is not None: full_params.update(params) try: ...
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_URL.format( protocol=proto,...
def cr_login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param str hash_id (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user']...
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)
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(value)
def parse_seconds(value): ''' Parse string into Seconds instances. Handled formats: HH:MM:SS HH:MM SS ''' svalue = str(value) colons = svalue.count(':') if colons == 2: hours, minutes, seconds = [int(v) for v in svalue.split(':...
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