Source code for xerparser.model.classes.pcattype

# PyP6XER
# Copyright (C) 2020, 2021 Hassan Emam <hassan@constology.com>
#
# This file is part of PyP6XER.
#
# PyP6XER library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License v2.1 as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PyP6XER is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyP6XER.  If not, see <https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html>.


[docs] class PCatType:
[docs] obj_list =[]
def __init__(self, params): # Unique ID generated by the system.
[docs] self.proj_catg_type_id = int(params.get('proj_catg_type_id').strip()) if params.get( 'proj_catg_type_id') else None
# The sequence number of this Project Activity Code.
[docs] self.seq_num = int(params.get('seq_num').strip()) if params.get('seq_num') else None
# Sequence number for sorting.
[docs] self.proj_catg_short_len = params.get('proj_catg_short_len').strip() if params.get( 'proj_catg_short_len') else None
# Each Activity Code has a list of possible values, any of which can be assigned to an activity. Activity # Codes allow you to classify and categorize activities.
[docs] self.proj_catg_type = params.get('proj_catg_type').strip() if params.get('proj_catg_type') else None
# Identifies the project which owns this Activity Code (if this is a project-level Activity Code).
[docs] self.export_flag = int(params.get('export_flag')) if params.get('export_flag') else None
PCatType.obj_list.append(self) # %F proj_catg_type_id seq_num proj_catg_short_len proj_catg_type export_flag
[docs] def get_id(self): return self.proj_catg_type_id
[docs] def get_tsv(self): tsv = ['%R', self.proj_catg_type_id, self.seq_num, self.proj_catg_short_len, self.proj_catg_type, self.export_flag] return tsv
@classmethod
[docs] def find_by_id(cls, id): """ Function to search list of activity code type by an ID Args: id: Unique ID generated by the system. Returns: ActType that matches the ID """ obj = list(filter(lambda x: x.proj_catg_type_id == id, cls.obj_list)) if len(obj) > 0: return obj[0] else: obj = None return obj
[docs] def __repr__(self): return self.proj_catg_type_id