Ejemplo n.º 1
0
class _SAPEmploymentTuple(_SAPTupleBase):
    """Adaptor class for feide_persti.txt.

    The field split looks like this:

      Field  Description
        0     SAP person ID
        1     orgeh (magic number constituting part of the SAP OU id)
        2     funksjonstittel (magic employment code)
        3     lonnstittel     (magic employment code)
        4     forretningsområdekode (magic number constituting part of the SAP
              OU id)
        5     Employment start date
        6     Employment end date
        7     Employment type (hoved-/bistilling)
        8     Employment percentage (0-100, as a float)
    """

    _field_count = 9
    _field_rules = {
        'sap_ansattnr': 0,
        'funksjonstittel': 2,
        'lonnstittel': 3,
        'start_date': (5, lambda x: strptime(x, "%Y%m%d")),
        'end_date': (6, lambda x: strptime(x, "%Y%m%d")),
        'stillingstype': 7,
        'percentage': (8, float),
        'sap_ou_id': 1,
    }

    def valid(self):
        # '99999999' comes from SAP / "Stillnum"
        return self.funksjonstittel != '99999999'
Ejemplo n.º 2
0
 def get_national_holidays(begin, end):
     """return french national days off between begin and end"""
     begin = Date(begin.year, begin.month, begin.day)
     end = Date(end.year, end.month, end.day)
     holidays = [strptime(datestr, '%Y-%m-%d')
                 for datestr in list(FRENCH_MOBILE_HOLIDAYS.values())]
     for year in range(begin.year, end.year+1):
         for datestr in list(FRENCH_FIXED_HOLIDAYS.values()):
             date = strptime(datestr % year, '%Y-%m-%d')
             if date not in holidays:
                 holidays.append(date)
     return [day for day in holidays if begin <= day < end]
Ejemplo n.º 3
0
class _SAPUtvalgTuple(_SAPTupleBase):
    """Abstracting away 'utvalg' data from SAP, from feide_perutvalg.txt.

    The field split looks like this:

      Field  Description
        0    SAP person ID
        1    Seksjonstilhørighet - forretningsområde ID? - orgeh?
        2    Ansattkode (vert erstatta av MEG/MUG) - employment type?
        3    Fagmiljø
        4    Start date
        5    End date
        6    Role

    """

    _field_count = 7
    _field_rules = {
        'sap_ansattnr': 0,
        'sap_orgeh': 1,
        'sap_unknown': 2,
        'sap_fagmiljo': 3,
        'sap_start_date': (4, lambda x: x and strptime(x, "%Y%m%d") or None),
        'sap_termination_date':
        (5, lambda x: x and strptime(x, "%Y%m%d") or None),
        'sap_role': 6,
    }

    def expired(self):
        """Is this entry expired?"""
        return (self.sap_termination_date
                and (self.sap_termination_date < now()))

    def valid(self):
        """Is this entry to be ignored?"""
        return (not self.sap_start_date) or (self.sap_start_date < now())
Ejemplo n.º 4
0
class _SAPPersonDataTuple(_SAPTupleBase):
    """Adaptor class for feide_persondata.txt.

    The field split looks like this:

      Field  Description
       0   SAP person ID
       2   Employment termination date
       3   Name initials
       4   SSN / norwegian fødselsnr
       5   Birth date
       6   First name
       7   Middle name
       8   Last name
      12   Contact phone private
      13   Contact phone
      14   Contact phone cellular
      15   Contact phone cellular - private
      18   Bostedsadr. C/O
      19   Bostedsadr. Gate
      20   Bostedsadr. husnr.
      21   Bostedsadr. Tillegg
      22   Bostedsadr. Poststed
      23   Bostedsadr. postnr.
      24   Bostedsadr. Land
      25   Forretningsområde ID
      26   Office building code
      27   Office room number
      28   Work title
    """

    _field_count = 39
    _field_rules = {
        'sap_ansattnr':
        0,
        'sap_termination_date':
        (2, lambda x: x and strptime(x, "%Y%m%d") or None),
        'sap_fnr':
        4,
        # <- defer fnr check to later
        'sap_birth_date': (5, lambda x: strptime(x, "%Y%m%d")),
        'sap_middle_name':
        _with_strip(7),
        'sap_first_name':
        ((6, 7), lambda x, y: y and x.strip() + " " + y.strip() or x.strip()),
        'sap_last_name':
        _with_strip(8),
        'sap_initials':
        _with_strip(3),
        'sap_personal_title':
        _with_strip(28),
        'sap_phone_private':
        _with_strip(12),
        'sap_phone':
        _with_strip(13),
        'sap_phone_mobile':
        _with_strip(14),
        'sap_phone_mobile_private':
        _with_strip(15),
        'sap_fax':
        _with_strip(29),
        'sap_address':
        (range(18,
               22), lambda *rest: ", ".join(x.strip() for x in rest) or None),
        'sap_zip':
        _with_strip(23),
        'sap_city':
        _with_strip(22),
        'sap_country':
        _with_strip(24),
        'sap_building_code':
        _with_strip(26),
        'sap_roomnumber':
        _with_strip(27),
        'sap_publish_tag':
        _with_strip(36),
    }

    def expired(self):
        """Is this entry expired?"""
        return (self.sap_termination_date
                and (self.sap_termination_date < now()))

    # TODO: Should this really just return True?
    def valid(self):
        """Is this entry to be ignored?"""
        return True

    def reserved_for_export(self):
        """Whether this person is reserved from export to catalogue
        services."""
        return (self.sap_publish_tag
                and (self.sap_publish_tag != "Kan publiseres"))
Ejemplo n.º 5
0
 def convert_mxtime(ustr):
     try:
         return strptime(ustr, '%H:%M:%S')
     except:
         # DateTime used as Time?
         return strptime(ustr, '%Y-%m-%d %H:%M:%S')
Ejemplo n.º 6
0
 def convert_mxdatetime(ustr):
     return strptime(ustr, '%Y-%m-%d %H:%M:%S')
Ejemplo n.º 7
0
 def convert_mxtime(ustr):
     try:
         return strptime(ustr, '%H:%M:%S')
     except:
         # DateTime used as Time?
         return strptime(ustr, '%Y-%m-%d %H:%M:%S')
Ejemplo n.º 8
0
 def convert_mxdatetime(ustr):
     return strptime(ustr, '%Y-%m-%d %H:%M:%S')