示例#1
0
class PaymentInformation(dexml.Model):
    payment_information_identification = fields.String(tagname="PmtInfId")
    payment_method = fields.String(tagname="PmtMtd")
    payment_type_information =  fields.Model(PaymentTypeInformation)
    requested_collection_date = fields.String(tagname="ReqdColltnDt")
    creditor = fields.Model(Creditor)
    creditor_account = fields.Model(CreditorAccount)
    creditor_agent = fields.Model(CreditorAgent)
    creditor_scheme_identification = fields.Model(CreditorSchemeIdentification)
    direct_debit_transaction_information = fields.Model(DirectDebitTransactionInformation)

    def __init__(self, payment_id=None):
        self.payment_type_information = PaymentTypeInformation()
        if not payment_id:
            self.payment_information_identification = generated_id(35)
        self.requested_collection_date = iso_date()
        self.creditor = Creditor()
        self.creditor_account = CreditorAccount()
        self.creditor_agent = CreditorAgent()
        self.direct_debit_transaction_information = DirectDebitTransactionInformation()
        self.creditor_scheme_identification = CreditorSchemeIdentification()
        self.payment_method = "DD"

    def render(self, **kwargs):
        self.payment_information_identification = clean_string(self.payment_information_identification, 35)
        self.requested_collection_date = clean_string(self.requested_collection_date, 2)

        return super(PaymentInformation, self).render(**kwargs)

    class meta:
        tagname = "PmtInf"
示例#2
0
class SignOnLineCmd(dexml.Model):
    declare_sunat = fields.String(attrname="declare-sunat")
    declare_direct_sunat = fields.String(attrname="declare-direct-sunat")
    publish = fields.String()
    output = fields.String()
    parametros = fields.List(Parameter)
    documentos = fields.List(Documento)
示例#3
0
文件: test.py 项目: saltycrane/dexml
        class junk(dexml.Model):
            class meta:
                order_sensitive = True

            name = fields.String(tagname=True)
            notes = fields.List(fields.String(tagname="note"))
            amount = fields.Integer(tagname=True)
示例#4
0
文件: test.py 项目: saltycrane/dexml
        class A(dexml.Model):
            class meta:
                namespace = 'T:'

            a = fields.String(attrname=('A:', 'a'))
            b = fields.String(attrname=(None, 'b'))
            c = fields.String(tagname=(None, 'c'))
示例#5
0
class PackageElement(dexml.Model):
    class meta:
        tagname = "package"
        order_sensitive = False

    name = fields.String(tagname="name")
    fileHash = fields.String(tagname="hash")
    size = fields.String(tagname="size")
示例#6
0
class results(dexml.Model):
    method = fields.String(tagname='method')
    response = fields.String(tagname='response',required=False)
    token = fields.String(tagname='token',required=False)
    file_infos = fields.List(fields.Model(file_info),required=False)
    folder_info = fields.Model(folder_info, required=False)
    folders = fields.List("folder_info", tagname="folders", required=False)
    files = fields.List("file_info", tagname="files", required=False)
示例#7
0
class InstructedAmount(dexml.Model):
    '''Importe del adeudo directo expresado en euros (AT-06).'''

    currency = fields.String(attrname="Ccy")
    amount = fields.String(tagname=".")

    def __init__(self):
        self.currency = "EUR"

    class meta:
        tagname = "InstdAmt"
示例#8
0
class Object(dexml.Model):
    command = fields.String()

    left = fields.Integer()
    top = fields.Integer()
    right = fields.Integer()
    bottom = fields.Integer()

    fill = fields.String()

    probability = fields.Float()
示例#9
0
class MandateRelatedInformation(dexml.Model):
    '''Conjunto de elementos utilizado para suministrar mayor información sobre el mandato firmado entre acreedor y deudor.'''
    """Este elemento es de uso obligatorio. Si la etiqueta 2.50 ‘Indicador de modificación’ tiene el valor ‘false’,
    no se permite la presencia del elemento 2.51 ‘Detalles de la modificación’. Si la etiqueta 2.50 ‘Indicador de modificación’
    tiene el valor ‘true’, el elemento 2.51 ‘Detalles de la modificación’ debe estar presente.
    """
    mandate_identification = fields.String(tagname="MndtId")
    date_of_signature = fields.String(tagname="DtOfSgntr")

    def __init__(self):
        self.mandate_identification = generated_id(35)
        self.date_of_signature = iso_date()

    class meta:
        tagname = "MndtRltdInf"
示例#10
0
class FinancialInstitutionIdentification(dexml.Model):
    '''Identificación única e inequívoca de una entidad de crédito, asignada en virtud de un esquema internacional reconocido de identificación.'''

    bic = fields.String(tagname="BIC", required=False)

    class meta:
        tagname = "FinInstnId"
示例#11
0
class Identification(dexml.Model):
    '''Identificación única e inequívoca de la cuenta del acreedor.'''

    iban = fields.String(tagname="IBAN")

    class meta:
        tagname = "Id"
示例#12
0
class RouteModel(dexml.Model):
    class meta:
        namespace = 'http://www.sam-electronics.de/2010/reducedRouteModel.xsd'
        tagname = "RouteModel"

    name = fields.String(tagname="Name")
    waypoints = fields.List(Waypoint)
示例#13
0
class PaymentIdentification(dexml.Model):
    '''Conjunto de elementos que sirven de referencia de una instrucción de pago.'''

    instruction_identification = fields.String(tagname="InstrId", required=False)
    end_to_end_identification = fields.String(tagname='EndToEndId')

    def __init__(self):
        self.end_to_end_identification = generated_id(35)

    def render(self, **kwargs):
        self.end_to_end_identification = clean_string(self.end_to_end_identification, 35)

        return super(PaymentIdentification, self).render(**kwargs)

    class meta:
        tagname = "PmtId"
示例#14
0
class DirectDebitTransactionInformation(dexml.Model):
    """
    Conjunto de elementos utilizados para proporcionar información sobre cada una de las operaciones individuales
    incluidas en el mensaje.
    """

    payment_identification = fields.Model(PaymentIdentification)
    instructed_amount = fields.Model(InstructedAmount)
    charge_bearer = fields.String(tagname="ChrgBr")
    direct_debit_transaction = fields.Model(DirectDebitTransaction)
    debtor_agent = fields.Model(DebtorAgent)
    debtor = fields.Model(Debtor)
    debtor_account = fields.Model(DebtorAccount)
    remittance_information = fields.Model(RemittanceInformation)

    def __init__(self):
        self.payment_identification = PaymentIdentification()
        self.instructed_amount = InstructedAmount()
        self.charge_bearer = "SLEV"
        self.debtor_agent = DebtorAgent()
        self.debtor = Debtor()
        self.debtor_account = DebtorAccount()
        self.direct_debit_transaction = DirectDebitTransaction()

    class meta:
        tagname = "DrctDbtTxInf"
class SegResult(MainModel):
    """Main model for tracker output when run on a sample."""
    class meta:
        tagname = "seg_result"
    # FIXME relative or absolute? Should be **relative** to dataset root
    source_sample_file   = fields.String(tagname="source_sample_file")
    segmentation_results = fields.List(FrameSegResult, tagname="segmentation_results")
class Frame(dexml.Model):
    """Store information about a frame to process: index in original stream, filename of extracted version, etc."""
    class meta:
        tagname = "frame"
    index     = fields.Integer(required=False)
    time      = fields.Float(required=False)
    filename  = fields.String() # can be relative to root given to a tool on command line
示例#17
0
class activelock(_davbase):
    """XML model for an activelock response message."""
    lockscope = fields.Model("lockscope")
    locktype = fields.Model("locktype")
    depth = fields.String(tagname="depth")
    owner = fields.XmlNode(tagname="owner", encoding="UTF-8", required=False)
    timeout = TimeoutField(required=False)
    locktoken = fields.Model("locktoken", required=False)
示例#18
0
class GroupTextLine(dexml.Model):
    lines = fields.List(Line)
    probability = fields.Float()
    type = fields.String()
    def __init__(self, probability= 0.0, type='NULL'):
        self.probability = probability
        self.type = type
        self.real_lines = []
示例#19
0
class response(_davbase):
    """XML model for an individual response in a multi-status message."""
    href = HrefField()
    # TODO: ensure only one of hrefs/propstats
    hrefs = fields.List(HrefField(), required=False)
    status = StatusField(required=False)
    propstats = fields.List("propstat", required=False)
    description = fields.String(tagname="responsedescription", required=False)
示例#20
0
class Line(dexml.Model):
    #id = fields.Integer(attrname="id")
    height = fields.Integer()
    text_min_height_prob = fields.Float()

    y_space_step = fields.Integer()
    cells = fields.List(Cell)
    type = fields.String()
    probability = fields.Float()
    repeat = fields.Integer()
示例#21
0
class Other(dexml.Model):
    '''Identificación única de una parte, asignada por una institución, mediante un esquema de identificación.'''

    identification = fields.String(tagname="Id")

    def __init__(self):
        pass

    class meta:
        tagname = "Othr"
示例#22
0
class LocalInstrument(dexml.Model):
    '''Instrumento específico del esquema SEPA.'''

    code = fields.String(tagname="Cd")

    def __init__(self):
        self.code = "CORE"

    class meta:
        tagname = "LclInstrm"
示例#23
0
class Update(dexml.Model):
    class meta:
        tagname = "update"
        order_sensitive = False

    version = fields.Integer()
    targetVersion = fields.String(tagname="targetVersion")
    platform = fields.String(tagname="platform")
    dependencies = fields.List(fields.String(tagname="file"),
                               tagname="dependencies")
    pathprefix = fields.String(tagname="pathprefix", required=False)

    install = fields.List(FileElement, tagname="install", required=False)
    patches = fields.List(PatchElement, tagname="patches", required=False)
    manifest = fields.List(FileElement, tagname="manifest")
    packages = fields.List(PackageElement, tagname="packages")

    def get_filemap(self):
        return {a.name: a for a in self.manifest}
示例#24
0
class ServiceLevel(dexml.Model):
    '''Acuerdo o reglas que rigen cómo debe procesarse la operación.'''

    code = fields.String(tagname="Cd")

    def __init__(self):
        self.code = "SEPA"

    class meta:
        tagname = "SvcLvl"
示例#25
0
class GroupHeader(dexml.Model):
    '''Conjunto de características compartidas por todas las operaciones incluidas en el mensaje.'''

    message_identification = fields.String(tagname='MsgId')
    creation_date_time = fields.String(tagname='CreDtTm')
    number_of_transactions = fields.String(tagname='NbOfTxs')
    control_sum = fields.Float(tagname="CtrlSum", required=False)
    initiating_party = fields.Model(InitiatingParty)

    def __init__(self):
        self.message_identification = generated_id(35)
        self.creation_date_time = iso_datetime()
        self.initiating_party = InitiatingParty()
        self.number_of_transactions = "1"

    def render(self, **kwargs):
        return super(GroupHeader, self).render(**kwargs)

    class meta:
        tagname = "GrpHdr"
示例#26
0
class sr(dexml.Model):
    rlsid = fields.String()
    team = fields.String(tagname='team')
    fmt = fields.String(tagname='fmt')
    hits = fields.Integer(tagname='hits')
    duration_string = fields.String(tagname='duration')
    dur = None

    def get_duration(self):
        if self.dur is None:
            try:
                timet1 = datetime.strptime(self.duration_string, "%H:%M:%S")
            except ValueError:
                timet1 = datetime.strptime(self.duration_string, "%M:%S")
            delta1 = timedelta(hours=timet1.time().hour,
                               minutes=timet1.time().minute,
                               seconds=timet1.time().second)
            self.dur = delta1.total_seconds() * 1000
        return self.dur

    duration = property(get_duration)
示例#27
0
class InitiatingParty(dexml.Model):
    '''Parte que presenta el mensaje. En el mensaje de presentación, puede ser el “acreedor” o “el presentador”.'''

    name = fields.String(tagname="Nm", required=False)
    # identification = fields.String(tagname="Id", required=False)
    identification = fields.Model(Identification_Organisation)

    def __init__(self):
        self.identification = Identification_Organisation()

    class meta:
        tagname = "InitgPty"
示例#28
0
class Waypoint(dexml.Model):
    class meta:
        tagname = 'Waypoints'

    name = fields.String(tagname="Name")
    latitude = fields.Float(tagname='Latitude')  # radians
    longitude = fields.Float(tagname='Longitude')  # radians
    track_limit = fields.Float(tagname='TrackLimit', default=0)
    course_limit = fields.Float(tagname='CourseLimit', default=0)
    economy = fields.Float(tagname='Economy', default=0)
    max_speed = fields.Float(tagname='MaximalSpeed', default=0)
    controller_type = fields.String(tagname='ControllerType', default='')
    notes = fields.String(tagname="Notes", default='')
    is_parameter_point = fields.Boolean(tagname="IsParameterPoint",
                                        default=False)
    is_arrival_point = fields.Boolean(tagname="IsArrivalPoint", default=False)

    # 0 great circle, 1 rhumb
    # latter sailmode corresponds to leg's sailmode
    sail_mode = fields.Integer(tagname="SailMode")
    radius = fields.Float(tagname='Radius')  # meters
class MainModel(dexml.Model):
    """Basis for main models. Manages automatically the generation timestamp.
    Version "number" and optionnal software information are still to provide."""
    version   = fields.String()
    generated = fields.String() # Could be a date object at some point
    software_used  = fields.Model(Software, required=False)

    def __init__(self,**kwds):
        super(MainModel, self).__init__(**kwds)
        self.version   = "0.3"
        self.generated = datetime.datetime.now().isoformat() # warning: no TZ info here

    def exportToFile(self, filename, pretty_print=False):
        out_str = self.render(encoding="utf-8") # no pretty=pretty_print here, done by lxml
        if pretty_print:
            # lxml pretty print should be way faster than the minidom one used in dexml
            root = etree.fromstring(out_str)
            out_str = etree.tostring(root, xml_declaration=True, encoding='utf-8', pretty_print=True)
        # print "Output file's content:\n%s" % out_str
        with open(os.path.abspath(filename), "wb") as out_f:
            out_f.write(out_str)

    @classmethod 
    def loadFromFile(cls, filename):
        path_file = os.path.abspath(filename)
        if not os.path.isfile(path_file):
            err = "Error: '%s' does not exist or is not a file." % filename
            print(err)
            raise Exception(err)

        # Note: parsing a file directly with dexml/minidom is supposedly slower, si I used lxml one, 
        #       but I did not benchmark it.
        tree = etree.parse(path_file)
        handler = SAX2DOM()
        sax.saxify(tree, handler)
        dom = handler.document

        # In case, you can pass the filename to parse() here to skip lxml
        mdl = cls.parse(dom)
        return mdl
示例#30
0
class PatchElement(dexml.Model):
    class meta:
        tagname = "patch"
        order_sensitive = False

    name = fields.String(tagname="name")
    patchName = fields.String(tagname="patchName")
    patchHash = fields.String(tagname="patchHash")

    targetHash = fields.String(tagname="targetHash")
    targetSize = fields.String(tagname="targetSize")
    targetPerm = fields.String(tagname="targetPerm")

    sourceHash = fields.String(tagname="sourceHash")

    package = fields.String(tagname="package")